function checkWholeForm(theForm) {
        	
	if (checkEname(theForm.name.value) != "") {
		alert (checkEname(theForm.name.value));
		document.enquiry.name.focus();
       return false;
	}
		if (checkEcompany(theForm.company.value) != "") {
		alert (checkEcompany(theForm.company.value));
		document.enquiry.company.focus();
       return false;
	}
	if (checkEaddress(theForm.address.value) != "") {
		alert (checkEaddress(theForm.address.value));
		document.enquiry.address.focus();
       return false;
	}
	if (checkEcity(theForm.city.value) != "") {
		alert (checkEcity(theForm.city.value));
		document.enquiry.city.focus();
       return false;
	}
	if (checkEstate(theForm.state.value) != "") {
		alert (checkEstate(theForm.state.value));
		document.enquiry.state.focus();
       return false;
	}
	  if (checkPhone(theForm.ph.value) != "") {
		alert (checkPhone(theForm.ph.value));
		document.enquiry.ph.focus();
       return false;
	}
	   if (checkEmail(theForm.email.value) != "") {
		alert (checkEmail(theForm.email.value));
		document.enquiry.email.focus();
       return false;
	}
	return true;
}
//name
function checkEname (strng) {
	var error = "";
	if (trim(strng) == "") {
		error = "You didn't enter your name.\n";
	}
	if (strng.length > 30) {
		error = "The  name must be <30 characters.\n";
	}
	return error;
}
function trim(str)
{
  return str.replace(/^\s*|\s*$/g,"");
}
//company
function checkEcompany (strng) {
	var error = "";
	if (trim(strng) == "") {
		error = "You didn't enter your Company name.\n";
	}
	if (strng.length > 60) {
		error = "The  Company name must be <60 characters.\n";
	}
	return error;
}
function trim(str)
{
  return str.replace(/^\s*|\s*$/g,"");
}
//address
function checkEaddress (strng) {
	var error = "";
	if (trim(strng) == "") {
		error = "You didn't enter your address.\n";
	}
	return error;
}
function trim(str)
{
  return str.replace(/^\s*|\s*$/g,"");
}
//city
function checkEcity (strng) {
	var error = "";
	if (trim(strng) == "") {
		error = "You didn't enter your city.\n";
	}
	if (strng.length > 60) {
		error = "city must be <60 characters.\n";
	}
	return error;
}
function trim(str)
{
  return str.replace(/^\s*|\s*$/g,"");
}
//state
function checkEstate (strng) {
	var error = "";
	if (trim(strng) == "") {
		error = "You didn't enter your state.\n";
	}
	if (strng.length > 60) {
		error = "state must be <60 characters.\n";
	}
	return error;
}
function trim(str)
{
  return str.replace(/^\s*|\s*$/g,"");
}
//Phone
function checkPhone (strng) {
	if (strng == "") {
	   return "You didn't enter a phone number.\n";
	}
	
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
        return "The phone number contains illegal characters.\n";
    }
	
	return "";
}
//Email
function checkEmail (strng) {
	var error = "";
	
	if (strng == "") {
	   return "You didn't enter an email address.\n";
	}

	if ((strng.indexOf('@') < 0) || ((strng.charAt(strng.length-4) != '.') && (strng.charAt(strng.length-3) != '.'))) 
		error = "Invalid email address. Please try again.\n";
	return error;    
}
