var DD={};DD.MakesModels=function(a,b,h,c,f,k,j,g,d,i){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(h,10);this.mks=Com.$(c);this.mds=Com.$(f);this.tgl=k;this.tgl_label=(j?j:"");var e=this;if(g!==undefined){this.mkshtml=DD.buildHTML("select",g)+">"}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(d!==undefined){this.mdshtml=DD.buildHTML("select",d)+">"}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(i!==undefined){this.tglhtml=DD.buildHTML('input type="radio"',i)}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(e)}var l={method:"post",parameters:"",onSuccess:e.fillMakes,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",l,e)};this.fillMakes=function(o){var m,l=e.mkshtml,n=QU.cache.makes?QU.cache:Com.evalJSON(o.responseText);if(n.makes===undefined){return}for(m=0;m<n.makes.length;m+=1){l+='<option value="'+n.makes[m].make_id+'"'+(parseInt(n.makes[m].make_id,10)===parseInt(e.mki,10)?' selected="selected"':"")+">"+n.makes[m].make_name+(typeof Landing!=="undefined"&&Landing.promo_makes!==undefined&&QU.in_array(n.makes[m].make_id,Landing.promo_makes)?" *":"")+"</option>"}e.mks.innerHTML=l+"</select>";e.getModels()};this.getModels=function(){e.clearToggle();if(e.mki===999){e.mdi=999;e.mds.innerHTML=e.mdshtml+"</select>";if(Local!==undefined&&typeof Local.turnON==="function"){Local.turnON(e)}}else{if(QU.cache[e.mki]){this.fillModels(null);return}else{if(Local!==undefined&&typeof Local.turnOFF==="function"){Local.turnOFF(e)}var l={method:"post",parameters:"make_id="+e.mki,onSuccess:e.fillModels,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",l,e)}}};this.fillModels=function(o){var m,l=e.mdshtml,n=QU.cache[e.mki]?QU.cache[e.mki]:Com.evalJSON(o.responseText);if(n.models===undefined){return}for(m=0;m<n.models.length;m+=1){l+='<option value="'+n.models[m].model_id+'"'+(parseInt(n.models[m].model_id,10)===parseInt(e.mdi,10)?' selected="selected"':"")+">"+n.models[m].model_name+(typeof Landing!=="undefined"&&Landing.promo_models!==undefined&&QU.in_array(n.models[m].model_id,Landing.promo_models)?" *":"")+"</option>"}e.mds.innerHTML=l+"</select>";if(parseInt(e.mdi,10)!==999){if(typeof QU.cache.model_years!=="undefined"){e.showToggle()}else{e.getModelYears()}}if(Local!==undefined&&typeof Local.turnON==="function"){Local.turnON(e)}};this.getModelYears=function(){var l={method:"post",parameters:"model_years="+e.mdi,onSuccess:e.showToggle,onFailure:QU.fracaso};QU.ajaxRequest("/ajax/makes_models.php",l,e)};this.showToggle=function(o){var m,l="",n=typeof QU.cache.model_years!=="undefined"?QU.cache.model_years[e.mdi]:Com.evalJSON(o.responseText);if(n.years===undefined){return}e.clearToggle();if(e.year===0){e.year=e.defaultYear(n.years)}if(n.years.length===1){e.year=parseInt(n.years[0],10);l=e.tglhtml+' value="'+e.year+'" style="display:none" />'}else{if(n.years.length>1){Com.$(e.tgl+"_").innerHTML=e.tgl_label;for(m=0;m<n.years.length;m+=1){l+="&nbsp; "+e.tglhtml+' value="'+n.years[m]+'"'+(parseInt(n.years[m],10)===parseInt(e.year,10)?' checked="checked"':"")+"/> "+n.years[m]+(typeof Landing!=="undefined"&&Landing.promo_years!==undefined&&Landing.promo_models!==undefined&&QU.in_array(DD.MakesModels.mdi,Landing.promo_models)&&QU.in_array(n.years[m],Landing.promo_years)?"* ":"")}}}Com.$(e.tgl).innerHTML=l};this.clearToggle=function(){Com.$(e.tgl).innerHTML="";Com.$(e.tgl+"_").innerHTML=""};this.resetMakeModels=function(n,o){var l,m;if(parseInt(e.mki,10)===parseInt(n,10)){e.mdi=o;m=DD.getSelect(e.mds);for(l=0;l<m.options.length;l+=1){if(parseInt(m.options[l].value,10)===parseInt(o,10)){m.options[l].selected=true}}}else{e.mki=n;e.mdi=o;m=DD.getSelect(e.mks);for(l=0;l<m.options.length;l+=1){if(parseInt(m.options[l].value,10)===parseInt(n,10)){m.options[l].selected=true}}e.getModels()}};this.defaultYear=function(l){return l[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.fixIeDropDown=function(c){c=(typeof c==="string")?Com.$(c):c;if(!c.attachEvent||c.multiple||c.currentStyle.width==="auto"){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()}};