// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
function emailvalidation(entered, alertbox)
{
with (entered)
	{
	apos=value.indexOf("@"); 
	dotpos=value.lastIndexOf(".");
	lastpos=value.length-1;
	if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
	{if (alertbox) {alert(alertbox);} return false;}
	else {return true;}
	}
} 

function emptyvalidation(entered, alertbox)
{
with (entered)
	{
	if (value==null || value=="")
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function checkvalidentry(entered, alertbox)
{
with (entered)
	{
	var _alpha = value.search(/[a-z]|[A-Z]/);
	var _num = value.search(/[0-9]/);
	if (value==null || value=="" || _alpha==-1 && _num==-1)
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function emptySelect(entered, alertbox)
{
// Emptyfield Validation for Select boxes by Puc Covelli / Mick Casey
// Please do not remove this line and the two lines above.
/* Checking if the Selectbox's field is empty.
Optional parameters are:
text --text that will show in an alertbox if content is illegal.*/
with (entered)
	{
	if (options[selectedIndex].value==null || options[selectedIndex].value=="")
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function allSelect(entered, alertbox)
{
with (entered)
	{
	if (options[selectedIndex].value=="All")
	{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
} 

// from /search/index.cfm
function formvalidation1(thisform)
{
with (thisform)
	{
	if (checkvalidentry(searchtext,"Please enter something in the search box")==false) {searchtext.focus(); return false;};
	}
} 

// from /contact/index.cfm
function formvalidation2(thisform)
{
with (thisform)
	{
	if (checkvalidentry(name,"Please complete the name field")==false) {name.focus(); return false;};
	if (checkvalidentry(companyname,"Please enter your company name")==false) {companyname.focus(); return false;};
	if (emailvalidation(email, "Please enter a valid email address")==false) {email.focus(); return false;};
	}
}

// from /media/index.cfm
function formvalidation3(thisform)
{
with (thisform)
	{
	if (checkvalidentry(firstname,"Please enter your first name")==false) {firstname.focus(); return false;};
	if (checkvalidentry(lastname,"Please enter your last name")==false) {lastname.focus(); return false;};
	if (checkvalidentry(companyname,"Please enter your company name")==false) {companyname.focus(); return false;};
	if (emailvalidation(email, "Please enter a valid email address")==false) {email.focus(); return false;};
	
	// checkbox validation
	if (privacy.checked == false) {alert ("Please read the Privacy Policy and check the box\n"); return false;}

	}
}

// from /investor/index.cfm
function formvalidation4(thisform)
{
with (thisform)
	{
	if (checkvalidentry(name,"Please complete the name field")==false) {name.focus(); return false;};
	if (checkvalidentry(companyname,"Please enter your company name")==false) {companyname.focus(); return false;};
	if (emailvalidation(email, "Please enter a valid email address")==false) {email.focus(); return false;};
	
	// checkbox validation
	if (privacy.checked == false) {alert ("Please read the Privacy Policy and check the box\n"); return false;}

	}
}

