function checkfields()
 { var ok_to_send = true; with (document.forms.form1)
 { if (firstname.value == "" ) { alert("Please type in your first name.");
 firstname.focus(); ok_to_send = false; }
else if (surname.value == "" ) { alert("Please type in your last name."); surname.focus(); ok_to_send = false; }
else if (emailaddress.value == "" ) 
{ 
	alert("Please type in your email address."); 
	emailaddress.focus(); 
	ok_to_send = false; 
}else if(!isValidEmail(emailaddress.value))
{
	alert("Please type valid email address."); 
	emailaddress.focus(); 
	ok_to_send = false; 
}
else if (address.value == "" ) { alert("Please type in your House Number"); address.focus(); ok_to_send = false; }
else if (postcode.value == "" ) { alert("Please type in your Postcode"); postcode.focus(); ok_to_send = false; }
else if (telephone.value == "" ) { alert("Please type in your Tel. Number."); telephone.focus(); ok_to_send = false; }
/*else if ( mobile.value == "") { alert("Please type Mobile Number"); mobile.focus(); ok_to_send = false; }*/
if (ok_to_send) { return true; }
else { return false; }
 }
}


function isValidEmail (emailIn){

	var isEmailOk = false;
//	var filter = /^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9-]+(\.[a-zA-Z][a-zA-Z-]+)+$/
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;


	if(emailIn.search(filter) != -1)
		isEmailOk = true;
	if(emailIn.indexOf("..") != -1)
		isEmailOk = false;
	if(emailIn.indexOf(".@") != -1)
		isEmailOk = false;
	if(emailIn.indexOf("'") != -1 || emailIn.indexOf("''") != -1 || emailIn.indexOf("\"") != -1 || emailIn.indexOf("\"\"") != -1 || emailIn.indexOf("(") != -1  || emailIn.indexOf(")") != -1 || emailIn.indexOf("[") != -1 || emailIn.indexOf("]") != -1 || emailIn.indexOf("{") != -1  || emailIn.indexOf("}") != -1 || emailIn.indexOf(",") != -1 || emailIn.indexOf(",,") != -1 || emailIn.indexOf(":") != -1 || emailIn.indexOf(";") != -1 || emailIn.indexOf("#") != -1 || emailIn.indexOf("mailto:") != -1)
		isEmailOk = false;

	return isEmailOk;
} // Ends 
