 function yourEmail(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("yourEmail").style.backgroundColor = '#d9e2f1';	
		
		   error = "please enter your e-mail\n";
		   return error;
		}

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

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

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

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

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

		   return error;
		 }

		   return error; 
}


function validate_formThree() {
var reason = "";


	reason += validateyourName();	
	reason += validateyourCompany();
	reason += validateyourPosition();
	reason += validateyourAddress();
	reason += validateyourPostcode();
	reason += validateyourTel();
	reason += yourEmail(document.refer.yourEmail.value);

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


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

}

function validateyourCompany() {
    var error = "";
 
    if (document.refer.yourCompany.value == "") 
	{	
		document.getElementById("yourCompany").style.backgroundColor = '#d9e2f1';
        error = "Please specify your company name.\n";
    } 
    return error;  
}

function validateyourPosition() {
    var error = "";
 
    if (document.refer.yourPosition.value == "") 
	{	
		document.getElementById("yourPosition").style.backgroundColor = '#d9e2f1';
        error = "Please specify your position.\n";
    } 
    return error;  
}

function validateyourAddress() {
    var error = "";
 
    if (document.refer.yourAddress.value == "") 
	{	
		document.getElementById("yourAddress").style.backgroundColor = '#d9e2f1';
        error = "Please specify your address.\n";
    } 
    return error;  
}

function validateyourPostcode() {
    var error = "";
 
    if (document.refer.yourPostcode.value == "") 
	{	
		document.getElementById("yourPostcode").style.backgroundColor = '#d9e2f1';
        error = "Please specify your postcode.\n";
    } 
    return error;  
}

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