 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 += validatename();	
  	reason += validateservice();
  	reason += validatecomments();
	
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{
   document.form.submit();
   }


}
function validatename() {
    var error = "";
 
    if (document.form.name.value == "") 
	{	
		document.getElementById("name").style.backgroundColor = '#d9e2f1';
        error = "Please specify your name.\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 validatecomments() {
    var error = "";
 
    if (document.form.comments.value == "") 
	{	
		document.getElementById("comments").style.backgroundColor = '#d9e2f1';
        error = "Please specify your message.\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;  
//}	

