 function emailadr(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("emailadr").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("emailadr").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("emailadr").style.backgroundColor = '#d9e2f1';	
	
		       error = "Invalid E-mail\n";
		   return error;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		document.getElementById("emailadr").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("emailadr").style.backgroundColor = '#d9e2f1';	

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

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

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

		   return error;
		 }

		   return error; 
}

function validate_form() {
var reason = "";


	reason += emailadr(document.beboform.emailadr.value);
	reason += validatefullname();
	reason += validatewebURL();
	reason += validatecode();
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{
  document.beboform.submit();
   }



}
function validatefullname() {
    var error = "";
 
    if (document.beboform.fullname.value == "") 
	{	
		document.getElementById("fullname").style.backgroundColor = '#d9e2f1';
        error = "Please specify your full name.\n";
    } 
    return error;  

}

function validatewebURL() {
    var error = "";
 
    if (document.beboform.webURL.value == "") 
	{	
		document.getElementById("webURL").style.backgroundColor = '#d9e2f1';
        error = "Please specify your web address.\n";
    } 
    return error;  

}

function validatecode() {
    var error = "";
 
    if (document.beboform.code.value == "") 
	{	
		document.getElementById("code").style.backgroundColor = '#d9e2f1';
        error = "Please enter the correct answer.\n";
    } 
    return error;  

}
