
function doValidationForm2(theForm)
{
	var filledOut = true;

	filledOut = checkEmptyField (theForm.firstname, "Please enter a valid first name.");
	if (!filledOut) {
		return false;
	}

	filledOut = checkEmptyField (theForm.lastname, "Please enter a valid last name.");
	if (!filledOut) {
		return false;
	}

	/*  Allows only valid EMail address.*/

	checkStr=theForm.email.value;
	if(checkStr=="" || checkStr.lastIndexOf("@")==-1 || checkStr.lastIndexOf(".")==-1) {
		alert("Please enter a valid Email address");
		theForm.email.focus();
		filledOut=false;
		return false;
	}
	
	var emailArr=checkStr.split("@");
	var user = new String( emailArr[0] );
	var domainAddress = new String( emailArr[1] );
	var domainAddressArr = domainAddress.split(".");
	var domain = new String( domainAddressArr[0] );
	var net = new String( domainAddressArr[1] );
		
	if ((user.length==0) || (domain.length==0) || (net.length==0)) {
		alert("Please enter a valid Email address.");
		theForm.email.focus();
		filledOut=false;
		return false;	
	}

	filledOut = checkEmptyField (theForm.address, "Please enter a valid address.");
	if (!filledOut) {
		return false;
	}

	filledOut = checkEmptyField (theForm.city, "Please enter a valid city.");
	if (!filledOut) {
		return false;
	}

	/*  Allows only valid State*/
	var checkStr = theForm.state.options[theForm.state.options.selectedIndex].value;
	if (checkStr == null || checkStr == "")	{
		alert("Please select a state.");
		theForm.state.focus();
		filledOut=false;
		return (false);
	}

	/*Allows only valid Zip*/
	filledOut = checkZip (theForm);
	if (!filledOut) {
		return false;
	}

	/* Allows only valid HomeAreaCode(only numeric values) */
	checkStr=theForm.areacode.value;
	var objRegExp = /(^\d{3}$)/;
	if (!objRegExp.test(checkStr)) {
		alert("Please enter valid AreaCode (Numeric only)");
		theForm.areacode.focus();
		filledOut=false;
		return(false);
	}

	/* Allows only valid HomePrefix(only numeric values)*/
   	checkStr=theForm.prefix.value;
   	var objRegExp = /(^\d{3}$)/;
	if (!objRegExp.test(checkStr)) {
		alert("Please enter valid HomePrefix(Numeric only)");
		theForm.prefix.focus();
		filledOut=false;
		return(false);
	}
	
	/* Allows only valid HomeNumber(only numeric values) */
	checkStr=theForm.phone.value;
	var objRegExp = /(^\d{4}$)/;
	if (!objRegExp.test(checkStr)) {
		alert("Please enter valid HomeNumber (Numeric only)");
		theForm.phone.focus();		
		filledOut=false;
		return(false);
	}

	checkStr = theForm.payment.options[theForm.payment.options.selectedIndex].value;
	if (checkStr == null || checkStr == "")	{
		alert("Please select a Payment.");
		theForm.payment.focus();
		filledOut=false;
		return (false);
	}

	return true;
}

function doValidationForm1(theForm)
{
	var filledOut = true;

	filledOut = checkEmptyField (theForm.make, "Please select a make.");
	if (!filledOut) {
		return false;
	}

	filledOut = checkEmptyField (theForm.model, "Please select a model.");
	if (!filledOut) {
		return false;
	}

	filledOut = checkEmptyField (theForm.autoid, "Please select a trim.");
	if (!filledOut) {
		return false;
	}

	/*Allows only valid Zip*/
	filledOut = checkZip (theForm);
	if (!filledOut) {
		return false;
	}

	return (true);
}

function checkEmptyField (fieldObj, message)
{
	var checkStr=fieldObj.value;

	if(checkStr == null || checkStr == "") {
		alert(message);
		fieldObj.focus();
		return false;
	}

	return true;
}

function checkZip (theForm)
{
	var objRegExp = /(^\d{5}$)/;

	//check for valid US Zipcode
	if (!objRegExp.test(theForm.zip.value)) {
		alert("Please enter a valid zip.");
		theForm.zip.focus();
		return false;
	}

	return true;
}

function doValidationForm3(theForm)
{
	var filledOut = true;

	filledOut = checkEmptyField (theForm.make1, "Please select a make.");
	if (!filledOut) {
		return false;
	}

	if(theForm.make1.value==theForm.make.value) {
		alert("You have already requested a quote for a " + theForm.make.value + ".  Please select another make for another quote.");
		theForm.make1.focus();
		return (false);
	}

	if(theForm.make2.value==theForm.make.value) {
		alert("You have already requested a quote for a " + theForm.make.value + ".  Please select another make for another quote.");
		theForm.make2.focus();
		return (false);
	}

	if(theForm.make1.value==theForm.make2.value) {
		alert("You have already selected a " + theForm.make1.value + " for a quote.  Please select another make for another quote.");
		theForm.make2.focus();
		return (false);
	}

	filledOut = checkEmptyField (theForm.model1, "Please select a model.");
	if (!filledOut) {
		return false;
	}

	return (true);
}