//**********************************************************************
//						Registration/Login
//**********************************************************************
// Registration Validation
function registrationValidation(fn,em,cem,pass,cpass,sn,sq,sa)
{
	var firstname = Trim(document.getElementById(fn).value);
	var email = Trim(document.getElementById(em).value);
	var cemail = Trim(document.getElementById(cem).value);
	var password = Trim(document.getElementById(pass).value);
	var cpassword = Trim(document.getElementById(cpass).value);
	var screenname = Trim(document.getElementById(sn).value);
	var question = document.getElementById(sq).selectedIndex;
	var answer = Trim(document.getElementById(sa).value);
	
	var valid = true;

	if(answer.length == 0 || answer == null)
	{
		document.getElementById('spanSAReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanSAReq').style.display="none";
	
		
	if(question == "0" || question == null)
	{
		document.getElementById('spanSQReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanSQReq').style.display="none";

	if(screenname.length <= 0 || screenname == null)
	{
		document.getElementById('spanSNReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanSNReq').style.display="none";

	if(cpassword.length == 0 || cpassword == null)
	{
		document.getElementById('spanCPReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanCPReq').style.display="none";

	if(password.length == 0 || password == null)
	{
		document.getElementById('spanPWReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanPWReq').style.display="none";

	if(cemail.length == 0 || cemail == null)
	{
		document.getElementById('spanCEReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanCEReq').style.display="none";

	if(email.length == 0 || email == null)
	{
		document.getElementById('spanEmReq').style.display="inline";
		document.getElementById('spanReqToLog').style.display="none";
		valid = false;
	}
	else
		document.getElementById('spanEmReq').style.display="none";

	if(firstname.length == 0 || firstname == null)
	{
		document.getElementById('spanFNReq').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spanFNReq').style.display="none";



	// If email does not contain "@" and a "." after the @, it's not valid
	if(InvalidEmail(email) && email.length > 0)
	{
		document.getElementById('spanInvEm').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanInvEm').style.display = "none";

	if(InvalidEmail(cemail) && cemail.length > 0)
	{
		document.getElementById('spanInvCE').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanInvCE').style.display = "none";
	
	if(email != cemail)
	{
		document.getElementById('spanEmailMatch').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanEmailMatch').style.display = "none";
		
	if(password != cpassword)
	{
		document.getElementById('spanPassMatch').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanPassMatch').style.display = "none";
	
	if(document.getElementById("txtSCAvilable").innerHTML.indexOf("already taken!") != -1)
		valid = false;
	
	if(document.getElementById("txtEmailAvilable").innerHTML.indexOf("already registered!") != -1)
		valid = false;

	if(valid)
	{			
		document.frmMyPlaceLogin.registerid.value="true";
		document.frmMyPlaceLogin.loginid.value="";
		document.frmMyPlaceLogin.submit();
	}
}



// Login Validation
function loginRegValidation(em,pass)
{
	var valid = true;
	var	email = Trim(document.getElementById(em).value);
	var password = Trim(document.getElementById(pass).value);
	
	if(email.length <= 0)
	{
		document.getElementById('spanLoginEm').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanLoginEm').style.display = "none";
		
	if(password.length <= 0)
	{
		document.getElementById('spanLoginPW').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanLoginPW').style.display = "none";
		
	if(InvalidEmail(email) && email.length > 0)
	{
		document.getElementById('spanLoginInv').style.display = "inline";
		valid = false;
	}
	else
		document.getElementById('spanLoginInv').style.display = "none";

	if(valid)
	{			
		document.frmMyPlaceLogin.loginid.value="true";
		document.frmMyPlaceLogin.registerid.value="";
		document.frmMyPlaceLogin.submit();
	}

}

// Login Validation
function loginValidation(em,pass,formname)
{
	var strErr ="";
	var email; 
	var password;
	
	if(formname == "Login1" && document.forms[0].name == "frmBusinessSearchResult")
	{	
		/*R:
		email = Trim(document.getElementById("MainHeader1_" + em).value);
		password = Trim(document.getElementById("MainHeader1_" + pass).value);		
		*/
		
		/*R: The above changed for the following: */ 
		
		var tmp1 = document.getElementById("MainHeader1_" + em);
		var tmp2 = document.getElementById("MainHeader1_" + pass);
		
		if (tmp1 == undefined)
			email = Trim(document.getElementById(em).value);
		else
			email = Trim(tmp1); 
			
		if (tmp2 == undefined)
			password = Trim(document.getElementById(pass).value);
		else
			password = Trim(tmp2); 
	}
	else
	{
		email = Trim(document.getElementById(em).value);
		password = Trim(document.getElementById(pass).value);
	}

	if(email.length <= 0 && password.length <= 0)
		strErr = "Please enter an email and password.";
		
	else if(email.length <= 0 && password.length > 0)
		strErr = "Please enter an email address.";
			
	else if(password.length <= 0 && email.length > 0)
		strErr = "Please enter a password.";
		
	else if(InvalidEmail(email))
		strErr = "Please enter a valid email.";
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{			
		if(formname == "frmMyPlaceLogin")
		{
			document.frmMyPlaceLogin.loginid.value="true";
			document.frmMyPlaceLogin.registerid.value="";
			document.frmMyPlaceLogin.submit();
		}
		else if(formname == "Login1")
		{
		
			document.getElementById("loginwuc").value="true";
			document.forms[0].submit();
		}
	}

}

//**********************************************************************
//							Searching
//**********************************************************************

// Business Search Validation
function businessSearchValidation(sCategory, chkName, sCZACode, sState, formname, addr)
{
	var category = Trim(document.getElementById(sCategory).value);
	var namebtn = document.getElementById(chkName);
	var city = Trim(document.getElementById(sCZACode).value);
	var state = document.getElementById(sState).selectedIndex;
	
	if(addr == "")
		var chkAddr = null;
	else	
		var chkAddr = document.getElementById(addr);
	
	var last = false;
	var comma = false;	
	var noenter = true;	
	var strErr ="";
	var andDone = false;
	
	if(chkAddr != null && !chkAddr.checked)
	{
		if(state == "0" || state == null)
		{
			strErr = "select a state";
			last = true;
			comma = true;	
			noenter = true;	
		}
	
		if (city.length == 0) 
		{
			if(last && !andDone)
			{
				strErr = "and " + strErr;
				andDone = true;
			}
			else
			{
				last = true;
			}
			
			noenter = false;

			if(comma)
				strErr = "a city or zip, " + strErr;
			else
			{
				strErr = "a city or zip";
				comma = true;
			}	
		}
	}
	
	if(category.length <= 0)
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
		{
			if(namebtn.checked)
				strErr = "a business name, " + strErr;
			else
				strErr = "a category or keyword, " + strErr;
		}
		else
		{
			if(namebtn.checked)
				strErr = "a business name" + strErr;
			else
				strErr = "a category or keyword" + strErr;
				
			comma = true;
		}				
	}
	
	if(comma)
	{
		if(noenter)
			strErr = "Please " + strErr + ".";
		else
			strErr = "Please enter " + strErr + ".";
	}
	else
	{
		if(chkAddr != null && !chkAddr.checked && isInteger(city) && InvalidZip(city))
			strErr = "Please enter a valid zip code.  ";
			
		if(namebtn.checked && category.length < 3)
			strErr += "Please enter at least three characters for the Business Category.";
		else if(!namebtn.checked && category.length < 2)
			strErr += "Please enter at least two characters for the Business Name.";
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{	
		if(formname == "frmHome")
		{
			document.getElementById("busid").value="true";
			document.frmHome.submit();
		}
		else if(formname == "frmBusinessSearchResult")
		{
			document.getElementById("busid").value="true";
			document.frmBusinessSearchResult.submit();
		}
	}
}


//**********************************************************************
//							Feedback
//**********************************************************************

// Feedback Validation
function feedbackvalidation(cts,nm,em,chkcontact,ph,zp)
{
	var strError = "";
	var comments = Trim(document.getElementById(cts).value);
	var name = Trim(document.getElementById(nm).value);
	var email = Trim(document.getElementById(em).value);
	var phone = Trim(document.getElementById(ph).value);
	var zip = Trim(document.getElementById(zp).value);

	if(comments.length <= 0)
		strError = "Please fill in the Comments field.";
	else if(document.getElementById(chkcontact).checked)
	{
		if(name.length <= 0 && email.length <= 0)
			strError = "Please enter your name and email address.";
		else if(name.length <= 0 && email.length > 0)
			strError = "Please enter your name.";
		else if(name.length > 0 && email.length <= 0)
			strError = "Please enter your email address.";
		else if(email.length > 0 && InvalidEmail(email))
			strError = "Please enter a valid email address.";
	}
	

	if(phone.length > 0 && InvalidPhone(phone))
		strError = "Please enter a valid phone number.";
	else if(phone.length > 0 && phone.length < 10)
		strError = "Please include your area code in your phone number.";
	else if(zip.length > 0 && InvalidZip(zip))
		strError = "Please enter a valid zip code.";
		
	
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{	
		document.getElementById("feedbackid").value="true";
		document.frmContact.submit();
	}	
		
}

// Forget Password Validation
function forgotValidation(em,secq,seca)
{
	var comma = false;
	var last = false;
	var andDone = false;

	var strErr = "";
	
	var email = Trim(document.getElementById(em).value);
	var question = document.getElementById(secq).selectedIndex;
	var answer = Trim(document.getElementById(seca).value);
	

	if(answer.length <= 0)
	{
		strErr = "answer your secret question";
		last = true;
		comma = true;	
	}
	if(question == "0")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "select a secret question, " + strErr;
		else
		{
			strErr = "select a secret question";
			comma = true;
		}				
	}
	if(email.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "enter an email address, " + strErr;
		else
		{
			strErr = "enter an email address";
			comma = true;
		}
		
	}

	if(comma)
	{
		strErr = "Please " + strErr + ".";
		alert(strErr);
		return false;
	}
	else
	{
		if(InvalidEmail(email))
		{
			strErr = "Not a valid email address.";
			comma = true;
			alert(strErr);
			return false;
		}
	}
	
	if(strErr.length == 0)
	{	
		document.getElementById("forgotid").value="true";
		document.frmForgotPass.submit();
	}	
}

//**********************************************************************
//							Review
//**********************************************************************

// Rate Business Validation
function rateValidation(ttl,rvw)
{
	var strError = "";

	var title = Trim(document.getElementById(ttl).value);
	var review = Trim(document.getElementById(rvw).value);
	var multiple = false;
	
	if(review.length <= 0)
	{
		multiple = true;

		strError += "a Review.";
	}
	if(title.length <= 0)
	{
		if(multiple) strError = "a Title and " + strError;
		else strError += "a Title.";
	}
	
	if(strError.length != 0)
	{
		strError = "Please enter " + strError;
		alert(strError);
		return false;
	}
	else
	{	
		/*
		var reviewtxt = review;

		// replace excess white space
		while(reviewtxt.indexOf("\s\s") != -1) reviewtxt = reviewtxt.replace("\s\s"," ");
		
		// Convert all word breaks to commas
		reviewtxt = ((reviewtxt.replace(/ /g,",")).replace(/\n/g,",")).replace(/\t/g,",");
		reviewtxt = (((reviewtxt.replace(/\./g,",")).replace(/\"/g,",")).replace(/\;/g,",")).replace(/\?/g,",");
		reviewtxt = (((reviewtxt.replace(/!/g,",")).replace(/\)/g,",")).replace(/\(/g,",")).replace(/</g,",");
		reviewtxt = ((reviewtxt.replace(/>/g,",")).replace(/\[/g,",")).replace(/\]/g,",");
		
		// Replace any double commas
		while(reviewtxt.indexOf(",,") != -1) reviewtxt = reviewtxt.replace(",,",",");
		
		var num_words = reviewtxt.split(",");

		if(num_words.length < 20)
		{
			strError = "Review must be at least 20 words long.";
			alert(strError);
			return false;
		}
		else
		{}
		*/
		
		document.getElementById("rateid").value="true";
		document.frmRate.submit();
	}	
}

//**********************************************************************
//							Set Address
//**********************************************************************

function setAddressValidation(addr,cty,st,zp,sid)
{
	var comma = false;
	var last = false;
	var andDone = false;
	var noenter = false;
	
	var address = Trim(document.getElementById(addr).value);
	var city = Trim(document.getElementById(cty).value);
	var state = document.getElementById(st).selectedIndex;
	var zip = Trim(document.getElementById(zp).value);
	//var sid = Trim(document.getElementById(id).value);
	
	var strErr = "";

	if(zip.length <= 0 || zip == "Zip")
	{
		strErr = "enter a zip code";
		last = true;
		comma = true;	
		noenter = true;
	}
	if(state == "0" || state == null)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}
		
		noenter = true;

		if(comma)
			strErr = "select a state, " + strErr;
		else
		{
			strErr = "select a state";
			comma = true;
		}				
	}
	if(city.length <= 0 || city == "City")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}
		
		noenter = false;

		if(comma)
			strErr = "a city, " + strErr;
		else
		{
			strErr = "a city";
			comma = true;
		}
		
	}
	if(address.length <= 0 || address == "Address")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}
		
		noenter = false;

		if(comma)
			strErr = "an address, " + strErr;
		else
		{
			strErr = "an address";
			comma = true;
		}
		
	}

	if(comma)
	{
		if(noenter)
			strErr = "Please " + strErr + ".";
		else
			strErr = "Please enter " + strErr + ".";
	}
	else
	{
		if(InvalidZip(zip))
		{
			strErr = "Not a valid zip code.";
			comma = true;
		}
	}


	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{			
		if(sid=="SetAddressGov1_setaddressid1")
			document.getElementById("setaddressid1").value="true";
		else
			document.getElementById("setaddressid").value="true";
		document.forms[0].submit();
	}
}

//**********************************************************************
//					Business Update
//**********************************************************************

// Business Update - Phone Search Validation
function phoneValidation(ph)
{

	var phone = Trim(document.getElementById(ph).value);
	var strError = "";

	if(phone.length <= 0 || phone == "Phone number")
		strError = "Please enter a phone number.";
	else if(InvalidPhone(phone))
		strError = "Please enter a valid phone number.";
	else if(phone.length > 0 && phone.length < 10)
		strError = "Please include your area code.";
	
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("phoneid").value="true";
		document.frmBusUpdate.submit();
	}
}

// Business Update - Non-Advertiser Contact/Business Validation
function busupdateValidation(cn,ct,ce,cce,cp,bn,ba,bc,bs,bz,bp,be,btfp)
{
	var conname = Trim(document.getElementById(cn).value);
	var contitle = Trim(document.getElementById(ct).value);
	var conemail = Trim(document.getElementById(ce).value);
	var concemail = Trim(document.getElementById(cce).value);
	var conphone = Trim(document.getElementById(cp).value);
	var busname = Trim(document.getElementById(bn).value);
	var address = Trim(document.getElementById(ba).value);
	var city = Trim(document.getElementById(bc).value);
	var state = document.getElementById(bs).selectedIndex;
	var zip = Trim(document.getElementById(bz).value);
	var phone = Trim(document.getElementById(bp).value);
	var busemail = Trim(document.getElementById(be).value);
	var tollfree = Trim(document.getElementById(btfp).value);

	var comma = false;
	var last = false;
	var andDone = false;

	var strErr = "";

	if(conphone.length <= 0)
	{
		strErr = "a phone number";
		last = true;
		comma = true;	
	}
    
	if(concemail.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your confirmed email address, " + strErr;
		else
		{
			strErr = "your confirmed email address";
			comma = true;
		}				
	}

	if(conemail.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your email address, " + strErr;
		else
		{
			strErr = "your email address";
			comma = true;
		}				
	}
    
	if(contitle.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your job title, " + strErr;
		else
		{
			strErr = "your job title";
			comma = true;
		}				
	}
	if(conname.length <= 0 || name == "Name")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your name, " + strErr;
		else
		{
			strErr = "your name";
			comma = true;
		}
		
	}

	if(comma)
	{
		strErr = "Please enter " + strErr + ".";
	}
	else
	{
		if(InvalidEmail(conemail))
		{
			strErr = "Not a valid email address.  ";
			comma = true;
		}
		if(InvalidEmail(concemail))
		{
			strErr += "Not a valid confirm email address.  ";
			comma = true;
		}
		if(conemail != concemail)
		{
			strErr += "Emails do not match.  ";
			comma = true;
		}
		if(InvalidPhone(conphone))
		{
			strErr += "Not a valid phone number.";
			comma = true;
		}
		else if(conphone.length < 10)
		{
			strErr += "Contact phone number must include an area code.";
		}
	}
				
	
	var strBusErr = businessValidation(busname,address,city,state,zip,phone);
	
	if(strErr != "")
	{				
		strErr = "Contact Information: " + strErr;

		if(strBusErr != "")
			strErr += "\n\n";
	}
	if(strBusErr != "")
	{
		strErr += "Business Information: " + strBusErr;
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{			
		if(busemail.length > 0)
		{
			if(InvalidEmail(busemail))
				strErr = "Not a valid Business Email Address.  ";
		}
		if(tollfree.length > 0 && strErr.length == 0)
		{
			if(InvalidPhone(tollfree))
				strErr += "Not a valid Toll-Free Phone Number.  ";
		}
		if(phone.length < 10)
			strErr += "Business phone number must include an area code.";
			
		if(strErr.length != 0)
		{
			alert(strErr);
			return false;
		}
		if(strErr.length == 0)
		{	
			document.getElementById("busid").value="true";
			document.frmBusUpdate.submit();
		}
	}			
}

// Business Update - Non-Advertiser Contact/Business Validation
function dashBusUpdateValidation(cn,ct,ce,cce,cp,bn,ba,bc,bs,bz,bp,be,btfp)
{
	var conname = Trim(document.getElementById(cn).value);
	var contitle = Trim(document.getElementById(ct).value);
	var conemail = Trim(document.getElementById(ce).value);
	var concemail = Trim(document.getElementById(cce).value);
	var conphone = Trim(document.getElementById(cp).value);
	var busname = Trim(document.getElementById(bn).value);
	var address = Trim(document.getElementById(ba).value);
	var city = Trim(document.getElementById(bc).value);
	var state = document.getElementById(bs).selectedIndex;
	var zip = Trim(document.getElementById(bz).value);
	var phone = Trim(document.getElementById(bp).value);
	var busemail = Trim(document.getElementById(be).value);
	var tollfree = Trim(document.getElementById(btfp).value);

	var comma = false;
	var last = false;
	var andDone = false;

	var strErr = "";

	if(conphone.length <= 0)
	{
		strErr = "a phone number";
		last = true;
		comma = true;	
	}
    
	if(concemail.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your confirmed email address, " + strErr;
		else
		{
			strErr = "your confirmed email address";
			comma = true;
		}				
	}

	if(conemail.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your email address, " + strErr;
		else
		{
			strErr = "your email address";
			comma = true;
		}				
	}
    
	if(contitle.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your job title, " + strErr;
		else
		{
			strErr = "your job title";
			comma = true;
		}				
	}
	
	if(conname.length <= 0 || name == "Name")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your name, " + strErr;
		else
		{
			strErr = "your name";
			comma = true;
		}
		
	}

	if(comma)
	{
		strErr = "Please enter " + strErr + ".";
	}
	else
	{
		if(conemail.length > 0 && InvalidEmail(conemail))
		{
			strErr = "Not a valid email address.  ";
			comma = true;
		}
		if(concemail.length > 0 && InvalidEmail(concemail))
		{
			strErr += "Not a valid confirm email address.  ";
			comma = true;
		}
		if((conemail.length > 0 || conemail.length > 0) && conemail != concemail)
		{
			strErr += "Emails do not match.  ";
			comma = true;
		}
		if(conphone.length > 0 && InvalidPhone(conphone))
		{
			strErr += "Not a valid phone number.";
			comma = true;
		}
		else if(conphone.length > 0 && conphone.length < 10)
		{
			strErr += "Contact phone number must include an area code.";
		}
	}
				
	
	var strBusErr = businessValidation(busname,address,city,state,zip,phone);
	
	if(strErr != "")
	{				
		strErr = "Contact Information: " + strErr;

		if(strBusErr != "")
			strErr += "\n\n";
	}
	if(strBusErr != "")
	{
		strErr += "Business Information: " + strBusErr;
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{			
		if(busemail.length > 0)
		{
			if(InvalidEmail(busemail))
				strErr = "Not a valid Business Email Address.  ";
		}
		if(tollfree.length > 0 && strErr.length == 0)
		{
			if(InvalidPhone(tollfree))
				strErr += "Not a valid Toll-Free Phone Number.  ";
		}
		if(phone.length < 10)
			strErr += "Business phone number must include an area code.";
			
		if(strErr.length != 0)
		{
			alert(strErr);
			return false;
		}
		if(strErr.length == 0)
		{	
			document.getElementById("busid").value="true";
			document.frmBusUpdate.submit();
		}
	}			
}

// Business Update - Advertiser Contact/Business Validation
function busupdateAdvValidation(cn,ct,ce,cce,cpass,ccpass,cq,ca,cp,bn,ba,bc,bs,bz,bp,be,btfp)
{
	var conname = Trim(document.getElementById(cn).value);
	var contitle = Trim(document.getElementById(ct).value);
	var conemail = Trim(document.getElementById(ce).value);
	var concemail = Trim(document.getElementById(cce).value);
	var conpass = Trim(document.getElementById(cpass).value);
	var concpass = Trim(document.getElementById(ccpass).value);
	var conquestion = document.getElementById(cq).selectedIndex;
	var conanswer = Trim(document.getElementById(ca).value);	
	var conphone = Trim(document.getElementById(cp).value);
	var busname = Trim(document.getElementById(bn).value);
	var address = Trim(document.getElementById(ba).value);
	var city = Trim(document.getElementById(bc).value);
	var state = document.getElementById(bs).selectedIndex;
	var zip = Trim(document.getElementById(bz).value);
	var phone = Trim(document.getElementById(bp).value);
	var busemail = Trim(document.getElementById(be).value);
	var tollfree = Trim(document.getElementById(btfp).value);

	var comma = false;
	var last = false;
	var andDone = false;
	var noenter = false;

	var strErr = "";

	if(conphone.length <= 0)
	{
		strErr = "a phone number";
		last = true;
		comma = true;	
	}
    
	if(conanswer.length <= 0)
	{
		noenter = true;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "answer your secret question, " + strErr;
		else
		{
			strErr = "answer your secret question";
			comma = true;
		}				
	}
	if(conquestion <= 0)
	{
		noenter = true;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "select a secret question, " + strErr;
		else
		{
			strErr = "select a secret question";
			comma = true;
		}				
	}

	if(concpass.length <= 0)
	{
		noenter = true;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "confirm your password, " + strErr;
		else
		{
			strErr = "confirm your password";
			comma = true;
		}				
	}
	if(conpass.length <= 0)
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "a password, " + strErr;
		else
		{
			strErr = " password";
			comma = true;
		}				
	}

	if(concemail.length <= 0)
	{
		noenter = true;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "confirm your email address, " + strErr;
		else
		{
			strErr = "confirm your email address";
			comma = true;
		}				
	}

	if(conemail.length <= 0)
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your email address, " + strErr;
		else
		{
			strErr = "your email address";
			comma = true;
		}				
	}
    
	if(contitle.length <= 0)
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your job title, " + strErr;
		else
		{
			strErr = "your job title";
			comma = true;
		}				
	}
	if(conname.length <= 0 || conname == "Name")
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your name, " + strErr;
		else
		{
			strErr = "your name";
			comma = true;
		}
		
	}

	if(comma)
	{
		if(noenter)
			strErr = "Please " + strErr + ".";
		else
			strErr = "Please enter " + strErr + ".";
	}
	else
	{
		if(InvalidEmail(conemail))
		{
			strErr = "Not a valid email address.  ";
			comma = true;
		}
		if(InvalidEmail(concemail))
		{
			strErr += "Not a valid confirm email address.  ";
			comma = true;
		}
		if(conemail != concemail)
		{
			strErr += "Emails do not match.  ";
			comma = true;
		}
		if(conpass != concpass)
		{
			strErr += "Passwords do not match.  ";
			comma = true;
		}
		if(InvalidPhone(conphone))
		{
			strErr += "Not a valid phone number.  ";
			comma = true;
		}
		else if(conphone.length < 10)
		{
			strErr += "Contact phone number must include an area code.";
			comma = true;
		}
	}
	
	var strBusErr = businessValidation(busname,address,city,state,zip,phone);
	
	if(strErr != "")
	{				
		strErr = "Contact Information: " + strErr;

		if(strBusErr != "")
			strErr += "\n\n";
	}
	if(strBusErr != "")
	{
		strErr += "Business Information: " + strBusErr;
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{				
		if(busemail.length > 0)
		{
			if(InvalidEmail(busemail))
				strErr = "Not a valid Business Email Address.  ";
		}
		if(tollfree.length > 0)
		{
			if(InvalidPhone(tollfree))
				strErr += "Not a valid Toll-Free Phone Number.";
		}
		if(phone.length < 10)
		{
			strErr += "Business phone number must include an area code.";
			comma = true;
		}
	
		if(strErr.length != 0)
		{
			alert(strErr);
			return false;
		}
		else
		{	
			document.getElementById("busid").value="true";
			document.frmBusUpdate.submit();
		}
	}			
}

// Business Update - Business Information Validation
function businessValidation(busname,address,city,state,zip,phone)
{
	var comma = false;
	var last = false;
	var andDone = false;
	var nostate = false;

	var strErr = "";

	if(phone.length <= 0)
	{
		strErr = "a phone number";
		last = true;
		comma = true;	
	}
	if(zip.length <= 0 || zip == "Zip")
	{
		if(last && !andDone)
		{
			strErr = "and enter " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "a zip code, " + strErr;
		else
		{
			strErr = "a zip code";
			comma = true;
		}
		
	}
	if(state == "0" || state == null)
	{
		nostate = true;

		if(last && !andDone)
		{
			strErr = "and enter " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "select a state, " + strErr;
		else
		{
			strErr = "select a state";
			comma = true;
		}				
	}
	if(city.length <= 0 || city == "City")
	{
		nostate = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "a city, " + strErr;
		else
		{
			strErr = "a city";
			comma = true;
		}
		
	}
	if(address.length <= 0 || address == "Address")
	{
		nostate = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "an address, " + strErr;
		else
		{
			strErr = "an address";
			comma = true;
		}
		
	}
	if(busname.length <= 0 || busname == "Name")
	{
		nostate = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "a business name, " + strErr;
		else
		{
			strErr = "a business name";
			comma = true;
		}
		
	}

	if(comma)
	{
		if(nostate)
			strErr = "Please " + strErr + ".";
		else
			strErr = "Please enter " + strErr + ".";
	}
	else
	{
		if(InvalidZip(zip))
		{
			strErr = "Not a valid zip code.  ";
			comma = true;
		}
		if(InvalidPhone(phone))
		{
			strErr += "Not a valid phone number.";
			comma = true;
		}
		else if(phone.length < 10)
		{
			strErr += "Business phone number must include an area code.";
		}
	}

	return strErr;
}

// Business Update - I Agree Validation
function iAgreeValidation(agr,advertiser)
{
	var agreechk = document.getElementById(agr);
	var strError = "";

	if(!agreechk.checked)
		strError = "You must agree to the Terms and Conditions.";
	
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		if(advertiser)
			document.getElementById("advagreeid").value="true";
		else
			document.getElementById("agreeid").value="true";
			
		document.frmBusUpdate.submit();
	}
}

// Business Update - Remove My Listing Validation
function removeValidation(rmvck,rmvtxt)
{
	var removechk = document.getElementById(rmvck);
	var removetxt = Trim(document.getElementById(rmvtxt).value);
	var strError = "";

	if(removechk.checked)
	{
		if(removetxt.length == 0)
			strError = "You must enter a reason for removing your listing.";
	}
	else
	{
		strError = "Please check \"Remove My Listing\"";
		if(removetxt.length == 0)
			strError += " and enter a reason for removing your listing.";
		else
			strError += ".";
	}
	
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("removeid").value="true";
		document.frmBusUpdate.submit();
	}
}

// Business Update - Advertiser Login
function advertiserValidation(usr,pass)
{
	var username = Trim(document.getElementById(usr).value);
	var password = Trim(document.getElementById(pass).value);
	var strError = "";

	if(username.length <= 0 && password.length <= 0) 
	{
		strError = "Please enter a username and password.";
	}
	else if(username.length <= 0 && password.length > 0) 
	{
		strError = "Please enter a username.";
	}
	else if(username.length > 0 && password.length <= 0) 
	{
		strError = "Please enter a password.";
	}
	
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("advid").value="true";
		document.frmBusUpdate.submit();
	}
}

// Business Update - Advertiser Forgot Password
function BUForgotPasswordValidation(em,qst,ans)
{
	var email = Trim(document.getElementById(em).value);
	var question = document.getElementById(qst).selectedIndex;
	var answer = Trim(document.getElementById(ans).value);
	
	var strErr = "";

	var comma = false;
	var last = false;
	var andDone = false;
	var pleaseenter = true;

	if(answer.length <= 0)
	{
		strErr = "answer your secret question";
		last = true;
		comma = true;	
		pleaseenter = false;
	}
	if(question.length == 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "select a secret question, " + strErr;
		else
		{
			strErr = "select a secret question";
			comma = true;
		}				
		pleaseenter = false;
	}
	if (email.length <= 0 || email == "Email")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "an email address, " + strErr;
		else
		{
			strErr = "an email address";
			comma = true;
		}				
		pleaseenter = true;
	}


	if(comma)
	{
		if(pleaseenter)
			strErr = "Please enter " + strErr + ".";
		else
			strErr = "Please " + strErr + ".";
	}
	else
	{
		if(InvalidEmail(email))
		{
			strErr = "Not a valid email address.";
			comma = true;
		}
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{			
		document.getElementById("advfpid").value="true";
		document.frmBusUpdate.submit();
	}
}

// Business Update / Dashboard - Advertiser Havn't Received Password
function BUHaveNotReceived(bn, cn, em, ph, pass, cpass, qst, ans)
{
	var bname = Trim(document.getElementById(bn).value);
	var cname = Trim(document.getElementById(cn).value);
	var email = Trim(document.getElementById(em).value);
	var phone = Trim(document.getElementById(ph).value);
	var password = Trim(document.getElementById(pass).value);
	var cpassword = Trim(document.getElementById(cpass).value);
	var question = document.getElementById(qst).selectedIndex;
	var answer = Trim(document.getElementById(ans).value);
	
	var comma = false;
	var last = false;
	var andDone = false;
	var pleaseenter = true;

	var strErr = "";

	if(answer.length <= 0)
	{
		strErr = "answer your secret question";
		last = true;
		comma = true;	
		pleaseenter = false;
	}
	if(question == 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "select a secret question, " + strErr;
		else
		{
			strErr = "select a secret question";
			comma = true;
		}				
		pleaseenter = false;
	}
	if(cpassword.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "confirm your password, " + strErr;
		else
		{
			strErr = "confirm your password";
			comma = true;
		}			
		pleaseenter = false;
	}
	if(password.length <= 0)
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your password, " + strErr;
		else
		{
			strErr = "your password";
			comma = true;
		}				
		pleaseenter = true;
	}
	if(phone.length <= 0 || phone == "Phone")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your phone number, " + strErr;
		else
		{
			strErr = "your phone number";
			comma = true;
		}
		pleaseenter = true;
	}
	if(email.length <= 0 || email == "Email")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your email address, " + strErr;
		else
		{
			strErr = "your email address";
			comma = true;
		}
		pleaseenter = true;
	}
	if(cname.length <= 0 || cname == "Contact Name")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your contact name, " + strErr;
		else
		{
			strErr = "your contact name";
			comma = true;
		}
		pleaseenter = true;
	}
	if(bname.length <= 0 || bname == "Business Name")
	{
		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your business name, " + strErr;
		else
		{
			strErr = "your business name";
			comma = true;
		}
		pleaseenter = true;
	}

	if(comma)
	{
		if(pleaseenter)
			strErr = "Please enter " + strErr + ".";
		else
			strErr = "Please " + strErr + ".";
	}
	else
	{
		if(InvalidEmail(email))
		{
			strErr = "Not a valid email address.";
			comma = true;
		}
		else if(InvalidPhone(phone))
		{
			strErr = "Not a valid phone number.";
			comma = true;
		}
		else if(phone.length <10)
		{
			strErr = "Phone number must include an area code.";
			comma = true;
		}
		else if(password != cpassword)
		{
			strErr = "Passwords do not match.";
			comma = true;
		}
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{		
			
		document.getElementById("advHNRid").value="true";
		document.forms[0].submit();
	}
}

//**********************************************************************
//						Dashboard
//**********************************************************************
// Dashboard - User Setup Validation
function userSetupValidation(fn,ln,em,cem,pass,cpass,chka,chkl,chkc,chks,chko,chkp,chkpp,txtp,txtpp)
{
	var strError = "";

	var fname = Trim(document.getElementById(fn).value);
	var lname = Trim(document.getElementById(ln).value);
	var email = Trim(document.getElementById(em).value);
	var cemail = Trim(document.getElementById(cem).value);
	var password = Trim(document.getElementById(pass).value);
	var cpassword = Trim(document.getElementById(cpass).value);
	var chkadmin = document.getElementById(chka);
	var chklist = document.getElementById(chkl);
	var chkcontact = document.getElementById(chkc);
	var chkstats = document.getElementById(chks);
	var chkother = document.getElementById(chko);
	var chkpartner = document.getElementById(chkp);
	var chkprivpartner = document.getElementById(chkpp);
	var partner = Trim(document.getElementById(txtp).value)
	var privpartner = Trim(document.getElementById(txtpp).value)
	
	var valid = true;

	var pleaseenter = false;
	var andDone = false;
	var last = true;
	var comma = false;
	
	if(fname.length == 0)
	{
		document.getElementById('spFName').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spFName').style.display="none";
		
	if(lname.length == 0)
	{
		document.getElementById('spLName').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spLName').style.display="none";
		
	if(email.length == 0)
	{
		document.getElementById('spEmail').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spEmail').style.display="none";
	
	if(cemail.length == 0)
	{
		document.getElementById('spCEmail').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spCEmail').style.display="none";
		
	if(password.length == 0)
	{
		document.getElementById('spPassword').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spPassword').style.display="none";
		
	if(cpassword.length == 0)
	{
		document.getElementById('spCPassword').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spCPassword').style.display="none";
		
	if(!chkadmin.checked && !chklist.checked && !chkcontact.checked && !chkstats.checked && !chkother.checked && !chkpartner.checked && !chkprivpartner.checked)
	{
		document.getElementById('spRole').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spRole').style.display="none";
		
	if(chkpartner.checked && (partner.length == 0 || partner == "enter company name"))
	{
		document.getElementById('spPartner').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spPartner').style.display="none";
	
	if(chkprivpartner.checked && (privpartner.length == 0 || privpartner == "enter company name"))
	{
		document.getElementById('spPrivPartner').style.display="inline";
		valid = false;
	}
	else
		document.getElementById('spPrivPartner').style.display="none";
		
	if(email.length > 0)
	{
		if(InvalidEmail(email))
		{
			document.getElementById('spInvEmail').style.display="inline";
			valid = false;			
		}
		else
			document.getElementById('spInvEmail').style.display="none";
	}
	else
		document.getElementById('spInvEmail').style.display="none";
	
	
	if(cemail.length > 0)
	{
		if(InvalidEmail(cemail))
		{
			document.getElementById('spInvCEmail').style.display="inline";
			valid = false;			
		}
		else
			document.getElementById('spInvCEmail').style.display="none";
	}
	else
		document.getElementById('spInvCEmail').style.display="none";
			
	if(email != cemail && email.length > 0 && cemail.length > 0)
	{
		document.getElementById('spEmailMatch').style.display="inline";
		valid = false;			
	}
	else
		document.getElementById('spEmailMatch').style.display="none";
		
	if(password != cpassword && password.length > 0 && cpassword.length > 0)
	{
		document.getElementById('spPasswordMatch').style.display="inline";
		valid = false;			
	}
	else
		document.getElementById('spPasswordMatch').style.display="none";
			
			
	if(valid)
	{
		document.getElementById("setupid").value="true";
		document.forms[0].submit();
	}
}


// Dashboard - Feedback Response Validation
function responseValidation(sbj,resp)
{
	var subject = Trim(document.getElementById(sbj).value);
	var response = Trim(document.getElementById(resp).value);
	var strError = "";

	var last = false;
	var andDone = false;
	var comma = false;
	
	if(response.length == 0)
	{
		strError = "a response";
		last = true;
		comma = true;
	}
	if(subject.length == 0)
	{
		if(last && !andDone)
		{
			strError = "and " + strError;
			last = false;
			andDone = true;
		}
		else
			last = true;
			
		if(comma)
			strError = "a subject " + strError;
		else
		{
			strError = "a subject";
			comma = true;
		}					
	}
	
	if(strError.length != 0)
	{
		strError = "Please enter " + strError + ".";
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("responseid").value="true";
		document.frmDashboard.submit();
	}
}


// Dashboard - Search Validation
function dashSearchValidation(srch,st)
{
	var search = Trim(document.getElementById(srch).value);
	var state = document.getElementById(st).selectedIndex;
	var strError = "";

	if(search.length == 0)
	{
		strError = "Please enter a Case Number, Company Name, or Phone Number.";
		//if(state == 0)
		//	strError += ", and select a State.";
		//else
		//	strError += ".";	
	}
//	else
//	{
//		if(state == 0)
//			strError = "Please select a State.";	
//	}
		
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("searchid").value="true";
		document.frmDashboard.submit();
	}
}

// Dashboard - Feedback Search Validation
function dashFeedbackSearchValidation(srch)
{
	var search = Trim(document.getElementById(srch).value);
	var strError = "";

	if(search.length == 0)
		strError = "Please enter a Case Number, Name, Email, City, Zip, or Phone Number.";
		
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("searchid").value="true";
		document.frmDashboard.submit();
	}
}

// Dashboard - Password Search Validation
function dashPassSearchValidation(srch)
{
	var search = Trim(document.getElementById(srch).value);
	var strError = "";

	if(search.length == 0)
		strError = "Please enter a Phone Number.";
	else
	{
		if(InvalidPhone(search))
			strError = "Please enter a valid Phone Number.";
		else if(search.length < 10)
			strError = "Phone number must include an area code.";	
	}
		
	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("searchid").value="true";
		document.frmDashboard.submit();
	}
}


// Dashboard - Business Update: Non-Advertiser Business Validation
function busupdateNCValidation(bn,ba,bc,bs,bz,bp,be,btfp)
{
	var busname = Trim(document.getElementById(bn).value);
	var address = Trim(document.getElementById(ba).value);
	var city = Trim(document.getElementById(bc).value);
	var state = document.getElementById(bs).selectedIndex;
	var zip = Trim(document.getElementById(bz).value);
	var phone = Trim(document.getElementById(bp).value);
	var busemail = Trim(document.getElementById(be).value);
	var tollfree = Trim(document.getElementById(btfp).value);

	var comma = false;
	var last = false;
	var andDone = false;

	var strErr = "";
	
	var strBusErr = businessValidation(busname,address,city,state,zip,phone);
	
	if(strBusErr != "")
	{
		strErr += "Business Information: " + strBusErr;
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{			
		if(busemail.length > 0)
		{
			if(InvalidEmail(busemail))
				strErr = "Not a valid Business Email Address.  ";
		}
		if(tollfree.length > 0 && strErr.length == 0)
		{
			if(InvalidPhone(tollfree))
				strErr += "Not a valid Toll-Free Phone Number.  ";
		}
		if(phone.length < 10)
			strErr += "Phone number must include an area code.";
	
		if(strErr.length != 0)
		{
			alert(strErr);
			return false;
		}
		if(strErr.length == 0)
		{	
			document.getElementById("busid").value="true";
			document.frmBusUpdate.submit();
		}
	}			
}


// Dashboard - Feedback Reply
function dashFeedbackReply(rpl)
{
	var reply = Trim(document.getElementById(rpl).value);
	var strError = "";

	if(reply.length == 0)
		strError = "Please enter a reply.";

	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("replyid").value="true";
		document.frmFeedbackReponse.submit();
	}
}



// Dashboard - Yahoo Validation
function yahooValidation(cat,cty,st)
{
	var category = Trim(document.getElementById(cat).value);
	var city = Trim(document.getElementById(cty).value);
	var state = document.getElementById(st).selectedIndex;
	var strError = "";

	var last = false;
	var andDone = false;
	var comma = false;
	
	if(state == 0)
	{
		strError = "a state";
		last = true;
		comma = true;
	}
	if(city.length == 0)
	{
		if(last && !andDone)
		{
			strError = "and " + strError;
			last = false;
			andDone = true;
		}
		else
			last = true;
			
		if(comma)
			strError = "a city, " + strError;
		else
		{
			strError = "a city";
			comma = true;
		}					
	}
	if(category.length == 0)
	{
		if(last && !andDone)
		{
			strError = "and " + strError;
			last = false;
			andDone = true;
		}
		else
			last = true;
			
		if(comma)
			strError = "a category, " + strError;
		else
		{
			strError = "a category";
			comma = true;
		}		
	}
	
	if(strError.length != 0)
	{
		strError = "Please enter " + strError + ".";
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("yahooid").value="true";
		document.frmYahooRating.submit();
	}
}

// Dashboard - Feedback Reply
function dashFeedbackEmail(em)
{
	var email = Trim(document.getElementById(em).value);
	var strError = "";

	if(email.length == 0)
		strError = "Please enter an email address.";

	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		if(InvalidEmail(email))
		{
			strError = "Please enter a valid email address.";
			alert(strError);
			return false;
		}
		else
		{
			document.getElementById("emailid").value="true";
			document.frmFeedbackReponse.submit();
		}
	}
}


// Dashboard - Advertiser Contact/Business Validation
function dashBUAdvValidation(cn,ce,cce,cpass,ccpass,cp,bn,ba,bc,bs,bz,bp,be,btfp)
{
	var conname = Trim(document.getElementById(cn).value);
	//var contitle = Trim(document.getElementById(ct).value);
	var conemail = Trim(document.getElementById(ce).value);
	var concemail = Trim(document.getElementById(cce).value);
	var conpass = Trim(document.getElementById(cpass).value);
	var concpass = Trim(document.getElementById(ccpass).value);
	//var conquestion = document.getElementById(cq).selectedIndex;
	//var conanswer = Trim(document.getElementById(ca).value);	
	var conphone = Trim(document.getElementById(cp).value);
	var busname = Trim(document.getElementById(bn).value);
	var address = Trim(document.getElementById(ba).value);
	var city = Trim(document.getElementById(bc).value);
	var state = document.getElementById(bs).selectedIndex;
	var zip = Trim(document.getElementById(bz).value);
	var phone = Trim(document.getElementById(bp).value);
	var busemail = Trim(document.getElementById(be).value);
	var tollfree = Trim(document.getElementById(btfp).value);

	var comma = false;
	var last = false;
	var andDone = false;
	var noenter = false;

	var strErr = "";

	/*
	if(concemail.length <= 0)
	{
		strErr = "confirm your email address";
		last = true;
		comma = true;	
		noenter = true;		
	}

	if(conemail.length <= 0)
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your email address, " + strErr;
		else
		{
			strErr = "your email address";
			comma = true;
		}				
	}
	if(conname.length <= 0 || conname == "None")
	{
		noenter = false;

		if(last && !andDone)
		{
			strErr = "and " + strErr;
			andDone = true;
		}
		else
		{
			last = true;
		}

		if(comma)
			strErr = "your name, " + strErr;
		else
		{
			strErr = "your name";
			comma = true;
		}
		
	}*/

	if(comma)
	{
		if(noenter)
			strErr = "Please " + strErr + ".";
		else
			strErr = "Please enter " + strErr + ".";
	}
	else
	{
	
		if(conemail.length > 0 && InvalidEmail(conemail))
		{
			strErr = "Not a valid email address.  ";
			comma = true;
		}
		if(concemail.length > 0 && InvalidEmail(concemail))
		{
			strErr += "Not a valid confirm email address.  ";
			comma = true;
		}
		if((conemail.length > 0 || conemail.length > 0) && conemail != concemail)
		{
			strErr += "Emails do not match.  ";
			comma = true;
		}
		
		if(Trim(conpass).length>0 || Trim(concpass).length>0)
		{
			if(conpass != concpass)
			{
				strErr += "Passwords do not match.  ";
				comma = true;
			}
		}
		if(Trim(conphone).length>0 && conphone != "None")
		{
			if(InvalidPhone(conphone))
			{
				strErr += "Not a valid phone number.  ";
				comma = true;
			}
			else if(conphone.length < 10)
			{
				strErr += "Contact phone number must include an area code.";
				comma = true;
			}
		}
	}
	
	var strBusErr = businessValidation(busname,address,city,state,zip,phone);
	
	if(strErr != "")
	{				
		strErr = "Contact Information: " + strErr;

		if(strBusErr != "")
			strErr += "\n\n";
	}
	if(strBusErr != "")
	{
		strErr += "Business Information: " + strBusErr;
	}
	
	if(strErr.length != 0)
	{
		alert(strErr);
		return false;
	}
	else
	{				
		if(busemail.length > 0)
		{
			if(InvalidEmail(busemail))
				strErr = "Not a valid Business Email Address.  ";
		}
		if(tollfree.length > 0)
		{
			if(InvalidPhone(tollfree))
				strErr += "Not a valid Toll-Free Phone Number.";
		}
		if(phone.length < 10)
		{
			strErr += "Business phone number must include an area code.";
			comma = true;
		}
	
		if(strErr.length != 0)
		{
			alert(strErr);
			return false;
		}
		else
		{	
			document.getElementById("busid").value="true";
			document.frmBusUpdate.submit();
		}
	}			
}
//**********************************************************************
//								FCNs
//**********************************************************************

// FCNs Add Category 
function FCNAddCat(txt)
{
	var add = Trim(document.getElementById(txt).value);
	//var move = document.getElementById(ddl).selectedIndex;
	var strError = "";

	if((add.length == 0 || add == "Add a new category"))
		strError = "Please enter a new category name.";

	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("fcnaddcatid").value="true";
		document.frmMyPlaceLogin.submit();
	}

}

// FCNs Add Category 
function FCNMoveCat(ddl)
{
	var move = document.getElementById(ddl).selectedIndex;
	var strError = "";

	if(move <= 0)
		strError = "Please select a category.";

	if(strError.length != 0)
	{
		alert(strError);
		return false;
	}
	else
	{			
		document.getElementById("fcnaddcatid").value="true";
		document.frmMyPlaceLogin.submit();
	}

}

//**********************************************************************
//								Registration
//**********************************************************************


function RegVerify(cd,ps)
{
	var code = Trim(document.getElementById(cd).value);
	var pass = Trim(document.getElementById(ps).value);
	var valid = true;

	if(code.length <= 0)
	{
		document.getElementById("spanCodeReq").style.display = "inline";
		valid = false;
	}
	else
		document.getElementById("spanCodeReq").style.display = "none";

	if(pass.length <= 0)
	{
		document.getElementById("spanPassReq").style.display = "inline";
		valid = false;
	}
	else
		document.getElementById("spanPassReq").style.display = "none";
		
	if(valid)
	{		
		document.getElementById("validid").value="true";
		document.frmMyPlaceLogin.submit();
	}

}


function LoadAddFriends(chk)
{
	var cbox = "0";
	
	if(document.getElementById(chk).checked)
		cbox = "1";

	location.href='frmAddFriends.aspx?invb=' + cbox;
}


function LoadMyPlace(chk)
{
	var cbox = "0";
	
	if(document.getElementById(chk).checked)
		cbox = "1";

	location.href='frmUpdateProfile.aspx?invb=' + cbox;
}


//**********************************************************************
//****                    Formatting Functions                      ****
//**********************************************************************

// Trim String
function Trim(inString) 
{
  inString = inString.replace( /^\s+/g, "" );	// strip leading
  return inString.replace( /\s+$/g, "" );		// strip trailing
}

// Invalid E-mail
function InvalidEmail(email)
{
	var atsign = email.indexOf("@");
	var period = email.lastIndexOf(".");
	
	if(atsign == -1)
		return true;
	else if(atsign == 0 || atsign == email.length)
		return true;
	
	if(period == -1)
		return true;
	else if(period == 0 || period == email.length)
		return true;
	else if(email.charAt(period-1) == '@')
		return true;
	else if(period < atsign)
		return true;
		
	return false;
}

// Invalid Zip code
function InvalidZip(zip)
{
	numberzip = Trim(zip).replace("-","");
	
	if(!isInteger(numberzip))
		return true;
		
	if(zip.indexOf("-") == -1)
	{
		if(Trim(zip).length != 5)
			return true;	
	}
	else
	{	
		var zipstart = Trim(zip).substring(0,zip.indexOf("-"));
		var zipend = Trim(zip).substring(zip.indexOf("-")+1,Trim(zip).length);
		
		if(zipstart.length != 5 || zipend.length != 4)
			return true;
	}

	return false;
}

// Invalid Phone No.
function InvalidPhone(phone)
{
	var fmtphone = Trim(phone).replace(/ /g,"");
	fmtphone = fmtphone.replace(/-/g,"");
	fmtphone = fmtphone.replace("(","");
	fmtphone = fmtphone.replace(")","");
	
	if(!isInteger(fmtphone))
		return true;

	// 9999999
	if(fmtphone.length == 7)
	{
		if(phone.indexOf("-") != -1)
		{
			if(Trim(phone).charAt(3) != '-')
				return true;
			else if(!isInteger(Trim(phone).replace("-","")))
				return true;
		}	
	}
	// 1112223333
	else if(fmtphone.length == 10)
	{
		if(phone.indexOf("(") != -1)
		{
			if(Trim(phone).charAt(0) != '(' && Trim(phone).charAt(4) != ')')
				return true;
			if(Trim(phone).charAt(Trim(phone).length-5) != '-')
				return true;		
		}
		else if(phone.indexOf("-") != -1)
		{
			// (111) 222-3333 or 111-222-3333 or 111 222-3333
			if(!(Trim(phone).charAt(3) == '-' || Trim(phone).charAt(3) == ' ') ||
			 Trim(phone).charAt(Trim(phone).length-5) != '-')
				return true;	
		}
	}
	// 18001112222 
	else if(fmtphone.length == 11)
	{
		var nospace = phone.replace(/ /g,"");
		
		if(phone.indexOf("(") != -1)
		{
			if(nospace.charAt(1) != '(' && nospace.charAt(4) != ')')
				return true;
			else if(nospace.charAt(nospace.length-5) != '-')
				return true;		
		}
		else if(phone.indexOf("-") != -1)
		{		
			if(!(Trim(phone).charAt(1) == '-' || Trim(phone).charAt(1) == ' ') || 
		 	!(Trim(phone).charAt(5) == '-' || Trim(phone).charAt(5) == ' ') ||
			nospace.charAt(nospace.length-5) != '-')
				return true;
		}
	}
	else
		return true;

	return false;
}

// Check to see if string is all numeric
function isInteger(num)
{
	var numbers = "0123456789";
	var i = 0;
	
	for(i=0;i<num.length;i++)
	{
		if(numbers.indexOf(num.charAt(i)) == -1)
			return false;	
	}
	
	return true;
}