function ValidateLetter(){if(event.keyCode==46||event.keyCode==126)event.returnValue=false;if(event.keyCode>32&&event.keyCode<48||event.keyCode>57&&event.keyCode<65||event.keyCode>90&&event.keyCode<97||event.keyCode>45&&event.keyCode<=57)event.returnValue=false}function ValidateNumber(){var a=event.keyCode;if(a==47||a==126)event.returnValue=false;if((a<=45||a>57)&&a!=13)event.returnValue=false}function PhoneTab(a,b){(document.getElementById?document.getElementById(a):eval("document.all['"+a+"']")).value.length==3&&(document.getElementById?document.getElementById(b):eval("document.all['"+b+"']")).focus()}function SSNTab(a,b){(document.getElementById?document.getElementById(a):eval("document.all['"+a+"']")).value.length==2&&(document.getElementById?document.getElementById(b):eval("document.all['"+b+"']")).focus()}function ValidateEmail(a){var d=a,c=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,b=c.test(a);return b?true:false}function ShowSpouseInfo(){switch((document.getElementById?document.getElementById("SpouseToggle"):eval("document.all['"+SpouseToggle+"']")).selectedIndex){case 0:(document.getElementById?document.getElementById("CoAppInfo"):eval("document.all['"+CoAppInfo+"']")).style.display="none";break;case 1:(document.getElementById?document.getElementById("lblCoApp"):eval("document.all['"+lblCoApp+"']")).innerHTML="Spouse Information";(document.getElementById?document.getElementById("TD5"):eval("document.all['"+TD5+"']")).innerHTML="Spouse First Name";(document.getElementById?document.getElementById("TD6"):eval("document.all['"+TD6+"']")).innerHTML="Spouse Last Name";(document.getElementById?document.getElementById("TD7"):eval("document.all['"+TD7+"']")).innerHTML="Spouse Date of Birth";(document.getElementById?document.getElementById("CoAppInfo"):eval("document.all['"+CoAppInfo+"']")).style.display="block";if((document.getElementById?document.getElementById("SpouseLastName"):eval("document.all['"+SpouseLastName+"']")).value=="")(document.getElementById?document.getElementById("SpouseLastName"):eval("document.all['"+SpouseLastName+"']")).value=(document.getElementById?document.getElementById("LastName"):eval("document.all['"+LastName+"']")).value;break;case 2:(document.getElementById?document.getElementById("lblCoApp"):eval("document.all['"+lblCoApp+"']")).innerHTML="Co-Applicant Information";(document.getElementById?document.getElementById("TD5"):eval("document.all['"+TD5+"']")).innerHTML="Co-Applicant First Name:";(document.getElementById?document.getElementById("TD6"):eval("document.all['"+TD6+"']")).innerHTML="Co-Applicant Last Name";(document.getElementById?document.getElementById("TD7"):eval("document.all['"+TD7+"']")).innerHTML="Co-Applicant Date of Birth";(document.getElementById?document.getElementById("CoAppInfo"):eval("document.all['"+CoAppInfo+"']")).style.display="block"}(document.getElementById?document.getElementById("SpouseToggle"):eval("document.all['"+SpouseToggle+"']")).selectedIndex==0}function ShowAddressInput(){switch((document.getElementById?document.getElementById("AddressToggle"):eval("document.all['"+AddressToggle+"']")).selectedIndex){case 0:(document.getElementById?document.getElementById("CoAddress"):eval("document.all['"+CoAddress+"']")).style.display="none";break;case 1:(document.getElementById?document.getElementById("CoAddress"):eval("document.all['"+CoAddress+"']")).style.display="block"}}function ValidateOffer(){var b,a;a=document.getElementById?document.getElementById("form1"):eval("document.all['"+form1+"']");if(a.LastName.value.length==0){alert("Please fill in Last Name");a.LastName.focus();return false}if(a.FirstName.value.length==0){alert("Please fill in First Name");a.FirstName.focus();return false}if(a.Email.value.length==0){alert("Please fill in Email Address");a.Email.focus();return false}else if(!ValidateEmail(a.Email.value)){alert("Please fill in a proper Email Address");a.Email.focus();return false}if(a.Daytime1.value.length==0){alert("Please fill in Daytime Phone Number");a.Daytime1.focus();return false}if(a.Daytime2.value.length==0){alert("Please fill in Daytime Phone Number");a.Daytime2.focus();return false}if(a.Daytime3.value.length==0){alert("Please fill in Daytime Phone Number");a.Daytime3.focus();return false}if(a.Evening1.value.length==0){alert("Please fill in Evening Phone Number");a.Evening1.focus();return false}if(a.Evening2.value.length==0){alert("Please fill in Evening Phone Number");a.Evening2.focus();return false}if(a.Evening3.value.length==0){alert("Please fill in Evening Phone Number");a.Evening3.focus();return false}if(a.ContactTime.value.length==0){alert("Please fill in your desired Contact Time");a.ContactTime.focus();return false}return true}function ValidateSection(a,c){var d;switch(c){case 1:if(a.LastName.value.length==0){alert("Please fill in Last Name");a.LastName.focus();return false}if(a.FirstName.value.length==0){alert("Please fill in First Name");a.FirstName.focus();return false}if(a.DobYear.selectedIndex==0){alert("Please fill in Date of Birth (Year)");a.DobYear.focus();return false}if(a.DobMonth.selectedIndex==0){alert("Please fill in Date of Birth (Month)");a.DobMonth.focus();return false}if(a.DobDay.selectedIndex==0){alert("Please fill in Date of Birth (Day)");a.DobDay.focus();return false}if(a.DriversLicNo.value.length==0){alert("Please fill in Driver's License Number");a.DriversLicNo.focus();return false}if(a.DriversLicState.selectedIndex==0){alert("Please fill in Driver's License State");a.DriversLicState.focus();return false}if(a.SpouseToggle.selectedIndex>0){var b;if(a.SpouseToggle.selectedIndex==1)b="Spouse";else b="Co-Applicant";if(a.SpouseLastName.value.length==0){alert("Please fill in "+b+" Last Name");a.SpouseLastName.focus();return false}if(a.SpouseFirstName.value.length==0){alert("Please fill in "+b+" First Name");a.SpouseFirstName.focus();return false}if(a.SpouseDobYear.selectedIndex==0){alert("Please fill in "+b+" Date of Birth (Year)");a.SpouseDobYear.focus();return false}if(a.SpouseDobMonth.selectedIndex==0){alert("Please fill in "+b+" Date of Birth (Month)");a.SpouseDobMonth.focus();return false}if(a.SpouseDobDay.selectedIndex==0){alert("Please fill in "+b+" Date of Birth (Day)");a.SpouseDobDay.focus();return false}}break;case 2:if(a.Address.value.length==0){alert("Please fill in Address");a.Address.focus();return false}if(a.City.value.length==0){alert("Please fill in City");a.City.focus();return false}if(a.State.selectedIndex==0){alert("Please fill in State");a.State.focus();return false}if(a.Zip.value.length==0){alert("Please fill in Zip Code");a.Zip.focus();return false}if(a.Daytime1.value.length==0){alert("Please fill in Daytime Phone Number");a.Daytime1.focus();return false}if(a.Daytime2.value.length==0){alert("Please fill in Daytime Phone Number");a.Daytime2.focus();return false}if(a.Daytime3.value.length==0){alert("Please fill in Daytime Phone Number");a.Daytime3.focus();return false}if(a.Evening1.value.length==0){alert("Please fill in Evening Phone Number");a.Evening1.focus();return false}if(a.Evening2.value.length==0){alert("Please fill in Evening Phone Number");a.Evening2.focus();return false}if(a.Evening3.value.length==0){alert("Please fill in Evening Phone Number");a.Evening3.focus();return false}if(a.Email.value.length==0){alert("Please fill in Email Address");a.Email.focus();return false}else if(!ValidateEmail(a.Email.value)){alert("Please fill in a proper Email Address");a.Email.focus();return false}if(a.YearsRes.selectedValue<3){if(a.PrevAddress.value.length==0){alert("Please fill in previous Address");a.PrevAddress.focus();return false}if(a.PrevCity.value.length==0){alert("Please fill in previous City");a.PrevCity.focus();return false}if(a.PrevState.selectedIndex==0){alert("Please fill in previous State");a.PrevState.focus();return false}if(a.PrevZip.value.length==0){alert("Please fill in previous Zip");a.PrevZip.focus();return false}}break;case 3:if(a.EmployerName.value.length==0){alert("Please fill in Employer Name");a.EmployerName.focus();return false}if(a.Salary.value.length==0){alert("Please fill in Salary");a.Salary.focus();return false}if(a.OtherIncome.value.length>0)if(a.OtherIncomeSource.value.length==0){alert("Please fill in Other Income Source");(document.getElementById?document.getElementById("TD3"):eval("document.all['"+TD3+"']")).style.display="block";(document.getElementById?document.getElementById("TD4"):eval("document.all['"+TD4+"']")).style.display="block";a.OtherIncomeSource.focus();return false}if(a.DesiredPayment.value.length==0){alert("Please fill in Desired Payment");a.DesiredPayment.focus();return false}if(a.DownPayment.value.length==0){alert("Please fill in Desired Down Payment");a.DownPayment.focus();return false}if(a.TradeIn.selectedIndex>0){if(a.TradeYear.selectedIndex==0){alert("Please fill in Trade Year");a.TradeYear.focus();return false}if(a.TradeMake.value.length==0){alert("Please fill in Trade Make");a.TradeMake.focus();return false}if(a.TradeModel.value.length==0){alert("Please fill in Trade Model");a.TradeModel.focus();return false}if(a.TradeMiles.value.length==0){alert("Please fill in Trade Miles");a.TradeMiles.focus();return false}if(a.TradeAmount.value.length==0){alert("Please fill in Amount Owed on Trade");a.TradeAmount.focus();return false}}if(a.txtDisclaimer.value.toUpperCase()!="AGREE"){alert("Please read the terms and conditions and then type the word 'Agree' in the last box to indicate your agreement of the terms");a.txtDisclaimer.focus();return false}}return true}function NextSection(b,a){if(a==0){if((document.getElementById?document.getElementById("Link1"):eval("document.all['"+Link1+"']")).style.cursor=="Default")a=1;if((document.getElementById?document.getElementById("Link2"):eval("document.all['"+Link2+"']")).style.cursor=="Default")a=2;if((document.getElementById?document.getElementById("Link3"):eval("document.all['"+Link3+"']")).style.cursor=="Default")a=3}if(ValidateSection(document.getElementById?document.getElementById("form1"):eval("document.all['"+form1+"']"),a)){(document.getElementById?document.getElementById("SecPic"):eval("document.all['"+SecPic+"']")).src="FinanceJPGs/Finance_"+b+".gif";switch(b){case 1:(document.getElementById?document.getElementById("PersonalInfoSection"):eval("document.all['"+PersonalInfoSection+"']")).style.display="block";(document.getElementById?document.getElementById("ContactInfoSection"):eval("document.all['"+ContactInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("FinanceInfoSection"):eval("document.all['"+FinanceInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("Header"):eval("document.all['"+Header+"']")).innerText="Personal Information";break;case 2:(document.getElementById?document.getElementById("PersonalInfoSection"):eval("document.all['"+PersonalInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("ContactInfoSection"):eval("document.all['"+ContactInfoSection+"']")).style.display="block";(document.getElementById?document.getElementById("FinanceInfoSection"):eval("document.all['"+FinanceInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("Header"):eval("document.all['"+Header+"']")).innerText="Contact Information";break;case 3:(document.getElementById?document.getElementById("PersonalInfoSection"):eval("document.all['"+PersonalInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("ContactInfoSection"):eval("document.all['"+ContactInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("FinanceInfoSection"):eval("document.all['"+FinanceInfoSection+"']")).style.display="block";(document.getElementById?document.getElementById("Header"):eval("document.all['"+Header+"']")).innerText="Financial Information"}}}function NextSection2(b,a){if(a==0){if((document.getElementById?document.getElementById("Link1"):eval("document.all['"+Link1+"']")).style.cursor=="Default")a=1;if((document.getElementById?document.getElementById("Link2"):eval("document.all['"+Link2+"']")).style.cursor=="Default")a=2;if((document.getElementById?document.getElementById("Link3"):eval("document.all['"+Link3+"']")).style.cursor=="Default")a=3}var c=document.forms.aspnetForm;if(!theForm)theForm=document.aspnetForm;if(ValidateSection(theForm,a)){(document.getElementById?document.getElementById("SecPic"):eval("document.all['"+SecPic+"']")).src="FinanceJPGs/Finance_"+b+".gif";switch(b){case 1:(document.getElementById?document.getElementById("PersonalInfoSection"):eval("document.all['"+PersonalInfoSection+"']")).style.display="block";(document.getElementById?document.getElementById("ContactInfoSection"):eval("document.all['"+ContactInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("FinanceInfoSection"):eval("document.all['"+FinanceInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("Header"):eval("document.all['"+Header+"']")).innerText="Personal Information";break;case 2:(document.getElementById?document.getElementById("PersonalInfoSection"):eval("document.all['"+PersonalInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("ContactInfoSection"):eval("document.all['"+ContactInfoSection+"']")).style.display="block";(document.getElementById?document.getElementById("FinanceInfoSection"):eval("document.all['"+FinanceInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("Header"):eval("document.all['"+Header+"']")).innerText="Contact Information";break;case 3:(document.getElementById?document.getElementById("PersonalInfoSection"):eval("document.all['"+PersonalInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("ContactInfoSection"):eval("document.all['"+ContactInfoSection+"']")).style.display="none";(document.getElementById?document.getElementById("FinanceInfoSection"):eval("document.all['"+FinanceInfoSection+"']")).style.display="block";(document.getElementById?document.getElementById("Header"):eval("document.all['"+Header+"']")).innerText="Financial Information"}}}function ShowPreviousAddress(){if((document.getElementById?document.getElementById("YearsRes"):eval("document.all['"+YearsRes+"']")).selectedIndex<=2)(document.getElementById?document.getElementById("PreviousAddressInformation"):eval("document.all['"+PreviousAddressInformation+"']")).style.display="block";else(document.getElementById?document.getElementById("PreviousAddressInformation"):eval("document.all['"+PreviousAddressInformation+"']")).style.display="none"}function ShowPreviousEmployment(){if((document.getElementById?document.getElementById("yrsJob"):eval("document.all['"+yrsJob+"']")).selectedIndex<=2)(document.getElementById?document.getElementById("PreviousEmploymentInfo"):eval("document.all['"+PreviousEmploymentInfo+"']")).style.display="block";else(document.getElementById?document.getElementById("PreviousEmploymentInfo"):eval("document.all['"+PreviousEmploymentInfo+"']")).style.display="none"}function ShowTrade(){if((document.getElementById?document.getElementById("TradeIn"):eval("document.all['"+TradeIn+"']")).selectedIndex==0)(document.getElementById?document.getElementById("TradeinInfo"):eval("document.all['"+TradeinInfo+"']")).style.display="none";else(document.getElementById?document.getElementById("TradeinInfo"):eval("document.all['"+TradeinInfo+"']")).style.display="block"}function CheckEmail(a){spot=a.indexOf("@");return a.indexOf(".")>2&&spot>0&&a.indexOf(".")>spot}function FixDate(b,c,d){whYear=(document.getElementById?document.getElementById(b):eval("document.all['"+b+"']")).selectedIndex;inMonth=(document.getElementById?document.getElementById(c):eval("document.all['"+c+"']")).selectedIndex;inYear=(document.getElementById?document.getElementById(b):eval("document.all['"+b+"']")).options[whYear].value;Day=document.getElementById?document.getElementById(d):eval("document.all['"+d+"']");var a=0;if(whYear>0){if(inMonth==0)Day.selectedIndex=0;if(inYear%4==0)isLeapYear=true;else isLeapYear=false;switch(inMonth){case 2:if(isLeapYear)a=30;else a=29;break;case 1:case 3:case 5:case 7:case 8:case 10:case 12:a=32;break;case 4:case 6:case 9:case 11:a=31}if(a>0){Day.length=a;Day.options[0].text="Day";Day.options[0].value="Day";for(i=1;i<a;i++){Day.options[i].text=i;Day.options[i].value=i}}}else{(document.getElementById?document.getElementById(c):eval("document.all['"+c+"']")).selectedIndex=0;Day.selectedIndex=0}}function ShowOtherIncome(){var a=document.getElementById?document.getElementById("form1"):eval("document.all['"+form1+"']");if(a.OtherIncome.value.length>0){(document.getElementById?document.getElementById("TD3"):eval("document.all['"+TD3+"']")).style.display="block";(document.getElementById?document.getElementById("TD4"):eval("document.all['"+TD4+"']")).style.display="block";a.OtherIncomeSource.focus()}else{(document.getElementById?document.getElementById("TD3"):eval("document.all['"+TD3+"']")).style.display="none";(document.getElementById?document.getElementById("TD4"):eval("document.all['"+TD4+"']")).style.display="none"}}function calculatePMT(b,a,d){princ=d;intRate=b/100/12;months=a;var c=Math.floor(princ*intRate/(1-Math.pow(1+intRate,-1*months))*100)/100;return c}function pv(b,a,c,d){a=parseFloat(a);c=parseFloat(c);d=parseFloat(d);b=eval(b/100/12);if(c==0||a==0){alert("zeros?");return 0}if(b==0)pv_value=-(d+c*a);else{x=Math.pow(1+b,-a);y=Math.pow(1+b,a);pv_value=-(x*(-1*c+y*c))/b}pv_value=conv_number(pv_value,2);return pv_value}function conv_number(d,b){var a=""+Math.round(eval(d)*Math.pow(10,b));while(a.length<=b)a="0"+a;var c=a.length-b;return a.substring(0,c)+"."+a.substring(c,a.length)}function CalculateForm(a){var b,c;if(a.btPayment.checked){c=parseFloat(a.Price.value)+parseFloat(a.Price.value)*a.Tax.value/100+parseFloat(a.Warranty.value)+parseFloat(a.Gap.value)-parseFloat(a.Cash.value)-parseFloat(a.TradeValue.value)+parseFloat(a.TradeLien.value)+300;a.Payment.value=calculatePMT(parseFloat(a.Rate.value),parseFloat(a.Term.value),c)}else{c=pv(parseFloat(a.Rate.value),parseFloat(a.Term.value),-1*parseFloat(a.Payment.value),0);b=c+parseFloat(a.Cash.value)+parseFloat(a.TradeValue.value)-parseFloat(a.TradeLien.value)-parseFloat(a.Warranty.value)-parseFloat(a.Gap.value)-300;alert(b);alert(1+parseFloat(a.Tax.value));b=conv_number(b/(1+parseFloat(a.Tax.value)),2);alert(b);if(b>0)a.Price.value=b;else a.Price.value=1}}
