
function IsEmpty(a) {
   if ((a.value.length==0) ||
   (a.value==null)) {
      return true;
   }
   else { return false; }
}	


function checkform ( form )
{
		var mesg ="";

   if(IsEmpty(form.licence)) 
   { 
	  mesg += 'Please enter your License Plate number' + '\n\n';
      form.licence.focus(); 
	  form.licence.className = "inputtxterror";
	}  else {
		form.licence.className = "inputtxt";
	}


   if(IsEmpty(form.name)) 
   { 
	  mesg += 'Please enter your Name'  + '\n\n';
      form.name.focus(); 
	  form.name.className = "inputtxterror";
	}  else {
		form.name.className = "inputtxt";
	}

   if(IsEmpty(form.phone)) 
   { 
	  mesg += 'Please enter your phone number' + '\n\n';
      form.phone.focus(); 
	  form.phone.className = "inputtxterror";
	}  else {
		form.phone.className = "inputtxt";
	}

   if (!isPhoneNumber(form.phone))
   {
      return false; 
   } 

	if (valButton(form.contacted) == null) {
	  mesg += 'Please tell us if you would like us to contact you' + '\n\n';
   } 

   
   if(IsEmpty(form.city)) 
   { 
      form.city.focus(); 
	  form.city.className = "inputtxterror";
	  mesg += 'Please enter the City' + '\n\n';
   } else {
		form.city.className = "inputtxt";
		}

	if (!ValidateEmail(form.email)) {
      return false; 
	}
	
	
	if(IsEmpty(form.modelcar)) 
  	 { 
	  mesg += 'Please enter the Model of your car' + '\n\n';
      form.modelcar.focus(); 
	  form.modelcar.className = "inputtxterror";
	   }   	else {
		 form.modelcar.className = "inputtxt";
	}
  

	if (valButton(form.contacted) == null) {
	  	  mesg += 'Please tell us if you would like us to contact you' + '\n\n';
		  form.contacted.className = "inputradioerror";inputradioerror
	   }   	else {
		 form.contacted.className = "inputradio";
	}

	if (valButton(form.attitude) == null) {
	  	  mesg += 'Please select a rating for the Attitude of Employees' + '\n\n';
		  form.attitude.className = "inputradioerror";
	   }   	else {
		 form.attitude.className = "inputradio";
	}
	

	if (valButton(form.appearance) == null) {
	  	  mesg += 'Please select a rating for the appearance of Employees' + '\n\n';
   } 

   if (valButton(form.vacuum) == null) {
	  	  mesg += 'Please select a rating for the vacuum quality' + '\n\n';
   } 
	
	if (valButton(form.exterior) == null) {
	  	  mesg += 'Please select a rating for the Exterior Quality' + '\n\n';
   } 
	
	if (valButton(form.window) == null) {
	  	  mesg += 'Please select a rating for the Window Quality' + '\n\n';
   }

	if (valButton(form.dusting) == null) {
	  	  mesg += 'Please select a rating for the Dusting Quality' + '\n\n';
   } 
		
	if (valButton(form.cleanliness) == null) {
	  	  mesg += 'Please select a rating for the Cleanliness of the facility' + '\n\n';
   } 
   
	if (valButton(form.handling) == null) {
	  	  mesg += 'Please select a rating for the Handling of the Vehicle' + '\n\n';
   } 
  
		

   //if (IsEmpty(form.treatvehicle))
	//{
	  //mesg += 'Please tell us how  we did treat your vehicle' + '\n\n';
     // form.treatvehicle.focus(); 
	 // form.treatvehicle.className = "inputtxterror";
   //} else {
//		form.treatvehicle.className = "inputtxt";
	//}


   if (valButton(form.servicetime) == null)
	{
	  	 mesg += 'Please tell us if we served you in a satisfactory time' + '\n\n';

   } 


   if (IsEmpty(form.betterserve))
	{
	  	mesg += 'Please tell us how we  can better serve you' + '\n\n';
      form.betterserve.focus(); 
	  form.betterserve.className = "inputtxterror";
   } else {
		form.betterserve.className = "inputtxt";
	}

    if ( mesg != "") {
		alert (mesg);
		return false;
	} else {
		return true;
	}

}

	
	function isPhoneNumber(s) 
{
 
     // Check for correct phone number
     rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
     if (!rePhoneNumber.test(s.value)) {
          alert("Phone Number Must Be Entered As: (555) 555-1234");
          s.focus(); 
          return false;
     }
 
       return true;
}

function echeck(str) {
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid  E-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid  E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid  E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid  E-mail address")
		    return false
		 }

 		 return true					
	}

function ValidateEmail(emailID){
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }



// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function valButton(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}
                  


