function validatefields() {
	var strname;
	var stremail;
	var strhomephone;
	var strworkphone;
	var strcellphone;
	var error=false;
	var msg="";
	
	strname=window.document.contact.name.value;
	stremail=window.document.contact.email.value;
	strhomephone=window.document.contact.homephone.value;
	strworkphone=window.document.contact.workphone.value;
	strcellphone=window.document.contact.cellphone.value;
	
	
	if (strname=="") {
		msg="Please enter your first and last name.\n"
		error=true;
	}
	
	if (stremail=="") {
		msg = msg +"Please put in an email address so we may contact you.\n";
		error=true;
	}
	else if(!EmailIsValid(stremail)){
		msg = msg + "Please enter in a valid email address.\n";
		error = true;
	}
	
	if ((strhomephone=="")&&(strworkphone=="")&&(strcellphone=="")) {
		msg = msg + "Please put in a phone number so we may contact you.\n";
		error=true;
	} 
	
	if (error==true) {
			alert(msg);
			return false;
	}
	return true;
}

function EmailIsValid(checkThisEmail)
{
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID

if (myAtSymbolAt < 1 )
 {myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID

if (myLastDotAt < myAtSymbolAt)
 {myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2)
 {myEMailIsValid = false}


// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid

if (mySpaceAt != -1)
 {myEMailIsValid = false}

return myEMailIsValid
}
