 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 = '#bbddef';	
		
		   error = "please enter your e-mail\n";
		   return error;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){  
		document.getElementById("email").style.backgroundColor = '#bbddef';	
	
		   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 = '#bbddef';	
	
		       error = "Invalid E-mail\n";
		   return error;
		}

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

		     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 = '#bbddef';	

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

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

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

		   return error;
		 }

		   return error; 
}

function validate_form() {
var reason = "";


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


}

function validatewhen() {
    var error = "";
 
    if (document.form.when.value == "") 
	{	
		document.getElementById("when").style.backgroundColor = '#bbddef';
        error = "Please specify when you would like to see us.\n";
    } 
    return error;  

}

function validatename() {
    var error = "";
 
    if (document.form.name.value == "") 
	{	
		document.getElementById("name").style.backgroundColor = '#bbddef';
        error = "Please specify your full name.\n";
    } 
    return error;  

}


