$(document).ready(function(){
	//$("#makes").val(0);
	$('#makes').change(function(){	
		var nveh_Make = $("#makes").val();
		if (nveh_Make != '0')
			getModels(nveh_Make);
	});
	$('#models').change(function(){	
		var nveh_Model = $("#models").val();
		if (nveh_Model != '0')
			getOpts(nveh_Model);
	});
	
	if ($("#makes").val() != "0"){
		var passThis = $("#makes").val();
		if ($("#hid_model").val() != "0"){
			passThis = passThis + "," + $("#hid_model").val();
		}
		getModels(passThis);
	}
	
	if ($("#hid_model").val() != "0"){
		getOpts($("#hid_model").val());
	}

});


function getModels(nveh_Make){

	$.AjaxCFC({
	    url: "/com/models.cfc",
	    method: "getModels",
	    data: [nveh_Make],
	    unnamedargs: true,
	    success: function(data) 
	  	{   	
	    	
	    	$('#modelList').html(data.models);
	    	//alert(data.models);
	    	
	  	}
	});

}

function getOpts(nveh_Make){

	$.AjaxCFC({
	    url: "/com/models.cfc",
	    method: "getMoreOptions",
	    data: [nveh_Make],
	    unnamedargs: true,
	    success: function(data) 
	  	{   	
	    	
	    	$('#moreoptions').html(data.opts);
	    	//alert(data.models);
	    	
	  	}
	});

}


// CODE ADDED BY GARY TAYLOR FOR FORM VALIDATION
function validateFormPost(frm) {
  // First Name
  if (frm.fname.value=='') {
    alert("First Name is Required");
    frm.fname.focus(); return false;
  }

  // Last Name
  if (frm.lname.value=='') {
    alert("Last Name is Required");
    frm.lname.focus(); return false;
  }

  // Phone check
  if (frm.hphone.value=='' && frm.dphone.value=='' && frm.cell.value=='') {
    alert("Please specify at least one Phone contact, Home Phone, Day Phone or Cell Phone.");
    frm.hphone.focus(); return false;
  }
  
  // E-mail Check
  if (frm.email.value=='') {
    alert("E-Mail Addres is required");
    frm.email.focus(); return false;
  }
  // Valid Syntax
  atpos=frm.email.value.indexOf("@");
  dotpos=frm.email.value.lastIndexOf(".");
  if (atpos<1||dotpos-atpos<2) {
    alert("E-Mail Address is not valid");
    frm.email.focus(); return false;
  }

  // Zipcode
  if (frm.zip.value=='') {
    alert("Zip code is Required");
    frm.zip.focus(); return false;
  }
  
  // Form is complete and valid, return to POST
  return true;
}
// END ADDITION BY GARY TAYLOR