var ModelCompare=new function(){this.categories=new Array();this.models=new Array();this._vars=new Array();this.load=function(f,g,j,h){var i=0;var e=function(){if(g==null){g=(ModelCompare.variations.length>1?[0,0]:[0]);if(window.localStorage.getItem("pv")){var k=JSON.parse(window.localStorage.getItem("pv"));if(!k.model){k.model=Vehicles.getBaseModel(k)}g=Vehicles.getVariation(k);g=g.split("-")}}if(g.length>1){if(ModelCompare._vars[g[0]]&&ModelCompare._vars[g[0]].constructor==Array&&ModelCompare._vars[g[0]][g[1]]){ModelCompare.models=ModelCompare._vars[g[0]][g[1]];i++}else{d();return}}else{if(ModelCompare._vars[g[0]]){ModelCompare.models=ModelCompare._vars[g[0]];i++}else{d();return}}i++;if(i==2){j.call(h)}if(typeof $select==="object"&&typeof $select!=="undefined"&&$select!==null){$select.iterate();$select.resetValues()}};var d=function(){var k=new cllc.request.ajax(String.format("/hostb/assets/data/compare/{0}.models.{1}.json",f,g.length>1?(g[0]+"-"+g[1]):g[0]));k.responseType="json";k.onsuccess=function(l){if(g.length>1){if(!ModelCompare._vars[g[0]]){ModelCompare._vars[g[0]]=new Array()}ModelCompare._vars[g[0]][g[1]]=l}else{ModelCompare._vars[g[0]]=l}if(ModelCompare.preferredModel&&ModelCompare.preferredVariation){l.sort(function(n,m){return(m.id===ModelCompare.preferredModel?1:-1)});setTimeout(function(){ModelCompare.UIController.updateVariation(g,function(){screenInit(true)})},2000)}ModelCompare.models=l;e()};k.send()};cllc.lazy.requires([{src:"/hostb/assets/data/compare/"+f+".categories.js"}],e)};this.applyColorHighlight=function(){var e=$("table.data tbody, .contentHolder,.st-mc-chart tfoot");var d=1;if(Vehicles.getTrimFromCcode(e.find("th:eq("+d+")").attr("data-myc"))==PV.get("trim")){e.find("th:eq("+d+")").addClass("active").css("background","#e7e7e7");e.find("tr").find("td:eq("+d+")").addClass("active").css({background:"#e7e7e7","border-right":"802d1b","border-left":"802d1b",})}};this.getCategory=function(e){for(var d=0;d0){l.features.push(m.features[e])}}l.features.sort(function(j,i){return j.sort-i.sort})}}h.push(l)}for(var g=0;g=1){d.features[e]["type"]="feature";l[n.id][d.id].features.push(d.features[e])}}}}}for(var o in l){var h=[];for(var m in l[o]){h.push(m);if(m!="id"&&m!="name"&&null!=l[o][m].features){if(l[o][m].features.length<=0){delete l[o][m]}}}if(h.length<=2){delete l[o];h=[]}}return l};this.getIcon=function(d){return(d&&this.icons[d]?this.icons[d]:"gc-icon-check-mark-circle")};this.getFeaturesAndSpecs=function(e,d){};this.getColor=function(f,e,d){return a.call(this,"colors",f,e,d)};this.getExteriorColor=function(d){return a.call(this,"colors",d,"exterior","exterior_colors")};this.getInteriorColor=function(d){return a.call(this,"colors",d,"interior","interior_colors")};this.getFeature=function(f,e,d){return a.call(this,"features",f,e,d)};this.getSpec=function(f,e,d){return a.call(this,"specs",f,e,d)};var a=function(n,d,h,o){var e,g;if(h){e=this.getCategory(h);if(o){g=this.getSubCategory(o);for(var m=0;m