function checkfields() {
	var strlname;
	var strfname;
	var straddress;
	var strcity;
	var strzip;
	var strhphone;
	var strwphone;
	var stremail;
	var strbmonth;
	var strbday;
	var strbyear;
	var strecontact;
	var strephone;
	var strerelation;
	var strbackground;
	var strexperience;
	var strworkshop;
	var error=false;
	var msg="";
	
	strlname=window.document.contact.last_name.value;
	strfname=window.document.contact.first_name.value;
	straddress=window.document.contact.address.value;
	strcity=window.document.contact.city.value;
	strzip=window.document.contact.zipcode.value
	strhphone=window.document.contact.home_phone.value;
	strwphone=window.document.contact.work_phone.value;
	stremail=window.document.contact.email.value;
	strbmonth=window.document.contact.birth_month.value;
	strbday=window.document.contact.birth_day.value;
	strbyear=window.document.contact.birth_year.value;
	strecontact=window.document.contact.emergency_contact.value;
	strephone=window.document.contact.emergency_contact_phone.value;
	strerelation=window.document.contact.emergency_contact_relationship.value;
	strbackground=window.document.contact.educational_background.value;
	strexperience=window.document.contact.bodywork_experience.value;
	strworkshop=window.document.contact.workshop.value;
	
	
	if (strlname=="") {
		msg="Please provide your last name.\n"
		error=true;
	}
	
	if (strfname=="") {
		msg = msg +"Please provide your first name.\n";
		error=true;
	}
	
	if (straddress=="") {
		msg = msg +"Please provide your address.\n";
		error=true;
	}
	
	if (strcity=="") {
		msg = msg +"Please provide your city.\n";
		error=true;
	}
	
	if (document.contact.state.selectedIndex == 0){
        msg = msg +"Please select a state.\n";
			error=true;
    }
	
	if (strzip=="") {
		msg = msg +"Please provide your zipcode.\n";
		error=true;
	}
	
	if (strhphone=="") {
		msg = msg +"Please provide your home phone.\n";
		error=true;
	}
	
	if (strwphone=="") {
		msg = msg +"Please provide your work phone.\n";
		error=true;
	}
	
	if (stremail=="") {
		msg = msg +"Please provide your email address.\n";
		error=true;
	}
	
	else if(!EmailIsValid(stremail)){
		msg = msg + "Please enter in a valid email address.\n";
		error = true;
	}
	
	if (strbmonth=="") {
		msg = msg +"Please provide your birth month.\n";
		error=true;
	}
	
	if (strbday=="") {
		msg = msg +"Please provide your birth day.\n";
		error=true;
	}
	
	if (strbyear=="") {
		msg = msg +"Please provide your birth year.\n";
		error=true;
	}
	
	if ((document.contact.sex[0].checked==false)
		&& (document.contact.sex[1].checked==false)) {
			msg = msg +"Please provide your sex.\n";
			error=true;
	}
	
	if (strecontact=="") {
		msg = msg +"Please provide emergency contact name.\n";
		error=true;
	}
	
	if (strephone=="") {
		msg = msg +"Please provide emergency contact phone.\n";
		error=true;
	}
	
	if (strerelation=="") {
		msg = msg +"Please provide relationship with emergency contact.\n";
		error=true;
	}
	
	if (strbackground=="") {
		msg = msg +"Please provide your educational background.\n";
		error=true;
	}
	
	if (strexperience=="") {
		msg = msg +"Please provide any bodywork experience.\n";
		error=true;
	}
	
	if (strworkshop=="") {
		msg = msg +"Please provide the workshop name.\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
}