// JavaScript Document
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){

		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){

		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){

		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){

		    return false
		 }

 		 return true					
	}



function check_form(form)
{
	var error = document.getElementById("error");
	var first_name = document.getElementById("first_name");
	var surname = document.getElementById("surname");
	var address1 = document.getElementById("address1");
	var city = document.getElementById("city");
	var county = document.getElementById("county");	
	var country = document.getElementById("country");	
	var post_code = document.getElementById("post_code");	
	var email = document.getElementById("email");	
	var return_val=true;
	
	email.style.backgroundColor="#FFFFFF";			
	post_code.style.backgroundColor="#FFFFFF";
	country.style.backgroundColor="#FFFFFF";
	county.style.backgroundColor="#FFFFFF";		
	city.style.backgroundColor="#FFFFFF";		
	address1.style.backgroundColor="#FFFFFF";
	surname.style.backgroundColor="#FFFFFF";
	first_name.style.backgroundColor="#FFFFFF";				
				
	if((form.email.value=="")||(echeck(form.email.value)==false))
		{   
		error.firstChild.nodeValue="Please enter a valid E-mail address"; 
		form.email.focus();
		form.email.select();
		email.style.backgroundColor="#FFCC80";		
		return_val=false;
		}			
	if(form.post_code.value=="")
	{
		error.firstChild.nodeValue="Please enter your post code";
		form.post_code.focus();
		form.post_code.select();
		post_code.style.backgroundColor="#FFCC80";
		return_val=false		
	}
	if(form.country.value=="")
	{
		error.firstChild.nodeValue="Please enter your country";
		form.country.focus();
		form.country.select();
		country.style.backgroundColor="#FFCC80";
		return_val=false;		
	}
	if(form.county.value=="")
	{
		error.firstChild.nodeValue="Please enter your county";
		form.county.focus();
		form.county.select();
		county.style.backgroundColor="#FFCC80";
		return_val=false;		
	}
	if(form.city.value=="")
	{
		error.firstChild.nodeValue="Please enter your city";
		form.city.focus();
		form.city.select();
		city.style.backgroundColor="#FFCC80";
		return_val=false;		
	}
	if(form.address1.value=="")
	{
		error.firstChild.nodeValue="Please enter your address";
		form.address1.focus();
		form.address1.select();
		address1.style.backgroundColor="#FFCC80";
		return_val=false;	
	}
	if(form.surname.value=="")
	{
		error.firstChild.nodeValue="Please enter your surname";
		form.surname.focus();
		form.surname.select();
		surname.style.backgroundColor="#FFCC80";
		return_val=false;	
	}
		if(form.first_name.value=="")
	{
		error.firstChild.nodeValue="Please enter your first name";
		form.first_name.focus();
		form.first_name.select();
		first_name.style.backgroundColor="#FFCC80";
		return_val=false;		
	}

	return(return_val);
}
function check_email(form)
{
	var emailerror = document.getElementById("emailerror");
	var email = document.getElementById("email");	
	var return_val=true;
	
	email.style.backgroundColor="#FFFFFF";			
			
	if((form.email.value=="")||(echeck(form.email.value)==false))
		{   
		emailerror.firstChild.nodeValue="Invalid E-mail address"; 
		form.email.focus();
		form.email.select();
		email.style.backgroundColor="#FFCC80";		
		return_val=false;
		}			

	return(return_val);
}



