var DD={};DD.MakesModels=function(a,b,i,c,g,l,k,h,e,j,d){this.mki=isNaN(a)||a===0?999:parseInt(a,10);this.mdi=isNaN(b)||b===0||this.mki===999?999:parseInt(b,10);this.year=parseInt(i,10);this.mks=Com.$(c);this.mds=Com.$(g);this.tgl=l;this.tgl_label=(k?k:"");var f=this;if(h!==undefined){this.mkshtml=DD.buildHTML("select",h)+">"}else{this.mkshtml=this.mks.innerHTML;this.mkshtml=this.mkshtml.substr(this.mkshtml.indexOf("<select"),this.mkshtml.indexOf(">")+1)}this.mkshtml+='<option value="999">Select a Make</option>';if(e!==undefined){this.mdshtml=DD.buildHTML("select",e)+">"}else{this.mdshtml=this.mds.innerHTML;this.mdshtml=this.mdshtml.substr(this.mdshtml.indexOf("<select"),this.mdshtml.indexOf(">")+1)}this.mdshtml+='<option value="999">Select a Model</option>';if(d==true){this.tglhtml='<input type="checkbox" onclick="Local.yearCheck();"'}else{if(j!==undefined){this.tglhtml=DD.buildHTML('input type="radio"',j)}else{this.tglhtml='<input type="radio" id="2f_year" name="2f_year" onclick="this.checked=true;Local.yearToggle(this.value);"'}}this.getMakes=function(){if(QU.cache.makes){this.fillMakes(null);return}if(Local!==undefined&&typeof Local.turnOFF==="function"){Local.turnOFF(f)}var m={method:"post",parameters:"",onSuccess:f.fillMakes,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",m,f)};this.fillMakes=function(p){var n,m=f.mkshtml,o=QU.cache.makes?QU.cache:Com.evalJSON(p.responseText);if(o.makes===undefined){return}for(n=0;n<o.makes.length;n+=1){m+='<option value="'+o.makes[n].make_id+'"'+(parseInt(o.makes[n].make_id,10)===parseInt(f.mki,10)?' selected="selected"':"")+">"+o.makes[n].make_name+(typeof Landing!=="undefined"&&Landing.promo_makes!==undefined&&QU.in_array(o.makes[n].make_id,Landing.promo_makes)?" *":"")+"</option>"}f.mks.innerHTML=m+"</select>";f.getModels()};this.getModels=function(){f.clearToggle();if(f.mki===999){f.mdi=999;f.mds.innerHTML=f.mdshtml+"</select>";if(Local!==undefined&&typeof Local.turnON==="function"){Local.turnON(f)}}else{if(QU.cache[f.mki]){this.fillModels(null);return}else{if(Local!==undefined&&typeof Local.turnOFF==="function"){Local.turnOFF(f)}var m={method:"post",parameters:"make_id="+f.mki,onSuccess:f.fillModels,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",m,f)}}};this.fillModels=function(p){var n,m=f.mdshtml,o=QU.cache[f.mki]?QU.cache[f.mki]:Com.evalJSON(p.responseText);if(o.models===undefined){return}for(n=0;n<o.models.length;n+=1){m+='<option value="'+o.models[n].model_id+'"'+(parseInt(o.models[n].model_id,10)===parseInt(f.mdi,10)?' selected="selected"':"")+">"+o.models[n].model_name+(typeof Landing!=="undefined"&&Landing.promo_models!==undefined&&QU.in_array(o.models[n].model_id,Landing.promo_models)?" *":"")+"</option>"}f.mds.innerHTML=m+"</select>";if(parseInt(f.mdi,10)!==999){if(typeof QU.cache.model_years!=="undefined"){f.showToggle()}else{f.getModelYears()}}if(Local!==undefined&&typeof Local.turnON==="function"){Local.turnON(f)}};this.getModelYears=function(){if(typeof QU.cache.model_years[f.mdi]!=="undefined"){f.showToggle()}else{var m={method:"post",parameters:"model_years="+f.mdi,onSuccess:f.showToggle,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",m,f)}};this.showToggle=function(q){var n,m="",p=typeof QU.cache.model_years!=="undefined"?QU.cache.model_years[f.mdi]:Com.evalJSON(q.responseText);if(p===undefined||p.years===undefined){return}f.clearToggle();if(f.year===0){f.year=f.defaultYear(p.years)}if(d==true){Com.$(f.tgl+"_").innerHTML=f.tgl_label;var o="";for(n=0;n<p.years.length;n+=1){m+="&nbsp; "+f.tglhtml+' value="'+p.years[n]+'" id="year_'+p.years[n]+'" name="myear" checked="checked" /> '+p.years[n];o+=","+p.years[n]}m+='<input name="myears" id="myears" type="hidden" value="'+o.substr(1)+'" />'}else{if(p.years.length===1){f.year=parseInt(p.years[0],10);m=f.tglhtml+' value="'+f.year+'" style="display:none" />'}else{if(p.years.length>1){Com.$(f.tgl+"_").innerHTML=f.tgl_label;for(n=0;n<p.years.length;n+=1){m+="&nbsp; "+f.tglhtml+' value="'+p.years[n]+'"'+(parseInt(p.years[n],10)===parseInt(f.year,10)?' checked="checked"':"")+"/> "+p.years[n]+(typeof Landing!=="undefined"&&Landing.promo_years!==undefined&&Landing.promo_models!==undefined&&QU.in_array(DD.MakesModels.mdi,Landing.promo_models)&&QU.in_array(p.years[n],Landing.promo_years)?"* ":"")}}}}Com.$(f.tgl).innerHTML=m;if(d==true&&typeof Local.yearCheck==="function"){Local.yearCheck()}};this.clearToggle=function(){Com.$(f.tgl).innerHTML="";Com.$(f.tgl+"_").innerHTML=""};this.resetMakeModels=function(o,p){var m,n;if(parseInt(f.mki,10)===parseInt(o,10)){f.mdi=p;n=DD.getSelect(f.mds);for(m=0;m<n.options.length;m+=1){if(parseInt(n.options[m].value,10)===parseInt(p,10)){n.options[m].selected=true}}}else{f.mki=o;f.mdi=p;n=DD.getSelect(f.mks);for(m=0;m<n.options.length;m+=1){if(parseInt(n.options[m].value,10)===parseInt(o,10)){n.options[m].selected=true}}f.getModels()}};this.defaultYear=function(m){return m[0]}};DD.StylesColors=function(b,h,c,a,f,d,j,i,e){this.mdi=parseInt(b,10);this.year=parseInt(h,10);this.sti=parseInt(c,10);this.clr=this.sti===0?0:a;this.inc=j;this.sts=Com.$(f);this.cls=Com.$(d);var g=this;if(i!==undefined){this.stshtml=DD.buildHTML("select",i)+">"}else{this.stshtml=this.sts.innerHTML;this.stshtml=this.stshtml.substr(this.stshtml.indexOf("<select"),this.stshtml.indexOf(">")+1)}if(this.sti===0){this.stshtml+='<option value="0">Select Style</option>'}if(e!==undefined){this.clshtml=DD.buildHTML("select",e)+">"}else{this.clshtml=this.cls.innerHTML;this.clshtml=this.clshtml.substr(this.clshtml.indexOf("<select"),this.clshtml.indexOf(">")+1)}if(this.clr===0){this.clshtml+='<option value="0">Select Colors</option>'}this.clshtml+='<option value="No Preferences|No Preferences">Undecided</option>';this.getStyles=function(){if(Local!==undefined&&typeof Local.turnOFF==="function"){Local.turnOFF(g)}var k={method:"post",parameters:"model_id="+g.mdi+"&year="+g.year,onSuccess:g.fillStyles,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",k,g)};this.fillStyles=function(n){var l,k=g.stshtml,m=Com.evalJSON(n.responseText);if(m.trims===undefined){return}for(l=0;l<m.trims.length;l+=1){k+='<option value="'+m.trims[l].style_id+'"'+(parseInt(m.trims[l].style_id,10)===parseInt(g.sti,10)?' selected="selected"':"")+">"+m.trims[l].style+"</option>"}k+="</select>";if(m.trims.length===1){g.sti=m.trims[0].style_id;g.clr="No Preferences|No Preferences";k=m.trims[0].style+'<span style="display:none">'+k+"</span>"}g.sts.innerHTML=k;g.getColors();if(m.trims.length>1&&Com.isIE()){DD.fixIeDropDown(DD.getSelect(g.sts))}};this.getColors=function(){if(parseInt(g.sti,10)===0){g.resetColors();if(Local!==undefined&&Local.turnON==="function"){Local.turnON(g)}}else{if(typeof Local!=="undefined"&&typeof Local.turnOFF==="function"){Local.turnOFF(g)}var k={method:"post",parameters:"style_id="+g.sti,onSuccess:g.fillColors,onFailure:QU.fracaso};if(g.inc&&parseInt(mvc.zipcode.value,10)){k.parameters+="&zip="+mvc.zipcode.value}QU.ajaxRequest("/ajax/makes_models.php",k,g)}};this.fillColors=function(n){var l,k=g.clshtml,m=Com.evalJSON(n.responseText);if(typeof m.colors==="undefined"){return}if(parseInt(g.sti,10)===0){g.clr=0}else{if(m.colors.length&&parseInt(g.clr,10)===0){g.clr="No Preferences|No Preferences"}}for(l=0;l<m.colors.length;l+=1){k+='<option value="'+m.colors[l].exterior+"|"+m.colors[l].interior+'"'+(m.colors[l].exterior+"|"+m.colors[l].interior===g.clr?' selected="selected"':"")+">Exterior: "+m.colors[l].exterior+" - Interior: "+m.colors[l].interior+"</option>"}k+="</select>";if(m.colors.length===0){g.clr="N/A|N/A";k='No detailed colors available.<span style="display:none">'+k+"</span>"}g.cls.innerHTML=k;if(m.colors.length>1&&Com.isIE()){DD.fixIeDropDown(DD.getSelect(g.cls))}if(typeof Local!=="undefined"){if(typeof Local.showVehicleData==="function"){Local.showVehicleData(m,g)}if(typeof Local.turnON==="function"){Local.turnON(g)}}};this.resetColors=function(){g.cls.innerHTML=g.clshtml+"</select>";g.clr=0}};DD.buildHTML=function(c,b){var d,e;e="<"+c;for(d in b){if(b.hasOwnProperty(d)){e+=" "+d+'="'+b[d]+'"'}}return e};DD.getSelect=function(b){for(var a=0;a<b.childNodes.length;a+=1){if(b.childNodes[a].type==="select-one"){return b.childNodes[a]}}return false};DD.getSelected=function(a){obj=DD.getSelect(a);return obj.options[obj.options.selectedIndex].innerHTML};DD.fixIeDropDown=function(c){c=(typeof c==="string")?Com.$(c):c;if(!c.attachEvent||c.multiple||c.currentStyle.width==="auto"||c.offsetWidth===0){return}var a,e,b,d;a=document.getElementsByTagName("body").item(0);e=c.cloneNode(true);e.style.position="absolute";e.style.visibility="hidden";e.style.width="auto";a.appendChild(e);c.initialOffsetWidth=c.offsetWidth;c.initialOffsetHeight=c.offsetHeight;c.autoWidth=e.offsetWidth;a.removeChild(e);c.style.position="absolute";c.style.width=c.initialOffsetWidth+"px";c.parentNode.style.width=c.initialOffsetWidth+"px";c.parentNode.style.height=c.initialOffsetHeight+"px";if(c.autoWidth>c.initialOffsetWidth){b=function(){event.srcElement.parentNode.style.zIndex=1;event.srcElement.style.width="auto";if(event.srcElement.offsetWidth>event.srcElement.initialOffsetWidth){event.srcElement.style.width="auto"}else{event.srcElement.style.width=event.srcElement.initialOffsetWidth+"px"}};d=function(){event.srcElement.parentNode.style.zIndex=0;event.srcElement.style.width=event.srcElement.initialOffsetWidth+"px"};c.attachEvent("onactivate",b);c.attachEvent("ondeactivate",d);c.attachEvent("onchange",d)}};QU.cache={};QU.MMpreload=function(){var a={method:"post",parameters:"cache=1",onSuccess:QU.MMcache,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",a,null)};QU.MMcache=function(a){QU.cache=Com.evalJSON(a.responseText);if(typeof Local.DDinit==="function"){Local.DDinit()}};
