/**
 * DO NOT EDIT THIS FILE!
 * This is a generated file.  Your changes will be overwritten.
 */
with(Configurator){
Configurator.LandingPageController=Class.create(ControllerCommon,{initialize:function(_1){
this.zip=_1;
this.seriesCategory="";
this.needsZipPrompt=false;
this.displayZipError=false;
this.currentModelInfo="";
this.zipWarningTooltip;
this.imageBasePath="/configurator/images/start_page/";
this.zipErrorMsg="Please input a valid zip code";
var _2=(window.location+"").toLowerCase().toQueryParams();
if(_2.lang&&_2.lang=="es"){
this.langString="_es";
}else{
this.langString="";
}
if(this.zip==null||this.zip==""|this.zip==undefined){
if(_2.zipcode){
this.zip=_2.zipcode;
}
if(_2.zip_code){
this.zip=_2.zip_code;
}
}
this.loadImages();
document.observe("dom:loaded",function(){
this.handleOnload();
}.bind(this));
this.writeCookie("bytpe","",-1,window.location.host,"/");
},loadImages:function(){
document.getElementsByClassName("vehImage").each(function(_3){
this[_3.id+"off"]=precache_image(this.imageBasePath+_3.id+"_off.jpg");
}.bind(this));
},handleOnload:function(){
if(this.zip!=null||this.zip!=""|this.zip!=undefined){
if(this.zip.match(/^[0-9]{5}$/)&&!this.zipOutOfBounds){
this.needsZipPrompt=false;
}
}
if(this.needsZipPrompt){
this.showZipPrompt();
}else{
this.updateZip(this.zip);
}
this.setMSRPFormat();
Event.observe($("zipEditInputTextField"),"keypress",function(_4){
if(Event.KEY_RETURN==_4.keyCode){
this.manualZipUpdate();
Event.stop(_4);
}
}.bindAsEventListener(this));
},handleInitialZipCode:function(_5,_6){
this.needsZipPrompt=true;
var _7=false;
if(_5.match(/^[0-9]{5}$/)){
this.zip=_5;
_7=true;
}
if(_6.include("zipCode.outOfBounds")){
_7=false;
this.zipOutOfBounds=true;
}
if(!_5||_5==null||_5==undefined||_5==""||_7){
Debug.log("handleInitialZipCode empty zip: "+_5);
this.displayZipError=false;
}else{
Debug.log("handleInitialZipCode zip error. zip: "+_5);
this.displayZipError=true;
}
},showZipPrompt:function(){
var mb=new Configurator.ModalBackdrop();
mb.enable();
Element.show($("zip_input_popup"));
Configurator.PopupCommon.positionCenter($("zip_input_popup"));
DOM.IEPNG($("zip_input_popup_icon"));
$("zipCodeInput").focus();
if(this.displayZipError){
Element.update($("zip_popup_error_holder"),this.zipErrorMsg);
}
function zipCodeSubmitButton_onclick(){
var _9=$("zipCodeInput").value;
if(_9.match(/^[0-9]{5}$/)){
try{
Element.update($("zip_popup_error_holder"),"");
this.updateZip(_9);
if(this.seriesCategory!=""&&this.seriesCategory!=undefined){
this.setOptionByCategory(this.seriesCategory,null);
return false;
}else{
$("zip_input_popup").style.display="none";
mb.disable();
}
}
catch(e){
Debug.error(e);
}
}else{
Element.update($("zip_popup_error_holder"),this.zipErrorMsg);
}
return false;
}
Event.observe($("zipCodeSubmitButton"),"click",zipCodeSubmitButton_onclick.bindAsEventListener(this));
Event.observe($("zipCodeInput"),"keypress",function(_a){
if(Event.KEY_RETURN==_a.keyCode){
if(!zipCodeSubmitButton_onclick.bind(this)()){
Event.stop(_a);
}
}
}.bindAsEventListener(this));
},updateZip:function(_b){
this.zip=_b;
$("zipCodeInput").value=_b;
$("zipCode").value=_b;
$("zipEditInputTextField").value=_b;
TMSSite.setZip(_b);
TMSSite.initZipFromCookie();
},manualZipUpdate:function(_c){
var _d=$F("zipEditInputTextField");
if(_d.match(/^[0-9]{5}$/)){
$("zipEditInputTextField").style.border="1px solid #CCCCCC";
if(this.error_tooltip){
this.error_tooltip.hide();
this.error_tooltip.removeTrigger($("zipEditInputTextField"));
}
this.updateZip(_d);
}else{
$("zipEditInputTextField").style.border="1px solid red";
var _e="";
if(this.langES){
_e="<div>Por favor introduce un c&oacute;digo postal v&aacute;lido.</div>";
}else{
_e="<div>Please input a valid zip code.</div>";
}
if(this.error_tooltip==null){
this.error_tooltip=new Tooltip($("zipEditInputTextField"),_e,{position_type:Tooltip.POSITION_BELOW});
}else{
this.error_tooltip.addTrigger($("zipEditInputTextField"));
}
}
},setOptionByCategory:function(_f,_10,_11,_12){
$("configurationForm").seriesCategory.value=_f;
$("configurationForm").zipCode.value=this.zip;
if(_11){
$("configurationForm").modelGroupId.value=_12;
}
if(this.langString=="_es"){
om_market="Esp";
om_location="esp";
}else{
om_market="GM";
om_location="tcom";
}
var _13=((_10)?_10:"");
if(_13.toLowerCase()=="venza"){
_13=_13.toUpperCase();
}
s.eVar3=om_location+"_byt_rollover_build_"+_13;
s.prop7=this.zip;
s.eVar15=this.zip;
s.eVar25=om_market+":"+_13;
s.prop46=om_market+":"+_13+":BYT:Build";
s.linkTrackVars="prop7,prop46,eVar3,eVar15,eVar25,events";
s.pageName="";
s.linkTrackEvents="event4";
s.events="event4";
s.tl((new Object),"o",om_location+"_byt_build_"+_13);
$("configurationForm").submit();
},setOptionByModelGroup:function(_14,_15,_16){
$("configurationForm").seriesCategory.value=_14;
$("configurationForm").modelGroupId.value=_15;
$("configurationForm").zipCode.value=this.zip;
if(this.langString=="_es"){
om_market="Esp";
om_location="esp";
}else{
om_market="GM";
om_location="tcom";
}
var _17=((_16)?_16:"");
s.eVar3=om_location+"_byt_rollover_build_"+_17;
s.prop7=this.zip;
s.eVar15=this.zip;
s.eVar25=om_market+":"+_17;
s.prop46=om_market+":"+_17+":BYT:Build";
s.linkTrackVars="prop7,prop46,eVar3,eVar15,eVar25,events";
s.pageName="";
s.linkTrackEvents="event4";
s.events="event4";
s.tl((new Object),"o",om_location+"_byt_build_"+_17);
$("configurationForm").submit();
},comImgOn:function(_18){
this.comImgOff(this.currentModelInfo);
this.currentModelInfo=_18;
$(_18).style.display="block";
},comImgOff:function(_19){
if(this.currentModelInfo!=""){
$(_19).style.display="none";
}
},swapImage:function(_1a,_1b){
$(_1a).src=_1b;
},setMSRPFormat:function(){
document.getElementsByClassName("msrpOutput").each(function(_1c){
var _1d=_1c.firstChild.nodeValue;
_1c.firstChild.nodeValue="$"+_1d.moneyFormat();
});
},writeCookie:function(_1e,_1f,_20,_21,_22){
_22=(!_22)?"/":_22;
var _23=(_22)?";path="+_22:"";
var _24=(_21)?";domain="+_21:"";
var _25=new Date();
_25.setDate(_25.getDate()+_20);
var _26=(_20)?";expires="+_25.toUTCString():"";
document.cookie=_1e+"="+_1f+_24+_23+_26;
}});
}


