/**
 * DO NOT EDIT THIS FILE!
 * This is a generated file.  Your changes will be overwritten.
 */
Configurator.ModelCommon={basic_assign:function(_1,_2){
var _3=_2.nodeName.unCamelCase();
if(_1.indexOf(_3)>-1&&_2.firstChild){
this[_3]=_2.firstChild.data;
return true;
}else{
return false;
}
},int_assign:function(_4,_5){
var _6=_5.nodeName.unCamelCase();
if(_4.indexOf(_6)>-1&&_5.firstChild){
this[_6]=parseInt(_5.firstChild.data);
return true;
}else{
return false;
}
},bool_assign:function(_7,_8){
var _9=_8.nodeName.unCamelCase();
if(_7.indexOf(_9)>-1&&_8.firstChild){
this[_9]=_8.firstChild.data.match(/true|yes/i)?true:false;
return true;
}else{
return false;
}
},object_lookup:function(_a,id,_c){
if(App[_a]){
var _d=App[_a].find(function(e){
return e.id==id;
});
if(!_d&&_c){
var _d=new _c({id:id});
App[_a].push(_d);
}
return _d;
}else{
return null;
}
}};
function Stub(_f){
Object.extend(this,_f);
}

with(Configurator){
Configurator.Accessory=Class.create();
Object.extend(Accessory.prototype,ModelCommon);
Object.extend(Accessory.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
this.id="";
this.long_description="";
this.description="";
this.glossary_description="";
this.source="";
this.code="";
this.msrp=0;
this.flash_key="";
this.flash_orientation=0;
this.includes=[];
this.excludes=[];
this.disclaimers=[];
this.excludes_int=[];
this.excludes_ext=[];
this.requirement_type="";
this.requirements=[];
Object.extend(this,_1);
},initWithXML:function(_2){
with(Configurator){
this.id=_2.getAttribute("id");
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["description","long_description","glossary_description","thumbnail_id","image_id","source","flash_key","code"],_3)){
}else{
if(this.int_assign(["msrp"],_3)){
}else{
if(_3.nodeName=="groupId"){
if(_3.firstChild){
this.group=this.object_lookup("accessory_groups",_3.firstChild.data,AccessoryGroup);
this.group.accessories.push(this);
}
}else{
if(_3.nodeName=="excludedAccys"){
$NL(_3.childNodes).elements().each(function(n){
this.excludes.push(this.object_lookup("accessories",n.firstChild.data,Accessory));
}.bind(this));
}else{
if(_3.nodeName=="includedAccys"){
$NL(_3.childNodes).elements().each(function(n){
this.includes.push(this.object_lookup("accessories",n.firstChild.data,Accessory));
}.bind(this));
}else{
if(_3.nodeName=="excludedExteriors"){
$NL(_3.childNodes).elements().each(function(n){
this.excludes_ext.push(this.object_lookup("exterior_colors",n.firstChild.data,ExteriorColor));
}.bind(this));
}else{
if(_3.nodeName=="excludedInteriors"){
$NL(_3.childNodes).elements().each(function(n){
this.excludes_int.push(this.object_lookup("interior_colors",n.firstChild.data,InteriorColor));
}.bind(this));
}else{
if(_3.nodeName=="disclaimers"){
$NL(_3.childNodes).elements().each(function(n){
this.disclaimers.push(this.object_lookup("disclaimers",n.firstChild.data,Disclaimer));
}.bind(this));
}else{
if(_3.nodeName=="dependencies"){
this.requirement_type=$NL(_3.getElementsByTagName("operator")).first().firstChild.data;
$NL($NL(_3.getElementsByTagName("dependentAccys")).first().childNodes).elements().each(function(_9){
this.requirements.push(this.object_lookup("accessories",_9.firstChild.data,Accessory));
}.bind(this));
}
}
}
}
}
}
}
}
}
if((_3.nodeName=="flashKey")&&(_3.getAttribute("orientation")!=null)){
this.flash_orientation=parseInt(_3.getAttribute("orientation"));
}
}.bind(this));
}
return true;
}});
}

with(Configurator){
Configurator.AccessoryGroup=Class.create();
Object.extend(AccessoryGroup.prototype,ModelCommon);
Object.extend(AccessoryGroup.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
this.id="";
this.name="";
this.accessories=[];
Object.extend(this,_1);
},initWithXML:function(_2){
this.id=_2.getAttribute("id");
$NL(_2.childNodes).elements().each(function(_3){
this.basic_assign(["name"],_3);
}.bind(this));
return true;
}});
}


with(Configurator){
Configurator.Dealer=Class.create();
Object.extend(Dealer.prototype,ModelCommon);
Object.extend(Dealer.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
this.id="";
this.name="";
this.distance=0.1;
this.url="";
this.address1="";
this.address2="";
this.phone="";
this.fax="";
this.map_url="";
this.quote_url="";
this.map_url="";
this.pma="";
Object.extend(this,_1);
},initWithXML:function(_2){
this.id=_2.getAttribute("id");
this.distance=parseFloat(_2.getAttribute("distance"))||0.1;
this.pma=_2.getAttribute("pma").toLowerCase()=="true";
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["name","address1","phone","fax","city","state","zip"],_3)){
}
}.bind(this));
},popupMap:function(_4){
var _5=window.location+"";
var _6=_5.toLowerCase().toQueryParams();
var _7="";
var _8="";
if(_6.zipcode){
_7=_6.zipcode;
}
if(_6.lang){
_8=_6.lang;
}
var _9="dealerMap.do?&dealerCode="+this.id+"&position="+_4+"&lang="+_8+"&zipCode="+_7;
window.open(_9,"map","height=640,width=780,scrollbars=yes,menubar=no,resizable=yes,status=yes,toolbar=no");
NotificationCenter.sendNotification("Show Maps",{id:this.id,position:_4});
}});
}

with(Configurator){
Configurator.Disclaimer=Class.create();
Object.extend(Disclaimer.prototype,ModelCommon);
Object.extend(Disclaimer.prototype,{initialize:function(_1){
this.id="";
this.order="";
this.symbol="";
this.description="";
this.usages=[];
this.usage_orders={};
Object.extend(this,_1||{});
},initWithXML:function(_2){
this.id=_2.getAttribute("id");
this.order=_2.getAttribute("displayOrder");
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["symbol","description"],_3)){
}else{
if(_3.nodeName=="appUsages"){
$NL(_3.childNodes).elements().each(function(n){
this.usages.push(n.getAttribute("name").toLowerCase());
this.usage_orders[n.getAttribute("name").toLowerCase()]=parseInt(n.getAttribute("displayOrder"));
}.bind(this));
}
}
}.bind(this));
}});
}

with(Configurator){
Configurator.ExteriorColor=Class.create();
Object.extend(ExteriorColor.prototype,ModelCommon);
Object.extend(ExteriorColor.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
this.id="";
this.name="";
this.flash_key="";
this.flash_orientation=0;
this.is_available=false;
this.default_int_color=null;
this.off_swatch_image_id=false;
this.on_swatch_image_id=false;
this.model_color_image_id=false;
this.int_colors=[];
this.display_order=0;
Object.extend(this,_1);
},initWithXML:function(_2){
if(_2.nodeName.unCamelCase()=="exterior_color"){
this.id=_2.getAttribute("id");
this.display_order=parseInt(_2.getAttribute("displayOrder"));
this.is_inventory_conflict=(_2.getAttribute("isInventoryConflict")&&_2.getAttribute("isInventoryConflict").toUpperCase()=="YES");
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["name","color_code","off_swatch_image_id","on_swatch_image_id","model_color_image_id","flash_key"],_3)){
}else{
if(this.int_assign(["msrp"],_3)){
}else{
if(_3.nodeName=="interiors"){
$NL(_3.childNodes).elements().each(function(n){
this.int_colors.push(this.object_lookup("interior_colors",n.firstChild.data,InteriorColor));
}.bind(this));
}
}
}
if((_3.nodeName=="flashKey")&&(_3.getAttribute("orientation")!=null)){
this.flash_orientation=parseInt(_3.getAttribute("orientation"));
}
}.bind(this));
return true;
}else{
return false;
}
},validate:function(_5,_6,_7){
var _8=_5.colors.find(function(c){
return c.exterior==this;
}.bind(this));
var _a=_7?!!_7.find(function(a){
return a.excludes_ext.include(this);
}.bind(this)):false;
return (_8&&(!_6||_8.interiors.include(_6))&&(!_a));
}});
}

with(Configurator){
Configurator.GlossaryTerm=Class.create();
Object.extend(GlossaryTerm.prototype,ModelCommon);
Object.extend(GlossaryTerm.prototype,{initialize:function(_1){
this.id="";
this.term="";
this.definition="";
Object.extend(this,_1||{});
},initWithXML:function(_2){
this.id=_2.getAttribute("id");
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["term","definition"],_3)){
}
}.bind(this));
}});
}

with(Configurator){
Configurator.InteriorColor=Class.create();
Object.extend(InteriorColor.prototype,ModelCommon);
Object.extend(InteriorColor.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
this.id="";
this.name="";
this.msrp=0;
this.is_available=false;
this.is_default=null;
this.off_swatch_image_id=false;
this.on_swatch_image_id=false;
this.model_interior_image_id=false;
this.display_order=0;
this.flash_key="";
Object.extend(this,_1);
},initWithXML:function(_2){
if(_2.nodeName.unCamelCase()=="interior_color"){
this.id=_2.getAttribute("id");
this.display_order=parseInt(_2.getAttribute("displayOrder"));
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["name","model_interior_image_id","on_swatch_image_id","off_swatch_image_id","flash_key"],_3)){
}else{
if(this.int_assign(["msrp"],_3)){
}else{
if(this.bool_assign(["is_available"],_3)){
}else{
if(_3.nodeName=="includedAccessories"||_3.nodeName=="factoryAccessories"){
$NL(_3.childNodes).elements().each(function(n){
this.accessories.push(this.object_lookup("accessories",n.firstChild.data,Accessory));
}.bind(this));
}
}
}
}
}.bind(this));
return true;
}else{
return false;
}
},validate:function(_5,_6,_7){
var _8=_7?!!_7.find(function(a){
return a.excludes_ext.include(this);
}.bind(this)):false;
if(_6){
var _a=_5.colors.find(function(c){
return c.exterior==_6;
}.bind(this));
return (_a&&_a.interiors.include(this))&&!_8;
}else{
return _5.colors.pluck("interiors").flatten().include(this)&&!_8;
}
}});
}

with(Configurator){
Configurator.Model=Class.create();
Object.extend(Model.prototype,ModelCommon);
Object.extend(Model.prototype,{initialize:function(_1){
this.id="";
this.code="";
this.name="";
this.msrp="";
this.year="";
this.series_code="";
this.bed="";
this.cab="";
this.drive="";
this.engine="";
this.grade="";
this.transmission="";
this.description="";
this.destination_fee="";
this.city_mpg="";
this.highway_mpg="";
this.horsepower="";
this.title_media_id="";
this.image_media_id="";
this.flash_key="";
this.flash_description="";
this.link_image_id="";
this.link_image_url="";
this.accessories=[];
this.exterior_colors=[];
this.interior_colors=[];
this.packages=[];
Object.extend(this,_1||{});
},to_s:function(){
return "Model: "+this.id+" ("+[this.cab.name,this.bed.name,this.drive.name,this.engine.name,this.grade.name,this.transmission.name].join(", ")+")";
},initWithXML:function(_2){
if(_2.nodeName=="model"){
this.id=_2.getAttribute("id");
this.year=_2.getAttribute("year");
this.code=_2.getAttribute("code");
this.series_code=_2.getAttribute("seriesCode");
$NL(_2.childNodes).elements().each(function(_3){
var _4=_3.nodeName.unCamelCase();
var _5=["name","msrp","code","year","seriesCode","description","destination_fee","city_mpg","highway_mpg","horsepower","title_media_id","image_media_id","flash_key","link_image_id","link_image_u_r_l","flash_description","color_flash_key","interior_flash_key"];
var _6=["bed","cab","drive","engine","grade","transmission"];
var _7=["msrp","year","destination_fee"];
if(_5.indexOf(_4)>-1){
this[_4]=_3&&_3.firstChild?_3.firstChild.data:"";
}else{
if(_6.indexOf(_4)>-1){
this[_4]=this.object_lookup(_4+"s",_3.firstChild.data,window[_4.substr(0,1).toUpperCase()+_4.substr(1)]);
}else{
if(_4=="accessories"){
$NL(_3.childNodes).elements().each(function(_8){
var ao=new Accessory();
ao.initWithXML(_8);
this.accessories.push(ao);
}.bind(this));
}else{
if(_4=="features"){
$NL(_3.childNodes).elements().each(function(_a){
this.features.push(_a.firstChild.data);
}.bind(this));
}
}
}
}
_7.each(function(_b){
this[_b]=parseInt(this[_b]);
}.bind(this));
}.bind(this));
this.link_image_url=this.link_image_u_r_l;
return true;
}else{
return false;
}
}});
}

with(Configurator){
Configurator.ModelAttribute=Class.create();
Object.extend(ModelAttribute.prototype,ModelCommon);
Object.extend(ModelAttribute.prototype,{initialize:function(_1){
this.id="";
this.is_default=false;
this.name="";
this.description="";
this.long_description="";
Object.extend(this,_1||{});
},initWithXML:function(_2){
this.id=_2.getAttribute("id");
this.is_default=_2.getAttribute("default")&&_2.getAttribute("default").toLowerCase()=="true"?true:false;
$NL(_2.childNodes).elements().each(function(_3){
this.basic_assign(["name","description","long_description","media_id"],_3);
}.bind(this));
return true;
}});
}

with(Configurator){
Configurator.Package=Class.create();
Object.extend(Package.prototype,ModelCommon);
Object.extend(Package.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
this.id="";
this.name="";
this.long_description="";
this.flash_key="";
this.msrp=0;
this.accessories=[];
this.int_colors=[];
this.ext_colors=[];
this.colors=[];
Object.extend(this,_1);
},initWithXML:function(_2){
this.id=_2.getAttribute("id");
this.is_default=_2.getAttribute("default")&&_2.getAttribute("default").toLowerCase()=="true"?true:false;
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["name","long_description","flash_key"],_3)){
}else{
if(this.int_assign(["msrp"],_3)){
}else{
if(_3.nodeName=="includedAccessories"||_3.nodeName=="factoryAccessories"){
$NL(_3.childNodes).elements().each(function(n){
this.accessories.push(this.object_lookup("accessories",n.firstChild.data,Accessory));
}.bind(this));
}else{
if(_3.nodeName=="exteriorAssociations"){
$NL(_3.childNodes).elements().each(function(n){
this.colors.push(new Package_ColorAssociation(this.object_lookup("exterior_colors",n.getAttribute("exteriorId"),ExteriorColor),$NL(n.childNodes).elements().map(function(i){
return this.object_lookup("interior_colors",i.firstChild.data,InteriorColor);
}.bind(this))));
}.bind(this));
}
}
}
}
}.bind(this));
this.accessories=this.accessories.partition(function(a){
return a.source!="F";
}).invoke("sortBy",function(_8){
return _8.code;
}).flatten();
this.fios=this.accessories.select(function(a){
return a.source=="F";
}).sortBy(function(_a){
return _a.msrp;
});
if(this.fios.length==0||(this.msrp==0&&this.accessories.length==1)){
this.name="Base Model";
}else{
this.name=((this.fios.last().long_description!=undefined)?this.fios.last().long_description:"&nbsp;");
}
return true;
}});
Configurator.Package_ColorAssociation=Class.create();
Object.extend(Package_ColorAssociation.prototype,{initialize:function(_b,_c){
this.exterior=_b;
this.interiors=_c;
}});
}



with(Configurator){
Configurator.Series=Class.create();
Object.extend(Series.prototype,ModelCommon);
Object.extend(Series.prototype,{initialize:function(_1){
this.id="";
this.name="";
this.flash_key="";
Object.extend(this,_1||{});
},initWithXML:function(_2){
this.id=_2.getAttribute("categoryId");
this.name=_2.getAttribute("name");
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["flash_key"],_3)){
}
}.bind(this));
}});
}

with(Configurator){
Configurator.SeriesGroup=Class.create();
Object.extend(SeriesGroup.prototype,{initialize:function(_1){
if(!_1){
var _1={};
}
var id;
this.id=_1.id||"";
var _3;
this.name=_1.name||"";
var _4;
this.series_list=_1.series_list||[];
},initWithXML:function(_5){
if(_5.nodeName=="seriesgroup"){
this.id=_5.getAttribute("id");
$NL(_5.childNodes).elements().each(function(_6){
if(_6.nodeName=="name"){
this.name=_6.firstChild.data;
}else{
if(_6.nodeName=="series_list"){
$NL(_6.childNodes).elements().each(function(_7){
var s=new Series();
if(s.initWithXML(_7)){
s.series_group=this;
this.series_list.push(s);
}
}.bind(this));
}
}
}.bind(this));
return true;
}else{
return false;
}
}});
}

with(Configurator){
Configurator.Status=Class.create();
Object.extend(Status.prototype,ModelCommon);
Object.extend(Status.prototype,{initialize:function(_1){
this.code="";
this.message="";
Object.extend(this,_1);
},initWithXML:function(_2){
this.code=_2.getAttribute("statusCode");
$NL(_2.childNodes).elements().each(function(_3){
if(this.basic_assign(["message"],_3)){
}
}.bind(this));
}});
}

with(Configurator){
Configurator.Vehicle=Class.create();
Object.extend(Vehicle.prototype,{initialize:function(_1){
this.series=null;
this.model=null;
this.pkg=null;
this.extColor=null;
this.intColor=null;
this.userAccessories=[];
this.baseMsrp=0;
this.pkg_acc_subtotal=0;
this.fee=0;
this.totalMsrp=0;
Object.extend(this,_1||{});
},initWithXML:function(_2){
return false;
},getSelectedAccessories:function(){
if(this.pkg&&this.pkg.accessories){
return this.userAccessories.concat(this.pkg.accessories).concat(this.pkg.accessories.pluck("includes").flatten()).uniq();
}else{
return this.userAccessories;
}
},updateMsrp:function(){
this.baseMsrp=this.model?this.model.msrp:0;
this.fee=this.model?this.model.destination_fee:0;
this.pkg_acc_subtotal=this.pkg?this.pkg.msrp:0;
this.pkg_acc_subtotal+=this.extColor?this.extColor.msrp:0;
this.pkg_acc_subtotal+=this.intColor?this.intColor.msrp:0;
var _3=this.pkg?this.pkg.accessories.pluck("includes").flatten():[];
this.userAccessories.concat(_3).uniq().each(function(_4){
if(!this.pkg.accessories.include(_4)){
this.pkg_acc_subtotal+=_4.msrp;
}
}.bind(this));
this.totalMsrp=this.baseMsrp+this.pkg_acc_subtotal+this.fee;
try{
NotificationCenter.sendNotification("MSRP Updated",this);
}
catch(e){
Debug.error(e);
}
setTimeout(function(){
if(App.app_is_ready){
var _5=new Cookie("saved_configuration");
_5.set(this.toJSON(),21,{path:"/byt"});
}
}.bind(this),10);
},addUserAccessory:function(_6){
if(!this.userAccessories.include(_6)){
this.userAccessories.push(_6);
}
if(!_6.flash_key){
NotificationCenter.sendNotification("Accessory Without Flash Key");
}
if((_6.flash_key)&&(_6.flash_orientation!=null)&&(parseInt(_6.flash_orientation)!=0)){
NotificationCenter.sendNotification("Accessory With Flash Orientation",[_6.flash_orientation]);
}
setTimeout(function(){
this.updateMsrp();
App.accessoriesChanged();
}.bind(this),100);
},removeUserAccessory:function(_7){
this.userAccessories=this.userAccessories.reject(function(a){
return a==_7;
});
this.updateMsrp();
App.accessoriesChanged();
},getParamList:function(){
return "sessionName="+this.model.name+"&seriesCategory="+this.series.id+"&zipCode="+App.zip_code+"&modelId="+this.model.id+"&packageId="+(this.pkg?this.pkg.id:"")+"&exteriorColorId="+(this.extColor?this.extColor.id:"")+"&interiorId="+(this.intColor?this.intColor.id:"")+"&packageName="+encodeURIComponent(this.pkg?this.pkg.name:"")+(this.userAccessories.length?"&":"")+this.userAccessories.collect(function(a){
return "accessories="+a.id;
}).join("&");
},toJSON:function(){
if(this.model&&this.series&&this.model&&this.pkg&&this.extColor&&this.intColor&&this.pkg){
return Hash.toJSON({session_name:this.model.name,series_category:this.series.id,zip_code:App.zip_code,model_id:this.model.id,package_id:this.pkg.id,exterior_id:this.extColor.id,interior_id:this.intColor.id,package_name:this.pkg.name,accessory_ids:this.userAccessories.pluck("id")});
}
}});
}

