var bc=Class.create();bc.prototype={ab:{},d:{},ai:{},contentArea:'',templates:{printSection:'',printPicture:'',printProduct:'',printOrderInfo:'',orderOption:'',orderOptionItem:''},cM:0,initialize:function(l){o(this.templates,'Basket');this.cb();this.bX();this.contentArea=l.contentArea;this.m();this.cN();},cN:function(){var cK=JSONstring.toObject(aq.get('OrderOptions','listOptions'));var cI=JSONstring.toObject(aq.get('OrderOptions','listOptionItems'));this.cM=$A(cK).size();var cJ='';var i=0;for(i=0;i<this.cM;i++){var cL='';for(j=0;j<$A(cI[i]).size();j++){cL+=this.templates.orderOptionItem.evaluate({orderOptionItemId:cI[i][j],selectedText:(j==0)?'selected':''});}cJ+=this.templates.orderOption.evaluate({orderOptionId:'orderOption_'+i,label:cK[i],orderOptionItems:cL});}$('Basket_orderOptions').innerHTML=cJ;var i=0;for(i=0;i<this.cM;i++){new Autocompleter.SelectBox('orderOption_'+i);}},aE:function(item){var key=this.aI(item.pictureId,item.f);this.ab[key]=item;this.aM();},aN:function(aO){if(!U(aO)){var key=this.aI(aO.pictureId,aO.f);}else{var key=aO;}var ab=$H(this.ab);ab.remove(key);this.ab=ab;this.aM();},clear:function(item){this.ab={};this.d={};this.aM();},getItem:function(key){return this.ab[key];},m:function(){Event.observe('Basket_submitButtonPaypal','click',function(ev){Event.stop(ev);this.aM();$('Basket_submitFormBasket').value=JSONstring.make(this.d);$('Basket_submitFormAppConfig').value=JSONstring.make(moConfigData);$('Basket_submitFormInstanceInfo').value=JSONstring.make(moInstanceInfo);if($H(this.ab).values().size()==0){aB.show({error:true,type:'error',caption:'Payment...',text:'Your Basket is empty.'});return;}$('Basket_submitFormData').value=this.by();var aa=this.bH();if(!aa.error){aB.show({type:'yesno',yesText:'Continue',noText:'Back',caption:'Start payment process...',text:'You are going to be redirected to the payment screen. Please follow the instructions.',onYes:function(){catchExitEvent=false;$('Basket_submitForm').submit();},onNo:function(){}});}else{aB.show(aa);}}.bindAsEventListener(this));},bH:function(){var aa={error:true,type:'error',caption:'Payment...',text:'Please fill all required information to continue with your order.'};if(this.ai.name==''||this.ai.addressLine1==''||this.ai.zip==''||this.ai.country==''||this.ai.phone==''||this.ai.email=='')return aa;return{error:false};},by:function(){document.getElementsByClassName('Basket_input',this.contentArea).each(function(el){this.ai[el.name]=$F(el);}.bindAsEventListener(this));for(i=0;i<this.cM;i++){this.ai['orderOption_'+i]=$F('orderOption_'+i+'_combo');}return w('FormData',this.ai);},bX:function(){this.ai=C('FormData');if($H(this.ai).keys().size()==0)return;document.getElementsByClassName('Basket_input',this.contentArea).each(function(el){el.value=this.ai[el.name];}.bindAsEventListener(this));},ci:function(cl,ce){var s;var an='';var nettTotal=0;$A(cl).each(function(el){if(!P(el)){s={key:ce,description:el.productName,price:g(el.pricePerUnit),qty:el.quantity,cost:g(el.pricePerUnit*el.quantity)};an+=this.templates.printProduct.evaluate(s);nettTotal+=el.pricePerUnit*el.quantity;}}.bindAsEventListener(this));return{html:an,nettTotal:nettTotal};},aU:function(){if($H(this.ab).values().size()==0){this.cB();return;}var az=$H(this.cA());var nettTotal=0;var bz='';var bv='';az.each(function(el){var aY=this.ci(el.value,el.key);nettTotal+=aY.nettTotal;var as=new ay(el.key,'id');bz+=this.templates.printPicture.evaluate({src:as.bp(),pictureId:as.au(),productInfo:aY.html});bv+=this.templates.printPicture.evaluate({src:B()+as.bp(),pictureId:as.au(),productInfo:aY.html});}.bindAsEventListener(this));this.d.nettTotal=nettTotal;this.d.shippingCost=aq.get('Prices','shippingCost');this.d.taxAmount=this.d.nettTotal*Number(aq.get("Prices","taxPct"))/100;var aZ;if(aq.get("Prices","taxApplied")=='true')aZ='(inc. Tax)';var total=Number(nettTotal)+Number(this.d.shippingCost)+Number(this.d.taxAmount);var cC=this.templates.printOrderInfo.evaluate({orderId:moInstanceInfo.orderId,printsInfo:bz,nettTotal:g(nettTotal),taxAmount:g(this.d.taxAmount),taxPct:aq.get("Prices","taxPct"),shippingCost:g(this.d.shippingCost),taxInclText:aZ,total:g(total)});var cy=this.templates.printOrderInfo.evaluate({orderId:moInstanceInfo.orderId,printsInfo:bv,nettTotal:g(nettTotal),taxAmount:g(this.d.taxAmount),taxPct:aq.get("Prices","taxPct"),shippingCost:g(this.d.shippingCost),taxInclText:aZ,total:g(total)});this.d.total=total;var an=this.templates.printSection.evaluate({orderInfo:cC});$('Basket_itemListArea').innerHTML=an;this.cq();this.d.tableHTML=cy.replace("\\r\\n","");document.getElementsByClassName('Basket_pictureLink','Basket_itemListArea').each(function(el){Event.observe(el,'click',function(ev){Event.stop(ev);H(el.id.replace('Basket_editItem_',''));}.bindAsEventListener(this));}.bindAsEventListener(this));document.getElementsByClassName('Basket_removeItemButton','Basket_itemListArea').each(function(el){Event.observe(el,'click',function(ev){var key=el.id.replace('Basket_removeItem_','');this.aN(key);this.aU();Event.stop(ev);}.bindAsEventListener(this));}.bindAsEventListener(this));Event.observe('Basket_clearButton','click',function(ev){Event.stop(ev);aB.show({type:'yesno',caption:'Clear Basket',text:"Are you sure?",onYes:function(){this.clear();this.aU();}.bindAsEventListener(this),onNo:function(){}});}.bindAsEventListener(this));},aI:function(pictureId,f){return escape(JSONstring.make([pictureId,f]));},bY:function(key){return JSONstring.toObject(unescape(key));},aM:function(){this.d.ab=this.ab;w('Basket',this.d);},cb:function(){this.d=C('Basket');if(this.d.ab==null)this.d.ab={};this.ab=this.d.ab;},cA:function(){var b=$H(this.ab);var az={};var key=[];b.each(function(el){key=this.bY(el.key);if(az[key[0]]==null)az[key[0]]=[];az[key[0]][key[1]]=el.value;}.bindAsEventListener(this));return az;},cB:function(){var an=this.templates.printSection.evaluate({orderId:moInstanceInfo.orderId,printsInfo:''});$('Basket_itemListArea').innerHTML=an;Element.hide('Basket_Buttons');Element.show('Basket_emptyMsg');return;},cq:function(){Element.show('Basket_Buttons');Element.hide('Basket_emptyMsg');return;}};
