Configurator.DiffFactory=new Class({initialize:function(viewport){var self=this;
this.viewport=viewport;
this.stepFrom=this.viewport.params.To;
this.modelId=this.viewport.params.modelId;
this.userPriceType=this.viewport.params.userPriceType;
App.addEvent("onRefreshFragmentAfterDiff",function(){self.setPrices(App.lastReponses)
})
},getDiff:function(id,isSelected){var self=this;
var Query=Object.toQueryString({stepFrom:this.stepFrom,modelKey:this.modelId,update:"",userPriceType:this.userPriceType!=undefined?this.userPriceType:"",select:isSelected,criteria:id,nocache:Math.random()});
new Ajax(Setup.JsonURI+Query,{method:"get",onRequest:function(){this.viewport.loader.show()
}.bind(this),onSuccess:function(text){App.lastReponses=this.response;
self.setPrices(this.response)
},onFailure:function(request){var errorCode=Json.evaluate(request.responseText).error.$;
new Configurator.ApplicationError(new Element("div",{"class":"errorContainer"}),eval("Locale."+errorCode)+" : <a class='chevron' href='"+configuratorUrl+"'>"+Locale.Restart+"</a>",false);
this.viewport.loader.hide()
}.bind(this)}).request()
},assetDiff:function(datas){var aspectRet=null;
var extimgRet=null;
var extimgRetZoom=null;
var intimgRet=null;
var intimgRetZoom=null;
var versionBlock=null;
if(datas.meta){financeParameters.idVehicle=datas.meta.modscla.$;
financeParameters.model=datas.meta.modfinkey.$;
financeParameters.version=datas.meta.verscla.$;
financeParameters.engine=datas.meta.modeng.$;
financeParameters.power=datas.meta.modpow.$
}if(datas.aspect){aspectRet=this.fetchDatas(datas.aspect);
extimgRet=datas.aspect.extimg.$;
extimgRetZoom=datas.aspect.extzmimg.$;
intimgRet=datas.aspect.intimg.$;
intimgRetZoom=datas.aspect.intzmimg.$
}if(datas.cgs instanceof Array){if(datas.cgs[0].cg){$checkIterable(datas.cgs[1],"cg");
datas.cgs[1].cg.unshift(datas.cgs[0].cg)
}datas.cgs=datas.cgs[1]
}if(datas.bks.vblk==null){versionBlock=null
}else{versionBlock=datas.bks.vblk.vers.$
}return{aspect:aspectRet,carpicture:{normal:extimgRet,zoom:extimgRetZoom},interiorpicture:{normal:intimgRet,zoom:intimgRetZoom},config:this.fetchDatas({cgs:{cg:datas.bks.cblk.cg}}),choices:this.fetchDatas(datas),configuration:{price:datas.bks.pblk,summary:datas.bks.cblk,version:versionBlock},tinies:[datas.aspect.pimgsmpl.$,datas.aspect.sadimgsmpl.$,datas.aspect.dashimgsmpl.$],wfp:datas.wfp,meta:datas.meta,upselling:function(){var block=datas.bks.ublk;
if(block){$checkIterable(block.eblk,"chg").chg.each(function(choiceGroup){$checkIterable(choiceGroup,"ch")
});
return block
}else{return null
}}(),implications:function(){if(datas.impls.fxs){$checkIterable(datas.impls.fxs,"fx");
return{cause:datas.impls.cause,effects:datas.impls.fxs.fx}
}}()}
},setSecondPrice:function(objPrices,isCS){var self=this;
var jsonData=Json.evaluate(objPrices.text);
if(isCS){if(jsonData.diff.bks.pblk.pp){jsonData.diff.bks.pblk.fmp.$=objPrices.diff.bks.pblk.fmp.$;
jsonData.diff.bks.pblk.fpp.$=objPrices.diff.bks.pblk.fpp.$
}else{jsonData.diff.bks.pblk.fmp.$=objPrices.diff.bks.pblk.fmp.$
}jsonData.diff.bks.cblk.chcs=objPrices.diff.bks.cblk.chcs
}var test=jsonData;
this.aP=[];
this.explorePrice(jsonData);
new Sixtools.remotePrice(this.aP,function(newPrices){self.mergePrices(newPrices,jsonData);
objPrices.preferences=jsonData;
self.fireEvent("onDiff",[self.assetDiff(objPrices.preferences.diff),objPrices])
})
},explorePrice:function(data){for(key in data){if(key=="p"||key=="pntp"||key=="fpp"||key=="fmp"||key=="pntfp"||key=="fpam"||key=="pp"||key=="mp"){if(!!data[key].$.toString().match(/,/)){data[key].$=data[key].$.toString().replace(".","")
}else{data[key].$=data[key].$.toString().replace(".",",")
}this.aP.push(data[key].$)
}else{if(typeof data[key]!="function"&&typeof data[key]!="string"&&typeof data[key]!="number"){this.explorePrice(data[key])
}}}},mergePrices:function(aPrices,data){for(key in data){if(key=="p"||key=="pntp"||key=="fpp"||key=="fmp"||key=="pntfp"||key=="fpam"||key=="pp"||key=="mp"){data[key+"Sec"]={"$":aPrices[0]};
aPrices.shift()
}else{if(typeof data[key]!="function"&&typeof data[key]!="string"&&typeof data[key]!="number"){this.mergePrices(aPrices,data[key])
}}}},setPrices:function(data){var self=this;
var text=data.text;
if($("nameContrat")&&$("priceContrat")){var dataSet;
self.setCSPrices(data,function(values){dataSet=values;
if(exchangeRateDef.enabled){self.viewport.loader.hide();
self.setSecondPrice(dataSet,true)
}else{self.viewport.loader.hide();
self.fireEvent("onDiff",[self.assetDiff(dataSet.diff),data])
}})
}else{if(exchangeRateDef.enabled){self.setSecondPrice(data);
self.viewport.loader.hide()
}else{self.viewport.loader.hide();
self.fireEvent("onDiff",[self.assetDiff(Json.evaluate(text).diff),data])
}}},setCSPrices:function(incomingData,callback){var self=this;
var jsonData=Json.evaluate(incomingData.text);
var labelCS=$("nameContrat").getText();
var fPriceCS=$("yearlyPriceToDisplay").value;
var priceCS=parseFloat($("yearlyPrice").value);
jsonData.diff.bks.cblk.chcs={lab:{$:labelCS},p:{$:priceCS},fp:{$:fPriceCS}};
price=jsonData.diff.bks.pblk.mp.$.toFloat()+priceCS.toFloat();
price=price.toString().replace(/\./,",");
if(jsonData.diff.bks.pblk.pp.$.toFloat()>0){pricePromo=jsonData.diff.bks.pblk.pp.$.toFloat()+priceCS.toFloat();
pricePromo=pricePromo.toString().replace(/\./,",");
new Sixtools.remotePrice([price,pricePromo],function(response){jsonData.diff.bks.pblk.fmp.$=response[0];
jsonData.diff.bks.pblk.fpp.$=response[1];
incomingData.diff=jsonData.diff;
callback(incomingData)
},true)
}else{new Sixtools.remotePrice([price],function(response){jsonData.diff.bks.pblk.fmp.$=response[0];
incomingData.diff=jsonData.diff;
callback(incomingData)
},true)
}},fetchDatas:function(base){try{var changed=[];
$checkIterable(base,"cgs");
base.cgs.each(function(cgs){$checkIterable(cgs,"cg");
cgs.cg.each(function(group){$checkIterable(group,"c");
group.c.each(function(choice){changed.push(choice)
})
})
})
}catch(e){}return changed
}});
Configurator.DiffFactory.implement(new Events);
Configurator.Datastore=new Class({initialize:function(datas){this.datas=datas;
$each(this.datas,function(value,key){this.datas[key]=this.process(value)
},this);
return this.datas
},process:function(datas){return this.testView(datas)||this.json(datas)||this.xml(datas)||this.text(datas)||datas
},testView:function(datas){if(datas.view){return datas
}else{return null
}},json:function(datas){try{return Json.evaluate(datas.text)
}catch(e){return null
}},xml:function(datas){if(datas.xml){return datas.xml.firstChild
}else{return null
}},text:function(datas){return datas.text
}});
Configurator.ApplicationError=new Class({initialize:function(container,message,displayClose){var text='<div class="block insideSpace frame"><h5 class="head txtC"><strong>'+message+"</strong></h5></div>";
if(displayClose){text+='<div class="txtC tMarginLg"><a class="closer bouton" href="#"><strong>'+Locale.Close+"</strong></a></div>"
}var content=new Element("div").setHTML(text);
this.container=container.adopt(content);
this.layer=new Sixtools.Layer(window,this.container,{top:getHeight()/2-50,showCloseCross:displayClose}).show()
}});
Configurator.ConfigurationView=new Class({initialize:function(model,parent){this.model=model;
this.parent=parent;
this.pricePH=$$(".configuration-price").getElement("span");
this.priceNewDealPH=$$(".configuration-price").getElement(".AjaxMakolabOffer");
this.summaryPH=$("configuration").getElement("div");
this.install()
},install:function(){var self=this;
this.model.addEvent("onSummaryCreated",function(output){this.summaryPH.setHTML(output)
}.bind(this));
this.model.addEvent("onPriceCreated",function(output){this.priceUpdate(output)
}.bind(this));
this.model.addEvent("onPriceUpdate",function(datas){var output=new Template(this.model.priceTemplate).render(datas);
this.pricePH.setHTML(output)
}.bind(this));
this.model.addEvent("onUpdate",function(datas){if(datas.version){this.parent.versionLabel.setHTML(datas.version)
}else{this.parent.versionLabel.setHTML("")
}this.priceUpdate(datas.price);
$each(datas.summary,function(v,k){if(v.lab&&v.lab.$!=""&&v.lab.$!="null"){if(v.pSec&&v.pSec.$==null){v.pSec.$=""
}$(k).getFirst().empty().adopt(new Element("li").addClass("context").setHTML("<span> "+(v.p&&v.p.$!=""?v.fp.$:"")+"<span>"+(v.pSec&&v.pSec.$!=""?v.pSec.$:"")+"</span></span>"+v.lab.$))
}else{if(v.items){$(k).getFirst().empty();
$checkIterable(v,"items");
v.items.each(function(item){$(k).getFirst().adopt(new Element("li").addClass("context").setHTML("<span> "+(item.p&&item.p.$!=""?item.fp.$:"")+"<span>"+(item.pSec&&item.pSec.$!=""?item.pSec.$:"")+"</span></span>"+item.lab.$))
})
}else{$(k).getFirst().empty()
}}["chin","chout"].each(function(Section){var sectionElement=$(Section);
if(sectionElement.getFirst().getChildren().length==0){sectionElement.setStyle("display","none")
}else{sectionElement.setStyle("display","block")
}})
});
this.datasToKeep=datas
}.bind(this))
},priceUpdate:function(price){glob_modelPrice=price.pwoo.$;
var output=new Template(this.model.priceTemplate).render(price);
this.pricePH.setHTML(output);
var self=this;
var url=price.pcmsfr.$;
if(url){new Ajax(url,{onComplete:function(xhr){$("fragmentMentions").setHTML(xhr)
},onFailure:function(){}}).request()
}else{$("fragmentMentions").empty()
}try{if(componentFinanceLib!=undefined){if(price.pr.$=="true"){financeParameters.price=price.pp.$
}else{financeParameters.price=price.mp.$
}financeParameters.priceWoOptions=price.pwoo.$;
financeParameters.promo=price.pr.$;
componentFinanceLib.getMakolabOffersVN(financeParameters,"vnPricefrom",[".AjaxMakolabOffer"])
}}catch(e){}}});
Configurator.Webform=new Class({initialize:function(datas,differ){this.datas=datas,this.differ=differ
},install:function(){this.differ.addEvent("onDiff",function(diffDatas){this.datas=diffDatas.wfp
}.bind(this))
}});
Configurator.Webform.implement(new Events);
Configurator.PreferencesView=new Class({initialize:function(model,parent){this.model=model;
this.parent=parent;
this.base=$("choices");
this.totalVersion=$("TotalVersion");
this.cache={};
this.install()
},install:function(){this.model.addEvent("onVersionTotalLoaded",function(labeltotalversion){if(this.parent.params.To==2){this.totalVersion.setHTML(labeltotalversion)
}}.bind(this));
this.model.addEvent("onrender",function(template,dataset,to){this.buildSections(template,dataset,to);
this.setactions();
this.setdiffcallbacks()
}.bind(this));
this.iframe=new Element("iframe",{frameborder:0}).setStyle("display","none");
this.iframeLayer=new Sixtools.Layer(window,this.iframe,{top:50});
this.implicationlayer=new Sixtools.Layer(window,new Element("div"),{top:100,showCloseCross:false});
this.upsellingLayer=new Sixtools.Layer(window,new Element("div"),{top:100,showCloseCross:false})
},buildSections:function(template,dataset,step){var lazy=new Sixtools.LazyCruncher({chunkSize:1,interval:400}).pause();
lazy.addEvent("Crunched",function(){this.fireEvent("loaded")
}.bind(this));
for(var i=0;
i<dataset.length;
i++){lazy.push((function(kwargs){var content=new Element("div").setHTML(template.render(kwargs));
this.base.adopt(this.buildChoiceBoxes(content.getFirst()))
}).bind(this,{choice:dataset[i],lang:Locale,step:step}))
}lazy.resume()
},buildChoiceBoxes:function(field){var self=this;
field.getElements("li").each(function(li,index,arr){var spanParent=li.getElement("span.confListPromo");
if(spanParent){var span=spanParent.getElement("span");
if(span){var url=span.getAttribute("rel");
new Ajax(url,{onComplete:function(xhr){spanParent.getElement(".tipBoxLayer").setHTML(xhr)
},onFailure:function(){}}).request()
}}var input=li.getElement("input");
var label=li.getElement("label");
var checkbox=new Sixtools.Checkbox(input);
this.cache[input.id]=checkbox;
if(this.parent.params.To==2){this.iframeLayer.closer.addEvent("click",function(){$$("iframe")[0].contentWindow.location.assign("about:blank")
}.bind(this));
label.addClass("clickable").addEvent("click",function(){this.iframe.contentWindow.location.assign(componentNamespace+"/view.action?versionDetail=&modelKey="+this.parent.params.modelId+"&userPriceType="+(this.parent.params.userPriceType!=undefined?this.parent.params.userPriceType:"")+"&versionCriteria="+input.id);
this.iframeLayer.show()
}.bind(this))
}if(["IMPLIED"].contains(li.className)){li.addEvent("mouseenter",function(){var catchedMessage=$("messageTipBoxImplied").getText();
var layer=new Element("span",{id:"tipBox"}).setText(catchedMessage);
$("body").adopt(layer);
var coordLi=li.getCoordinates();
var coordBody=$("body").getCoordinates();
layer.setStyles({width:coordLi.width-li.getStyle("padding-left").toInt()*2,top:(coordLi.top-coordBody.top)+coordLi.height+4,left:(coordLi.left-coordBody.left)});
if((layer.getCoordinates().top+layer.getCoordinates().height)>document.documentElement.clientHeight){layer.setStyle("top",(coordLi.top-coordBody.top)-(coordLi.height))
}});
li.addEvent("mouseleave",function(){var tipBox=$("tipBox");
if(tipBox){tipBox.remove()
}})
}if(["POSSIBLE","FORBIDDEN","IMPLIED","CHOSEN"].contains(li.className)){function callDiffer(){self.lastClicked=input.id;
self.model.calldiff(input.id,checkbox.getChecked())
}checkbox.addClickCallback(callDiffer)
}},this);
return field
},setactions:function(){this.parent.addEvent("toStep3",function(){if(this.userHasChosenAnOption()!=true){return new Configurator.ApplicationError(new Element("div",{"class":"errorContainer"}),Locale.VersionRequired,true)
}if(this.model.getLastUpselling()!=null){var output=new Template(this.model.upsellingTemplate).render(this.model.getLastUpselling());
this.upsellingLayer.content.setHTML(output);
$("upsellPricePopup").setHTML($("upsellPrice").innerHTML);
this.upsellingLayer.show();
$("upselling").getElement(".yes").addEvent("click",function(e){new Event(e).stop();
var id=this.model.getLastUpselling().upselling.newCarId;
this.model.differ.getDiff(id,true);
this.model.differ.addEvent("onDiff",function(){this.upsellingLayer.hide();
this.parent.setUrl(this.parent.computeUrl(this.parent.params.To+1))
}.bind(this))
}.bind(this));
$("upselling").getElement(".no").addEvent("click",function(e){new Event(e).stop();
this.parent.setUrl(this.parent.computeUrl(this.parent.params.To+1))
}.bind(this))
}else{this.parent.setUrl(this.parent.computeUrl(this.parent.params.To+1))
}}.bind(this));
if(this.parent.params.To==2){$("compareVersion").getElement(".first").addEvent("click",function(){var w=window.open(this.computeCompareVersionLink(),"ComparisonPopup","scrollbars=yes,resizable=yes,toolbar=0,menubar=0,directories=0,width=985,height=700");
w.focus()
}.bind(this))
}},setdiffcallbacks:function(){var self=this;
this.model.addEvent("onImplication",function(implicationOutput){this.implicationlayer.content.setHTML(implicationOutput);
this.implicationlayer.show();
$("implication").getElement(".yes").addEvent("click",function(e){new Event(e).stop();
this.implicationlayer.hide()
}.bind(this));
$("implication").getElement(".no").addEvent("click",function(e){new Event(e).stop();
this.model.differ.getDiff(this.lastClicked,false);
this.implicationlayer.hide()
}.bind(this))
}.bind(this));
this.model.addEvent("onChoiceChangeState",function(choices){if(this.parent.params.To==2){if(this.userHasChosenAnOption()==true){if(document.body.getElement(".print")){document.body.getElement(".print").setStyle("visibility","visible")
}if(document.body.getElement(".save")){document.body.getElement(".save").setStyle("visibility","visible")
}}else{if(document.body.getElement(".print")){document.body.getElement(".print").setStyle("visibility","hidden")
}if(document.body.getElement(".save")){document.body.getElement(".save").setStyle("visibility","hidden")
}if(this.parent.params.ecoPreference==false){this.displayEco2Picture(false)
}}}choices.each(function(choice){var id=choice.v.$;
if($(id)){var li=$(id).getParent().getParent();
li.removeEvents("mouseenter");
function callDiffer(){self.lastClicked=id;
self.model.calldiff(id,self.cache[id].getChecked())
}this.setNeutral(li,choice);
if(this.parent.params.To>1){if(choice.p.$!="-1"){if(li.getElement("strong")){li.getElement("strong").innerHTML=choice.p.$;
if(exchangeRateDef.enabled&&choice.pSec.$!=null){li.getElement("strong").innerHTML+="<span>"+choice.pSec.$+"</span>"
}}}else{if(li.getElement("strong")){li.getElement("strong").innerHTML=""
}}}switch(choice.st.$){case"IMPLIED":this.cache[id].setChecked(true);
li.addEvent("mouseenter",function(){var catchedMessage=$("messageTipBoxImplied").getText();
var layer=new Element("span",{id:"tipBox"}).setText(catchedMessage);
$("body").adopt(layer);
var coordLi=li.getCoordinates();
var coordBody=$("body").getCoordinates();
layer.setStyles({width:coordLi.width-li.getStyle("padding-left").toInt()*2,top:(coordLi.top-coordBody.top)+coordLi.height+4,left:(coordLi.left-coordBody.left)});
if((layer.getCoordinates().top+layer.getCoordinates().height)>document.documentElement.clientHeight){layer.setStyle("top",(coordLi.top-coordBody.top)-(coordLi.height))
}});
li.addEvent("mouseleave",function(){var tipBox=$("tipBox");
if(tipBox){tipBox.remove()
}});
break;
case"PRECHECKED":this.cache[id].setChecked(true);
this.cache[id].element.removeEvents("click");
break;
case"CHOSEN":this.cache[id].setChecked(true);
if((this.cache[id].element.$events&&this.cache[id].element.$events.click==null)||this.cache[id].element.$events==null){this.cache[id].addClickCallback(callDiffer)
}if(this.parent.params.To==1||this.parent.params.To==2){if(choice.eco.$=="true"){this.displayEco2Picture(true)
}else{this.displayEco2Picture(false)
}this.computeCompareVersionLink(id)
}break;
case"POSSIBLE":if((this.cache[id].element.$events&&this.cache[id].element.$events.click==null)||this.cache[id].element.$events==null){this.cache[id].addClickCallback(callDiffer)
}if(this.parent.params.To==1&&choice.eco.$=="true"){this.displayEco2Picture(false)
}break;
case"FORBIDDEN":if((this.cache[id].element.$events&&this.cache[id].element.$events.click==null)||this.cache[id].element.$events==null){this.cache[id].addClickCallback(callDiffer,null)
}this.cache[id].setDisabled(true);
li.setStyle("color","#999");
break
}}else{}},this)
}.bind(this))
},setNeutral:function(li,choice){li.className=choice.st.$;
li.setStyle("color","#000");
this.cache[choice.v.$].setChecked(false);
this.cache[choice.v.$].setDisabled(false)
},userHasChosenAnOption:function(){for(var option in this.cache){if(this.cache[option].getChecked()){return true
}}return false
},displayEco2Picture:function(display){if(display){if(document.body.getElementById("spanECO2")){document.body.getElementById("spanECO2").className="eco2visible"
}}else{if(document.body.getElementById("spanECO2")){document.body.getElementById("spanECO2").className="eco2hidden"
}}},computeCompareVersionLink:function(){var chosen=function(){return this.base.getElement("li.CHOSEN").getElement("input").id
}.attempt(null,this);
var versionID=(chosen)?"&versions="+chosen:"";
var selectedCriterias="";
if(this.model.meta){selectedCriterias=this.model.meta.sc.$
}return componentNamespace+"/pricespecs/index.jsp?modelKey="+this.parent.params.modelId+versionID+"&codes="+selectedCriterias+"&userPriceType="+(this.parent.params.userPriceType!=undefined?this.parent.params.userPriceType:"")
}});
Configurator.PreferencesView.implement(new Events);
Configurator.PreferencesModel=new Class({initialize:function(datas,meta,template,differ,params,parent){this.output="";
this.parent=parent;
this.rawdatas=datas;
this.datas=new Object();
this.datas.cg=new Array();
this.meta=meta;
this.state={upselling:null,params:params};
this.setLastUpselling(datas);
this.template=$xmlSection(template,"choice");
this.implicationTemplate=$xmlSection(template,"implication");
this.upsellingTemplate=$xmlSection(template,"upselling");
this.differ=differ;
if(this.rawdatas){try{if(this.rawdatas.unshift){for(var i=0;
i<this.rawdatas.length;
i++){var currentobj=this.rawdatas[i];
this.addChoiceGroups(this.datas.cg,currentobj)
}}else{this.addChoiceGroups(this.datas.cg,this.rawdatas)
}}catch(e){if(window.console){console.warn("error",e)
}}finally{$checkIterable(this.datas,"cg");
if(this.datas&&this.datas.cg){this.datas.cg.each(function(c){$checkIterable(c,"c").c.each(function(choice){if(choice.desc){var ReformatedLine=choice.desc.$.split("|").map(function(line){return"- "+line.trim()
}).join("<br/>");
choice.desc.$=["<em>",ReformatedLine,"</em>"].join("")
}})
})
}}}},install:function(){this.output=new Template(this.template);
if(this.datas){this.fireEvent("onrender",[this.output,this.datas.cg,this.state.params.To])
}this.fireEvent("onVersionTotalLoaded",this.parent.db.bks.vblk.vsum.$);
this.differ.addEvent("onDiff",function(datas){if(this.state.params.To==2){try{if(componentFinanceLib!=undefined){financeParameters.price=datas.upselling.vorigprice.$;
financeParameters.engine=datas.upselling.vupeng.$;
financeParameters.power=datas.upselling.vuppow.$;
componentFinanceLib.getBestCarMakolabOffersVN(financeParameters,datas.upselling.vupprice.$,"vnUpsell",["#upsellPrice"]);
financeParameters.upperPrice=""
}}catch(e){}}if(datas.choices){this.fireEvent("onChoiceChangeState",[datas.choices])
}if(datas.implications&&datas.implications.effects){var outputImplication=new Template(this.implicationTemplate).render(datas.implications);
this.fireEvent("onImplication",outputImplication)
}if(datas.upselling!=undefined){this.setLastUpselling(datas)
}else{this.state.upselling=null
}this.meta=datas.meta
}.bind(this))
},calldiff:function(id,selected){this.differ.getDiff(id,selected)
},setLastUpselling:function(datas){if(datas&&datas.upselling){this.state.upselling={newCarlabel:datas.upselling.vuplab,originalCarlabel:datas.upselling.voriglab,optionGroups:datas.upselling.eblk.chg,newCarId:datas.upselling.vupcrit.$}
}},getLastUpselling:function(){if(this.state.upselling!=null){return{upselling:this.state.upselling}
}else{return null
}},addChoiceGroups:function(cgarray,myjsonobject){if(myjsonobject.type){if(myjsonobject.cg){if(myjsonobject.cg.each){myjsonobject.cg.each(function(cg){cgarray.push(cg)
})
}else{cgarray.push(myjsonobject.cg)
}}}else{if(myjsonobject.lab){cgarray.push(myjsonobject)
}}}});
Configurator.PreferencesModel.implement(new Events);
Configurator.PickerView=new Class({initialize:function(model,parent){this.firstInteriorLoading=true;
this.model=model;
this.parent=parent;
this.cache={};
this.cache.picture={car:{normal:null,zoom:null},interior:{normal:null,zoom:null}};
this.cache.sample={};
this.cache.imageSamples=[];
this.base=$("color-picker");
this.colorChoices=$("color-choices");
this.state=$("picker-state");
this.car={normal:$("car-picture"),zoom:new Element("div",{id:"car-picture-zoom"})};
this.interior={normal:$("interior-picture"),zoom:new Element("div",{id:"int-picture-zoom"}).setStyle("display","none")};
this.infoContainer=new Element("div",{id:"info"});
this.selectedcolors=this.base.getElement(".media");
this.catchphrase=this.selectedcolors.getParent();
this.install();
this.setdiffcallbacks()
},install:function(){this.layer=new Sixtools.Layer(window,[this.car.zoom,this.interior.zoom]);
this.infoContainer.setHTML("<p>"+Locale.Unavailable+"</p>").injectInside(document.body);
this.model.addEvent("onCarLoaded",function(){this.setPictures.apply(this,arguments)
}.bind(this));
this.model.addEvent("onInteriorLoaded",function(){this.setPictures.apply(this,arguments)
}.bind(this));
this.model.addEvent("onTinyLoaded",function(tinies){var tinies=tinies.map(this.getSampleAsset.bind(this)).remove(undefined);
$$(tinies).addEvent("click",this.setToggleEvent.bind(this));
this.selectedcolors.empty().adopt(tinies)
}.bind(this));
this.model.addEvent("onPicturesLoaded",function(output){this.colorChoices.setHTML(output);
this.setactions()
}.bind(this))
},setPictures:function(type,normalSrc,zoomSrc){var self=this;
var normalPic=this[type].normal.getElement("img");
var zoomPic=this[type].zoom.getElement("img");
var otherType=(type=="car")?"interior":"car";
var methodType=(type=="car")?"removeClass":"addClass";
if(normalSrc!=this.cache.picture[type].normal){if(!normalPic){normalPic=new Element("img").injectInside(this[type].normal)
}if(this.firstInteriorLoading&&type=="interior"){this.firstInteriorLoading=false;
normalPic.set({src:Setup.ImageFolder+normalSrc})
}else{if(self.prevImg&&self.prevImg!=Setup.ImageFolder+normalSrc){normalPic.setOpacity(0)
}self.prevImg=Setup.ImageFolder+normalSrc;
normalPic.addEvent("load",function(e){if(type=="car"){if(self[type].normal.getStyle("display")=="none"){self[otherType].normal.setStyle("display","none");
self[type].normal.setStyle("display","block");
self[otherType].zoom.setStyle("display","none");
self[type].zoom.setStyle("display","block");
$("views")[methodType]("leftHighLighted")
}}this.effect("opacity").start(1);
if(window.getScrollTop()>$("views").getTop()){var scroll=new Fx.Scroll(window,{wait:false,duration:1000,offset:{x:-($("views").getLeft()),y:0},transition:Fx.Transitions.Quad.easeInOut});
scroll.toElement("views")
}}).set({src:Setup.ImageFolder+normalSrc})
}this.cache.picture[type].normal=null
}if(zoomSrc!=this.cache.picture[type].zoom){if(zoomPic){zoomPic.remove()
}this[type].zoom.adopt(new Element("img",{src:[Setup.ImageFolder,zoomSrc].join("")}));
this.cache.picture[type].zoom=zoomSrc
}},setactions:function(){var total=$("color-picker").getElements("li").filter(function(item){return item.hasClass("IMPLIED")||item.hasClass("CHOSEN")
});
var ChoicesComplete=(total.length==3);
this.catchHide=new Fx.Slide(this.catchphrase);
this.colorToggle=new Fx.Slide(this.colorChoices,{onStart:function(){if(this.open==true){$$(".color-choice").each(function(item){item.effect("opacity").start(0)
})
}},onComplete:function(){if(this.open==false){$$(".color-choice").each(function(item){item.effect("opacity").start(1)
})
}}});
if(this.parent.params.To!=3||ChoicesComplete){this.colorToggle.hide();
$$(".color-choice").setOpacity(0)
}else{this.state.setText(Locale.Close);
this.catchHide.hide()
}this.colorToggle.addEvent("onStart",function(){if(this.colorToggle.open){this.state.setText(Locale.Open);
this.state.removeClass("close")
}else{this.state.setText(Locale.Close);
this.state.addClass("close")
}this.catchHide.toggle()
}.bind(this));
this.state.addEvent("click",this.setToggleEvent.bind(this));
$$(".cross").addEvents({click:function(e){this.getParent().setSelected(true).fireEvent("click",e);
$("info").setStyle("display","none")
},mouseover:function(e){$("info").setStyles({display:"block",top:this.getTop()+25,left:this.getLeft()+20})
},mouseout:function(){$("info").setStyle("display","none")
}});
this.colorChoices.getElements(".color-choice").each(function(choice,index){choice.getElements("li").each(function(item){$extend(item.$tmp,{show:choice.getElement(".media"),textContainer:choice.getElement(".media").getElement("span"),image:item.getElement("img"),label:item.getElement("img").getAttribute("alt"),choiceIndex:index,selected:(item.getElement("img").getAttribute("rel")=="true")?true:false});
this.cache.imageSamples.push(item.$tmp.image);
item.setSelected=function(state){this.$tmp.selected=state;
return this
};
item.addEvent("click",this.sendChoice.bind(item,this));
item.addEvent("click",this.setDefaultPreviewChoice.bind(item,this));
item.addEvent("mouseover",this.previewChoice.bind(item,this));
item.addEvent("mouseout",this.getDefaultPreviewChoice.bind(item,this))
},this)
},this);
this.fireEvent("loaded")
},setToggleEvent:function(){this.colorToggle.toggle()
},setdiffcallbacks:function(){this.model.addEvent("onColorsChangeState",function(colors){colors.each(function(color){var id=$(color.v.$);
if(id){var item=id.setProperty("class",color.st.$).setSelected(false);
id.setAttribute("rel",color.selimg.$);
item.setAttribute("colorPrice",color.p.$);
if(exchangeRateDef.enabled&&color.pSec.$!=null){item.setAttribute("colorPriceSec",color.pSec.$)
}switch(color.st.$){case"CHOSEN":item.setSelected(true);
item.fireEvent("mouseover");
break;
case"PRECHECKED":item.setSelected(true);
item.fireEvent("mouseover");
break;
case"POSSIBLE":item.setSelected(false);
break;
case"IMPLIED":item.setSelected(true);
item.fireEvent("mouseover");
break;
case"FORBIDDEN":break
}}else{}},this)
}.bind(this))
},sendChoice:function(self){App.carViewMode=this.getAttribute("carViewMode")||"exterior";
if(this.hasClass("IMPLIED")){return 
}this.setSelected(this.$tmp.selected?false:true);
self.model.calldiff(this.getAttribute("id"),this.$tmp.selected)
},previewChoice:function(self){var sampleContainer=this.$tmp.show.getElement("p");
if(sampleContainer.getAttribute("rel")=="no_sample"){sampleContainer=$("combined_preview")
}sampleContainer.empty();
new Element("img").set({src:Setup.ImageFolder+this.getAttribute("rel")}).injectInside(sampleContainer);
this.colorPriceChoice=this.getAttribute("colorPrice")=="-1"?"":this.getAttribute("colorPrice");
if(exchangeRateDef.enabled&&this.colorPriceChoice){this.colorPriceSecond=this.getAttribute("colorPriceSec")=="-1"?"":" / "+this.getAttribute("colorPriceSec");
this.$tmp.textContainer.innerHTML=this.$tmp.label+"<br />"+this.colorPriceChoice+this.colorPriceSecond
}else{this.$tmp.textContainer.innerHTML=this.$tmp.label+"<br />"+this.colorPriceChoice
}},setDefaultPreviewChoice:function(self){self.cache.sample[this.$tmp.choiceIndex]=this
},getDefaultPreviewChoice:function(self){if(self.cache.sample[this.$tmp.choiceIndex]){if(this.$tmp.choiceIndex!=2){this.$tmp.show.getElement("img").setProperty("src",Setup.ImageFolder+self.cache.sample[this.$tmp.choiceIndex].getAttribute("rel"))
}this.colorPriceChoice=self.cache.sample[this.$tmp.choiceIndex].getAttribute("colorPrice")=="-1"?"":self.cache.sample[this.$tmp.choiceIndex].getAttribute("colorPrice");
if(exchangeRateDef.enabled&&this.colorPrice){this.colorPriceSecond=self.cache.sample[this.$tmp.choiceIndex].getAttribute("colorPriceSec")=="-1"?"":" / "+self.cache.sample[this.$tmp.choiceIndex].getAttribute("colorPriceSec");
this.$tmp.textContainer.setHTML(self.cache.sample[this.$tmp.choiceIndex].$tmp.label+"<br />"+this.colorPriceChoice+this.colorPriceSecond)
}else{this.$tmp.textContainer.setHTML(self.cache.sample[this.$tmp.choiceIndex].$tmp.label+"<br />"+this.colorPriceChoice)
}}},getSampleAsset:function(tiny){if(!!tiny){return new Element("img",{src:Setup.ImageFolder+tiny,width:25,height:25})
}}});
Configurator.PickerView.implement(new Events);
var connect=function(oEl,sEvType,fn,bCapture){return document.addEventListener?oEl.addEventListener(sEvType,fn,bCapture||false):oEl.attachEvent?oEl.attachEvent("on"+sEvType,fn):false
};
var css={remove:function(oEl,sClass){var rep=oEl.className.match(" "+sClass)?" "+sClass:sClass;
oEl.className=oEl.className.replace(rep,"")
},add:function(oEl,sClass){if(!css.has(oEl,sClass)){oEl.className+=oEl.className?" "+sClass:sClass
}},has:function(oEl,sClass){return new RegExp("\\b"+sClass+"\\b").test(oEl.className)
}};
function setHighLight(){var oConfig=document.getElementById("color-choices");
if(!oConfig){return 
}var aDivs=oConfig.getElementsByTagName("div"),iDiv=aDivs.length,aColorChoices=[];
while(iDiv-->0){if(css.has(aDivs[iDiv],"color-choice")){aColorChoices.push(aDivs[iDiv])
}}var iColorChoice=aColorChoices.length,aExts=[],aInts=[];
while(iColorChoice-->0){var aImgs=aColorChoices[iColorChoice].getElementsByTagName("img"),iImg=aImgs.length;
if(iColorChoice!=aColorChoices.length-1){while(iImg-->0){aInts.push(aImgs[iImg])
}}else{while(iImg-->0){aExts.push(aImgs[iImg])
}}}var oViews=document.getElementById("views");
var iInt=aInts.length;
while(iInt-->0){connect(aInts[iInt],"click",function(){return css.add(oViews,"leftHighLighted")
})
}var iExt=aExts.length;
while(iExt-->0){connect(aExts[iExt],"click",function(){return css.remove(oViews,"leftHighLighted")
})
}}connect(window,"load",function(){return setTimeout(setHighLight,100)
});
Configurator.PickerModel=new Class({initialize:function(datas,template,differ){this.datas=datas;
this.template=$xmlSection(template,"colors");
this.differ=differ;
this.datas.cgs.each(function(cg){$checkIterable(cg,"cg");
cg.cg.each(function(c,index){$checkIterable(c,"c")
})
});
this.zoomCarPicture=datas.extzmimg
},install:function(){this.output=new Template(this.template).render({colorList:this.datas.cgs,aspect:this.datas});
this.fireEvent("onInteriorLoaded",["interior",this.datas.intimg.$,this.datas.intzmimg.$]);
this.fireEvent("onCarLoaded",["car",this.datas.extimg.$,this.datas.extzmimg.$]);
this.fireEvent("onTinyLoaded",[[this.datas.pimgsmpl.$,this.datas.sadimgsmpl.$,this.datas.dashimgsmpl.$]]);
this.fireEvent("onPicturesLoaded",this.output);
this.differ.addEvent("onDiff",function(datas){if(datas.aspect){this.fireEvent("onColorsChangeState",[datas.aspect])
}if(datas.carpicture){this.fireEvent("onCarLoaded",["car",datas.carpicture.normal,datas.carpicture.zoom])
}if(datas.interiorpicture&&datas.interiorpicture.normal.$!=""){this.fireEvent("onInteriorLoaded",["interior",datas.interiorpicture.normal,datas.interiorpicture.zoom])
}if(datas.tinies){this.fireEvent("onTinyLoaded",[datas.tinies])
}}.bind(this))
},calldiff:function(id,selected){this.differ.getDiff(id,selected)
}});
Configurator.PickerModel.implement(new Events);
Configurator.ConfigurationModel=new Class({initialize:function(datas,meta,template,differ){this.base=$("configuration");
this.datas=datas;
this.meta=meta;
this.differ=differ;
this.template=$xmlSection(template,"summary");
this.priceTemplate=$xmlSection(template,"price");
if(this.datas.cblk){$checkIterable(this.datas.cblk.chprefs,"items");
$checkIterable(this.datas.cblk.chopts,"items")
}},install:function(){this.summaryOutput=new Template(this.template).render({summary:this.datas.cblk});
this.fireEvent("onSummaryCreated",this.summaryOutput);
financeParameters.idVehicle=this.meta.modscla.$;
financeParameters.model=this.meta.modfinkey.$;
financeParameters.version=this.meta.verscla.$;
financeParameters.engine=this.meta.modeng.$;
financeParameters.power=this.meta.modpow.$;
this.fireEvent("onPriceCreated",this.datas.pblk);
this.fireEvent("Version has been chosen",this.datas.vblk.vers.$);
this.differ.addEvent("onDiff",function(datas){this.fireEvent("onUpdate",datas.configuration)
}.bind(this))
}});
Configurator.ConfigurationModel.implement(new Events);
Application=new Class({initialize:function(){this.params=this.getParams();
this.requests={};
this.carViewMode="exterior";
this.requests.preferences=Setup.JsonURI+"stepTo="+this.params.To+"&modelKey="+this.params.modelId+"&userPriceType="+(this.params.userPriceType!=undefined?this.params.userPriceType:"")+"&noCache="+Math.random();
this.requests.templates=componentNamespace+"/templates.jsp?modelKey="+this.params.modelId+"&stepTo="+this.params.To
},install:function(){var self=this;
window.addEvent("load",function(){self.viewport=new Configurator.Viewport($("body"),self.params);
self.remote=new Sixtools.Remote(self.requests,{onComplete:function(){self.lastReponses=this.responses;
self.setPrices(this.responses)
},onFailure:function(status,url){self.Stop("Failed on calling initial stream \n\nUrl was : "+url+"\nStatus was "+status,Locale.GeneralError)
}})
});
this.addEvent("onRefreshFragmentAfterInstall",function(){self.setPrices(self.lastReponses)
});
return this
},getParams:function(){var query=window.location.search.substring(1).split("&").map(function(sp){return sp.split("=")
});
this.params=$dict(query,parseInt);
this.params.modelId=modelKey;
this.params.stepTo=currentStep;
this.params.userPriceType=(userPriceType!=undefined?userPriceType:"");
this.params.ecoPreference=ecoPreference;
return{To:$pick(this.params.stepTo,1),modelId:this.params.modelId,userPriceType:this.params.userPriceType,ecoPreference:this.params.ecoPreference}
},Start:function(responses){var datastore=new Configurator.Datastore(responses);
var diffFactory=new Configurator.DiffFactory(this.viewport);
this.db=datastore.preferences.view;
this.tmp=datastore.templates;
this.viewsLoaded=0;
if(this.getInitialState()==true){this.preferences={model:new Configurator.PreferencesModel(this.db.cgs,this.db.meta,this.tmp,diffFactory,this.params,this)};
this.preferences.view=new Configurator.PreferencesView(this.preferences.model,this.viewport);
this.picker={model:new Configurator.PickerModel(this.db.aspect,this.tmp,diffFactory,this)};
this.picker.view=new Configurator.PickerView(this.picker.model,this.viewport);
this.configuration={model:new Configurator.ConfigurationModel(this.db.bks,this.db.meta,this.tmp,diffFactory,this)};
this.configuration.view=new Configurator.ConfigurationView(this.configuration.model,this.viewport);
this.preferences.view.addEvent("loaded",this.addViewLoaded.bind(this,"preferences"));
this.picker.view.addEvent("loaded",this.addViewLoaded.bind(this,"picked"));
this.webform=new Configurator.Webform(this.db.wfp,diffFactory);
this.preferences.model.install();
this.picker.model.install();
this.configuration.model.install();
this.webform.install()
}else{var debug="Failed on getting intial application state!\n\nMissing one of 'cgs' or 'bks', or 'aspect' in stream\n\n"+["cgs","aspect","bks"].map(function(key){return key+" : "+this.db[key]
},this).join("\n");
return this.Stop(debug,Locale.GeneralError)
}this.viewport.fireEvent("loaded")
},Stop:function(debugError,uiError){if(window.console&&window.console.error){console.error(debugError)
}new Configurator.ApplicationError(new Element("div",{"class":"errorContainer"}),uiError,true);
$("main").effect("opacity").start(0)
},getInitialState:function(){if(this.db.aspect==undefined){return false
}else{return true
}return true
},addViewLoaded:function(name){this.viewsLoaded++;
if(this.viewsLoaded==2){this.fireEvent("everythingIsLoaded")
}},getConfigurationView:function(){return this.configuration.view
},setSecondPrice:function(objPrices,isCS){var self=this;
var jsonData=objPrices.preferences.text?Json.evaluate(objPrices.preferences.text):objPrices.preferences;
if(isCS){if(jsonData.view.bks.pblk.pp.$.toFloat()>0){jsonData.view.bks.pblk.fmp.$=objPrices.preferences.view.bks.pblk.fmp.$;
jsonData.view.bks.pblk.fpp.$=objPrices.preferences.view.bks.pblk.fpp.$
}else{jsonData.view.bks.pblk.fmp.$=objPrices.preferences.view.bks.pblk.fmp.$
}jsonData.view.bks.cblk.chcs=objPrices.preferences.view.bks.cblk.chcs
}this.aP=[];
this.explorePrice(jsonData);
new Sixtools.remotePrice(this.aP,function(newPrices){self.mergePrices(newPrices,jsonData);
objPrices.preferences=jsonData;
self.Start(objPrices)
})
},explorePrice:function(data){for(key in data){if(key=="p"||key=="pntp"||key=="fpp"||key=="fmp"||key=="pntfp"||key=="fpam"||key=="pp"||key=="mp"){if(!!data[key].$.toString().match(/,/)){data[key].$=data[key].$.toString().replace(".","")
}else{data[key].$=data[key].$.toString().replace(".",",")
}this.aP.push(data[key].$)
}else{if(typeof data[key]!="function"&&typeof data[key]!="string"&&typeof data[key]!="number"){this.explorePrice(data[key])
}}}},mergePrices:function(aPrices,data){for(key in data){if(key=="p"||key=="pntp"||key=="fpp"||key=="fmp"||key=="pntfp"||key=="fpam"||key=="pp"||key=="mp"){data[key+"Sec"]={"$":aPrices[0]};
aPrices.shift()
}else{if(typeof data[key]!="function"&&typeof data[key]!="string"&&typeof data[key]!="number"){this.mergePrices(aPrices,data[key])
}}}},setPrices:function(data){var self=this;
if($("nameContrat")&&$("priceContrat")){var dataSet;
self.setCSPrices(data,function(values){dataSet=values;
if(exchangeRateDef.enabled){self.setSecondPrice(dataSet,true)
}else{self.Start(dataSet)
}})
}else{if(exchangeRateDef.enabled){self.setSecondPrice(data)
}else{self.Start(data)
}}},setCSPrices:function(incomingData,callback){var self=this;
var jsonData=incomingData&&incomingData.preferences.text?Json.evaluate(incomingData.preferences.text):incomingData.preferences;
var labelCS=$("nameContrat").getText();
var fPriceCS=$("yearlyPriceToDisplay").value;
var priceCS=parseFloat($("yearlyPrice").value);
jsonData.view.bks.cblk.chcs={lab:{$:labelCS},p:{$:priceCS},fp:{$:fPriceCS}};
this.addEvent("onPriceFormatUpdate",function(data){incomingData.preferences.view=data.view;
callback(incomingData)
});
price=jsonData.view.bks.pblk.mp.$.toFloat()+priceCS.toFloat();
price=price.toString().replace(/\./,",");
jsonData.view.bks.pblk.mp.$=jsonData.view.bks.pblk.mp.$.toFloat()+priceCS.toFloat();
if(jsonData.view.bks.pblk.pp.$.toFloat()>0){pricePromo=jsonData.view.bks.pblk.pp.$.toFloat()+priceCS.toFloat();
pricePromo=pricePromo.toString().replace(/\./,",");
new Sixtools.remotePrice([price,pricePromo],function(response){jsonData.view.bks.pblk.fmp.$=response[0];
jsonData.view.bks.pblk.fpp.$=response[1];
if(suffixe){jsonData.view.bks.pblk.fpp.$+=" "+suffixe;
jsonData.view.bks.pblk.fmp.$+=" "+suffixe
}self.fireEvent("onPriceFormatUpdate",jsonData)
},true)
}else{new Sixtools.remotePrice([price],function(response){jsonData.view.bks.pblk.fmp.$=response[0];
if(suffixe){jsonData.view.bks.pblk.fmp.$+=" "+suffixe
}self.fireEvent("onPriceFormatUpdate",jsonData)
},true)
}}});
Application.implement(new Events);
var App=new Application().install();
Configurator.Viewport=new Class({initialize:function(base,params){this.base=base;
this.params=params;
this.leftPane=this.base.getElement("#leftColumn");
this.rightPane=this.base.getElement("#rightColumn");
this.versionLabel=this.base.getElement(".titleProduct").getFirst();
this.stepHeadings=this.leftPane.getElement("ul.stepHeading");
this.stepButtons=this.leftPane.getElements("ul.steps").getElements("li");
this.url=null;
this.loader=new Sixtools.Loader($("loading").injectInside(document.body).setStyles({display:"block",visibility:"hidden"}));
this.install()
},install:function(){this.addEvent("loaded",function(){this.loader.hide()
}.bind(this));
if(this.params.To==2){$$([this.stepButtons[0][1],this.stepButtons[1][1]],this.stepHeadings.getChildren()[2]).removeEvents("click").addEvent("click",function(e){new Event(e).stop();
this.fireEvent("toStep3")
}.bind(this))
}},computeUrl:function(stepTo){return"?stepTo="+stepTo+"&modelKey="+this.params.modelId+"&userPriceType="+(this.params.userPriceType!=undefined?this.params.userPriceType:"")
},setUrl:function(url){window.location.assign(url)
}});
Configurator.Viewport.implement(new Events);
Sixtools.Layer=new Class({options:{showCloseCross:true},initialize:function(over,content,options){this.over=over;
this.content=content;
this.closer=new Element("div",{"class":"closer"}).setText(Locale.Close);
this.container=new Element("div").setStyles({opacity:"0",position:"absolute",background:"#fff","z-index":"10001",padding:"15px",top:"0",overflow:"hidden"}).addClass("popsConfig").injectInside(document.body);
this.background=this.container.clone().setStyles({background:"#ddd","z-index":"10000",padding:0,display:"none"}).removeClass("popsConfig").injectInside(document.body);
this.container.adopt($$(this.closer,content));
this.setOptions(options);
var aClosers=document.getElements(".closer"),iCloser=aClosers.length;
while(iCloser-->0){aClosers[iCloser].addEvent("click",function(e){this.hide();
return new Event(e).stop()
}.bind(this))
}if(this.options.showCloseCross){this.closer.setStyle("display","block")
}else{this.closer.setStyle("display","none")
}window.addEvent("resize",this.updatePosition.bind(this))
},updatePosition:function(){var coordinates=this.getBackgroundSize();
$$(this.content).filterByTag("iframe").addClass("iframeContent").setStyle("display","block");
this.posX=window.getScrollLeft()+window.getWidth()/2-this.container.getSize().size.x/2;
this.posY=window.getScrollTop()+window.getHeight()/2-this.container.getSize().size.y/2;
this.posY=this.controlMinYPosition(this.posY);
this.background.setStyles(coordinates);
this.container.setStyles({left:this.posX,top:this.posY})
},controlMinYPosition:function(position){if(position<0){return 0
}else{return position
}},show:function(){this.updatePosition();
this.background.effect("opacity",{onStart:function(){this.background.setStyle("display","block");
$E("body").setStyle("overflow-x","hidden");
$E("html").setStyle("overflow-x","hidden")
}.bind(this)}).start(0.7);
this.container.effect("opacity").start(1)
},hide:function(){this.background.effect("opacity",{onComplete:function(){this.background.setStyle("display","none");
$E("body").setStyle("overflow-x","visible");
$E("html").setStyle("overflow-x","visible")
}.bind(this)}).start(0);
this.container.effect("opacity").start(0)
},getTopOffset:function(){return(this.over==window)?getScrollTop():0
},getBackgroundSize:function(){var coordinates={};
if(this.over==window){coordinates.width=window.getScrollWidth();
coordinates.height=window.getScrollHeight();
coordinates.top=0;
coordinates.left=0
}else{coordinates=this.over.getCoordinates()
}return coordinates
}});
Sixtools.Layer.implement(new Options,new Events);
Sixtools.Loader=new Class({initialize:function(loader){this.loader=loader;
this.updatePosition();
this.fade=new Fx.Style(this.loader,"opacity");
window.addEvent("scroll",this.updatePosition.bind(this));
window.addEvent("resize",this.updatePosition.bind(this))
},updatePosition:function(){this.loader.setStyles(this.computePosition())
},computePosition:function(){return{top:(window.getScrollTop()+window.getHeight()/2)-this.loader.getSize().size.y/2,left:(window.getScrollLeft()+window.getWidth()/2)-this.loader.getSize().size.x/2}
},show:function(){this.fade.set(1)
},hide:function(){this.fade.start(0)
}});
Sixtools.Checkbox=new Class({options:{checkboxStyles:{width:13,height:13,background:'url("/css/skin/checkbox.png")'}},initialize:function(checkbox,options){this.setOptions(options);
this.base=checkbox.clone();
this.element=new Element("div",{styles:this.options.checkboxStyles});
this.checked=!!checkbox.getAttribute("checked");
this.disabled=!!checkbox.getAttribute("disabled");
this.backgroundPosition={checked:{"true":"bottom","false":"top"},disabled:{"true":"right","false":"left"}};
this.sizeLayout={checked:{"true":"17px","false":"13px"}};
this.marginLayout={checked:{"true":"-4px","false":"0"}};
this.element.adopt(this.base.setStyle("display","none"));
checkbox.replaceWith(this.element);
this.setBackgroundPosition();
this.element.$tmp.widget=this
},addClickCallback:function(fn){this.element.addEvent("click",function(){if(!this.element.getParent().className.match(/\bIMPLIED\b/)){App.carViewMode="exterior";
this.setChecked(!this.getChecked());
fn()
}}.bind(this))
},setChecked:function(value){this.checked=value;
this.setBackgroundPosition();
return this
},getChecked:function(){return this.checked
},setDisabled:function(value){this.disabled=value;
this.setBackgroundPosition();
return this
},getDisabled:function(){return this.disabled
},setBackgroundPosition:function(){this.element.setStyles({"background-position":[this.backgroundPosition.checked[this.getChecked()],this.backgroundPosition.disabled[this.getDisabled()]].join(" "),height:this.sizeLayout.checked[this.getChecked()],width:this.sizeLayout.checked[this.getChecked()],"margin-top":this.marginLayout.checked[this.getChecked()],"margin-right":this.marginLayout.checked[this.getChecked()]})
}});
Sixtools.Checkbox.implement(new Events,new Options);
function $hashJoin(obj,kvsep,sep,filter){kvsep=$pick(kvsep,":");
sep=$pick(sep,",");
filter=$pick(filter,function(a){return a
});
var ret="";
for(key in obj){ret+=filter(key)+kvsep+filter(obj[key])+sep
}return ret.slice(0,ret.length-sep.length)
}function $xmlSection(xml,section){if(xml.nodeName=="xml"||xml.nodeType==3){xml=xml.nextSibling
}var node=xml.getElementsByTagName(section)[0];
return node&&(node.text||node.textContent)
}function $dict(arr,fun){var d={};
fun=$pick(fun,function(x){return x
});
arr.each(function(item){d[item[0]]=fun(item[1])
});
return d
}function $checkIterable(obj,key){if(obj&&$type(obj[key])!="array"&&obj[key]!=undefined){obj[key]=[obj[key]]
}return obj
}function pngTrans(elm){if(/MSIE [56]/.test(navigator.userAgent)){var imgurl=elm.currentStyle.backgroundImage.match(/url\((.*)\)/);
if(imgurl){imgurl=imgurl[1].replace(/[\"\']/g,"");
elm.style.backgroundImage="none";
elm.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',src='"+imgurl+"')"
}else{elm.style.filter=" "
}}else{elm.style.filter=" "
}};
Sixtools.Remote=new Class({initialize:function(callable,options){this.succeed=0;
this.responses={};
this.callable=new Hash(callable);
this.setOptions(options);
this.send()
},send:function(){this.callable.each(function(url,name){var xhr=new Ajax(url,{method:"get"});
xhr.addEvent("onFailure",function(request){this.fireEvent("onFailure",[request.status,url])
}.bind(this));
xhr.addEvent("onSuccess",this.setSucceed.bind(this,[name,xhr]));
xhr.request()
},this)
},setSucceed:function(name,xhr){this.responses[name]=xhr.response;
this.succeed+=1;
if(this.succeed==this.callable.length){this.fireEvent("onComplete")
}},retry:function(){this.succeed=0;
this.send()
}});
Sixtools.Remote.implement(new Options,new Events);
Sixtools.remotePrice=new Class({initialize:function(parameters,callBack,onlyFormat,url){this.parameters=parameters;
this.callBack=callBack?callBack:null;
this.urlParams="?json=true&";
this.url=url?url:((onlyFormat)?"/includes/format_price.jsp":"/includes/conversion_price.jsp");
this.not=[];
if(typeof parameters=="string"||typeof parameters=="number"){this.urlParams+="prices="+parameters
}else{for(var i=0;
i<parameters.length;
i++){if(!!!parameters[i]||parameters[i]==-1){this.not.push(i);
parameters[i]=0
}var sanitized=parameters[i].toString().replace("%","").replace(".","");
this.urlParams+="prices="+sanitized+"&"
}}this.send()
},send:function(){var _this=this;
new Ajax(this.url+this.urlParams,{method:"get",onComplete:function(response){var response=eval(response);
for(var i=0;
i<_this.not.length;
i++){response[_this.not[i]]=null
}if(_this.callBack){_this.callBack(response)
}},onFailure:function(){var paramError=[];
$A(_this.parameters).each(function(param){paramError.push(param+"_secPriceError")
});
if(_this.callBack){_this.callBack(paramError)
}}}).request()
}});
Sixtools.LazyCruncher=new Class({options:{interval:300,chunckSize:10},initialize:function(options){this.setOptions(options);
this.todo=[];
this.done=0;
this.crunchTimer=null;
this.resumeTimer=null;
this.paused=false;
window.addEvent("unload",function(){$clear(this.crunchTimer);
$clear(this.resumeTimer)
}.bind(this))
},push:function(callback){this.queued=this.todo.push(callback);
if(!this.crunchTimer&&!this.paused){this.crunchTimer=this.crunch.delay(this.options.interval,this)
}},pause:function(duration){$clear(this.crunchTimer);
$clear(this.resumeTimer);
this.paused=true;
if(duration){this.resumeTimer=this.resume.delay(duration,this)
}return this
},resume:function(){$clear(this.resumeTimer);
if(this.paused&&this.todo.length&&!this.crunchTimer){this.paused=false;
this.crunchTimer=this.crunch.delay(this.options.interval,this)
}},crunch:function(){this.todo.splice(0,this.options.chunckSize).each(function(func){func();
this.done++;
if(this.queued==this.done){this.fireEvent("Crunched")
}}.bind(this));
this.crunchTimer=null;
if(this.todo.length){this.crunchTimer=this.crunch.delay(this.options.interval,this)
}}});
Sixtools.LazyCruncher.implement(new Options,new Events);
Sixtools.FlashObject=new Class({initialize:function(file,options,flashvars,target){options=$pick(options,{});
flashvars=$pick(flashvars,{});
var escapedVars=$hashJoin(flashvars,"=","&",escape);
if($defined(window.ie)||$defined(window.opera)){var obj=document.createElement("object");
options.movie=file;
options.flashvars=escapedVars;
for(var item in options){if(!["width","height","id"].contains(item)){obj.appendChild(new Element("param",{name:item,value:options[item]}))
}}}else{var obj=document.createElement("embed");
obj.setAttribute("type","application/x-shockwave-flash");
for(var item in options){obj.setAttribute(item,options[item])
}obj.setAttribute("src",file);
obj.setAttribute("FlashVars",escapedVars)
}target.innerHTML="";
target.appendChild(obj);
if($defined(window.ie)||$defined(window.opera)){obj.setAttribute("classid","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
for(var item in options){if(["width","height","id"].contains(item)){obj.setAttribute(item,options[item])
}}}return target.firstChild
}});
if(!window.console){window.console=null
}var Template=function(){var TOKENTYPES={COMMENT:1,ECHO:2,DIRECTIVE:3};
var TOKENTYPE_IDENTIFIERS={"#":TOKENTYPES.COMMENT,"{":TOKENTYPES.ECHO,"}":TOKENTYPES.ECHO,"%":TOKENTYPES.DIRECTIVE};
function fold(iterable,fun,init){var acc=init;
for(var i=0;
i<iterable.length;
++i){acc=fun(acc,iterable[i])
}return acc
}function foldl1(iterable,fun){var acc=iterable[0];
for(var i=1;
i<iterable.length;
++i){acc=fun(acc,iterable[i])
}return acc
}var IDENTIFIER="[a-zA-Z_\\$][\\w\\$]*";
var ITEM="[\\w\\$]+";
var FILTER_PREFIX="\\s*\\|\\s*";
var NUMBER="\\d+(?:\\.\\d+)?";
var NUMBER_MATCHER=new RegExp("^"+NUMBER+"$");
var QUOTE_STRING="'[^']+'";
var DQUOTE_STRING='"[^"]+"';
var LITTERAL="(?:"+NUMBER+"|"+QUOTE_STRING+"|"+DQUOTE_STRING+")";
var LITTERAL_MATCHER=new RegExp("^"+LITTERAL+"$");
var FILTER_ARGUMENT="(?:\\s+"+LITTERAL+")?";
var FILTER=IDENTIFIER+FILTER_ARGUMENT;
var FILTERS="(?:"+FILTER_PREFIX+FILTER+")+";
var FILTERS_COLLECTION="("+FILTERS+")?";
var OBJECT=function(){var path="("+IDENTIFIER+"(?:\\."+ITEM+")*)";
var object=path+FILTERS_COLLECTION;
return object
}();
OBJECT="("+LITTERAL+"|"+OBJECT+")";
var NEG_OBJECT="(not\\s+)?(?:"+OBJECT+")";
var OR_PATH=NEG_OBJECT+"(?:\\s+or\\s+"+NEG_OBJECT+")*";
var AND_PATH=NEG_OBJECT+"(?:\\s+and\\s+"+NEG_OBJECT+")*";
var BOOLEAN_OPS="\\s?(==?|!=|<=?|>=?)\\s?";
var BOOLEAN_COMPS=OBJECT+BOOLEAN_OPS+OBJECT;
var TOKENS_MATCHERS={COMMENT:/^{#\s*(.*?)\s*#}$/,ECHO:new RegExp("^\\{\\{\\s*"+OBJECT+"\\s*\\}\\}$"),DIRECTIVE_START:/^{%\s*(.+?)\s+(.*?)\s*%}$/,DIRECTIVE_END:/^{%\s*end(\w+)\s*%}$/,DIRECTIVES:{FOR:new RegExp("^{%\\s*for ("+IDENTIFIER+") in "+OBJECT+"\\s*%}$"),IF:new RegExp("^{%\\s*if ("+OR_PATH+"|"+AND_PATH+"|"+BOOLEAN_COMPS+")\\s*%}$"),FILTER:new RegExp("^{%\\s*filter ("+FILTER+FILTERS_COLLECTION+")\\s*%}$"),WITH:new RegExp("^{%\\s*with "+OBJECT+" as ("+IDENTIFIER+")\\s*%}$"),FIRSTOF:new RegExp("^{%\\s*firstof ((?:"+OBJECT+"\\s*)+)\\s*%}$")}};
var PARSERS={"for":function(tokens,current_index,m){var v=m[1];
var iterable=m.slice(-2);
var ret=parse(tokens,"for",current_index+1);
var new_index=ret[0];
var body=new Template();
body.tmpl=ret[1];
return[new_index,new For(v,iterable,body)]
},"if":function(tokens,current_index,m){var cond=m[1];
var ret=parse(tokens,"if",current_index+1);
var new_index=ret[0];
var elseIndex=ret[1].indexOf("{% else %}");
var body=new Template();
var elseBody=null;
if(elseIndex===-1){body.tmpl=ret[1]
}else{elseBody=new Template();
body.tmpl=ret[1].slice(0,elseIndex);
elseBody.tmpl=ret[1].slice(elseIndex+1)
}return[new_index,new If(cond,body,elseBody)]
},"else":function(tokens,current_index){return[current_index,"{% else %}"]
},filter:function(tokens,current_index,m){var parsed_filters=parseFilters(m[1]);
var ret=parse(tokens,"filter",current_index+1);
var new_index=ret[0];
var body=new Template();
body.tmpl=ret[1];
return[new_index,new Filter(parsed_filters,body)]
},"with":function(tokens,current_index,m){var path=[m[2]||m[1],m[3]];
var alias=m[4];
var ret=parse(tokens,"with",current_index+1);
var new_index=ret[0];
var body=new Template();
body.tmpl=ret[1];
return[new_index,new With(alias,path,body)]
},firstof:function(tokens,current_index,m){var OBJECT_MATCHER=new RegExp("^"+OBJECT);
var items_string=m[1];
var items=[];
while(items_string){var n=OBJECT_MATCHER.exec(items_string);
items.push([n[2]||n[1],n[3]]);
items_string=items_string.slice(n[0].length+1)
}return[current_index,new FirstOf(items)]
}};
var jsdt={filters:{add:function(val,arg){return parseFloat(val)+parseFloat(arg)
},capfirst:function(val){return val.charAt(0).toUpperCase()+val.slice(1)
},capitalize:function(val){return val.charAt(0).toUpperCase()+val.slice(1).toLowerCase()
},"default":function(val,arg){return val||arg
},default_if_null:function(val,arg){return(val!==null)?val:arg
},divisibleby:function(val,arg){return 0===(parseFloat(val)%parseFloat(arg))
},escape:function(val){return val.replace(/("|')/g,function(a,b){switch(b){case"'":return"&#39;";
break;
case'"':return"&#34";
break
}})
},first:function(val){return val[0]||val.charAt(0)
},id:function(item){return item
},join:function(val,arg){return val.join(arg)
},length:function(val){return val.length
},length_is:function(val,arg){return(val.length===parseFloat(arg))
},lower:function(str){return str.toLowerCase()
},upper:function(str){return str.toUpperCase()
}}};
function addFilter(name,fun){jsdt.filters[name]=fun
}function removeFilter(name){jsdt.filters[name]=null
}function dict(o){this.items=o||{};
this.parent=null
}dict.prototype.get=function(key){var result=this.items[key];
if(null==result&&this.parent){return this.parent.get(key)
}return result
};
dict.prototype.set=function(key,value){var d=new dict();
d.parent=this;
d.items[key]=value;
return d
};
function tokenize(tmpl){var tokens=[];
var currentToken=[];
var len=tmpl.length;
for(var i=0;
i<len;
++i){if(tmpl.charAt(i)==="{"){if(TOKENTYPE_IDENTIFIERS[tmpl.charAt(i+1)]){tokens.push(currentToken.join(""));
currentToken=[]
}}currentToken.push(tmpl.charAt(i));
if(tmpl.charAt(i)==="}"){if(TOKENTYPE_IDENTIFIERS[tmpl.charAt(i-1)]){tokens.push(currentToken.join(""));
currentToken=[]
}}}if(currentToken.length){tokens.push(currentToken.join(""))
}return tokens
}function parse_directive(tokens,index,directive_name){var token=tokens[index];
var matcher=TOKENS_MATCHERS.DIRECTIVES[directive_name.toUpperCase()];
if(matcher){return PARSERS[directive_name](tokens,index,matcher.exec(token))
}else{return PARSERS[directive_name](tokens,index)
}}function parse(tokens,current_directive,token_index){var parseTree=[];
for(var i=token_index||0,len=tokens.length;
i<len;
++i){var token=tokens[i];
if(TOKENS_MATCHERS.COMMENT.exec(token)){}else{if(TOKENS_MATCHERS.ECHO.exec(token)){var echo_match=TOKENS_MATCHERS.ECHO.exec(token);
parseTree.push(new Echo([echo_match[2]||echo_match[1],echo_match[3]]))
}else{if(TOKENS_MATCHERS.DIRECTIVE_END.exec(token)){var directive_name=TOKENS_MATCHERS.DIRECTIVE_END.exec(token)[1];
if(directive_name!==current_directive){throw new SyntaxError("Closure of directive <<"+current_directive+">> was expected, got closure for directive <<"+directive_name+">> instead.")
}else{return[i,parseTree]
}}else{if(TOKENS_MATCHERS.DIRECTIVE_START.exec(token)){var m=TOKENS_MATCHERS.DIRECTIVE_START.exec(token);
var directive_name=m[1];
var out=parse_directive(tokens,i,directive_name);
i=out[0];
parseTree.push(out[1])
}else{parseTree.push(new Text(token))
}}}}}return parseTree
}function parseFilters(fs){if(!fs){return[]
}var flist=fs.replace(/^\s*\|\s*/,"").split(/\s*\|\s*/);
var filter_matcher=new RegExp("^("+IDENTIFIER+")(?:\\s+(\\d+|'[^']+'|\"[^\"]+\"))?$");
var resolved_filters=[];
for(var i=0;
i<flist.length;
++i){var fstring=flist[i];
if(filter_matcher.test(fstring)){var filter_parts=filter_matcher.exec(fstring).slice(-2);
var filter_name=filter_parts[0];
var filter_arg=filter_parts[1];
resolved_filters.push([jsdt.filters[filter_name],filter_arg&&filter_arg.replace(/[\'\"]/g,"")])
}}return resolved_filters
}function lookup(item,kwargs){if(LITTERAL_MATCHER.test(item[0])){var val=item[0];
if(NUMBER_MATCHER.test(val)){return parseFloat(val)
}else{return val.slice(1,-1)
}}var path=item[0].split(".");
var o=kwargs;
for(var i=0,len=path.length;
o&&i<len;
++i){var nextO=(o.get?o.get(path[i]):o[path[i]]);
if(nextO&&!!nextO.apply){o=nextO()
}else{o=nextO
}}if(item[1]){var filters=item[1];
for(var j=0;
j<filters.length;
++j){var filter_func=filters[j][0];
var filter_arg=filters[j][1];
o=filter_func(o,filter_arg)
}return o
}else{return o
}}function Template(ts){if(ts){this.tmpl=parse(tokenize(ts))
}}Template.prototype.render=function(kwargs){kwargs=kwargs.get?kwargs:new dict(kwargs);
var len=this.tmpl.length;
var out=[];
for(var i=0;
i<len;
++i){out.push(this.tmpl[i].render(kwargs))
}return out.join("")
};
function Text(data){this.data=data
}Text.prototype.toString=function(){return this.data
};
Text.prototype.render=function(){return this.data
};
function Echo(path){this.path=[path[0],parseFilters(path[1])]
}Echo.prototype.toString=function(){return"{{ "+this.path+" }}"
};
Echo.prototype.render=function(kwargs){return lookup(this.path,kwargs)
};
function For(varname,iterable,body){this.varname=varname;
this.iterable=[iterable[0],parseFilters(iterable[1])];
this.body=body
}For.prototype.toString=function(){return"{% for "+this.varname+" in "+this.iterablePath+" %}"
};
For.prototype.render=function(kwargs){function length(o){var len=0;
for(var key in o){++len
}return len
}try{var iterable=lookup(this.iterable,kwargs)
}catch(e){var iterable=[]
}var output=[];
var name=this.varname;
if(iterable.length){for(var i=0,len=iterable.length;
i<len;
++i){var kw=kwargs.set(name,iterable[i]);
kw.items.forloop={length:len,key:i,counter:i,counter1:i+1,first:(i===0),last:(i===len-1),revcounter:(len-i+1),revcounter1:(len-i),parentloop:(kwargs.get("forloop"))};
output.push(this.body.render(kw))
}}else{var len=length(iterable);
var i=0;
for(var key in iterable){var kw=kwargs.set(name,iterable[key]);
kw.items.forloop={length:len,key:key,counter:i,counter1:i+1,first:(i===0),last:(i===len-1),revcounter:(len-i+1),revcounter1:(len-i),parentloop:(kwargs.get("forloop"))};
i++;
output.push(this.body.render(kw))
}}return output.join("")
};
function If(condition,body,elseBody){this.parseCondition(condition);
this.body=body;
this.elseBody=elseBody
}If.prototype.parseCondition=function(condition){function make_path(p,litteral){return[p[0]||litteral,parseFilters(p[1])]
}var re_or=new RegExp("^"+OR_PATH+"$");
var re_and=new RegExp("^"+AND_PATH+"$");
var re_bool=new RegExp("^"+BOOLEAN_COMPS+"$");
var re_neg=new RegExp(NEG_OBJECT);
var not=function(e){return !e
};
var id=function(e){return !!e
};
this.conditions=[];
if(re_or.test(condition)){this.conditions.or=true;
this.conditions.and=false;
while(re_neg.test(condition)){var m=re_neg.exec(condition);
this.conditions.push({fn:(m[1]?not:id),path:make_path(m.slice(3),m[2])});
condition=condition.slice(m[0].length+4)
}}else{if(re_and.test(condition)){this.conditions.and=true;
this.conditions.or=false;
while(re_neg.test(condition)){var m=re_neg.exec(condition);
this.conditions.push({fn:(m[1]?not:id),path:make_path(m.slice(3))});
condition=condition.slice(m[0].length+5)
}}else{if(re_bool.test(condition)){this.conditions.and=false;
this.conditions.or=false;
var m=re_bool.exec(condition);
var comparators=function(){function eq(a,b){return a===b
}function neq(a,b){return a!==b
}function sup(a,b){return a>b
}function seq(a,b){return a>=b
}function inf(a,b){return a<b
}function ieq(a,b){return a<=b
}return{"=":eq,"==":eq,"!=":neq,">":sup,">=":seq,"<":inf,"<=":ieq}
}();
this.conditions.comparator=comparators[m[4]];
this.conditions.path1=make_path(m.slice(2,4),m[1]);
this.conditions.path2=make_path(m.slice(6),m[5])
}else{throw new SyntaxError("Incorrect condition syntax for condition <<"+condition+">>, template parsing failure")
}}}};
If.prototype.render=function(kwargs){var cond=null;
try{if(this.conditions.or){cond=fold(this.conditions,function(acc,cond){return acc||cond.fn(lookup(cond.path,kwargs))
},false)
}else{if(this.conditions.and){cond=fold(this.conditions,function(acc,cond){return acc&&cond.fn(lookup(cond.path,kwargs))
},true)
}else{cond=this.conditions.comparator(lookup(this.conditions.path1,kwargs),lookup(this.conditions.path2,kwargs))
}}}catch(e){if(console&&console.debug){console.debug(e)
}cond=null
}if(cond){return this.body.render(kwargs)
}else{if(this.elseBody){return this.elseBody.render(kwargs)
}else{return""
}}};
function Filter(filters,body){this.filters=filters;
this.body=body
}Filter.prototype.toString=function(){return"Filter"
};
Filter.prototype.render=function(kwargs){var out=this.body.render(kwargs);
for(var j=0;
j<this.filters.length;
++j){var filter_func=this.filters[j][0];
var filter_arg=this.filters[j][1];
out=filter_func(out,filter_arg)
}return out
};
function With(alias,path,body){this.alias=alias;
this.path=[path[0],parseFilters(path[1])];
this.body=body
}With.prototype.toString=function(){return"{% with "+this.path[0]+(this.path[1]||"")+" as "+this.alias+"%}"
};
With.prototype.render=function(kwargs){var item=lookup(this.path,kwargs);
return this.body.render(kwargs.set(this.alias,item))
};
function FirstOf(items){this.items=this.convertItems(items)
}FirstOf.prototype.convertItems=function(items){var out=[];
for(var i=0;
i<items.length;
++i){var item=items[i];
out.push([item[0],parseFilters(item[1])])
}return out
};
FirstOf.prototype.render=function(kwargs){var c=null;
for(var i=0;
i<this.items.length;
++i){c=lookup(this.items[i],kwargs);
if(c){return c
}}return""
};
return Template
}();
