
function setYears(yearString){var years_array=yearString.split("=");var count=0;document.lookupform.years.options.length=0;document.lookupform.makes.options.length=0;document.lookupform.models.options.length=0;document.lookupform.years.options[0]=new Option("Select Year","");while(count<years_array.length-1){document.lookupform.years.options[count+1]=new Option(years_array[count],years_array[count]);count++;}}
function setMakes(makeString){var makes_array=makeString.split("=");var count=0;document.lookupform.makes.options.length=0;document.lookupform.models.options.length=0;document.lookupform.makes.options[0]=new Option("Select Make","");while(count<makes_array.length-1){document.lookupform.makes.options[count+1]=new Option(makes_array[count],makes_array[count]);count++;}}
function setModels(modelString){var models_array=modelString.split("`");var count=0;var carNVpair=null;document.lookupform.models.options.length=0;document.lookupform.models.options[0]=new Option("Select Model","");while(count<models_array.length-1){carNVpair=models_array[count].split("=");document.lookupform.models.options[count+1]=new Option(carNVpair[0],carNVpair[1]);count++;}}
HTTPRequest=function(){var xmlhttp=null;try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(_e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(_E){}}
if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){try{xmlhttp=new XMLHttpRequest();}catch(e){xmlhttp=false;}}
return xmlhttp;}
function ask1(url){var http=new HTTPRequest();var result=null;http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){result=http.responseText;if(-1!=result.search("null")){}else{setMakes(result);}}};http.send(null);}
function ask2(url){var http=new HTTPRequest();var result=null;http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){result=http.responseText;if(-1!=result.search("null")){}else{setModels(result);}}};http.send(null);}
function yearchanged(){var year=document.lookupform.years[document.lookupform.years.selectedIndex].value;if(year!=null){ask1("/ajax_YearMakeMake.jsp?year="+year);}else{document.lookupform.makes.options.length=0;document.lookupform.models.options.length=0;}}
function makechanged(){var year=document.lookupform.years[document.lookupform.years.selectedIndex].value;var make=document.lookupform.makes[document.lookupform.makes.selectedIndex].value;if(make!=null){ask2("/ajax_YearMakeModel.jsp?year="+year+"&make="+make);}else{document.lookupform.models.options.length=0;}}
function modelchanged(){var model=document.lookupform.models[document.lookupform.models.selectedIndex].value;if(model!=null){var years=document.lookupform.years;var makes=document.lookupform.makes;var models=document.lookupform.models;var vehiclestring="";vehiclestring=years[years.selectedIndex].text+' '+makes[makes.selectedIndex].text+' '+models[models.selectedIndex].text;document.yearMakeSearchActionForm.vehicleString.value=vehiclestring;document.yearMakeSearchActionForm.vehicleID.value=model;document.lookupform.models.options.length=0;document.lookupform.models.options[0]=new Option("Working, Please Wait...","");var universal='false';if(document.yearMakeSearchActionForm.universals.checked==true){universal='true';}
window.location.href="/showCategoryAction.do?vehicle="+model+"&name="+vehiclestring+"&universal="+universal;}}
function resetVinyl(){setExtDescription(' ');document.getElementById('vinylfront').style.backgroundImage="url(/ImgApp/ProductImages/Vinyl/vinyl_bg.png)";document.getElementById('vinylbg').style.backgroundImage="url(/ImgApp/ProductImages/Vinyl/nocolor.gif)";document.addItemToCartActionForm.itemNo.value='';document.addItemToCartActionForm.variant.value='';document.getElementById('colortext').firstChild.nodeValue=' ';}
function kitTypeChanged(){resetVinyl();var kitType=document.vinylForm.kitTypes[document.vinylForm.kitTypes.selectedIndex].value;if(kitType!=null&&kitType!=''){document.getElementById('vinylfront').style.backgroundImage="url('/ImgApp/ProductImages/Vinyl/"+kitType+".png')";var ie7=document.documentElement&&typeof document.documentElement.style.maxHeight!="undefined";var ie55=window.createPopup;if(ie55&&!ie7){document.getElementById('vinylfront').runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/ImgApp/ProductImages/Vinyl/"+kitType+".png', sizingMethod='crop')",document.getElementById('vinylfront').runtimeStyle.backgroundImage="none";}}
else{setExtDescription('Please select a Vinyl Graphics Kit Type to continue.~');}}
function chooseColor(color,cname){var kitType=document.vinylForm.kitTypes[document.vinylForm.kitTypes.selectedIndex].value;if(kitType==null||kitType==''||color==null||color==''){resetVinyl();}
else{document.getElementById("vinylAddInfo").style.display='none';document.getElementById("vinylWait").style.display='block';document.getElementById('vinylbg').style.backgroundImage="url(/ImgApp/ProductImages/Vinyl/"+color+".gif)";document.addItemToCartActionForm.itemNo.value=kitType+' '+color;document.getElementById('colortext').firstChild.nodeValue='Color: '+cname;askExtDescription('ajax_ExtDescriptionLookup.jsp?itemNo='+kitType+' '+color+'&type=extwprice');}}
function askExtDescription(url){var http=new HTTPRequest();var result=null;http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){result=http.responseText;if(-1!=result.search("null")){}
else{setExtDescription(result);}}};http.send(null);}
function setExtDescription(description){if(description==null||description==''){document.getElementById('descriptionDiv').firstChild.nodeValue='No Description Found.';document.getElementById('priceDiv').firstChild.nodeValue='No Price Found.';}
else{var descriptionArray=description.split("~");document.getElementById('descriptionDiv').firstChild.nodeValue=descriptionArray[0];if(descriptionArray[1]==null||descriptionArray[1]==''||descriptionArray[1]==' '){document.getElementById('priceDiv').firstChild.nodeValue='';}
else{document.getElementById('priceDiv').firstChild.nodeValue='$'+descriptionArray[1]+' + Tax and Shipping';}}
document.getElementById("vinylWait").style.display='none';document.getElementById("vinylAddInfo").style.display='block';}
function submitVinylAddToCart(){if(document.addItemToCartActionForm.itemNo.value==null||document.addItemToCartActionForm.itemNo.value==''){alert('You have not selected a Vinyl Kit.');}
else{document.addItemToCartActionForm.submit();}}
function setDealers(xmldoc){var xmlObj;try{xmlObj=new ActiveXObject("Microsoft.XMLDOM");xmlObj.async="false";xmlObj.loadXML(xmldoc);}
catch(e){parser=new DOMParser();xmlObj=parser.parseFromString(xmldoc,"text/xml");}
var root=xmlObj.getElementsByTagName('locations').item(0);var title=root.getElementsByTagName('title').item(0);if(title!=null&&title.childNodes.item(0).data){document.getElementById('statetitle').innerHTML=title.childNodes.item(0).data;}
var locationsDiv=document.getElementById('dealerlocations');locationsDiv.innerHTML='';if(root.getElementsByTagName('location').length>0){var locations=xmlObj.getElementsByTagName('location');var currTable=document.createElement('table');var currTBody=document.createElement('tbody');var currRow,currCell;var anchor,mapAnchor,mapAnchorHref;var numCellsInRow=3;for(var i=0;i<locations.length;i++){if(i%(numCellsInRow)==0){currRow=document.createElement('tr');}
currCell=document.createElement('td');currCell.innerHTML+='<b>'+locations[i].getElementsByTagName('name').item(0).childNodes.item(0).data+'</b>';mapAnchor=document.createElement('a');mapAnchor.innerHTML='Click for Map and Directions';mapAnchor.href='http://maps.google.com/maps?z=15&iwloc=A&q=';mapAnchor.target='_blank';mapAnchorHref='';var addresses=locations[i].getElementsByTagName('address');for(var j=0;j<addresses.length;j++){if(addresses[j].childNodes.item(0).data.length>0){currCell.innerHTML+='<br />'+addresses[j].childNodes.item(0).data;mapAnchorHref+=addresses[j].childNodes.item(0).data.replace(/ /g,"+").replace(/#/g,"").replace(/&amp;/g,"")+'+';}}
mapAnchor.href+=mapAnchorHref+'&hnear='+mapAnchorHref;var phones=locations[i].getElementsByTagName('phone');for(var j=0;j<phones.length;j++){if(phones[j].childNodes.item(0).data.length>0){currCell.innerHTML+='<br />';if(phones[j].getAttribute('label')!=null&&phones[j].getAttribute('label').length>0){currCell.innerHTML+=phones[j].getAttribute('label')+': ';}
currCell.innerHTML+=phones[j].childNodes.item(0).data;}}
var websites=locations[i].getElementsByTagName('website');for(var k=0;k<websites.length;k++){if(websites[k].childNodes.item(0).data.length>0){currCell.innerHTML+='<br />';anchor=document.createElement('a');anchor.innerHTML=websites[k].childNodes.item(0).data;anchor.target='_blank';anchor.href='http://'+websites[k].childNodes.item(0).data;currCell.appendChild(anchor);}}
currCell.innerHTML+='<br />';currCell.appendChild(mapAnchor);currRow.appendChild(currCell);if(i%(numCellsInRow)==(numCellsInRow-1)||i>=(locations.length-1)){currTBody.appendChild(currRow);}}
currTable.appendChild(currTBody);locationsDiv.appendChild(currTable);}
document.getElementById('statetitle').style.display='block';document.getElementById('dealerlocations').style.display='block';}
function askDealers(url){var http=new HTTPRequest();var result=null;http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){result=http.responseText;if(-1!=result.search("null")){}
else{setDealers(result);}
hideWaitOverlay();}};http.send(null);}
function showWaitOverlay(){if(document.getElementById('waitOverlay')==null){var overlay=document.createElement('div');overlay.id='waitOverlay';var overlayImg=document.createElement('img');overlayImg.id='waitOverlayImg';overlayImg.src='images/ajax-loader.gif';overlay.appendChild(overlayImg);document.getElementsByTagName('body')[0].appendChild(overlay);}}
function hideWaitOverlay(){var overlay=document.getElementById('waitOverlay');if(overlay!=null){document.getElementsByTagName('body')[0].removeChild(overlay);}}
function getDealers(state){if(state!=null){showWaitOverlay();askDealers("ajax_DealerLookup.jsp?state="+state);}}