// JavaScript Document
<!-- Begin
function xreset() {
master = document.insform;
master.star01.src="images/star_01.gif";
master.star02.src="images/star_01.gif";
master.star03.src="images/star_01.gif";
master.star04.src="images/star_01.gif";
master.star05.src="images/star_01.gif";
master.star06.src="images/star_01.gif";
master.star07.src="images/star_01.gif";
master.star08.src="images/star_01.gif";
master.star09.src="images/star_01.gif";
master.star10.src="images/star_01.gif";
master.star11.src="images/star_01.gif";
master.star12.src="images/star_01.gif";
master.star13.src="images/star_01.gif";
master.star14.src="images/star_01.gif";
master.star15.src="images/star_01.gif";
master.star16.src="images/star_01.gif";
master.star17.src="images/star_01.gif";
master.star18.src="images/star_01.gif";
var i;
for (i = master.Model.options.length; i >= 0; i--) {
master.Model.options[i] = null; 
}
master.Model.options[0] = new Option('Please Select');
master.Model.options[0].value = 'Select'
master.Model.options[0].selected = false;
master.Model.selectedIndex = 0;
master.Make.selectedIndex = 0;
master.reset()
}
function GetModel(model, make, Engine_Type, Turbo, Four_Wheel_Drive)
{
var i, j;
for (i = model.options.length; i >= 0; i--) {
model.options[i] = null; 
}
if (AllTrim(make) != 'Select') {
	j = 1;
	model.options[0] = new Option('Please Select');
	model.options[0].value = 'Select'
	mak = AllTrim(make);
	if (mak.search("|") >= 0) {
		makaa = mak.split("|");
		mak = makaa[0];	
		}
	for (i = 0; i < sDataArray.length; i++) {
	if (sDataArray[i][0] == mak){
		model.options[j] = new Option(sDataArray[i][1]);
		model.options[j].value = sDataArray[i][1]; 
		j++;
		}
	}
	model.options[0].selected = true;
	model.selectedIndex = 0;
}
else {
	model.options[0] = new Option('Please Select');
	model.options[0].value = 'Select'
	model.options[0].selected = false;
	model.selectedIndex = 0;
}
Engine_Type[0].checked = true;
Engine_Type[1].checked = false;
Turbo.checked = false;
Four_Wheel_Drive.checked = false;
}
function GetOpt(Model, Engine_Type, Turbo, Four_Wheel_Drive)
{
	str=Model;
	str = str.toUpperCase();
	if (str.search("DIESEL") >= 0) {
		Engine_Type[0].checked = false;
		Engine_Type[1].checked = true;
	}
	else {
		Engine_Type[0].checked = true;
		Engine_Type[1].checked = false;
		}
	if (str.search("TURBO") >= 0) {
		Turbo.checked = true;
	}
	else {
		Turbo.checked = false;
		}
	if (str.search("4X4") >= 0 || str.search("AWD")>=0) {
		Four_Wheel_Drive.checked = true;
	}
	else {
		Four_Wheel_Drive.checked = false;
		}
}
function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
	err = err + "Email address seem incorrect (check @ and .'s) \n";
	return false;
	}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
		err = err + "Email username contains invalid characters \n";
		return false;
	   }
}
for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
		err = err + "Email domain name contains invalid characters \n";
		return false;
	   }
}
if (user.match(userPat)==null) {
	err = err + "Email username doesn't seem to be valid \n";
	return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			err = err + "Email destination IP address invalid \n";
			return false;
		   }
	}
	return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
		err = err + "Email Domain name does not seem to be valid \n";
		return false;
	}
}
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
	err = err + "Email address must end in a well-known domain or two letter country \n";
	return false;
	}
if (len<2) {
	err = err + "Email is missing a hostname \n";
	return false;
	}
return true;
}

function LeftTrim(xString,TrimChar)
{
 xString += ""         // Force argument to string.
 TrimChar += ""       // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 if(xString.length == 0)
  return(xString)
 var Count = 0
 for(Count = 0;Count < xString.length;Count++)
 {
  if(!(xString.charAt(Count) == TrimChar))
   return(xString.substring(Count,xString.length))
 }
 return("")
}
function RightTrim(xString,TrimChar)
{
 xString += ""        // Force argument to string.
 TrimChar += ""      // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 if(xString.length == 0)
  return(xString)
 var Count = 0
 for(Count = xString.length -1;Count >= 0;Count--)
 {
  if(!(xString.charAt(Count) == TrimChar))
   return(xString.substring(0,Count + 1))
 }
 return("")
}
function AllTrim(xString,TrimChar)
{
 xString += ""        // Force argument to string.
 TrimChar += ""      // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 return(RightTrim(LeftTrim(xString,TrimChar),TrimChar))
}
function FValidateControl(control)
{
	if (control.value == "") 
  	{
/*  	  alert(control.name+": this is a required field, and it must be filled in before your form can be processed.");
  	  control.focus();*/
  	  return false;
	}
	xstr = AllTrim(control.value);
	if (xstr.length == 0)
	{
/*  	  alert(control.name+": This is a required field, and it must be filled in before your form can be processed.");
  	  control.focus();*/
  	  return false;
	}
	return true;
}

function FNumValidate(control)
{
	if (isNaN(control.value))
  	{
/*  	  alert(control.name+": this should be a NUMERIC, and it must be filled in before your form can be processed.");
  	  control.focus();*/
  	  return false;
	}
	return true;
}
function FAlphaValidate(control)
{
	if (!isNaN(control.value))
  	{
/*  	  alert(control.name+": this should NOT be NUMERIC, and it must be filled in before your form can be processed.");
  	  control.focus();*/
  	  return false;
	}
	return true;
}
function ONumValidate(control)
{
	xstr = AllTrim(control.value);
	if (xstr.length > 0)
	{
		if (isNaN(control.value))
		{
/*		  alert(control.name+": this should be a NUMERIC, and it must be filled in before your form can be processed.");
		  control.focus();*/
		  return false;
		}
	}
	return true;
}
function OLengthValidate(control,lenval)
{
	xstr = AllTrim(control.value);
	if (xstr.length > 0)
	{
		if (xstr.length < lenval)
		{
/*		  alert(control.name+": Please enter correct value, and it must be filled in before your form can be processed.");
		  control.focus();*/
		  return false;
		}
	}
	return true;
}
function FLengthValidate(control,lenval)
{
	xstr = AllTrim(control.value);
	if (xstr.length < lenval)
	{
/*  	  alert(control.name+": Please enter correct value, and it must be filled in before your form can be processed.");
  	  control.focus();*/
  	  return false;
	}
	return true;
}
function FSelectValidate(control)
{
	if (control.selectedIndex == 0)
	{
/*		alert(control.name + ": this is a required field, and it must be filled in before your form can be processed.");
		control.focus();*/
		return false;
	}
	return true;
}
function FRadioValidate(control,n)
{
 var Count = 0;
 var Countx = 0;
 for(Count = 0;Count < n;Count++)
    {
	 if (control[Count].checked) {
	 	Countx++;
		}
	}
	if (Countx == 1) {
		return true;
	}
	return false;
}
function chkphone1(num1, num2, num3) {
	xcnt = 0;
	str = AllTrim(num1.value);
	ck = false;
	if (str.length == 0) xcnt = xcnt + 1;
	str = AllTrim(num2.value);
	if (str.length == 0) xcnt = xcnt + 1;
	str = AllTrim(num3.value);
	if (str.length == 0) xcnt = xcnt + 1;
	if (xcnt > 2) {
		return false;
		}
	return true;
}
function chkphone2(num1, num2, num3) {
	ph = AllTrim(num1.value);
	ph = ph + AllTrim(num2.value);
	ph = ph + AllTrim(num3.value);
	if (ph.length != 0) { 
		if (ph.search(' ') != -1) {
				return false;
			}
		else {
			if (isNaN(ph)) {
				return false;
				}
			else {
				str=num2.value;
				str1=num1.value;
				if ((ph.length != 10) ||
					 (parseInt(str) <= 199) || 
					 (parseInt(str) == 555) ||
					 (parseInt(str1) <= 199) ||
					 (parseInt(str1) == 555) ||
					 (parseInt(str1) >= 990)) {
						return false;
						}
				else {
					return true;
				}
			}
		}
	}
}
function chk()
{
	master = document.insform;
	err='';
	master.star01.src="images/star_01.gif";
	if (!FValidateControl(master.First_Name)) {
		master.star01.src="images/star_01err.gif";
		err = err + 'First Name is Missing\n';
		}
	else {
		if (!FAlphaValidate(master.First_Name)){
			master.star01.src="images/star_01err.gif";
			err = err + 'First Name should not be numeric\n';
			}
	}
	master.star02.src="images/star_01.gif";
	if (!FValidateControl(master.Last_Name)) {
		master.star02.src="images/star_01err.gif";
		err = err + 'Last Name is Missing\n';
		}
	else {
		if (!FAlphaValidate(master.Last_Name)) {
			master.star02.src="images/star_01err.gif";
			err = err + 'Last Name should not be numeric\n';
			}
	}
	master.star03.src="images/star_01.gif";
	if (!FValidateControl(master.Address)) {
		master.star03.src="images/star_01err.gif";
		err = err + 'Address is Missing\n';
		}
	master.star05.src="images/star_01.gif";
	if (!FValidateControl(master.City)) {
		master.star05.src="images/star_01err.gif";
		err = err + 'City is Missing\n';
		}
	else {
		if (!FAlphaValidate(master.City)) {
			master.star05.src="images/star_01err.gif";
			err = err + 'City Name should not be numeric\n';
			}
	}
	master.star06.src="images/star_01.gif";
	if (!FSelectValidate(master.State)) {
		master.star06.src="images/star_01err.gif";
		err = err + 'State has not been selected\n';
		}
	master.star07.src="images/star_01.gif";
	if (!FValidateControl(master.Zip)) {
		master.star07.src="images/star_01err.gif";
		err = err + 'ZipCode is Missing\n';
		}
	else {
		if (!FNumValidate(master.Zip)) {
			master.star07.src="images/star_01err.gif";
			err = err + 'ZipCode must be numeric\n';
			}
		else {
			if (!FLengthValidate(master.Zip,5)) {
				master.star07.src="images/star_01err.gif";
				err = err + 'Only the 5 digit ZipCode is required\n';
				}
		}
	}
	master.star08.src="images/star_01.gif";
	if (!FValidateControl(master.email)) {
		master.star08.src="images/star_01err.gif";
		err = err + 'eMail address is Missing\n';
		}
	else {
		str=AllTrim(master.email.value);
		if (str.length > 0) {
			str=str.toLowerCase();
			if (!emailCheck(str)) {
				master.star08.src="images/star_01err.gif";
				err = err + 'Enter Your Correct eMail Address\n';
				}
		}
	}
	master.star09.src="images/star_01.gif";
	master.star10.src="images/star_01.gif";
	hph = chkphone1(master.Home_Phone1, master.Home_Phone2, master.Home_Phone3)
	wph = chkphone1(master.Work_Phone1, master.Work_Phone2, master.Work_Phone3)
	if ((!hph) && (!wph)) {
		master.star09.src="images/star_01err.gif";
		err = err + 'Daytime and Evening Phone is missing\n';
		insform.star10.src="images/star_01err.gif";
		}
	else {
		if (!hph) {
			master.star10.src="images/star_01err.gif";
			err = err + 'Evening Phone is missing\n';
			}
		else {
			if (!chkphone2(master.Home_Phone1, master.Home_Phone2, master.Home_Phone3)) {
				master.star10.src="images/star_01err.gif";
				err = err + 'Enter Your Correct Evening Phone Number with Area Code\n';
				}
			else {
				if (!ONumValidate(master.hExt)) {
					master.star10.src="images/star_01err.gif";
					err = err + 'Enter Your Correct Evening extension Number\n';
					}
			}
		}
		if (!wph) {
			master.star09.src="images/star_01err.gif";
			err = err + 'Daytime Phone is missing\n';
			}
		else {
			if (!chkphone2(master.Work_Phone1, master.Work_Phone2, master.Work_Phone3)){
				master.star09.src="images/star_01err.gif";
				err = err + 'Enter Your Correct Daytime Phone Number with Area Code\n';
				}
			else {
				if (!ONumValidate(master.Ext)) {
					master.star09.src="images/star_01err.gif";
					err = err + 'Enter Your Correct Daytime extension Number\n';
					}
			}
		}
	}
	master.star11.src="images/star_01.gif";
	if (!FSelectValidate(master.Make)) {
		master.star11.src="images/star_01err.gif";
		err = err + 'Vehicle Make not selected\n';
		}
	master.star12.src="images/star_01.gif";
	if (!FSelectValidate(master.Model)) {
		master.star12.src="images/star_01err.gif";
		err = err + 'Vehicle Model not selected\n';
		}
	master.star13.src="images/star_01.gif";
	if (!FSelectValidate(master.myear)) {
		master.star13.src="images/star_01err.gif";
		err = err + 'Vehicle Year not selected\n';
		}
	master.star14.src="images/star_01.gif";
	if (!FValidateControl(master.mileage)) {
		master.star14.src="images/star_01err.gif";
		err = err + 'Vehicle Miles missing\n';
		}
	else {
		if (!FNumValidate(master.mileage)) {
			master.star14.src="images/star_01err.gif";
			err = err + 'Vehicle Miles not valid\n';
			}
		else {
			if (master.mileage.value > 150000) {
			master.star14.src="images/star_01err.gif";
			err = err + 'Vehicle Miles more then 150,000 not eligible\n';
			}
		}
	}
/*	if (!FSelectValidate(master.purchase_year)) return false; */
/*	if (!FSelectValidate(master.New_Used)) return false; */
/*	if (!FValidateControl(master.Purchase_price)) return false; */
/*	if (!FNumValidate(master.Purchase_price)) return false; */
/*
	if (!FSelectValidate(master.Four_Wheel_Drive)) { 
		insform.star17.src="images/star_01err.gif";
		err = err + 'Four Wheel Drive? not selected\n';
		}
	else {
		insform.star17.src="images/star_01.gif";
	}
	if (!FSelectValidate(master.Turbo)) {
		insform.star18.src="images/star_01err.gif";
		err = err + 'Turbo? not selected\n';
		}
	else {
		insform.star18.src="images/star_01.gif";
	}
	if (!FSelectValidate(master.Engine_Type)) { 
		insform.star19.src="images/star_01err.gif";
		err = err + 'Gas or Diesel not selected\n';
		}
	else {
		insform.star19.src="images/star_01.gif";
	}
*/
/*	if (!FSelectValidate(master.Cylinders)) return false; */

	master.star16.src="images/star_01.gif";
	if (!FRadioValidate(master.Engine_Type,2)) {
		master.star16.src="images/star_01err.gif";
		err = err + 'Gas or Diesel not selected\n';
	}
	master.star17.src="images/star_01.gif";
	if (!FRadioValidate(master.warranty,2)) {
		master.star17.src="images/star_01err.gif";
		err = err + 'Current factory warranty not selected\n';
		}

	master.star18.src="images/star_01.gif";
	if (!FSelectValidate(master.Best_Time_to_Contact_You)) {
		insform.star18.src="images/star_01err.gif";
		err = err + 'Best Time to Contact You not selected\n';
		}
	ret = (err == '');
	if (!ret) {
		alert(err);
		if (master.star01.nameProp == "star_01err.gif") {
			master.First_Name.focus();
			return false;
		}
		if (master.star02.nameProp == "star_01err.gif") {
			master.Last_Name.focus();
			return false;
		}
		if (master.star03.nameProp == "star_01err.gif") {
			master.Address.focus();
			return false;
		}
		if (master.star05.nameProp == "star_01err.gif") {
			master.City.focus();
			return false;
		}
		if (master.star06.nameProp == "star_01err.gif") {
			master.State.focus();
			return false;
		}
		if (master.star07.nameProp == "star_01err.gif") {
			master.Zip.focus();
			return false;
		}
		if (master.star08.nameProp == "star_01err.gif") {
			master.email.focus();
			return false;
		}
		if (master.star10.nameProp == "star_01err.gif") {
			master.Work_Phone1.focus();
			return false;
		}
		if (master.star09.nameProp == "star_01err.gif") {
			master.Home_Phone1.focus();
			return false;
		}
		if (master.star11.nameProp == "star_01err.gif") {
			master.Make.focus();
			return false;
		}
		if (master.star12.nameProp == "star_01err.gif") {
			master.Model.focus();
			return false;
		}
		if (master.star13.nameProp == "star_01err.gif") {
			master.myear.focus();
			return false;
		}
		if (master.star14.nameProp == "star_01err.gif") {
			master.mileage.focus();
			return false;
		}
/*
		if (master.star17.nameProp == "star_01err.gif") {
			master.Four_Wheel_Drive.focus();
			return false;
		}
		if (master.star18.nameProp == "star_01err.gif") {
			master.Turbo.focus();
			return false;
		}
		if (master.star19.nameProp == "star_01err.gif") {
			master.Engine_Type.focus();
			return false;
		}
*/
		if (master.star16.nameProp == "star_01err.gif") {
			master.Engine_Type[0].focus();
			return false;
		}
		if (master.star17.nameProp == "star_01err.gif") {
			master.warranty[0].focus();
			return false;
		}
		if (master.star18.nameProp == "star_01err.gif") {
			master.Best_Time_to_Contact_You.focus();
			return false;
		}
		return false;
		};
	PopUpExit = 0;
	return true;
}
function phonenum(cur_form, cur_name, maxLength, nxt_name, last_field){
  var curLength=eval('document.'+ cur_form+'.'+ cur_name+'.value.length');
  if(curLength==maxLength && last_field != 'T'){
	focusIt=eval('document.'+cur_form+'.'+ nxt_name);
    focusIt.focus();
  }
}
-->
