 function email(str) {
	    var error = "";
  var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){  
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	
		
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){  
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	
	
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	
	
		       error = "Invalid E-mail\n";
		   return error;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	

		     error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){	 
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	

		      error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){	
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	

		   error = "Invalid E-mail\n";
		   return error;
		 }
		
		 if (str.indexOf(" ")!=-1){
		     error = "Invalid E-mail\n";
		document.getElementById("email").style.backgroundColor = '#d9e2f1';	

		   return error;
		 }

		   return error; 
}

function validate_form() {
var reason = "";


	reason += email(document.form.email.value);
	reason += validatefname();	
  	reason += validatelname();
	reason += validatetelephone();
	reason += validateservice();
	
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{
   document.form.submit();
   }


}
function validatefname() {
    var error = "";
 
    if (document.form.fname.value == "") 
	{	
		document.getElementById("fname").style.backgroundColor = '#d9e2f1';
        error = "Please specify your first name.\n";
    } 
    return error;  

}

function validatelname() {
    var error = "";
 
    if (document.form.lname.value == "") 
	{	
		document.getElementById("lname").style.backgroundColor = '#d9e2f1';
        error = "Please specify your surname.\n";
    } 
    return error;  

}

function validatetelephone() {
    var error = "";
 
    if (document.form.telephone.value == "") 
	{	
		document.getElementById("telephone").style.backgroundColor = '#d9e2f1';
        error = "Please specify your telephone number.\n";
    } 
    return error;  
}

function validateservice() {
    var error = "";
 
    if (document.form.service.value == "Please Select") 
	{	
		document.getElementById("service").style.backgroundColor = '#d9e2f1';
        error = "Please specify the services you are interested in.\n";
    } 
    return error;  
}
	 
//function validatecheck() {
//    var error = "";
// 
// if (document.form.checkbox.checked == false)
//    {
//        document.getElementById("checkbox").style.backgroundColor = '#d9e2f1';	
//		error= "Please accept the Terms and Conditons\n";
//   
//    } 
//    return error;  
//}	

