// Garden cleaning quote
function validateGardenQuoteForm(form) {
if (form.fullname.value == "") {
   document.getElementById("errText").innerHTML = "<font color='red'><b>Please enter your name</b></font>";
   form.fullname.style.backgroundColor = '#CC3333';
   form.fullname.focus( );
   return false;
   }
   else
   {
   form.fullname.style.backgroundColor = '#ffffff';
   }

if (form.email.value == "") {
   document.getElementById("errText").innerHTML = "<font color='red'><b>Please enter your email address</b></font>";
   form.email.style.backgroundColor = '#CC3333';
   form.email.focus( );
   return false;
   }
   else
   {
   form.email.style.backgroundColor = '#ffffff';
   }
      
if (ewindowcheck(form.email.value)==false){
   document.getElementById("errText").innerHTML = "<font color='red'><b>Please enter a valid email address</b></font>";
   form.email.style.backgroundColor = '#CC3333';
   form.email.focus( );
   return false;
   }
   else
   {
   form.email.style.backgroundColor = '#ffffff';
   }
      
if (form.addr1.value == "") {
   document.getElementById("errText").innerHTML = "<font color='red'><b>Please enter the first line of your address</b></font>";
   form.addr1.style.backgroundColor = '#CC3333';
   form.addr1.focus( );
   return false;
   }
   else
   {
   form.addr1.style.backgroundColor = '#ffffff';
   } 
     
if (form.postcode.value == "") {
   document.getElementById("errText").innerHTML = "<font color='red'><b>Please enter the postcode of your address</b></font>";
   form.postcode.style.backgroundColor = '#CC3333';
   form.postcode.focus( );
   return false;
   }
   else
   {
   form.postcode.style.backgroundColor = '#ffffff';
   }
      
if (form.telno.value == "") {
   document.getElementById("errText").innerHTML = "<font color='red'><b>Please enter a contact number</b></font>";
   form.telno.style.backgroundColor = '#CC3333';
   form.telno.focus( );
   return false;
   }
   else
   {
   form.telno.style.backgroundColor = '#ffffff';
   }
}

// Email validation
function ewindowcheck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
}
