function doAlert(sMessage){
	$('alertholder').innerHTML = "";
	$('alertholder').style.display = "none";
	$('alertholder').innerHTML = sMessage;
	new Effect.Appear('alertholder');
}
function validateSearchForm(){
	if($('businesstype').selectedIndex==0){
		doAlert('Please select a business type.');
		new Effect.Highlight('businesstype',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}else{
		return true;	
	}
}
function validateEmailForm(){
	if($('title').selectedIndex==0){
		doAlert('Please select a title.');
		new Effect.Highlight('title',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}
	if (!JSLNotNull($('firstname'), "Please enter your first name.")) { 
		new Effect.Highlight('firstname',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}
	if (!JSLIsTextOnlyWithHyphens($('firstname'), "Please enter text only as your first name.")) { 
		new Effect.Highlight('surname',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}	
	if (!JSLNotNull($('surname'), "Please enter your surname.")) { 
		new Effect.Highlight('surname',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}	
	if (!JSLIsTextOnlyWithHyphens($('surname'), "Please enter text only as your surname.")) { 
		new Effect.Highlight('surname',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}
		if (!JSLNotNull($('email'), "Please enter your email address.")) { 
		new Effect.Highlight('email',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}	
	if (!JSLCheckIsEMail($('email'), "Please enter a valid email address.")) { 
		new Effect.Highlight('email',{startcolor:'#FAB320', endcolor:'#FFFFFF'});
		return false;
	}
	document.forms['emailresults'].submit();
}

function JSLNotNull(pctl, pmsg)
{
	if (pctl.value == "")
	{
		doAlert(pmsg); pctl.focus(); pctl.select(); return false;
	}
	return true;
}	

	
function JSLIsTextOnly(pctl, pmsg)
{
	pattern = /^([ ]|[a-zA-Z])+[a-zA-Z]+([ ]|[a-zA-Z])*$/;
	if (pattern.test(pctl.value)==false){doAlert(pmsg); pctl.focus(); pctl.select(); return false;}
	return true;
}

function JSLIsTextOnlyWithHyphens(pctl, pmsg)
{
	pattern = /^([ ]|[a-zA-Z-])+[a-zA-Z-]+([ ]|[a-zA-Z-])*$/;
	if (pattern.test(pctl.value)==false){doAlert(pmsg); pctl.focus(); pctl.select(); return false;}
	return true;
}		


function JSLCheckIsEMail(p_fld, pmsg) {
	 var atPos = p_fld.value.indexOf("@");
	 if (atPos < 1 || atPos == (p_fld.value.length - 1))
		 { doAlert(pmsg); p_fld.focus(); return false; }
	 atPos = p_fld.value.indexOf(" ");
	 if (atPos > -1)
		 { doAlert(pmsg); p_fld.focus(); return false; }
	 atPos = p_fld.value.indexOf(".");
	 if (atPos < 1 || atPos == (p_fld.value.length - 1))
		 { doAlert(pmsg); p_fld.focus(); return false; }
 return true;
}