function addoption(a,b,c){var d=document.createElement("OPTION");d.text=b;d.value=c;a.options.add(d)} function usedCarLoadValues(a){document.topDisplay_UsedCar.makeInSearch.options.length=1;document.topDisplay_UsedCar.modelInSearch.value="";for(subcatelements in usedCarTopcategories_array[a].subarr)addoption(document.topDisplay_UsedCar.makeInSearch,usedCarTopcategories_array[a].subarr[subcatelements].name,subcatelements);SortDropDown(document.topDisplay_UsedCar.makeInSearch,1);if(null!=document.topDisplay_UsedCar.usedCarSearch)document.topDisplay_UsedCar.cityInSearchPR.value="0",document.topDisplay_UsedCar.stateInSearchPR.value= "0";document.topDisplay_UsedCar.stateInSearch.value="0";document.topDisplay_UsedCar.stateSearch.value="0";document.topDisplay_UsedCar.stateInSearchPR.value="0";document.topDisplay_UsedCar.cityInSearch.value="0";document.topDisplay_UsedCar.citySearch.value="0";document.topDisplay_UsedCar.cityInSearchPR.value="0";document.topDisplay_UsedCar.makeInSearch.value="0";document.topDisplay_UsedCar.modelInSearch.value="0"} function loadValues(a){document.topDisplay.makeInSearch.options.length=1;document.DealerSearchForm.makeInSearchDealer.options.length=1;document.topDisplay.modelInSearch.value="";for(subcatelements in topcategories_array[a].subarr)addoption(document.topDisplay.makeInSearch,topcategories_array[a].subarr[subcatelements].name,subcatelements),addoption(document.DealerSearchForm.makeInSearchDealer,topcategories_array[a].subarr[subcatelements].name,subcatelements);SortDropDown(document.topDisplay.makeInSearch, 1);SortDropDown(document.DealerSearchForm.makeInSearchDealer,1);document.getElementById("stateInSearch").value="0";document.getElementById("stateInSearchPR").value="0";document.getElementById("stateSearch").value="0";document.getElementById("cityInSearch").value="0";document.getElementById("cityInSearchPR").value="0";document.getElementById("citySearch").value="0";document.getElementById("makeInSearch").value="0";document.getElementById("modelInSearch").value="0";InitializeTimer()} function loadCityInDealers(){document.DealerSearchForm.cityInSearchDealer.options.length=1;var a=document.DealerSearchForm.stateInSearchDealer.value;for(cityElements in country_array.IN.states[a].cities)addoption(document.DealerSearchForm.cityInSearchDealer,country_array.IN.states[a].cities[cityElements].name,cityElements);SortDropDown(document.DealerSearchForm.cityInSearchDealer,1)} function loadModelInSearch(a){document.topDisplay.catGroupId.options.length=1;var b=document.topDisplay.makeInSearch.value;if("0"!=b)for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.topDisplay.catGroupId,topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.topDisplay.catGroupId,1)} function loadCityInSearch(){document.getElementById("cityInSearch").options.length=1;var a=document.getElementById("stateInSearch").value;if(0!=a)for(cityElements in country_array.IN.states[a].cities)addoption(document.getElementById("cityInSearch"),country_array.IN.states[a].cities[cityElements].name,cityElements);SortDropDown(document.getElementById("cityInSearch"),1)} function MMSearchSubmit(){document.getElementById("miniPrice").selectedIndex=0;document.getElementById("maxiPrice").selectedIndex=0;document.getElementById("bodyStyle").value="0";if("0"==document.getElementById("makeInSearch").value&&""==document.getElementById("catGroupId").value)return alert("Select both Make & Model for search"),!1;"0"!=document.getElementById("makeInSearch").value&&""==document.getElementById("catGroupId").value?alert("Select both Make & Model for search"):document.getElementById("topDisplay").submit()} function PRSearchSubmit(){document.getElementById("stateInSearch").value="0";document.getElementById("cityInSearch").value="0";document.getElementById("makeInSearch").value="0";document.getElementById("catGroupId").value="";document.getElementById("bodyStyle").value="0";if("0"==document.getElementById("miniPrice").value&&"999999999"==document.getElementById("maxiPrice").value)return alert("Select Minimum & Maximum for search"),!1;if(parseFloat(document.getElementById("miniPrice").value)>parseFloat(document.getElementById("maxiPrice").value))return alert("Minimum price should not be greater than the maximum price"), !1;document.getElementById("topDisplay").submit()} function BSSearchSubmit(){document.getElementById("stateInSearch").value="0";document.getElementById("cityInSearch").value="0";document.getElementById("makeInSearch").value="0";document.getElementById("catGroupId").value="";document.getElementById("miniPrice").selectedIndex=0;document.getElementById("maxiPrice").selectedIndex=0;if("0"==document.getElementById("bodyStyle").value)return alert("Select Body Style for search"),!1;document.getElementById("topDisplay").submit()} function loadAttribute(){var a=document.topDisplay.bodyStyle.value;document.getElementById("attributeValue1").value=a}function DealerSearchButton(){if("0"==document.getElementById("makeInSearchDealer").value||"0"==document.getElementById("stateInSearchDealer").value||"0"==document.getElementById("cityInSearchDealer").value||"0"==document.getElementById("typeInSearchDealer").value)return alert("Select Make, State , City & Dealer for Dealer Search"),!1;document.DealerSearchForm.submit()} function link(a,b){obj=document.getElementById(b);var c=document.getElementById("miniPrice").value,d=document.getElementById("maxiPrice").value;obj.src=a+"&miniPrice="+c+"&maxiPrice="+d} function calculateEMI(){var a="true",b=/^[0-9 ]+$/,c="";document.AdvancedSearchForm.EMILowerLimit.value.match(b)||(c+=" EMI Lower Limit\n ",a="false");document.AdvancedSearchForm.EMIUpperLimit.value.match(b)||(c+=" EMI Upper Limit\n ",a="false");document.AdvancedSearchForm.DownPayment.value.match(b)||(c+=" DownPayment\n ",a="false");document.AdvancedSearchForm.InterestRate.value.match(b)||(c+=" InterestRate\n ",a="false");document.AdvancedSearchForm.tenure.value.match(b)||(c+=" tenure\n ",a="false"); var b=parseFloat(document.getElementById("EMILowerLimit").value),d=parseFloat(document.getElementById("EMIUpperLimit").value);if(b>d)return alert("EMI-Upper Limit should be greater than the Lower Limit"),!1;if("false"==a)return alert("Enter right values for\n "+c),!1;var a=parseFloat(document.getElementById("EMILowerLimit").value),c=parseFloat(document.getElementById("EMIUpperLimit").value),b=parseFloat(document.getElementById("DownPayment").value),e=parseFloat(document.getElementById("InterestRate").value); if(100<e)return alert("Please enter a valid annual Interest rate"),!1;d=parseFloat(document.getElementById("tenure").value);if(0==a)return alert("Please enter a valid EMI Lower Limit"),!1;if(0==c)return alert("Please enter a valid EMI Upper Limit"),!1;if(0==e)return alert("Please enter a valid Interest Rate"),!1;if(0==d)return alert("Please enter a valid tenure"),!1;if(0==b)return alert("Please enter a valid DownPayment"),!1;e*=0.01/12;d=e+e/(power(1+e,d)-1);Lowerprice=a/d+b;upperprice=c/d+b;document.getElementById("divSuggestButton").style.display= "block";document.AdvancedSearchForm.miniPrice.value=Math.round(Lowerprice);document.AdvancedSearchForm.maxiPrice.value=Math.round(upperprice)}function power(a,b){return Math.pow(a,b)}function submitSearch(a){!document.getElementById("miniPrice").value||!document.getElementById("maxiPrice").value?alert("Calculate the Price range before search for a car"):a.submit()} function calculateEMI_JSPF(){var a="true",b=/^[0-9 ]+$/,c="";document.getElementById("EMILowerLimit").value.match(b)||(c+=" EMI Lower Limit\n ",a="false");document.getElementById("EMIUpperLimit").value.match(b)||(c+=" EMI Upper Limit\n ",a="false");document.getElementById("DownPayment").value.match(b)||(c+=" DownPayment\n ",a="false");document.getElementById("InterestRate").value.match(b)||(c+=" InterestRate\n ",a="false");document.getElementById("tenure").value.match(b)||(c+=" tenure\n ",a="false"); var b=parseFloat(document.getElementById("EMILowerLimit").value),d=parseFloat(document.getElementById("EMIUpperLimit").value);if(b>d)return alert("EMI-Upper Limit should be greater than the Lower Limit"),!1;if("false"==a)return alert("Enter right values for\n "+c),!1;var a=parseFloat(document.AdvancedSearchForm.EMILowerLimit.value),c=parseFloat(document.AdvancedSearchForm.EMIUpperLimit.value),b=parseFloat(document.AdvancedSearchForm.DownPayment.value),e=parseFloat(document.AdvancedSearchForm.InterestRate.value), d=parseFloat(document.AdvancedSearchForm.tenure.value);if(100<e)return alert("Please enter the valid annual interest rate"),!1;if(0==a)return alert("Please enter a valid EMI Lower Limit"),!1;if(0==c)return alert("Please enter a valid EMI Upper Limit"),!1;if(0==e)return alert("Please enter a valid Interest Rate"),!1;if(0==d)return alert("Please enter a valid tenure"),!1;if(0==b)return alert("Please enter a valid DownPayment"),!1;e*=0.01/12;d=e+e/(power(1+e,d)-1);Lowerprice=a/d+b;upperprice=c/d+b;document.getElementById("divSuggestButton").style.display= "block";document.AdvancedSearchForm.miniPrice.value=Math.round(Lowerprice);document.AdvancedSearchForm.maxiPrice.value=Math.round(upperprice)} function LoadCities(a,b){document.DealerSearchForm.cityInSearchDealer.options.length=1;var c=a.stateInSearchDealer.value;for(cityElements in country_array.IN.states[c].cities)addoption(document.DealerSearchForm.cityInSearchDealer,country_array.IN.states[c].cities[cityElements].name,cityElements);SortDropDown(document.getElementById("cityInSearchDealer"),1);if(0==b)document.getElementById("cityInSearchDealer").selectedIndex=0}function submitDealerSearch(a){a.submit()} function onDealerLocationLoading(a,b,c,d,e){for(subcatelements in topcategories_array[a].subarr)addoption(document.DealerSearchForm.makeInSearchDealer,topcategories_array[a].subarr[subcatelements].name,subcatelements);SortDropDown(document.getElementById("makeInSearchDealer"),1);for(stateElements in country_array.IN.states)document.DealerSearchForm.stateInSearchDealer&&addoption(document.DealerSearchForm.stateInSearchDealer,country_array.IN.states[stateElements].name,stateElements);SortDropDown(document.getElementById("stateInSearchDealer"), 1);0!=b&&0!=c&&0!=d?(document.getElementById("makeInSearchDealer").value=b,document.getElementById("cityInSearchDealer").value=c,document.getElementById("stateInSearchDealer").value=d,document.getElementById("typeInSearchDealer").value=e):(document.getElementById("makeInSearchDealer").selectedIndex=0,document.getElementById("cityInSearchDealer").selectedIndex=0,document.getElementById("stateInSearchDealer").selectedIndex=0,document.getElementById("typeInSearchDealer").selectedIndex=0);if("0"!=d){document.DealerSearchForm.cityInSearchDealer.options.length= 1;for(cityElements in country_array.IN.states[d].cities)addoption(document.DealerSearchForm.cityInSearchDealer,country_array.IN.states[d].cities[cityElements].name,cityElements);document.DealerSearchForm.cityInSearchDealer.value=c}}function viewMap(a,b,c,d,e){window.open("/webapp/wcs/stores/servlet/DealerLocationMap?langId="+c+"&storeId="+d+"&catalogId="+e+"&address="+a+"&city="+b,"Dealer","width=800,height=510,status=no,scrollbars=yes")} function validateDealerSearch(){var a=document.getElementById("makeInSearchDealer").value,b=document.getElementById("cityInSearchDealer").value,c=document.getElementById("stateInSearchDealer").value,d=document.getElementById("typeInSearchDealer").value;if("0"==a||""==a||null==a)return alert("Please select a Make"),!1;if("0"==c||""==c||null==c)return alert("Please select state and city"),!1;if("0"==b||""==b||null==b)return alert("Please select a City"),!1;return"0"==d||""==d||null==d?(alert("Please select a Dealer Type"), !1):!0}function searchDealers(){validateDealerSearch()&&document.DealerSearchForm.submit()}function submitSearchAffCalc(a){var b=document.getElementById("maxPrice").value;if(""==b||null==b)return alert("All mandatory fields should be filled"),!1;document.getElementById("maxiPrice").value=document.getElementById("maxPrice").value;document.getElementById("miniPrice").value=document.getElementById("minPrice").value;a.submit()} function CalculateRemainIncome(){var a=/^[0-9]+$/,b=document.getElementById("monthly_income").value,c=document.getElementById("RentText").value,d=document.getElementById("FoodEntertainmentText").value,e=document.getElementById("creditCard").value,g=document.getElementById("homeLoan").value,h=document.getElementById("EduLoan").value,j=document.getElementById("otherLoan").value,k=document.getElementById("utilities").value,l=document.getElementById("OtherExpenseText").value;if(!b.match(a))return alert("Please enter the income"), !1;if(!c.match(a)||!d.match(a)||!e.match(a)||!g.match(a)||!h.match(a)||!j.match(a)||!k.match(a)||!l.match(a))return alert("Numeric values only allowed"),!1;a=b-c-d-e-g-h-j-k-l;document.getElementById("monthDisposableIncome").value=a;document.getElementById("MonthEMILower").value=25*a/100;document.getElementById("MonthEMIUpper").value=30*a/100} function CalculateAfford(){document.getElementById("errorMessage").innerHTML="";if(validateAfford()){var a=document.getElementById("DownPaymentText").value,b=document.getElementById("MonthEMILower").value,c=document.getElementById("MonthEMIUpper").value,d=document.getElementById("AnnInterestRateText").value/1200,e=document.getElementById("LoanTenure").value,e=Math.pow(1+d,e)-1,d=d+d/e,b=parseFloat(b/d)+parseFloat(a),a=parseFloat(c/d)+parseFloat(a);document.getElementById("minPrice").value=Math.round(b); document.getElementById("maxPrice").value=Math.round(a)}window.scroll(0,250)} function validateAfford(){var a=document.getElementById("monthly_income").value;if(""==a||null==a)return alert("Please enter the income"),!1;for(var b,c=0;c<a.length;c++)if(b=a.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid income"),!1;if(1<a.length&&"0"==a.substring(0,1))return alert("Please enter a valid income"),!1;for(var a=document.getElementById("RentText").value,d=document.getElementById("FoodEntertainmentText").value,e=document.getElementById("creditCard").value, g=document.getElementById("homeLoan").value,h=document.getElementById("EduLoan").value,j=document.getElementById("otherLoan").value,k=document.getElementById("utilities").value,l=document.getElementById("OtherExpenseText").value,c=0;c<a.length;c++)if(b=a.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid rent"),!1;for(c=0;c<d.length;c++)if(b=d.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid food expense"),!1;for(c=0;c<e.length;c++)if(b=e.charAt(c), "-1"=="0123456789.".indexOf(b))return alert("Please enter a valid credit card expense"),!1;for(c=0;c<g.length;c++)if(b=g.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid Home Loan expense"),!1;for(c=0;c<h.length;c++)if(b=h.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid Education Loan expense"),!1;for(c=0;c<j.length;c++)if(b=j.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid Other Loan expense"),!1;for(c=0;c<k.length;c++)if(b= k.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid Utility expense"),!1;for(c=0;c<l.length;c++)if(b=l.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid Other expense"),!1;a=document.getElementById("DownPaymentText").value;if(""==a||null==a||0==parseInt(a))return alert("Please enter a valid down Payment"),!1;for(c=0;c<a.length;c++)if(b=a.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid down Payment"),!1;d=document.getElementById("LoanTenure").value; if(""==d||null==d||0==parseInt(d))return alert("Please enter a valid Loan Tenure"),!1;for(c=0;c<a.length;c++)if(b=d.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid Loan Tenure"),!1;d=document.getElementById("AnnInterestRateText").value;if(""==d||null==d||0==parseInt(d))return alert("Please enter a valid interest Rate"),!1;for(c=0;c<d.length;c++)if(b=d.charAt(c),"-1"=="0123456789.".indexOf(b))return alert("Please enter a valid interest Rate"),!1;if(100<d)return alert("Annual Interest Rate cannot be more than 100"), !1;return 1<a.length&&"0"==a.substring(0,1)?(alert("Please enter a valid down Payment"),!1):!0}var rate,principal,emi,f=0,NomonthSelected; function EMICalculate(){document.getElementById("errorMessage").innerHTML="";if(validateEMICalc()){principal=document.EMICalculatorForm.loanAmount.value;rate=document.EMICalculatorForm.annualInterestRate.value/1200;for(var a=1+rate,b=0,c=0;5>c;){var b=b+12,d=Math.pow(a,b)-1;emi=(rate+rate/d)*principal;d=Math.round(emi);document.getElementById("numberMonths"+c).innerHTML=b;document.getElementById("hiddenNumberMonths"+c).value=b;document.getElementById("EMI"+c).innerHTML=d;document.getElementById("hiddenEMI"+ c).value=d;c++}a=document.getElementById("selectedItem").value;0==a%2?document.getElementById("row"+a).className="alt":document.getElementById("row"+a).className="";document.getElementById("downpay").style.display="block";document.getElementById("parah2").style.display="block";document.getElementById("parah3").style.display="block";document.getElementById("miniEMITable").style.display="block";document.getElementById("emiChart").style.display="none"}} function submitSearchEMICalc(a){if(!document.getElementById("loanAmount").value)return alert("Enter Loan Amount"),!1;if(!document.getElementById("annualInterestRate").value)return alert("Enter Annual Interest Rate"),!1;if(!document.getElementById("downpayment").value)return alert("Enter Down Payment"),!1;if(!0==isNaN(document.getElementById("downpayment").value))return alert("Enter Valid Amount in the Downpayment Field"),!1;var b=document.getElementById("downpayment").value,b=trimEMI(b);if(0==b)return alert("Please enter the valid down Payment"), !1;if(1<b.length&&"0"==b.substring(0,1))return alert("Please enter the valid down Payment"),!1;for(var c,d=0;d<b.length;d++)if(c=b.charAt(d),"-1"=="0123456789.".indexOf(c))return alert("Please enter the valid down Payment"),!1;c=document.getElementById("loanAmount").value;d=document.getElementById("downpayment").value;b=1.1*(parseFloat(c)+parseFloat(d));c=0.9*(parseFloat(c)+parseFloat(d));document.EMICalculatorForm.maxiPrice.value=b;document.EMICalculatorForm.miniPrice.value=c;a.submit()} function trimEMI(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")} function validateEMICalc(){principal=document.getElementById("loanamtdisplay").innerHTML=document.EMICalculatorForm.loanAmount.value;principal=trimEMI(principal);if(""==principal||null==principal)return document.getElementById("errorMessage").innerHTML="Please enter the Loan Amount",!1;var a=document.getElementById("annualInterestRate").value,a=trimEMI(a);if(100<a)return document.getElementById("errorMessage").innerHTML="The Annual Interest Rate cannot be more than 100",!1;if(!0==isNaN(principal))return document.getElementById("errorMessage").innerHTML= "Enter Valid Amount in the Loan Amount Field",!1;if(!0==isNaN(a))return document.getElementById("errorMessage").innerHTML="Enter Valid Amount in the Annual Interest Rate Field",!1;for(var b=0;b<principal.length;b++)if(a=principal.charAt(b),"-1"=="0123456789.".indexOf(a))return document.getElementById("errorMessage").innerHTML="Please enter a valid loan amount",!1;if(1<principal.length&&"0"==principal.substring(0,1))return document.getElementById("errorMessage").innerHTML="Please enter a valid loan amount", !1;if(0==principal)return document.getElementById("errorMessage").innerHTML="Please enter a valid loan amount",!1;var c=document.getElementById("Interestdisplay").innerHTML=document.EMICalculatorForm.annualInterestRate.value,c=trimEMI(c);if(""==c||null==c)return document.getElementById("errorMessage").innerHTML="Please enter the Rate of Interest",!1;for(b=0;b<c.length;b++)if(a=c.charAt(b),"-1"=="0123456789.".indexOf(a))return document.getElementById("errorMessage").innerHTML="Please enter a valid Rate of Interest", !1;if(0==c)return document.getElementById("errorMessage").innerHTML="Please enter a valid Rate of Interest",!1;return 1<c.length&&"0"==c.substring(0,1)?(document.getElementById("errorMessage").innerHTML="Please enter a valid Rate of Interest",!1):!0} function callCommand(a){var b=0;document.getElementById("selectedItem").value=a;for(b=0;5>b;b++)0==b%2?document.getElementById("row"+b).className="alt":document.getElementById("row"+b).className="";document.getElementById("row"+a).className="active";NomonthSelected=document.getElementById("hiddenNumberMonths"+a).value;a=document.getElementById("hiddenEMI"+a).value;if(0!=f)b=document.getElementById("prevSelected").value,deleteRows(b);arbit(a,NomonthSelected);f++;document.getElementById("prevSelected").value= NomonthSelected}function deleteRows(a){for(var b=1;b<=a;)document.getElementById("emiChartTable").deleteRow(2),b++} function arbit(a,b){var c,d,e;for(e=1;e<=b;e++){var g=document.getElementById("emiChartTable").insertRow(e+1);if(1==e){c=g.insertCell(0);c.innerHTML=e;c=g.insertCell(1);c.innerHTML=a;c=Math.round(principal*rate);var h=g.insertCell(2);h.innerHTML=c;c=Math.round(a-c);h=g.insertCell(3);h.innerHTML=c;d=Math.round(principal-c);g=g.insertCell(4);g.innerHTML=d}else c=g.insertCell(0),c.innerHTML=e,c=g.insertCell(1),c.innerHTML=a,c=Math.round(d*rate),h=g.insertCell(2),h.innerHTML=c,c=Math.round(a-c),h=g.insertCell(3), h.innerHTML=c,d=Math.round(d-c),g=g.insertCell(4),g.innerHTML=e==b?0:d}document.getElementById("emiChart").style.display="block"}function onResetEMI(){document.EMICalculatorForm.reset();document.getElementById("emiChart").style.display="none";document.getElementById("miniEMITable").style.display="none"} function loadsubcatLoanQuote(a){document.getElementById("Model").options.length=1;var b=document.getElementById("Make").value;for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.getElementById("Model"),topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.getElementById("Model"),1)} function loadsubsubcatLoanQuote(a){document.getElementById("Variant").options.length=1;var b=document.getElementById("Make").value,c=document.getElementById("Model").value;for(variantelements in topcategories_array[a].subarr[b].subsubarr[c].variantarr)addoption(document.getElementById("Variant"),topcategories_array[a].subarr[b].subsubarr[c].variantarr[variantelements].name,variantelements);SortDropDown(document.getElementById("Variant"),1)} function LoadLoanQuoteCities(a,b){document.LoanQuoteForm.LoanQuoteGuestUserCity.options.length=1;var c=a.LoanQuoteGuestUserState.value,d=0,e="0";for(cityElements in country_array.IN.states[c].cities)cityElements==b&&(d=1,e=cityElements),addoption(document.LoanQuoteForm.LoanQuoteGuestUserCity,country_array.IN.states[c].cities[cityElements].name,cityElements);SortDropDown(document.LoanQuoteForm.LoanQuoteGuestUserCity,1);if(0<d)document.LoanQuoteForm.LoanQuoteGuestUserCity.value=e} function GetLoanQuote(){if(validateLoanQuote()){document.getElementById("status").value="true";document.getElementById("showPrice").value="0";document.getElementById("newx").checked?document.getElementById("cartype").value=document.getElementById("newx").value:document.getElementById("cartype").value=document.getElementById("preowned").value;if(!document.getElementById("validlead").checked)document.getElementById("valid").value="N";document.getElementById("makePass").value=document.getElementById("Make").value; document.getElementById("modelPass").value=document.getElementById("Model").value;document.getElementById("urlVariantId").value=document.getElementById("Variant").value;document.LoanQuoteForm.submit()}} function validateLoanQuote(){if("0"==document.getElementById("Make").value)return alert("Please select the vehicle make"),document.getElementById("Make").focus(),!1;if("0"==document.getElementById("Model").value)return alert("Please select the vehicle model"),document.getElementById("Model").focus(),!1;if("G"==document.getElementById("userType").value){var a=document.getElementById("GuestUserFullName").value,a=trimEMI(a);if(!a||""==a)return document.getElementById("GuestUserFullName").select(),document.getElementById("GuestUserFullName").focus(), alert("User Name should not be empty"),!1;if(!a.match(/^[a-zA-Z\s\.]+$/))return document.getElementById("GuestUserFullName").select(),alert("User Name must be alphabets"),document.getElementById("GuestUserFullName").focus(),!1;var a=/^[0-9\s]+$/,b=document.getElementById("mobileCode").value;if(b&&!b.match(a))return alert("Please enter a valid mobile number"),document.getElementById("mobileCode").focus(),!1;b=document.getElementById("LoanQuoteMobileNo").value;if(!b||""==b)return document.getElementById("LoanQuoteMobileNo").select(), document.getElementById("LoanQuoteMobileNo").focus(),alert("Please enter a phone /mobile number"),!1;if(b&&!b.match(a))return alert("Please enter a valid mobile number"),document.getElementById("LoanQuoteMobileNo").focus(),!1;a=document.getElementById("LoanQuoteEmail").value;if(""==a||null==a)return alert("Please enter your Email ID"),document.getElementById("LoanQuoteEmail").focus(),!1;if(!isValidEmail(a))return alert("Please enter a valid email Id"),document.getElementById("LoanQuoteEmail").focus(), !1}return!0} function validateLoanQuoteDownPayment(){var a=document.getElementById("LoanDownPayment").value;if(""==a||null==a)return alert("Please enter the down Payment"),!0;for(var b=document.getElementById("LoanExShowRoomPrice").value,c,d=0;d<a.length;d++)if(c=a.charAt(d),"-1"=="0123456789.".indexOf(c))return alert("Please enter a valid down Payment amount"),!0;if(1<a.length&&"0"==a.substring(0,1))return alert("Please enter a valid down Payment amount"),!0;return parseFloat(a)>parseFloat(b)?(alert("Please enter a valid down Payment amount"),!0): !1}function validateLoanQuoteShowroomPrice(){var a=document.getElementById("LoanExShowRoomPrice").value;if(!a)return alert("Ex-showroom Price should not be Empty"),!0;if(!a.match(/^[0-9\.]+$/))return alert("The Ex-showroom Price Should be Numeric"),!0;var b=a.length,a=a.indexOf(".");return-1!=a&&b>a+3?(alert("Invalid Price(Rs.) format in Ex-showroom Price"),!0):!1} function calculateLoanAmount(){var a=document.getElementById("LoanExShowRoomPrice").value,b=document.getElementById("LoanDownPayment").value,b=a-b;"Price Not Available"==a?document.getElementById("LoanAmount").value="":document.getElementById("LoanAmount").value=b} function loadsubcatInsuranceQuote(a){document.getElementById("Model").options.length=1;var b=document.getElementById("Make").value;for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.getElementById("Model"),topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.getElementById("Model"),1)} function loadsubsubcatInsuranceQuote(a){document.getElementById("Variant").options.length=1;var b=document.getElementById("Make").value,c=document.getElementById("Model").value;for(variantelements in topcategories_array[a].subarr[b].subsubarr[c].variantarr)addoption(document.getElementById("Variant"),topcategories_array[a].subarr[b].subsubarr[c].variantarr[variantelements].name,variantelements);SortDropDown(document.getElementById("Variant"),1)} function LoadInsuranceQuoteCities(a,b){document.InsuranceQuoteForm.PriceQuoteGuestUserCity.options.length=1;var c=a.PriceQuoteGuestUserState.value,d=0,e=1,g="0";for(cityElements in country_array.IN.states[c].cities)cityElements==b&&(d=e,g=cityElements),addoption(document.InsuranceQuoteForm.PriceQuoteGuestUserCity,country_array.IN.states[c].cities[cityElements].name,cityElements),e++;SortDropDown(document.InsuranceQuoteForm.PriceQuoteGuestUserCity,1);if(0<d)document.InsuranceQuoteForm.PriceQuoteGuestUserCity.value= g}var today=new Date,t_year=today.getFullYear();function newInsurance(){document.getElementById("newRenewDiv").style.display="none";document.getElementById("newOrRenew").value="new";document.getElementById("newCrumb").style.display="block"}function renewInsurance(){document.getElementById("newOrRenew").value="renew";document.getElementById("newRenewDiv").style.display="block";document.getElementById("newCrumb").style.display="none"} function GetInsuranceQuote(){if(validateInsuranceQuote()){document.getElementById("errorMessage").innerHTML="";"G"==document.getElementById("usertype").value&&(document.getElementById("code"),document.getElementById("number"));document.getElementById("status").value="true";var a=document.InsuranceQuoteForm.Make.value,b=document.InsuranceQuoteForm.Model.value;document.getElementById("makePass").value=a;document.getElementById("modelPass").value=b;document.getElementById("urlVariantId").value=document.getElementById("Variant").value; if(!document.getElementById("validlead").checked)document.getElementById("valid").value="N";document.InsuranceQuoteForm.submit()}} function validateInsuranceQuote(){var a=document.getElementById("Make").value,b=document.getElementById("Model").value,c=document.getElementById("RegNumber").value,d=document.getElementById("InsuranceManufactureMonth").value;if("0"==a)return alert("Please Select a Vehicle Make"),!1;if("0"==b)return alert("Please Select a Vehicle Model"),!1;if("0"==d)return alert("Please select a month"),!1;if("0"==document.getElementById("InsuranceManufactureYear").value)return alert("Please select a year"),!1;if(!c|| ""==c)return alert("Registration Number should not be empty"),!1;if(!c.match(/^[a-zA-Z0-9\s\-]+$/))return alert("Registration Number must be alphaNumeric"),!1;b=document.getElementById("newOrRenew").value;if("renew"==b){a=document.getElementById("insuredExpireDate").value;if("0"==document.getElementById("InsuranceType").value)return alert("Select Insurance Type"),!1;if(""==a)return alert("Expiry Date can not be Empty"),!1}b=document.getElementById("newOrRenew").value;a=/^[a-zA-Z\s\.]+$/;if("renew"== b&&(document.getElementById("InsuranceQuoteInsured"),validateInsuranceQuoteInsured()))return!1;if("G"==document.getElementById("usertype").value){b=document.getElementById("GuestUserFullName").value;b=trimEMI(b);if(!b||""==b)return alert("User Name should not be empty"),!1;if(!b.match(a))return alert("User Name must be alphabets"),!1;if("0"==document.getElementById("PriceQuoteGuestUserState").value)return alert("Please select the state"),!1;if("0"==document.getElementById("PriceQuoteGuestUserCity").value)return alert("Please select the city"), !1;a=document.getElementById("PriceQuoteEmail").value;if(""==a||null==a)return alert("Your Email ID cannot be empty"),!1;if(!isValidEmail(a))return alert("Email ID entered is not valid"),!1;a=/^[0-9\s]+$/;if((b=document.getElementById("code").value)&&!b.match(a))return alert("Please enter a valid number"),!1;if((b=document.getElementById("number").value)&&!b.match(a))return alert("Please enter a valid number"),!1}return!0} function validateInsuranceQuotePremium(){var a=document.getElementById("InsuranceQuotePremium").value;if(!a)return alert("Premium Amount should not be Empty"),!0;if(!a.match(/^[0-9\.]+$/))return alert("Premium Amount Should be Numeric"),!0;var b=a.length,a=a.indexOf(".");return-1!=a&&b>a+3?(alert("Invalid Price(Rs.) format in Premium Amount"),!0):!1} function validateInsuranceQuoteInsured(){var a=document.getElementById("InsuranceQuoteInsured").value;if(!a)return alert("Insured Amount should not be Empty"),!0;if(0==a)return alert("Insured Amount should not be Zero"),!0;if(!a.match(/^[0-9\.]+$/))return alert("Insured Amount Should be Numeric"),!0;var b=a.length,a=a.indexOf(".");return-1!=a&&b>a+3?(alert("Invalid Price(Rs.) format in Insured Amount"),!0):!1} function loadCC(){var a=document.getElementById("Variant").value,a=varCCMap[a];document.getElementById("cubicCapacity").value=a;""==a?(alert("Please enter the cubic capacity value"),document.getElementById("cubicCapacity").readOnly=!1):document.getElementById("cubicCapacity").readOnly=!0}function imposeMaxLength(a,b){return a.value.length<=b} function loadsubcatPriceQuote(a){document.getElementById("Model").options.length=1;var b=document.getElementById("Make").value;for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.getElementById("Model"),topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.getElementById("Model"),1)} function loadsubsubcatPriceQuote(a){document.getElementById("Variant").options.length=1;var b=document.getElementById("Make").value,c=document.getElementById("Model").value;for(variantelements in topcategories_array[a].subarr[b].subsubarr[c].variantarr)addoption(document.getElementById("Variant"),topcategories_array[a].subarr[b].subsubarr[c].variantarr[variantelements].name,variantelements);SortDropDown(document.getElementById("Variant"),1)} function LoadPriceQuoteCities(a,b){document.PriceQuoteForm.PriceQuoteGuestUserCity.options.length=1;var c=a.PriceQuoteGuestUserState.value,d=0,e="0",g=1;for(cityElements in country_array.IN.states[c].cities)cityElements==b&&(d=g,e=cityElements),addoption(document.PriceQuoteForm.PriceQuoteGuestUserCity,country_array.IN.states[c].cities[cityElements].name,cityElements),g++;SortDropDown(document.PriceQuoteForm.PriceQuoteGuestUserCity,1);if(0<d)document.PriceQuoteForm.PriceQuoteGuestUserCity.value=e} function GetPriceQuote(){if(validatePriceQuote()){document.getElementById("errorMessage").innerHTML="";document.getElementById("status").value="true";document.getElementById("makePass").value=document.getElementById("Make").value;document.getElementById("modelPass").value=document.getElementById("Model").value;document.getElementById("searchStatus").value="false";document.getElementById("urlVariantId").value=document.getElementById("Variant").value;document.getElementById("state").value=document.getElementById("vState").value; document.getElementById("city").value=document.getElementById("vCity").value;if(!document.getElementById("validlead").checked)document.getElementById("valid").value="N";if("G"==document.getElementById("usertype").value){var a=document.getElementById("mainMobile").value;document.getElementById("PriceQuoteMobileNo").value=a}document.getElementById("bestdeal").className="bestdeal1";document.PriceQuoteForm.submit()}} function validatePriceQuote(){if("0"==document.getElementById("Make").value)return alert("Please select the Vehicle Make"),!1;if("0"==document.getElementById("Model").value)return alert("Please select the Vehicle Model"),!1;if("0"==document.getElementById("Variant").value)return alert("Please select the Vehicle Variant"),!1;if("0"==document.getElementById("vState").value)return alert("Select State"),!1;if("0"==document.getElementById("vCity").value)return alert("Select City"),!1;if("G"==document.getElementById("usertype").value){var a= document.getElementById("GuestUserFullName").value,a=trimEMI(a);if(!a||""==a)return alert("User Name should not be empty"),!1;if(!a.match(/^[a-zA-Z\s\.]+$/))return alert("User Name must be alphabets"),!1;document.getElementById("GuestUserAddress1");a=document.getElementById("PriceQuoteEmail").value;if(""==a||null==a)return alert("Please Enter the Email-Id"),!1;if(!isValidEmail(a))return alert("Please Enter the valid Email-Id"),!1;var a=/^[0-9\s]+$/,b=document.getElementById("mainMobile").value;if(!b|| ""==b)return alert("Mobile Number should not be empty"),!1;if(b){if(!b.match(a))return alert("Please enter a valid mobile number"),!1;if(10>b.length)return alert("Mobile should be at least 10 digit"),!1}}return!0}var loanOpt=0; function selectLoan(){loanOpt=0==loanOpt?1:0;if(1==loanOpt)document.getElementById("divForLoan").style.display="block";if(0==loanOpt)document.getElementById("divForLoan").style.display="none",document.getElementById("PriceQuoteLoanAmount").value="0",document.getElementById("PriceQuoteLoanDuration").value="0",document.getElementById("PriceQuoteIncomeYear").value="0"} function loadsubsubcatReadReviewRating(a,b){document.ReviewRatingForm.Model.options.length=1;var c=a.Make.value,d=1;for(subsubcatelements in topcategories_array[b].subarr[c].subsubarr)addoption(document.ReviewRatingForm.Model,topcategories_array[b].subarr[c].subsubarr[subsubcatelements].name,subsubcatelements),d++;SortDropDown(document.ReviewRatingForm.Model,1)} function loadsubsubcatReadReview(a,b){document.ReadReviewForm.modelInReadReview.options.length=1;var c=a.makeInReadReview.value,d=1;for(subsubcatelements in topcategories_array[b].subarr[c].subsubarr)addoption(document.ReadReviewForm.modelInReadReview,topcategories_array[b].subarr[c].subsubarr[subsubcatelements].name,subsubcatelements),d++;SortDropDown(document.ReadReviewForm.modelInReadReview,1)} function ReadReviewSubmit(){if(0==document.getElementById("modelInReadReview").value)return alert("Choose Make and Model for Read a Review"),!1;var a=document.getElementById("makeInReadReview")[document.getElementById("makeInReadReview").selectedIndex].innerHTML,b=document.getElementById("modelInReadReview")[document.getElementById("modelInReadReview").selectedIndex].innerHTML;document.getElementById("car").value=a+" "+b;document.getElementById("ReadReviewForm").submit()} function WriteReviewSubmit(){if(0==document.getElementById("Model").value)return alert("Choose Make and Model for Writing a Review"),!1;if(0==document.getElementById("VarientInWrite").value)return alert("Choose Varient for Writing a Review"),!1;document.getElementById("ReviewRatingForm").submit()} function loadsubcatTestDrive(a){document.getElementById("Model").options.length=1;var b=document.getElementById("Make").value;for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.getElementById("Model"),topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.getElementById("Model"),1)} function loadsubsubcatTestDrive(a){document.getElementById("Variant").options.length=1;var b=document.getElementById("Make").value,c=document.getElementById("Model").value;for(variantelements in topcategories_array[a].subarr[b].subsubarr[c].variantarr)addoption(document.getElementById("Variant"),topcategories_array[a].subarr[b].subsubarr[c].variantarr[variantelements].name,variantelements);SortDropDown(document.getElementById("Variant"),1)} function LoadCitiesTestDrive(a){document.bookTestDrive.City.options.length=1;a=a.State.value;for(cityElements in country_array.IN.states[a].cities)addoption(document.bookTestDrive.City,country_array.IN.states[a].cities[cityElements].name,cityElements);SortDropDown(document.bookTestDrive.City,1)} function changeValue(a,b){if(document.bookTestDrive.newsLetter1.checked)document.bookTestDrive.newsLetter.value="1";if(document.bookTestDrive.insurance1.checked)document.bookTestDrive.insurance.value="1";if(document.bookTestDrive.loan1.checked)document.bookTestDrive.loan.value="1";var c=document.getElementById("Make"),d=document.getElementById("Model");document.getElementById("MakeValue").value=c.options[c.selectedIndex].text;document.getElementById("ModelValue").value=d.options[d.selectedIndex].text; var c=document.getElementById("Make").value,d=document.getElementById("Model").value,e=document.getElementById("Variant").value;if("0"==c)return alert("Please Select The Make"),!1;if("0"==d)return alert("Please Select The Model"),!1;if("0"==e)return alert("Please Select The Variant"),!1;c=/^[0-9]+$/;if("G"==a){if(!document.bookTestDrive.name.value)return document.bookTestDrive.name.select(),alert("Your Name cannot be empty"),!1;if(!document.bookTestDrive.name.value.match(/^[a-zA-Z\s\.]+$/))return alert("User Name must be alphabets"), !1;if(!document.bookTestDrive.address1.value)return document.bookTestDrive.address1.select(),alert("Address field 1 cannot be empty"),!1;d=/^[a-zA-Z0-9\s\.\,\/\-]+$/;if(!document.bookTestDrive.address1.value.match(d))return alert("Special Characters cannot be entered in the address field"),!1;if(document.bookTestDrive.address2.value&&!document.bookTestDrive.address2.value.match(d))return alert("Special Characters cannot be entered in the address field"),!1;d=document.getElementById("vState").value; if(""==d||"0"==d)return alert("Please Select the State"),!1;if("0"==document.getElementById("vCity").value)return alert("Please Select the City"),!1;var d=document.getElementById("phone").value,e=document.getElementById("phone1").value,g=document.getElementById("MobileCode").value,h=document.getElementById("MobileNumber").value;if(0==trim(d)&&0==trim(e)&&0==trim(g)&&0==trim(h))return alert("Enter either Phone number or Mobile Number"),!1;if(0==trim(g)&&0==trim(h)){if(null!=e&&""!=e){if(!e.match(c))return alert("Enter Valid data for Phone - Code Field"), !1}else return alert("The Phone number should not be Empty"),!1;if(null!=d&&""!=d){if(!d.match(c))return alert("Enter Valid data for Phone"),!1}else return alert("Phone field should not be Empty"),!1}if(0==trim(d)&&0==trim(e)){if(null!=h&&""!=h){if(!h.match(c))return alert("Enter Valid data for Mobile Number - Code Field"),!1}else return alert("The Code Field in Mobile Number should not be Empty"),!1;if(null!=g&&""!=g){if(!g.match(c))return alert("Enter Valid data for Mobile Number"),!1}else return alert("Mobile Number should not be Empty"), !1}if(0!=trim(d)){if(!d.match(c))return alert("Enter Valid data for Phone Code"),!1;if(0==trim(e))return alert("Enter Valid data for Phone Number"),!1}if(0!=trim(e)){if(!e.match(c))return alert("Enter Valid data for Phone Number"),!1;if(0==trim(d))return alert("Enter Valid data for Phone Code"),!1}if(0!=trim(g)){if(!g.match(c))return alert("Enter Valid data for Mobile Code"),!1;if(0==trim(h))return alert("Enter Valid data for Mobile Number"),!1}if(0!=trim(h)){if(!h.match(c))return alert("Enter Valid data for Mobile Number"), !1;if(0==trim(g))return alert("Enter Valid data for Mobile Code"),!1}if(!document.bookTestDrive.email.value)return document.bookTestDrive.email.select(),alert("Email ID cannot be empty"),!1;c=document.bookTestDrive.email.value.toLowerCase();if(""!=c&&!isValidEmail(c))return alert("The Email ID entered is not valid"),!1}if(!document.bookTestDrive.testDriveDate.value)return document.bookTestDrive.testDriveDate.select(),alert("Select a Date for Test Drive"),!1;var e=[],e=document.bookTestDrive.testDriveDate.value.split("-"), c=e[0],d=e[1],e=e[2],g=[],g=b.substring(0,10).split("-"),h=g[1],j=g[2];if(g[0]>e)return alert("The selected year cannot be past year"),!1;if(h>c)return alert("The selected month cannot be past month"),!1;if(h==c&&j>d)return alert("The selected day cannot be past day"),!1;document.getElementById("state").value=document.getElementById("vState").value;document.getElementById("city").value=document.getElementById("vCity").value;if(!document.getElementById("validlead").checked)document.getElementById("valid").value= "N";document.bookTestDrive.submit()}function loadImage(){document.getElementById("Variant");var a=document.getElementById("Variant").value,a='<image src="'+varImgMap[a]+'" width="120" height="90"></img>';document.getElementById("defaultImage").innerHTML=a}function diablePreviousImages(){for(var a=0;a<varImgArr.length;a++)document.getElementById("image"+varImgArr[a]).style.display="none"} function onLoadingUserSignUp(a,b,c,d,e,g,h,j){for(subcatelements in topcategories_array[a].subarr)addoption(document.getElementById("make"),topcategories_array[a].subarr[subcatelements].name,subcatelements);SortDropDown(document.getElementById("make"),1);for(stateElements in country_array.IN.states)addoption(document.getElementById("state"),country_array.IN.states[stateElements].name,stateElements);SortDropDown(document.getElementById("state"),1);if(null!=b&&""!=b)document.getElementById("state").value= b,LoadCitiesUserSignUp(document.UserRegistrationAddForm);if(null!=c&&""!=c){if(0==c)if(document.getElementById("noradiob").checked=!0,document.getElementById("nobutton").style.display="block",document.getElementById("whentobuy").value=d,"New Car"==g)document.getElementById("newc").checked=!0;else if("Pre Owned Car"==g)document.getElementById("preowned").checked=!0;if(1==c)document.getElementById("yesradiob").checked=!0,document.getElementById("radi").style.display="block",document.getElementById("make").value= e,loadsubsubcatUserSignUp(document.UserRegistrationAddForm,a,j),document.getElementById("year").value=h}} function LoadCitiesUserSignUp(a,b,c){document.getElementById("city").options.length=1;var a=a.state.value,b=0,d=1;for(cityElements in country_array.IN.states[a].cities)cityElements==c&&(b=d),addoption(document.getElementById("city"),country_array.IN.states[a].cities[cityElements].name,cityElements),d++;if(0<b)document.getElementById("city").value=c;SortDropDown(document.getElementById("city"),1)} function loadsubsubcatUserSignUp(a,b,c){document.getElementById("model").options.length=1;var a=a.make.value,d=1,e=0;for(subsubcatelements in topcategories_array[b].subarr[a].subsubarr)subsubcatelements==c&&(e=d),addoption(document.getElementById("model"),topcategories_array[b].subarr[a].subsubarr[subsubcatelements].name,subsubcatelements),d++;if(0<e)document.getElementById("model").value=c;SortDropDown(document.getElementById("model"),1)} function carvalidation(){document.getElementById("newc").checked?(document.getElementById("newc").value="New Car",document.getElementById("preowned").value=""):(document.getElementById("newc").value="",document.getElementById("preowned").value="Pre Owned Car")}function radiovalidity(){document.getElementById("radi").style.display="block";document.getElementById("whentobuy").selectedIndex=0;document.getElementById("nobutton").style.display="none"} function radioinvalidity(){document.getElementById("radi").style.display="none";document.getElementById("nobutton").style.display="block";document.getElementById("make").selectedIndex=0;document.getElementById("model").selectedIndex=0;document.getElementById("year").selectedIndex=0}function TermsConditions(){window.open("/webapp/wcs/stores/TermsAndConditions.jsp")} function getMonthUserSignUp(a){var b;"Jan"==a&&(b="01");"Feb"==a&&(b="02");"Mar"==a&&(b="03");"Apr"==a&&(b="04");"May"==a&&(b="05");"Jun"==a&&(b="06");"Jul"==a&&(b="07");"Aug"==a&&(b="08");"Sep"==a&&(b="09");"Oct"==a&&(b="10");"Nov"==a&&(b="11");"Dec"==a&&(b="12");return b}function getdate(a){return 10>a?"0"+a:a} function submitUserSignUpForm(a){var b=!0;a.parentMember.value=constructParentOrgDN(a.ancestorOrgs.value);if(a.ancestorOrgs.value.toLowerCase()==defaultOrgName.toLowerCase())alert("Type your organization in the Buyer organization field"),a.ancestorOrgs.value="";else if(isValidUTF8length(a.employeeId.value,20))if(isValidUTF8length(a.firstName.value,50))if(isValidUTF8length(a.mainMobilePhone.value,10)){var c=a.logonUserId.value.toLowerCase();a.logonId.value=trim(c);if(""!=a.logonId.value&&!isValidEmail(a.logonId.value))alert("The value entered in the User ID field is not valid "); else if(""==a.logonUserId.value)alert("The User Id Should not be Empty");else if(c=/^[a-zA-Z\s\.]+$/,null!=a.firstName.value&&""!=trim(a.firstName.value))if(a.firstName.value.match(c)){if(""==trim(a.logonPassword.value))return alert("Enter valid password"),!1;if(""==trim(a.logonPasswordVerify.value))return alert("Enter valid password for verification"),!1;var c=/^[0-9]+$/,d=a.mainMobilePhone.value;null!=d&&""!=d?d.match(c)?(!1==a.sendMeEmail1.checked&&(alert("Accept Terms and Conditions"),b=!1),a.phone2.value= a.mainMobilePhone.value,b&&a.submit()):alert("Enter Valid data for Mobile Number"):alert("Mobile Number should not be Empty")}else alert("Enter alphabets for First Name");else alert("The First Name Should not be Empty")}else alert("The value entered in the Mobile field is too long.");else alert("The value entered in the First Name field is too long.");else alert("The value entered in the Employee ID field is too long.")} function passwordval(){document.getElementById("passWordError").style.display="block";document.getElementById("passWordError").innerHTML="";var a=document.getElementById("WC_UserRegistrationAddForm_FormInput_logonPassword_1").value,b=a.search(/[\.\!\@\#\$\%\&\*]{0,1}/),c=a.search(/[a-z]{1,}[A-Z]{0,}/),d=a.search(/[0-9]{1,}/);6<=a.length&&0==b&&0==c&&0!=d&&-1!=d?document.getElementById("passWordError").innerHTML="Strong password":document.getElementById("passWordError").innerHTML="Weak password"} function formReviewReset(){for(var a=document.getElementById("ProvideFeedback"),b=0;b<a.length;b++)if("radio"==a.elements[b].type)a.elements[b].checked=!1;else if("textarea"==a.elements[b].type)a.elements[b].value="";if("G"==document.getElementById("userType").value)for(b=0;b<a.length;b++)if("text"==a.elements[b].type)a.elements[b].value=""} function triggerReview(a){a.action="ProvideReviewFeedbackCmd";a.method="post";var b=document.getElementById("criteriaCount").value,c=document.getElementById("criDescCount").value,d,e,g=0;for(d=1;d<=b;d++)for(e=1;e<=c;e++)document.getElementById("Quesdesc_"+d+e).checked&&g++;if("G"==document.getElementById("userType").value){c=document.getElementById("email").value;d=document.getElementById("mobileNo").value;if(""!=c&&!isValidEmail(c))return alert("Please Enter the valid Email-Id"),!1;if(""!=d&&10> d.length)return alert("Mobile should be at least 10 digit"),!1;if(""!=d&&!isValidNumber(d))return alert("Please Enter the valid Mobile"),!1}g==b?a.submit():alert("Please give ratings for all the feedback questions")}function ismaxlength(a){var b=a.getAttribute?parseInt(a.getAttribute("maxlength")):"";if(a.getAttribute&&a.value.length>b)a.value=a.value.substring(0,b)}function createRequest(){return window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")} function loadVarient(a,b){var c=createRequest();c.onreadystatechange=function(){if(4==c.readyState&&200==c.status){var b=c.responseText.split("|,"),d,h;document.getElementById("Varient").options.length=1;for(i=0;i<b.length-1;i++)h=b[i].split("|:"),d=h[0],h=h[1],addoption(document.getElementById("Varient"),h,d);SortDropDown(document.getElementById("Varient"),1)}document.getElementById("Varient").value=a};var d;c.open("GET","MakeModelView?modelId="+modelValue+"&imgFlag=0&variant=1&catalogId="+b,!0); c.send(null)} function onLoadingReadReviewRatings(a,b,c,d,e){for(subcatelements in topcategories_array[a].subarr)addoption(document.getElementById("makeInReadReview"),topcategories_array[a].subarr[subcatelements].name,subcatelements);SortDropDown(document.getElementById("makeInReadReview"),1);document.getElementById("makeInReadReview").value=b;document.getElementById("modelInReadReview").options.length=1;document.getElementById("modelInReadReview").options.length=1;b=document.getElementById("makeInReadReview").value;for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.getElementById("modelInReadReview"), topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);document.getElementById("modelInReadReview").value=c;loadVarient(d,e)} function loadsubsubcatReadCompReview(a,b){document.getElementById("modelInReadReview").options.length=1;var c=document.getElementById("makeInReadReview").value;for(subsubcatelements in topcategories_array[b].subarr[c].subsubarr)addoption(document.getElementById("modelInReadReview"),topcategories_array[b].subarr[c].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.getElementById("modelInReadReview"),1)} function ReadReviewRatingSubmit(a){if(0==document.getElementById("modelInReadReview").value)return alert("Choose Make and Model for Reading a Review"),!1;a=a+"&modelInReadReview="+document.getElementById("modelInReadReview").value;a=a+"&makeInReadReview="+document.getElementById("makeInReadReview").value;a=a+"&urlVariantId=0&car="+document.getElementById("makeInReadReview")[document.getElementById("makeInReadReview").selectedIndex].innerHTML+document.getElementById("modelInReadReview")[document.getElementById("modelInReadReview").selectedIndex].innerHTML; window.location.href=a} function onLoadingReadCompleteReview(a,b,c,d,e){for(subcatelements in topcategories_array[a].subarr)addoption(document.getElementById("makeInReadReview"),topcategories_array[a].subarr[subcatelements].name,subcatelements);SortDropDown(document.getElementById("makeInReadReview"),1);document.getElementById("makeInReadReview").value=b;document.getElementById("modelInReadReview").options.length=1;document.getElementById("modelInReadReview").options.length=1;b=document.getElementById("makeInReadReview").value;for(subsubcatelements in topcategories_array[a].subarr[b].subsubarr)addoption(document.getElementById("modelInReadReview"), topcategories_array[a].subarr[b].subsubarr[subsubcatelements].name,subsubcatelements);document.getElementById("modelInReadReview").value=c;loadVarient(d,e)} function loadsubsubcatReadCompleteReview(a,b){document.getElementById("modelInReadReview").options.length=1;var c=document.getElementById("makeInReadReview").value;for(subsubcatelements in topcategories_array[b].subarr[c].subsubarr)addoption(document.getElementById("modelInReadReview"),topcategories_array[b].subarr[c].subsubarr[subsubcatelements].name,subsubcatelements);SortDropDown(document.getElementById("modelInReadReview"),1)} function ReadCompleteReviewSubmit(a){if(0==document.getElementById("modelInReadReview").value)return alert("Choose Make and Model for Reading a Review"),!1;a=a+"&modelInReadReview="+document.getElementById("modelInReadReview").value;a=a+"&makeInReadReview="+document.getElementById("makeInReadReview").value;window.location.href=a+"&urlVariantId=0"}function isEmptyFeedBackSite(a){return"string"==typeof a?!a.match(/[^\s]/):a?!1:!0} function isValidNameFeedBackSite(a){var b;b="~!@#$%^&*()+=[]{};:,<>?/|`\t'\"\\";if(isEmptyFeedBackSite(a))return!1;for(var c=0;c<a.length;c++)if(0<=b.indexOf(a.substring(c,c+1)))return!1;a=a.substring(0,1);for(c=0;10>c;c++)if(0<="0123456789".indexOf(a))return!1;return!0}function cancleFeedBackSite(a){if("G"==a)document.getElementById("userName").value="",document.getElementById("emailID").value="";document.getElementById("comment").value="";document.getElementById("ratingSite").selectedIndex=0} function submitFeedBackSite(a){document.getElementById("comment");document.getElementById("userstatus");var b=document.getElementById("userName").value,c=document.getElementById("emailID").value;if("G"==a){if("Enter your Name"==b||isEmptyFeedBackSite(b))return alert("Please enter your Name"),!1;if("Enter your Email ID"==c||isEmptyFeedBackSite(c))return alert("Please enter your E-Mail ID"),!1;if(isValidNameFeedBackSite(b)){if(!isValidEmail(c))return alert("Please enter valid E-Mail ID"),!1}else return alert("Please enter valid Name"), !1}document.feedBackSiteForm.action="FeedbackSiteCmd";document.feedBackSiteForm.submit()} function ReadReview(){if(0==document.getElementById("modelInReadReview").value)return alert("Choose Make and Model for Read a Review"),!1;if(0==document.getElementById("Varient").value)return alert("Choose Varient for Read a Review"),!1;url="user-reviews/read-reviews-"+document.getElementById("modelInReadReview")[document.getElementById("modelInReadReview").selectedIndex].innerHTML.replace(" ","-")+"/"+document.getElementById("makeInReadReview").value+"_"+document.getElementById("modelInReadReview").value+ "_"+document.getElementById("Varient").value;window.location.assign(location.protocol+"//"+location.host+"/"+url)};
