function formValidate(){
  if(isWhitespace(document.quote.firstname.value,true)){
   alert("Please Specify First Name ");
   document.quote.firstname.focus();
   return false;
  }
  if(isWhitespace(document.quote.lastname.value,true)){
   alert("Please Specify Last Name ");
   document.quote.lastname.focus();
   return false;
  }
  if(isWhitespace(document.quote.email.value,true)){
   alert("Please Specify Valid Email ID  ");
   document.quote.email.focus();
   return false;
  }
  if(!isEmail(document.quote.email.value,true)){
   alert("Please Specify Valid Email ID  ");
   document.quote.email.focus();
   return false;
  }
  if(isWhitespace(document.quote.address.value,true)){
   alert("Please Specify Home Address ");
   document.quote.address.focus();
   return false;
  }
  if(isWhitespace(document.quote.city.value,true)){
   alert("Please Specify City ");
   document.quote.city.focus();
   return false;
  }
  if(isWhitespace(document.quote.postcode.value,true)){
   alert("Please Specify Postcode ");
   document.quote.postcode.focus();
   return false;
  }
  if(!isDigit(document.quote.postcode.value)){
   alert("Please Specify a Valid Postcode ");
   document.quote.postcode.focus();
   return false;
  }
  if(isWhitespace(document.quote.phone.value,true)){
   alert("Please Specify Phone Number ");
   document.quote.phone.focus();
   return false;
  }
  if(!isDigit(document.quote.phone.value)){
   alert("Please Specify a Valid Phone Number ");
   document.quote.phone.focus();
   return false;
  }
  if(isWhitespace(document.quote.mobile.value,true)){
   alert("Please Specify Mobile Number ");
   document.quote.mobile.focus();
   return false;
  }
  if(!isDigit(document.quote.mobile.value)){
   alert("Please Specify a Valid Mobile Number ");
   document.quote.mobile.focus();
   return false;
  }
  if(!isValidSelection("services[]")){
   alert("Please Select a Service ");
   //document.quote.services[0].focus();
   return false;
  }
  if(!isValidSelection("how[]")){
   alert("Please Select How you find us ");
   //document.quote.services[0].focus();
   return false;
  }
  if(!isValidOther("how[]")){
   alert("Please Specify How you find us ");
   document.quote.other.focus();
   return false;
  }

  /*if(isWhitespace(document.quote.comments.value,true)){
   alert("Please Specify Comment ");
   document.quote.comments.focus();
   return false;
  }*/
  
  return true;
}

function isValidSelection(targetElement) {
  var mainForm = document.quote;
  var len = mainForm.elements.length;
  var isOK=false;
 
  for (var i = 0; i < len; i++) {
    var e = mainForm.elements[i];
    if (e.name == targetElement && e.checked) {
		isOK=true;
		break;
    }
  }
  
  return isOK;
}

function isValidOther(targetElement) {
  var mainForm = document.quote;
  var len = mainForm.elements.length;
  var isOK=false;
 
  var otherElementAt = 7;
  var curElementIndex = 1;
  
  for (var i = 0; i < len; i++) {
    var e = mainForm.elements[i];
    if (e.name == targetElement) {
		if(curElementIndex==otherElementAt){
			if(e.checked){
				if(!isWhitespace(document.quote.other.value,true)){
					isOK=true;
				}
				break;
			}
			else{
				isOK=true;
				break;
			}
		}
		curElementIndex+=1;
    }
  }
  
  return isOK;
}

function checkOtherCheckBox(){
	var mainForm = document.quote;
	var len = mainForm.elements.length;

	var otherElementAt = 7;
	var curElementIndex = 1;

	for (var i = 0; i < len; i++) {
		var e = mainForm.elements[i];
		if (e.name == "how[]"){ 
			if(curElementIndex==otherElementAt){
				if(document.quote.other.value.length>0){
					e.checked=true;
				}
				else{
					e.checked=false;
				}
			}
			curElementIndex+=1;
		}
	}
	
}