ColorPicker=Class.create({HUE_SLIDER_HEIGHT:11,HUE_SELECTOR_HEIGHT:200,CROSSHAIRS_WIDTH:21,CROSSHAIRS_HEIGHT:21,SATURATION_VALUE_SELECTOR_WIDTH:200,SATURATION_VALUE_SELECTOR_HEIGHT:200,initialize:function(){this.value=0;this.saturation=0;this.hue=0;this.red=0;this.green=0;this.blue=0;this.callbackHash=new Hash();this.saturationValueSelectorImage=$$("div.SaturationValueSelector img").first();this.hueSelectorImage=$("hueSelector")},setTextInput:function(a){this.textInput=a},displayFromClickEvent:function(a){this.disable();this.sourceElement=a.element();this.setTextInput(a.findElement("div").down("input"));this.activeCallback=this.callbackHash.get(this.sourceElement.readAttribute("id"));new Panel($("colorPicker"),this.sourceElement).setRightPosition().setCenterVerticalPosition().enable();this.enable()},addCallback:function(a,b){this.callbackHash.set(a.readAttribute("id"),b)},displayDebugData:function(){console.log("hue: "+this.hue+" saturation: "+this.saturation+" value: "+this.value);console.log("red: "+this.red+" green: "+this.green+" blue: "+this.blue);console.log("hexValue: "+this.hexValue)},disable:function(){if(this.textInput){this.textInput.stopObserving()}if(this.sourceElement){this.sourceElement.stopObserving();this.sourceElement.observe("click",this.displayFromClickEvent.bindAsEventListener(this))}this.saturationValueSelectorImage.stopObserving();this.hueSelectorImage.stopObserving();$("crossHairs").stopObserving();$("hueSlider").stopObserving();$$("#colorPicker .CloseButton").first().stopObserving();delete (this.hueMouseMoveCallback);delete (this.hueMouseUpCallback);delete (this.saturationValueMouseMoveCallback);delete (this.saturationValueMouseUpCallback);$("colorPicker").hide()},enable:function(){this.saturationValueSelectorImage.observe("mousedown",this.saturationValueSelectorMouseDown.bindAsEventListener(this));$("crossHairs").observe("mousedown",this.saturationValueSelectorMouseDown.bindAsEventListener(this));this.hueSelectorImage.observe("mousedown",this.hueSelectorMouseDown.bindAsEventListener(this));$("hueSlider").observe("mousedown",this.hueSelectorMouseDown.bindAsEventListener(this));if(this.textInput){this.textInput.observe("change",this.hexValueChanged.bindAsEventListener(this))}$$("#colorPicker .CloseButton").first().observe("click",this.disable.bindAsEventListener(this));this.sourceElement.stopObserving();this.sourceElement.observe("click",this.disable.bindAsEventListener(this));this.hexValueChanged();this.saturationValueSelectorOffsets=this.saturationValueSelectorImage.cumulativeOffset();this.hueSelectorOffsets=this.hueSelectorImage.cumulativeOffset();$("colorPicker").show()},hueSelectorMouseDown:function(a){this.hueMouseMoveCallback=this.hueSelectorPositionChanged.bindAsEventListener(this);this.hueMouseUpCallback=this.hueSelectorMouseUp.bindAsEventListener(this);document.observe("mousemove",this.hueMouseMoveCallback);document.observe("mouseup",this.hueMouseUpCallback);this.hueSelectorPositionChanged(a)},hueSelectorMouseUp:function(a){document.stopObserving("mousemove",this.hueMouseMoveCallback).stopObserving("mouseup",this.hueMouseUpCallback);this.hueSelectorPositionChanged(a)},hueSelectorPositionChanged:function(b){var a,c;b.stop();c=b.pointerY()-this.hueSelectorOffsets[1];(c<0)&&(c=0);(c>=this.HUE_SELECTOR_HEIGHT)&&(c=this.HUE_SELECTOR_HEIGHT-1);this.hue=c/(this.HUE_SELECTOR_HEIGHT-1);this.hsvChanged()},saturationValueSelectorMouseDown:function(a){this.saturationValueMouseMoveCallback=this.saturationValueSelectorPositionChanged.bindAsEventListener(this);this.saturationValueMouseUpCallback=this.saturationValueSelectorMouseUp.bindAsEventListener(this);document.observe("mousemove",this.saturationValueMouseMoveCallback);document.observe("mouseup",this.saturationValueMouseUpCallback);this.saturationValueSelectorPositionChanged(a)},saturationValueSelectorMouseUp:function(a){document.stopObserving("mousemove",this.saturationValueMouseMoveCallback).stopObserving("mouseup",this.saturationValueMouseUpCallback);this.saturationValueSelectorPositionChanged(a)},saturationValueSelectorPositionChanged:function(b){var a,c;b.stop();a=b.pointerX()-this.saturationValueSelectorOffsets[0];c=b.pointerY()-this.saturationValueSelectorOffsets[1];(a<0)&&(a=0);(c<0)&&(c=0);(a>=this.SATURATION_VALUE_SELECTOR_WIDTH)&&(a=this.SATURATION_VALUE_SELECTOR_WIDTH-1);(c>=this.SATURATION_VALUE_SELECTOR_HEIGHT)&&(c=this.SATURATION_VALUE_SELECTOR_WIDTH-1);this.saturation=1-(c/(this.SATURATION_VALUE_SELECTOR_HEIGHT-1));this.value=(a/(this.SATURATION_VALUE_SELECTOR_WIDTH-1));this.hsvChanged()},hexValueChanged:function(){this.hexValue=this.textInput.getValue();this.setupRgbFromHex();this.setupHsvFromRgb();this.setupColor()},hsvChanged:function(){this.setupRgbFromHsv();this.setupColor()},setupColor:function(){var d,c,a,b;this.setupHexValueFromRgb();d=this.hsvToRgb($H({hue:this.hue,saturation:1,value:1}));c=this.rgbToHex(d);$("colorPreview").setStyle({backgroundColor:"#"+this.hexValue});$$("div.SaturationValueSelector").first().setStyle({backgroundColor:"#"+c});this.textInput.setValue(this.hexValue.toLowerCase());if(this.activeCallback){this.activeCallback()}a=this.value*(this.SATURATION_VALUE_SELECTOR_WIDTH-1)-this.CROSSHAIRS_WIDTH*0.5;b=(1-this.saturation)*(this.SATURATION_VALUE_SELECTOR_HEIGHT-1)-this.CROSSHAIRS_HEIGHT*0.5;$("crossHairs").setStyle({left:a.toString()+"px",top:b.toString()+"px"});$("hueSlider").setStyle({top:Math.round(this.hue*(this.HUE_SELECTOR_HEIGHT-1)-this.HUE_SLIDER_HEIGHT*0.5).toString()+"px"})},setupHsvFromRgb:function(){var a,c,b,d,e,f;a=Math.max(Math.max(this.red,this.green),this.blue);c=Math.min(Math.min(this.red,this.green),this.blue);e=a;if(c==a){b=0;d=0}else{f=(a-c);d=f/a;if(a==this.red){b=(this.green-this.blue)/f}else{if(a==this.green){b=2+((this.blue-this.red)/f)}else{b=4+((this.red-this.green)/f)}}b/=6;if(b<0){b+=1}if(b>1){b-=1}}this.hue=b,this.saturation=d,this.value=e},setupRgbFromHex:function(){var d,c,a;if(this.hexValue.length==3){d=this.hexValue.substr(0,1);d+=d;c=this.hexValue.substr(1,1);c+=c;a=this.hexValue.substr(2,1);a+=a}else{if(this.hexValue.length==6){d=this.hexValue.substr(0,2);c=this.hexValue.substr(2,2);a=this.hexValue.substr(4,2)}else{d="00";c="00";a="00"}}d=parseInt(d,16);c=parseInt(c,16);a=parseInt(a,16);if(!isNaN(d)&&!isNaN(c)&&!isNaN(a)){this.red=d/255;this.green=c/255;this.blue=a/255}},setupHexValueFromRgb:function(){this.hexValue=this.rgbToHex($H({red:this.red,green:this.green,blue:this.blue}))},setupRgbFromHsv:function(){var a=this.hsvToRgb($H({hue:this.hue,saturation:this.saturation,value:this.value}));this.red=a.get("red");this.green=a.get("green");this.blue=a.get("blue")},rgbToHex:function(b){var d,c,a;d=Math.round(b.get("red")*255);c=Math.round(b.get("green")*255);a=Math.round(b.get("blue")*255);d=d.toString(16);if(1==d.length){d="0"+d}c=c.toString(16);if(1==c.length){c="0"+c}a=a.toString(16);if(1==a.length){a="0"+a}return(d+c+a).toUpperCase()},hsvToRgb:function(h){var c,d,m,j,g,l,e,k,b,a,n;j=h.get("hue");g=h.get("saturation");l=h.get("value");if(0==l){c=0;d=0;m=0}else{e=Math.floor(j*6);k=(j*6)-e;b=l*(1-g);a=l*(1-(g*k));n=l*(1-(g*(1-k)));switch(e){case 1:c=a;d=l;m=b;break;case 2:c=b;d=l;m=n;break;case 3:c=b;d=a;m=l;break;case 4:c=n;d=b;m=l;break;case 5:c=l;d=b;m=a;break;case 6:case 0:c=l;d=n;m=b;break}}return $H({red:c,green:d,blue:m})}});CustomizationPanel=Class.create({initialize:function(){this.customizationPanelElement=$("decorationDomain");NavigationService.updateNavigationListeners(this.customizationPanelElement);NavigationService.prepareTabView("Background",NavigationService.obtainTabLink($$("#decorationDomain .TabHeader").first(),"Background"));if(!this.colorPicker){this.colorPicker=new ColorPicker()}this.waitingServerReplyPanel=new WaitingServerReplyPanel(this.customizationPanelElement.down(".WaitingServerReplyPanel"),undefined)},updateImage:function(e,b,c,d,a){var f=["simple","intermediate","advanced"];if(["top","bottom","left","right"].indexOf(e)!=-1){this.activeMode="intermediate";f=["intermediate","advanced"]}if(["topLeft","topRight","bottomLeft","bottomRight"].indexOf(e)!=-1){this.activeMode="advanced";f=["advanced"]}f.each(function(i){var h,g;h=$$("#"+i+"ImageUpload ."+capitalize(e)+"ImagePreview img").first();h.show().writeAttribute({src:b}).setStyle({width:"",height:""});g=100;if(e=="central"){g=200}if(d>a){h.setStyle({width:g+"px"});h.setStyle({marginTop:Math.round((g-(a*g/d))*0.5)+"px",marginLeft:"0px"})}else{h.setStyle({marginLeft:Math.round((g-(d*g/a))*0.5)+"px",marginTop:"0px"});h.setStyle({height:g+"px"})}});$$("input[name="+e+"Image.id]").first().setValue(c)},changeImageCustomizationMode:function(a){var b;$("simpleImageUpload").hide();$("intermediateImageUpload").hide();$("advancedImageUpload").hide();b=$("imagesCustomizationUploadMode").getValue();$(b+"ImageUpload").show();if("simple"==b){$$("#imagesCustomizationUploadForm .FormFieldInfo").first().update("The central image should have a width of 200 pixels or less, in which case it will be tiled and repeated. If you provide a larger image, it will be scaled down to this size.");$("imagesCustomizationUploadBorderWidthRow").hide()}else{$("imagesCustomizationUploadBorderWidthRow").show()}},removeImages:function(){$$(".ImagePreview img").invoke("writeAttribute","src","about:blank");$$(".SmallImagePreview img").invoke("writeAttribute","src","about:blank");$$("input[name=centralImage.id]").first().setValue("null");$$("input[name=leftImage.id]").first().setValue("null");$$("input[name=rightImage.id]").first().setValue("null");$$("input[name=topImage.id]").first().setValue("null");$$("input[name=bottomImage.id]").first().setValue("null");$$("input[name=topLeftImage.id]").first().setValue("null");$$("input[name=topRightImage.id]").first().setValue("null");$$("input[name=bottomLeftImage.id]").first().setValue("null");$$("input[name=bottomRightImage.id]").first().setValue("null")},changeActiveImageHint:function(){if($F("imagesCustomizationUploadIntermediateLeft")){$$("#imagesCustomizationUploadForm .FormFieldInfo").first().update("The "+$F("imagesCustomizationUploadIntermediateLeft")+" image should ideally have a small width (10 pixels or so) and can not be larger than 40 pixels in width. It will be tiled and repeated vertically. If you check the above box, the image you upload will automatically be resized to the given width.")}if($F("imagesCustomizationUploadIntermediateRight")){$$("#imagesCustomizationUploadForm .FormFieldInfo").first().update("The "+$F("imagesCustomizationUploadIntermediateRight")+" image should ideally have a small width (10 pixels or so) and can not be larger than 40 pixels in width. It will be tiled and repeated vertically. If you check the above box, the image you upload will automatically be resized to the given width.")}if($F("imagesCustomizationUploadIntermediateTop")){$$("#imagesCustomizationUploadForm .FormFieldInfo").first().update("The "+$F("imagesCustomizationUploadIntermediateTop")+" image should ideally have a small width (10 pixels or so) and can not be larger than 40 pixels in width. It will be tiled and repeated vertically. If you check the above box, the image you upload will automatically be resized to the given width.")}},changePaddingCustomizationMode:function(a){var b=$("backgroundCustomizationPaddingMode").getValue();if("simple"==b){$$("form#backgroundCustomizationForm .SimplePaddingInterface").invoke("show");$$("form#backgroundCustomizationForm .AdvancedPaddingInterface").invoke("hide")}else{$$("form#backgroundCustomizationForm .SimplePaddingInterface").invoke("hide");$$("form#backgroundCustomizationForm .AdvancedPaddingInterface").invoke("show")}},changeRadiusMode:function(a){var b;$("backgroundCustomizationCustomRadius").hide();if(!a){switch($F("backgroundCustomizationRadius")){case"8":$("backgroundCustomizationRadiusMode").setValue("normal");break;case"4":$("backgroundCustomizationRadiusMode").setValue("small");break;default:$("backgroundCustomizationRadiusMode").setValue("custom");$("backgroundCustomizationCustomRadius").show()}return}b=$("backgroundCustomizationRadiusMode").getValue();switch(b){case"normal":$("backgroundCustomizationRadius").setValue("8");break;case"small":$("backgroundCustomizationRadius").setValue("4");break;case"custom":$("backgroundCustomizationCustomRadius").show();break}},changeShadowsSizeMode:function(a){var b;$("advancedCustomizationCustomShadowsSize").hide();if(!a){switch($F("advancedCustomizationShadowsSize")){case"8":$("advancedCustomizationShadowsSizeMode").setValue("normal");break;case"4":$("advancedCustomizationShadowsSizeMode").setValue("small");break;default:$("advancedCustomizationShadowsSizeMode").setValue("custom");$("advancedCustomizationCustomShadowsSize").show()}return}b=$("advancedCustomizationShadowsSizeMode").getValue();switch(b){case"normal":$("advancedCustomizationShadowsSize").setValue("8");break;case"small":$("advancedCustomizationShadowsSize").setValue("4");break;case"custom":$("advancedCustomizationCustomShadowsSize").show();break}},enable:function(a){$$("#imagesCustomizationUploadForm div.Action").first().observe("click",this.removeImages.bindAsEventListener(this));$("imagesCustomizationUploadMode").observe("change",this.changeImageCustomizationMode.bindAsEventListener(this));$$("#imagesCustomizationUploadForm input[type=radio]").invoke("observe","click",this.changeActiveImageHint.bindAsEventListener(this));$("uploadFrame").observe("load",DecorationController.imageUploaded.bindAsEventListener(DecorationController));this.customizationPanelElement.select(".ColorPicker").invoke("observe","click",this.colorPicker.displayFromClickEvent.bindAsEventListener(this.colorPicker));this.colorPicker.addCallback($("borderColorPicker"),this.setBorderWidth.bind(this));$("backgroundCustomizationPaddingMode").observe("change",this.changePaddingCustomizationMode.bindAsEventListener(this));$("backgroundCustomizationRadiusMode").observe("change",this.changeRadiusMode.bindAsEventListener(this));$("advancedCustomizationShadowsSizeMode").observe("change",this.changeShadowsSizeMode.bindAsEventListener(this));document.stopObserving("click").stopObserving("mousemove");this.customizationPanelElement.down(".GeneralFormMessage").update("");this.panel=new Panel(this.customizationPanelElement,a).setDisableCallback(this.disable.bind(this)).setDraggable("Title").enable()},disable:function(){this.colorPicker.disable();this.removeImages();document.fire("skinning:sectionChanged");$$("#imagesCustomizationUploadForm div.Action").first().stopObserving();$("imagesCustomizationUploadMode").stopObserving();$$("#imagesCustomizationUploadForm input[type=radio]").invoke("stopObserving");this.customizationPanelElement.select(".ColorPicker").invoke("stopObserving");$$("#decorationDomain .CloseButton").first().stopObserving();$$("#decorationDomain .ClosePanel").first().stopObserving();$("backgroundCustomizationPaddingMode").stopObserving();$("backgroundCustomizationRadiusMode").stopObserving();$("advancedCustomizationShadowsSizeMode").stopObserving();if(this.primaryInterface){DecorationController.toolTip.enable();document.observe("click",DecorationController.displayCustomizationPanelFromClickEvent.bindAsEventListener(DecorationController));document.observe("mousemove",DecorationController.highlightElement.bindAsEventListener(DecorationController))}this.panel&&this.panel.destroy()},setBorderWidth:function(){var a=$F("backgroundCustomizationBorderWidth");if(("0"==a)||(!a)){$("backgroundCustomizationBorderWidth").setValue("1")}}});InteractiveHelpPanel=Class.create(Panel,{initialize:function($super,a,b){this.appearEffect="grow";this.steps=new Hash();this.arrowElement=$("arrow");$super(a,b);this.verticalMargin=InteractiveHelpPanel.ARROW_HEIGHT-3;this.horizontalMargin=10},clearOptions:function($super){$super();this.unsetFixedPosition()},disableArrow:function(){this.arrowElement=undefined;return this},enableArrow:function(){this.arrowElement=$("arrow");return this},setContent:function(a){this.element.down(".Content").update(a);return this},obtainCenterVerticalPositionTopValue:function(){return Math.round(this.callingElementOffset[1]-this.verticalMargin+(this.callingElementDimensions.height-this.dimensions.height)*0.5)},setFixedPosition:function($super){$super();if(this.arrowElement){this.arrowElement.setStyle({position:"fixed"})}return this},unsetFixedPosition:function($super){$super();if(this.arrowElement){this.arrowElement.setStyle({position:"absolute"})}return this},show:function(){new Effect.Grow(this.element,{afterFinish:this.setupArrow.bind(this)})},hide:function($super){$super();if(this.currentEvents){this.currentEvents.each(function(a){a.events.each(function(b){b.element.stopObserving(b.eventName,a.currentCallback)})}.bind(this))}if(this.arrowElement){this.arrowElement.hide()}},registerExpectedEvents:function(b){var a;this.currentEvents=new Array();b.each(function(c){a=this.executeStep.curry(c.key).bindAsEventListener(this);c.value.each(function(d){d.element.observe(d.eventName,a)});this.currentEvents.push({callback:a,events:c.value})}.bind(this))},executeStep:function(a){var b;this.hide();if(a!=0){b=this.steps.get(a);this.clearOptions();if(b.optionsFunction){b.optionsFunction.bind(this)()}this.setContent(b.content);this.registerExpectedEvents(b.events);if(!b.targetElement){b.targetElement=$$(b.targetElementSelector).first()}this.callingElement=b.targetElement;this.enable();if(b.callback){b.callback()}}else{this.destroy()}},registerStep:function(a,b){this.currentStep=a;b.events=new Hash();b.content=b.contentElement.innerHTML;delete b.contentElement;this.steps.set(a,b);return this},registerEventsForStep:function(a,b){this.steps.get(this.currentStep).events.set(a,b);return this},setupArrow:function(){var b,a;if(!this.arrowElement){return this}b=this.elementOffset[1];if("left"==this.finalHorizontalPosition){a=this.elementOffset[0]+this.dimensions.width-InteractiveHelpPanel.ARROW_WIDTH}else{a=this.elementOffset[0]}if("center"==this.finalHorizontalPosition){if("top"==this.finalVerticalPosition){b=this.elementOffset[1]-20}else{b=this.elementOffset[1]+20}this.element.setStyle({top:b+"px"})}if("bottom"==this.finalVerticalPosition){b=b-InteractiveHelpPanel.ARROW_HEIGHT-InteractiveHelpPanel.ARROW_VERTICAL_MARGIN}else{b=b+this.dimensions.height+InteractiveHelpPanel.ARROW_VERTICAL_MARGIN}this.arrowElement.src=InteractiveHelpPanel.arrowImageSources[this.finalVerticalPosition+capitalize(this.finalHorizontalPosition)];this.arrowElement.setStyle({top:b+"px",left:a+"px"}).show();return this},destroy:function(){this.disableArrow().hide()}});InteractiveHelpPanel.ARROW_WIDTH=50;InteractiveHelpPanel.ARROW_HEIGHT=64;InteractiveHelpPanel.ARROW_VERTICAL_MARGIN=7;ReferenceItem=Class.create({initialize:function(h,b,f,d,c,a,e,g){this.id=h;this.name=b;this.shortDescription=f;this.description=d;this.manufacturer=c;this.model=a;this.previewImage=e;this.detailImage=g;this.rank=0},displayPreview:function(){var a=new Template(ReferenceItem.previewTemplate);$("itemListPanel").insert({bottom:a.evaluate(this)})},displayDetailPanel:function(){ShopService.showItemDetailPanel();var a=new Template(ReferenceItem.detailTemplate);$("itemDetailPanelContent").update(a.evaluate(this));NavigationService.updateNavigationListeners($("itemDetailPanelContent"))}});ShippingPolicyEditor=Class.create({initialize:function(){this.rules=new Array();this.rules.push(new ShippingPolicyRule(this));this.countries=new Array();this.valid=true;this.id="new";this.name="";this.description="";this.active=true},setupFromJSONData:function(a){this.id=a.id;this.name=a.name;this.description=a.description;this.active=a.active;this.rules=new Array();a.rules.each(function(c){var b=new ShippingPolicyRule(this);b.setupFromJSONData(c);this.rules.push(b)}.bind(this));this.countries=a.countries.split(",")},prepareView:function(){var c,a,b;a=$("policy"+this.id);if(a){a.remove()}if(this.active){this.action="disable";this.actionDescription=localeMessageResolverService.getMessage("js.editor.general.action.disable");c=$("activeShippingPoliciesList")}else{this.action="activate";this.actionDescription=localeMessageResolverService.getMessage("js.editor.general.action.activate");c=$("disabledShippingPoliciesList")}b=new Template(ShippingPolicyEditor.rowTemplate);new Insertion.Bottom(c,b.evaluate(this));NavigationService.updateNavigationListeners(c)},refreshView:function(){var a=$("policy"+this.id),b=new Template(ShippingPolicyEditor.rowTemplate);a.replace(b.evaluate(this));NavigationService.updateNavigationListeners(a)},update:function(b){var a;if("new"==this.id){ShippingController.policies.push(this);this.id=b.policyId;this.prepareView();NavigationService.changeNavigationStateWithRelativeURL("policy="+this.id);ShippingController.updateShippingPolicyManager.form.firstDescendant().update(b.resultMessage)}else{this.refreshView()}},remove:function(){var a=$("policy"+this.id);a.remove();ShippingController.policies=ShippingController.policies.without(this)},createShippingPolicyRule:function(){var a=new ShippingPolicyRule(this);a.setupFromPreviousRule(this.rules.last());this.rules.push(a);this.updateRules()},updateRules:function(){$$("#shippingTableBody tr").invoke("remove");this.rules.invoke("prepareView")},validate:function(){this.valid=true;this.rules.invoke("validate");return this.valid},toJSON:function(){var a=new Hash();a.set("policyId",this.id);a.set("name",this.name);a.set("description",this.description);a.set("policyRules",this.rules.toJSON());a.set("countries",this.countries.join(","));a.set("active",this.active);return a.toJSON()}});ShippingPolicyRule=Class.create({initialize:function(a){this.policy=a;this.rangeStart=0;this.rangeEnd=ShippingPolicyRule.UNLIMITED_END_RANGE;this.fixedCost=0;this.unitCost=0;this.id=0},setupFromJSONData:function(a){this.id=a.id;this.rangeStart=a.rangeStart;this.rangeEnd=a.rangeEnd;this.fixedCost=a.fixedCost;this.unitCost=a.unitCost},setupFromPreviousRule:function(a){if(a){this.id=a.id+1;if(ShippingPolicyRule.UNLIMITED_END_RANGE!=a.rangeEnd){this.rangeStart=a.rangeEnd}else{this.rangeStart=a.rangeStart;a.rangeEnd=a.rangeStart}}else{this.rangeStart=0;this.id=0}this.rangeEnd=ShippingPolicyRule.UNLIMITED_END_RANGE;this.fixedCost=0;this.unitCost=0},toJSON:function(){return $H({rangeStart:this.rangeStart,rangeEnd:this.rangeEnd,fixedCost:this.fixedCost,unitCost:this.unitCost}).toJSON()},setAttribute:function(b){var a,c;c=$F(b.element());a=b.element().readAttribute("name");if(localeMessageResolverService.getMessage("js.editor.shippingPolicyRule.unlimitedEndRange")==c){c=ShippingPolicyRule.UNLIMITED_END_RANGE}this[a]=localeMessageResolverService.convertStringToNumber(c);if("rangeStart"==a){this.policy.rules[this.id-1].setRangeEnd(this[a])}if("rangeEnd"==a){this.policy.rules[this.id+1].setRangeStart(this[a])}this.validate()},setRangeStart:function(a){this.rangeStart=a;this.validate()},setRangeEnd:function(a){this.rangeEnd=a;this.validate()},setId:function(a){this.id=a},remove:function(){var b,a;if(this.policy.rules.size()-1!=this.id){this.policy.rules[this.id+1].rangeStart=this.rangeStart}this.policy.rules.splice(this.id,1);for(b=0,a=this.policy.rules.size();b<a;++b){this.policy.rules[b].setId(b)}if(1==this.policy.rules.size()){this.policy.rules[0].rangeEnd=ShippingPolicyRule.UNLIMITED_END_RANGE}this.policy.updateRules()},updateStringProperties:function(){if(ShippingPolicyRule.UNLIMITED_END_RANGE==this.rangeEnd){this.rangeEndString=localeMessageResolverService.getMessage("js.editor.shippingPolicyRule.unlimitedEndRange")}else{this.rangeEndString=localeMessageResolverService.convertNumberToString(this.rangeEnd)}this.rangeStartString=localeMessageResolverService.convertNumberToString(this.rangeStart);this.fixedCostString=localeMessageResolverService.convertNumberToString(this.fixedCost);this.unitCostString=localeMessageResolverService.convertNumberToString(this.unitCost)},prepareView:function(){var b,a;this.updateStringProperties();b=new Template(ShippingPolicyRule.rowTemplate);new Insertion.Bottom($("shippingTableBody"),b.evaluate(this));a=$$("#shippingTableBody tr.DataRow")[this.id];a.select("input").invoke("observe","change",this.setAttribute.bindAsEventListener(this));a.select(".Action").first().observe("click",this.remove.bindAsEventListener(this));if(0==this.id){a.select("input").first().disable();a.select("td").last().hide()}else{a.select("td").last().show()}if(this.id==this.policy.rules.size()-1){a.select("input")[1].disable()}},refreshView:function(){var a=$$("#shippingTableBody tr.DataRow")[this.id];this.updateStringProperties();a.select('input[name="rangeStart"]').first().setValue(this.rangeStartString);a.select('input[name="rangeEnd"]').first().setValue(this.rangeEndString);if(this.valid){a.next().hide()}else{a.next().show();a.next().firstDescendant().update(this.errorMessage)}},validate:function(){this.valid=(ShippingPolicyRule.UNLIMITED_END_RANGE==this.rangeEnd)||(0<=this.rangeEnd);this.valid=this.valid&&(0<=this.rangeStart)&&(0<=this.fixedCost)&&(0<=this.unitCost);if(this.valid){if((ShippingPolicyRule.UNLIMITED_END_RANGE!=this.rangeEnd)&&this.rangeEnd<=this.rangeStart){this.valid=false;this.errorMessage=localeMessageResolverService.getMessage("js.editor.errors.shippingPolicy.row.constraint.1")}if(this.fixedCost.toString().empty()){this.valid=false;this.errorMessage=localeMessageResolverService.getMessage("shippingPolicyRule.fixedCost.nullable")}if(this.unitCost.toString().empty()){this.valid=false;this.errorMessage=localeMessageResolverService.getMessage("shippingPolicyRule.unitCost.nullable")}}else{this.errorMessage=localeMessageResolverService.getMessage("js.editor.errors.shippingPolicy.row.positive")}this.policy.valid=this.policy.valid&&this.valid;this.refreshView()}});ShippingPolicyRule.UNLIMITED_END_RANGE="UNLIMITED_END_RANGE";DecorationController={OPACITY_BLOCK_BORDER_WIDTH:3,initialize:function(d){var b,a,c;this.WORK_CSS_INDEX=document.styleSheets.length-1;this.customizationPanel=new CustomizationPanel();this.decorationsMap=d;this.decorationsMapByIdentifier=new Hash();this.toolTip=new ToolTipPanel($$(".ToolTip.CustomizationPanel").first(),document).setCenterVerticalPosition();$$("#customizeSwitcher img").first().observe("click",this.startListening.bindAsEventListener(this));for(b in this.decorationsMap){this.decorationsMap[b].identifiers.each(function(e){a=this.decorationsMapByIdentifier.get(e);if(a){a.push(b)}else{this.decorationsMapByIdentifier.set(e,[b])}}.bind(this))}this.backgroundCustomizationFormManager=new FormManager($("backgroundCustomizationForm"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationBackgroundColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationBorderColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationSecondBorderColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationBorderWidth")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.border.positive"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationSecondBorderWidth")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.border.positive"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationAllPadding")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.spacing.positive"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationTopPadding")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.spacing.positive"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationBottomPadding")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.spacing.positive"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationLeftPadding")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.spacing.positive"));this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationRightPadding")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.spacing.positive"));c=this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationRoundedCorners")).setupAsElementSelector();this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationRadius")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.size.positive")).setFormFieldStatus($$(".RoundedCornersCheckboxLinked .FormFieldStatus").first()).setCheckboxRequired(c);this.backgroundCustomizationFormManager.registerElement($("backgroundCustomizationPaddingMode"));this.backgroundCustomizationFormManager.registerElement($$("#backgroundCustomizationForm input[name='name']").first());this.backgroundCustomizationFormManager.setNoWaitingPanel();this.backgroundCustomizationFormManager.setSubmitCallback(this.updateElement.bind(this));this.backgroundCustomizationFormManager.setSuccessCallback(this.successUpdateElement.bind(this));this.backgroundCustomizationFormManager.setFailureCallback(this.failureUpdateElement.bind(this));this.backgroundCustomizationFormManager.setUncaughtFailureCallback(this.uncaughtFailureUpdateElement.bind(this));this.imagesCustomizationFormManager=new FormManager($("imagesCustomizationForm"));this.imagesCustomizationFormManager.registerElement($$("#imagesCustomizationForm input[name='name']").first());this.imagesCustomizationFormManager.setNoWaitingPanel();this.imagesCustomizationFormManager.setSubmitCallback(this.updateElement.bind(this));this.imagesCustomizationFormManager.setSuccessCallback(this.successUpdateElement.bind(this));this.imagesCustomizationFormManager.setFailureCallback(this.failureUpdateElement.bind(this));this.imagesCustomizationFormManager.setUncaughtFailureCallback(this.uncaughtFailureUpdateElement.bind(this));c=this.imagesCustomizationFormManager.registerElement($$("input[name='borderImageWidthActivation']").first()).setupAsElementSelector({inactiveEffect:$("imagesCustomizationBorderWidth")});this.imagesCustomizationFormManager.registerElement($$("#imagesCustomizationForm input[name='borderImageWidth']").first()).setCheckboxRequired(c).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.images.border.positive"));this.textCustomizationFormManager=new FormManager($("textCustomizationForm"));this.textCustomizationFormManager.registerElement($("textCustomizationColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.textCustomizationFormManager.registerElement($("textCustomizationLinkColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.textCustomizationFormManager.registerElement($("textCustomizationHoverColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.textCustomizationFormManager.registerElement($("textCustomizationLinkHoverColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.textCustomizationFormManager.registerElement($("textCustomizationFontSize")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.fontSize.positive"));this.imagesCustomizationFormManager.registerElement($$("#textCustomizationForm input[name='name']").first());this.textCustomizationFormManager.registerElements($$("#textCustomizationForm input[type='checkbox']"));this.textCustomizationFormManager.setNoWaitingPanel();this.textCustomizationFormManager.setSubmitCallback(this.updateElement.bind(this));this.textCustomizationFormManager.setSuccessCallback(this.successUpdateElement.bind(this));this.textCustomizationFormManager.setFailureCallback(this.failureUpdateElement.bind(this));this.textCustomizationFormManager.setUncaughtFailureCallback(this.uncaughtFailureUpdateElement.bind(this));this.advancedCustomizationFormManager=new FormManager($("advancedCustomizationForm"));this.advancedCustomizationFormManager.registerElement($("advancedCustomizationTopColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.advancedCustomizationFormManager.registerElement($("advancedCustomizationBottomColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));this.backgroundCustomizationFormManager.registerElement($("advancedCustomizationGradient"));this.advancedCustomizationFormManager.registerElement($("advancedCustomizationShadowsColorCode")).setHexadecimalConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal")).setLengthConstraint(6,6,localeMessageResolverService.getMessage("js.errors.skinnedElement.hexadecimal.length"));c=this.advancedCustomizationFormManager.registerElement($("advancedCustomizationShadows")).setupAsElementSelector();this.advancedCustomizationFormManager.registerElement($("advancedCustomizationShadowsSize")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.skinnedElement.size.positive")).setFormFieldStatus($$(".ShadowsCustomization .FormFieldStatus").first()).setCheckboxRequired(c);this.advancedCustomizationFormManager.registerElement($$("#advancedCustomizationForm input[name='name']").first());this.advancedCustomizationFormManager.setNoWaitingPanel();this.advancedCustomizationFormManager.setSubmitCallback(this.updateElement.bind(this));this.advancedCustomizationFormManager.setSuccessCallback(this.successUpdateElement.bind(this));this.advancedCustomizationFormManager.setFailureCallback(this.failureUpdateElement.bind(this));this.advancedCustomizationFormManager.setUncaughtFailureCallback(this.uncaughtFailureUpdateElement.bind(this))},successReadElement:function(b){if(b.borderImageWidth){b.borderImageWidthActivation=true}else{b.borderImageWidth=8;b.borderImageWidthActivation=false}this.backgroundCustomizationFormManager.bindDataToForm(b);this.imagesCustomizationFormManager.bindDataToForm(b);this.textCustomizationFormManager.bindDataToForm(b);this.advancedCustomizationFormManager.bindDataToForm(b);var a=["central","top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"];a.each(function(c){this.setupImage(c,b)}.bind(this));$("imagesCustomizationUploadMode").setValue(this.customizationPanel.activeMode);this.customizationPanel.changeImageCustomizationMode(undefined);this.customizationPanel.changePaddingCustomizationMode(undefined);this.customizationPanel.changeRadiusMode(undefined);this.customizationPanel.changeShadowsSizeMode(undefined);this.numberOfBorders=0;if($F("backgroundCustomizationBorderWidth")&&"0"!=$F("backgroundCustomizationBorderWidth")){$$(".BorderCustomization")[0].show();++this.numberOfBorders}if($F("backgroundCustomizationSecondBorderWidth")&&"0"!=$F("backgroundCustomizationSecondBorderWidth")){$$(".BorderCustomization")[1].show();++this.numberOfBorders}this.updateBorderControls()},setupImage:function(e,f){var c,a,d,b,g;c=f[e+"Image"];if(c){b=c.substr(0,c.lastIndexOf("/")+1);a=c.substr(c.lastIndexOf("/")+1);d=a.substr(0,a.indexOf("_"));a=a.substr(a.indexOf("_")+1);a=a.substr(a.indexOf("_")+1);a=b+d+"_"+a;g=$(new Image());g.src=c;this.customizationPanel.updateImage(e,c,d,g.width,g.height)}},imageUploaded:function(a){var b=frames.uploadFrame.document.getElementById("uploadFrameResultData").innerHTML.evalJSON();this.customizationPanel.updateImage(b.activeImage,b.imagePath,b.imageId,b.width,b.height)},updateElement:function(){document.fire("help:skinningSectionChanged");this.customizationPanel.waitingServerReplyPanel.enable()},successUpdateElement:function(a){this.rewriteCSS(a.newCSSContent);this.customizationPanel.waitingServerReplyPanel.disable()},failureUpdateElement:function(a){if(!a.customizationInProgress){this.customizationPanel.waitingServerReplyPanel.disable();this.customizationPanel.customizationPanelElement.down(".InvalidFormMessage").show().update(localeMessageResolverService.getMessage("js.errors.skinnedElement.skin.failure"))}},uncaughtFailureUpdateElement:function(){this.customizationPanel.waitingServerReplyPanel.disable()},displaySkinningDialog:function(){ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("editor.controlsPanel.customization.title"));ShopService.hideNavigation();ShopService.hideAction();ShopService.showOnlyMainPanelDialog();NavigationService.processGenericServerCall(true)},successDisplaySkinningDialog:function(b){var a=$$("#mainPanel > .Dialog").first();a.update(b);NavigationService.updateNavigationListeners(a);$("selectCustomizableElementSelector").observe("change",this.displayElementDescription.bindAsEventListener(this))},displayElementDescription:function(d){var b,a,e,c;b=d.element();a=b.up().down(".FormFieldInfo");e=b.getValue();if("NONE"==e){a.hide()}else{c=this.obtainElementDescription(e);a.show().update(c)}},obtainDecorationNameFromIdentifier:function(a){return this.decorationsMapByIdentifier.get(a).first()},obtainElementDescription:function(a){return this.decorationsMap[a].description},rewriteCSS:function(a){updateCSS(a,$("currentStyleSheet"),this.WORK_CSS_INDEX)},displayCustomizationPanelFromClickEvent:function(b){var a,c;b.stop();this.customizationPanel.disable();a="/decoration/readElement";c=this.retrieveDecorationName(this.element);$$(".OpacityBlock").first().hide();NavigationService.setupServerCallData(a,new Hash({decorationName:c}));NavigationService.processGenericServerCall(false);this.toolTip.disable();this.customizationPanel.enable(this.element);this.element.fire("skinning:elementSelected")},displayCustomizationPanelFromSelector:function(decorationName){var a="/decoration/readElement";this.primaryInterface=false;this.customizationPanel.disable();NavigationService.setupServerCallData(a,new Hash({decorationName:decorationName}));NavigationService.processGenericServerCall(false);this.customizationPanel.enable(document.body)},retrieveDecorationName:function(b){var c,a;if("Category"==this.element.readAttribute("class").split(" ").last()){return"Category"}if("InformationButton"==this.element.readAttribute("class").split(" ").last()){return"Information Links"}if(b==document.body){return"Page Background"}a=this.element.readAttribute("id");if(!a){a=this.element.readAttribute("class").split(" ").last()}c=this.obtainDecorationNameFromIdentifier(a);return c},startListening:function(c){c.stop();this.customizationPanel.primaryInterface=true;document.stopObserving("click").observe("click",this.displayCustomizationPanelFromClickEvent.bindAsEventListener(this));document.observe("mousemove",this.highlightElement.bindAsEventListener(this));this.toolTip.enable().doNotShowUntilMove();var a=$$("#customizeSwitcher img"),b;$$("#customizeSwitcher img").first().hide();a.last().show().stopObserving().observe("click",this.stopListening.bindAsEventListener(this));b=$$(".Message.CustomizeSwitcher").first().update(localeMessageResolverService.getMessage("js.editor.customization.button.active"));new Effect.Highlight(b,{startcolor:"#ed0c0c"})},stopListening:function(b){var a=$$("#customizeSwitcher img");b.stop();this.customizationPanel.disable();document.stopObserving("mousemove").stopObserving("click");$$(".OpacityBlock").first().hide();this.element=undefined;this.toolTip.disable();a.first().show().stopObserving().observe("click",this.startListening.bindAsEventListener(this));a.last().hide();$$(".Message.CustomizeSwitcher").first().update(localeMessageResolverService.getMessage("editor.controlsPanel.customization.paragraph.1"))},highlightElement:function(d){var a=d.pointerX(),f=d.pointerY(),e=$(document.body),c,b;$$(".Customizable").each(function(g){if(!g.visible()){return}var i=g.cumulativeOffset(),h=g.getDimensions(),k=0,j=-1;if((i[0]<a)&&(i[0]+h.width>a)&&(i[1]<f)&&(i[1]+h.height>f)){g.ancestors().each(function(m){var l=m.getStyle("z-index");if(l){k=l;throw $break}});if(k>j){j=k;e=g}if(g.descendantOf(e)){j=k;e=g}}});this.element=e;decorationName=this.retrieveDecorationName(this.element);this.toolTip.setContent(localeMessageResolverService.getMessageWithArguments("js.editor.customization.mode.active.tooltip.description",[decorationName]));b=$$(".OpacityBlock").first();b.setStyle({width:(e.getWidth()-2*this.OPACITY_BLOCK_BORDER_WIDTH)+"px",height:(e.getHeight()-2*this.OPACITY_BLOCK_BORDER_WIDTH)+"px",left:e.cumulativeOffset()[0]+"px",top:e.cumulativeOffset()[1]+"px"}).show()},decorationSectionBackground:function(){document.fire("help:skinningSectionChanged")},decorationSectionImages:function(){document.fire("help:skinningSectionChanged")},decorationSectionText:function(){document.fire("help:skinningSectionChanged")},decorationSectionAdvanced:function(){document.fire("help:skinningSectionChanged");document.fire("help:skinningSectionSelected")},addBorder:function(){var a=$F("backgroundCustomizationBorderWidth");if(0==this.numberOfBorders){$$(".BorderCustomization")[0].show();++this.numberOfBorders}else{$$(".BorderCustomization")[1].show();this.numberOfBorders=2}this.updateBorderControls()},removeBorder:function(){var a=$F("backgroundCustomizationSecondBorderWidth");if(2==this.numberOfBorders){$$(".BorderCustomization")[1].hide();$("backgroundCustomizationSecondBorderWidth").setValue("0");--this.numberOfBorders}else{$$(".BorderCustomization")[0].hide();$("backgroundCustomizationBorderWidth").setValue("0");this.numberOfBorders=0}this.updateBorderControls()},updateBorderControls:function(){var a=$$(".BorderControls a");a.invoke("show");if(2==this.numberOfBorders){a[0].hide()}if(0==this.numberOfBorders){a[1].hide()}}};ShippingController={shippingDomain:function(){NavigationService.processGenericServerCall(true)},successShippingDomain:function(a){$$("#mainPanel > .Dialog").first().update(a.htmlContent);ShopService.showOnlyMainPanelDialog();ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.shippingDomain.configuration.title"));ShopService.hideNavigation();ShopService.hideAction();this.shippingMainManager=undefined;this.updateShippingPolicyManager=undefined;this.currentShippingPolicy=undefined;this.policies=new Array();ShippingPolicyRule.rowTemplate=a.policyRuleRowTemplate;ShippingPolicyEditor.rowTemplate=a.policyRowTemplate;a.policyData.each(function(c){var d=new ShippingPolicyEditor();d.setupFromJSONData(c);d.prepareView();this.policies.push(d)}.bind(this));var b=NavigationService.getQueryParameter("section");if(undefined==b||(undefined==this["shippingSection"+b])){b="Main"}NavigationService.updateNavigationListeners($$("#mainPanel > .Dialog").first());this["shippingSection"+b]()},shippingSectionMain:function(){var a;NavigationService.prepareTabView("Main",NavigationService.obtainTabLink($$("#shippingDomain .TabHeader").first(),"Main"));if(this.shippingMainManager){this.shippingMainManager.reset($("updateMainShippingControlsForm"))}else{this.shippingMainManager=new FormManager($("updateMainShippingControlsForm"))}a=this.shippingMainManager.registerElement($("updateMainShippingControlsNoShipping")).setupAsElementSelector({inverse:true});this.shippingMainManager.registerElement($("shippingSectionMainCountriesMultipleSelector")).setCheckboxRequired(a).setMandatoryConstraint(localeMessageResolverService.getMessage("js.editor.errors.shippingDomain.main.country.mandatory"));a=this.shippingMainManager.registerElement($("updateMainShippingControlsPhysical")).setupAsElementSelector();this.shippingMainManager.registerElement($("updateMainShippingControlsAddress")).setCheckboxRequired(a).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.userAccount.address.mandatory")).setInstantValidation();this.shippingMainManager.registerElement($("updateMainShippingControlsCity")).setCheckboxRequired(a).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.userAccount.city.mandatory")).setInstantValidation();this.shippingMainManager.registerElement($("updateMainShippingControlsPostalCode")).setCheckboxRequired(a).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.userAccount.postalCode.mandatory")).setInstantValidation();this.shippingMainManager.registerElement($("updateMainShippingControlsCountryCode")).setCheckboxRequired(a).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.userAccount.country.mandatory"));this.shippingMainManager.setSuccessCallback(this.successShippingDomain.bind(this))},shippingSectionView:function(){NavigationService.prepareTabView("View",NavigationService.obtainTabLink($$("#shippingDomain .TabHeader").first(),"View"))},shippingSectionEdit:function(){$("shippingEditTab").show();NavigationService.prepareTabView("Edit",NavigationService.obtainTabLink($$("#shippingDomain .TabHeader").first(),"Edit"));var a=NavigationService.getQueryParameter("policy");if(!this.currentShippingPolicy){this.setupShippingSectionEdit(a)}else{if(this.currentShippingPolicy.id!=a){this.setupShippingSectionEdit(a)}}$$("#updateShippingPolicyForm .GeneralFormMessage").first().update("").removeClassName("ValidFormMessage")},setupShippingSectionEdit:function(a){if("new"==a||undefined==a){this.currentShippingPolicy=new ShippingPolicyEditor()}else{this.currentShippingPolicy=this.getPolicyById(a)}this.currentShippingPolicy.updateRules();if(this.updateShippingPolicyManager){this.updateShippingPolicyManager.reset($("updateShippingPolicyForm"))}else{this.updateShippingPolicyManager=new FormManager($("updateShippingPolicyForm"))}this.updateShippingPolicyManager.setAdditionalValidation(this.currentShippingPolicy.validate.bind(this.currentShippingPolicy));this.updateShippingPolicyManager.setSuccessCallback(this.currentShippingPolicy.update.bind(this.currentShippingPolicy));this.updateShippingPolicyManager.registerElement($("updateShippingPolicyName")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.editor.errors.shippingDomain.policyName.mandatory")).setInstantValidation();this.updateShippingPolicyManager.registerElement($("updateShippingPolicyDescription")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.editor.errors.shippingDomain.policyDescription.mandatory")).setInstantValidation();this.updateShippingPolicyManager.registerElement($("shippingSectionEditCountriesMultipleSelector")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.editor.errors.shippingDomain.country.mandatory"));this.updateShippingPolicyManager.bindObjectToForm(this.currentShippingPolicy)},createShippingPolicyRule:function(){this.currentShippingPolicy.createShippingPolicyRule()},getPolicyById:function(a){return this.policies.find(function(b){return(b.id==a)})},activateShippingPolicy:function(id){var a=this.getPolicyById(id);a.active=true;a.prepareView();NavigationService.processGenericServerCall(false)},disableShippingPolicy:function(id){var a=this.getPolicyById(id);a.active=false;a.prepareView();NavigationService.processGenericServerCall(false)},removeShippingPolicy:function(){var a,b;a=confirm(localeMessageResolverService.getMessage("js.editor.errors.shippingDomain.policy.delete.confirm"));if(a){b=this.getPolicyById(NavigationService.getQueryParameter("id"));b.remove();NavigationService.processGenericServerCall(false)}}};Object.extend(ShopCategoryController,{obtainCategoryNames:function(){this.namesArray=new Array();this.categories.each(function(a){if("Root"!=a.name){this.namesArray.push(a.name)}}.bind(this));return this.namesArray},getCategoryByName:function(a){return this.categories.find(function(b){return((b.name==a)&&("Root"!=b.name))})},insertControls:function(){this.insertCategoryControl(this.rootCategory);NavigationService.updateGlobalNavigationListeners()},insertCategoryControl:function(b){var a=new Template(this.createCategoryTemplate);b.getChildrenDiv().insert({bottom:a.evaluate(b)});if(b.isRoot()){$$("#categoryControl"+b.id+" span").first().update(localeMessageResolverService.getMessage("js.editor.shopCategory.action.add"));$$("#categoryControl"+b.id+" .DeleteCategoryControl").first().remove();$$("#categoryControl"+b.id+" .RenameCategoryControl").first().remove();$("categoryControl"+b.id).show().removeClassName("CategoryControl").addClassName("RootCategoryControl")}b.children.each(function(c){this.insertCategoryControl(c)}.bind(this))},toggleCategoryControl:function(a){$$(".CategoryControl").invoke("hide");$("categoryControl"+a).show()},toggleCreateCategoryControl:function(eventElement){eventElement.next("div").toggle()},toggleRenameCategoryControl:function(eventElement){eventElement.next("div").toggle()},successCreateCategory:function(a){ShopService.displayMessage(a.resultMessage);ShopService.showOnlyMainPanelDialog();this.createCategory(a);this.rootCategory.getChildrenDiv().update("");this.rootCategory.prepareView();this.currentCategory.select();this.insertControls(ShopCategoryController.rootCategory)},failureCreateCategory:function(a){ShopService.displayMessage(a.resultMessage);ShopService.showOnlyMainPanelDialog()},successRenameCategory:function(a){ShopService.displayMessage(a.resultMessage);ShopService.showOnlyMainPanelDialog();this.rootCategory.setCurrentCategoryById(a.id);this.currentCategory.name=a.name;this.rootCategory.getChildrenDiv().update("");this.rootCategory.prepareView();this.insertControls(ShopCategoryController.rootCategory)},failureRenameCategory:function(a){ShopService.displayMessage(a.resultMessage);ShopService.showOnlyMainPanelDialog()},deleteCategory:function(id,name){$("hiddenPanels").insert({bottom:this.deleteCategoryNode});this.deleteCategoryNode.down("span").update(name);this.deleteCategoryNode.down("input").setValue(id);new Panel(this.deleteCategoryNode,$("categoryControl"+id)).enable();NavigationService.updateNavigationListeners(this.deleteCategoryNode);this.deleteCategoryNode.down("button[type='button']").stopObserving().observe("click",function(a){a.stop();this.deleteCategoryNode.remove()}.bindAsEventListener(this))},successDeleteCategory:function(a){this.deleteCategoryNode.remove();ShopService.displayMessage(a.resultMessage);ShopService.showOnlyMainPanelDialog();this.rootCategory.setCurrentCategoryById(a.id);this.categories=this.categories.without(ShopCategoryController.currentCategory);this.currentCategory.remove();this.rootCategory.getChildrenDiv().update("");this.rootCategory.prepareView();this.insertControls(this.rootCategory)},failureDeleteCategory:function(a){this.deleteCategoryNode.remove();ShopService.displayMessage(a.resultMessage);ShopService.showOnlyMainPanelDialog()}});ShopEditorController=Object.extend(ShopBrowsingController,{defaultAction:"main",items:new Hash(),initialize:function(a){this.initializeBase(a);$$(".ShopEditor").invoke("show");this.setupControlsPanel()},setupControlsPanel:function(){this.controlsPanel=new Panel($("controlsPanel"),$(document.body)).forbidVerticalMove().enable();$$("#themeSelectionForm select").first().observe("change",this.changeBaseSkin.bindAsEventListener())},main:function(){var a,b;ShopService.hideNavigation();ShopService.hideAction();ShopService.showOnlyMainPanelDialog();if(NavigationService.firstLoad){a=$$("#welcomePage .Dialog").first();if(a){b=$("dialogPanel");b.update(a.innerHTML);b.select(".AjaxOnly").invoke("show");NavigationService.updateNavigationListeners(b);this.dialogPanel=new DialogPanel(b,$(document.body)).enable()}else{NavigationService.processGenericServerCall(true)}}else{NavigationService.processGenericServerCall(true)}},successMain:function(b){var a=$$("#mainPanel > .Dialog").first();ShopService.updateMainPanelTitle(b.captionMessage);a.update(b.resultMessage);NavigationService.updateNavigationListeners(a);ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.shop.temporary.welcome.title"))},queryCategory:function(id,currentPage,sort){ShopCategoryController.toggleCategoryControl(id);this.queryCategoryBase(id,currentPage,sort)},changeBaseSkin:function(){NavigationService.processNavigationCommand($("themeSelectionForm"))},successChangeBaseSkin:function(a){if(a.newCSSContent){DecorationController.rewriteCSS(a.newCSSContent)}},displayCreateItemDialog:function(){ShopService.hideItemDetailPanel();NavigationService.processGenericServerCall(true)},successDisplayCreateItemDialog:function(b){var a=$$("#mainPanel > .Dialog").first();a.update(b);ShopService.showOnlyMainPanelDialog();ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.item.add.title"));ShopEditorItemController.forceNewReferenceItemNode=$$(".EmbeddedTemplateNode.ForceNewReferenceItem").first().remove();$$("#mainPanel .Dialog").last().update(ShopEditorItemController.forceNewReferenceItemNode);document.fire("help:referenceItemSearch");NavigationService.updateNavigationListeners($("mainPanel"))},readMainConfiguration:function(){NavigationService.processGenericServerCall(true)},successReadMainConfiguration:function(b){var a=$$("#mainPanel > .Dialog").first();ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.shop.controls.title"));ShopService.hideNavigation();ShopService.hideAction();ShopService.showOnlyMainPanelDialog();a.update(b);NavigationService.updateNavigationListeners(a);if(this.generalControlsManager){this.generalControlsManager.reset($("updateMainConfigurationForm"))}else{this.generalControlsManager=new FormManager($("updateMainConfigurationForm"))}this.generalControlsManager.setSuccessCallback(this.successUpdateMainConfiguration.bind(this));this.generalControlsManager.registerElement($("updateMainConfigurationName")).setServerConstraint("/shop/checkShopName").setValidMessage(localeMessageResolverService.getMessage("js.editor.errors.shop.name.valid")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.editor.errors.shop.name.mandatory")).setInstantValidation();this.generalControlsManager.registerElement($("updateMainConfigurationPayPalAccount")).setServerConstraint("/account/checkPayPalAccount").setEmailConstraint(localeMessageResolverService.getMessage("js.editor.errors.shop.paypal.invalid")).setValidMessage(localeMessageResolverService.getMessage("js.editor.errors.shop.paypal.valid")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.editor.errors.shop.paypal.mandatory")).setInstantValidation();this.generalControlsManager.registerElement($("updateMainConfigurationTitle")).setMandatoryConstraint(localeMessageResolverService.getMessage("shopFront.title.size.toosmall")).setInstantValidation();document.fire("help:readMainConfiguration")},successUpdateMainConfiguration:function(a){ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.shop.settings.update.success.title"));$$("#mainPanel > .Dialog").first().update(a.resultMessage);if(a.redirect){window.location=a.redirectLocation}},successActivateShop:function(initialData){ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.shop.activation.success.title"));ShopService.displayMessage(initialData.resultMessage)},closeDialog:function(){if(this.dialogPanel){this.dialogPanel.disable()}$("dialogPanel").update("")},toggleCommunityMenu:function(){$("communityMenu").toggle()},successCreateNewsArticle:function(b){var a=$$("#mainPanel > .Dialog .NewsContainer").first();a.insert({top:b.template});NavigationService.updateNavigationListeners(a);$$("#createNewsArticleForm .GeneralFormMessage").first().update(b.resultMessage)},failureCreateNewsArticle:function(a){$$("#createNewsArticleForm .GeneralFormMessage").first().update(a.resultMessage)},successDeleteNewsArticle:function(b){var a=$$(".NewsContainer input[value='"+b.id+"']").first().up();a.previous().remove();a.remove();$$("#createNewsArticleForm .GeneralFormMessage").first().update(b.resultMessage)},successCreateAboutArticle:function(b){var a=$$("#mainPanel > .Dialog .AboutContainer").first();a.insert({bottom:b.template});NavigationService.updateNavigationListeners(a);$$("#createAboutArticleForm .GeneralFormMessage").first().update(b.resultMessage)},failureCreateAboutArticle:function(a){$$("#createAboutArticleForm .GeneralFormMessage").first().update(a.resultMessage)},successDeleteAboutArticle:function(b){var a=$$(".AboutContainer input[value='"+b.id+"']").first().up();a.previous().remove();a.remove();$$("#createAboutArticleForm .GeneralFormMessage").first().update(b.resultMessage)},successCreateFaqSection:function(b){var a=$$("#mainPanel > .Dialog .FaqContainer").first();a.insert({bottom:b.template});NavigationService.updateNavigationListeners(a);$$("#createFaqSectionForm .GeneralFormMessage").first().update(b.resultMessage)},failureCreateFaqSection:function(a){$$("#createFaqSectionForm .GeneralFormMessage").first().update(a.resultMessage)},successDeleteFaqSection:function(b){var a=$$("form.DeleteFaqSection input[value='"+b.id+"']").first().up().up();a.remove();$$("#createFaqSectionForm .GeneralFormMessage").first().update(b.resultMessage)},successCreateFaqElement:function(b){var a=$$("form#createFaqElementForm input[value='"+b.id+"']").first().up().previous();a.insert({before:b.template});NavigationService.updateNavigationListeners(a.up());$$("#createFaqSectionForm .GeneralFormMessage").first().update(b.resultMessage)},failureCreateFaqElement:function(a){$$("#createFaqSectionForm .GeneralFormMessage").first().update(a.resultMessage)}});ShopEditorHelpController={defaultAction:"help",help:function(){ShopService.hideNavigation();ShopService.hideAction();ShopService.showOnlyMainPanelDialog();NavigationService.processGenericServerCall(true)},successHelp:function(b){var a=$$("#mainPanel > .Dialog").first();ShopService.updateMainPanelTitle(b.captionMessage);a.update(b.resultMessage);NavigationService.updateNavigationListeners(a)},tutorial:function(){NavigationService.processGenericServerCall(true)},successTutorial:function(b){var a=$$("#mainPanel > .Dialog").first();ShopService.updateMainPanelTitle(b.captionMessage);a.update(b.resultMessage);NavigationService.updateNavigationListeners(a)},displaySendMessageToShoopzDialog:function(){if($("writeMessageToShoopzForm")){$$("#mainPanel > .Dialog").first().update()}NavigationService.processGenericServerCall(true)},successDisplaySendMessageToShoopzDialog:function(b){var a=$("dialogPanel");a.update(b);NavigationService.updateNavigationListeners(a);this.dialogPanel=new DialogPanel(a,$(document.body)).enable();if(this.writeMessageFormManager){this.writeMessageFormManager.reset($("writeMessageToShoopzForm"))}else{this.writeMessageFormManager=new FormManager($("writeMessageToShoopzForm"))}this.writeMessageFormManager.registerElement($("writeMessageToShoopzSubject"));if($("writeMessageToShoopzEmailAddress")){this.writeMessageFormManager.registerElement($("writeMessageToShoopzEmailAddress")).setEmailConstraint(localeMessageResolverService.getMessage("js.errors.userAccount.email.invalid")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.userAccount.email.mandatory")).setInstantValidation()}this.writeMessageFormManager.registerElement($("writeMessageToShoopzEmailMessage")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.contact.message.mandatory")).setInstantValidation()},successSendMessageToShoopz:function(b){var a=$$("#dialogPanel .Content").first();a.update(b.resultMessage);NavigationService.updateNavigationListeners(a)},closeDialog:function(){if(this.dialogPanel){this.dialogPanel.disable()}$("dialogPanel").update("")},displayTutorialHelp:function(a){this.setupTutorialHelp(a);this.helpPanel.executeStep(1)},setupTutorialHelp:function(c){var a,d,b;if(this.helpPanel){this.helpPanel.destroy()}this.helpPanel=new InteractiveHelpPanel($$(".HelpTutorialPanel").first(),undefined);switch(c){case"1":a=$$("#themeSelectionForm select").first();d={contentElement:$("helpTutorialStep1"),targetElement:a,optionsFunction:function(){this.setCornerPosition().setFixedPosition().setRightPosition().forbidScreenCentering()}};b=[{element:a,eventName:"change"}];this.helpPanel.registerStep(1,d).registerEventsForStep(0,b);break;case"2":a=$$("#customizeSwitcher span").first();d={contentElement:$("helpTutorialStep21"),targetElement:a,optionsFunction:function(){this.setCornerPosition().setFixedPosition().setRightPosition().forbidScreenCentering()}};b=[{element:$$("#customizeSwitcher img").first(),eventName:"click"}];this.helpPanel.registerStep(1,d).registerEventsForStep(2,b);a=$("navigationPanel");d={contentElement:$("helpTutorialStep22"),targetElement:a,optionsFunction:function(){this.setCenterVerticalPosition().forbidScreenCentering()}};b=[{element:document,eventName:"skinning:elementSelected"}];this.helpPanel.registerStep(2,d).registerEventsForStep(3,b);a=$$("#decorationDomain .SubmitButton").first();d={contentElement:$("helpTutorialStep23"),targetElement:a,optionsFunction:function(){this.setCornerPosition().setBottomPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:skinningSectionChanged"}];this.helpPanel.registerStep(3,d).registerEventsForStep(4,b);a=$$("#customizeSwitcher span").first();d={contentElement:$("helpTutorialStep24"),targetElement:a,optionsFunction:function(){this.setFixedPosition().setTopPosition().forbidScreenCentering()}};b=[{element:$$("#customizeSwitcher img").last(),eventName:"click"}];this.helpPanel.registerStep(4,d).registerEventsForStep(0,b);break;case"3":d={contentElement:$("helpTutorialStep31"),targetElement:$(document.body),optionsFunction:function(){this.disableArrow()}};b=[{element:document,eventName:"skinning:elementSelected"}];this.helpPanel.registerStep(1,d).registerEventsForStep(2,b);a=$$("#decorationDomain .TabHeader a").last();d={contentElement:$("helpTutorialStep32"),targetElement:a,optionsFunction:function(){this.enableArrow().setCornerPosition().setTopPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:skinningSectionSelected"}];this.helpPanel.registerStep(2,d).registerEventsForStep(3,b);a=$("decorationDomain");d={contentElement:$("helpTutorialStep33"),targetElement:a,optionsFunction:function(){this.enableArrow().setBottomPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:skinningSectionChanged"}];this.helpPanel.registerStep(3,d).registerEventsForStep(0,b);break;case"4":a=$$("#categories .RootCategoryControl").first();d={contentElement:$("helpTutorialStep41"),targetElement:a,optionsFunction:function(){this.setCornerPosition().forbidScreenCentering()}};b=[{element:a,eventName:"click"}];this.helpPanel.registerStep(1,d).registerEventsForStep(0,b);break;case"5":a=$$("#controlsPanel .ProductsConfiguration a").first();d={contentElement:$("helpTutorialStep51"),targetElement:a,optionsFunction:function(){this.setFixedPosition().setCornerPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:referenceItemSearch"}];this.helpPanel.registerStep(1,d).registerEventsForStep(2,b);a="#referenceSearchForm input[type='submit']";d={contentElement:$("helpTutorialStep52"),targetElementSelector:a,optionsFunction:function(){this.setCornerPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:referenceItemsFound"}];this.helpPanel.registerStep(2,d).registerEventsForStep(3,b);b=[{element:document,eventName:"help:noReferenceItemsFound"}];this.helpPanel.registerEventsForStep(4,b);d={contentElement:$("helpTutorialStep53"),targetElement:$("itemListPanel"),optionsFunction:function(){this.setBottomPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:updateShopItem"}];this.helpPanel.registerStep(3,d).registerEventsForStep(6,b);a="#noReferenceItems a";d={contentElement:$("helpTutorialStep54"),targetElementSelector:a,optionsFunction:function(){this.setBottomPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:readReferenceItem"}];this.helpPanel.registerStep(4,d).registerEventsForStep(5,b);d={contentElement:$("helpTutorialStep55"),targetElementSelector:"#updateReferenceItemForm",optionsFunction:function(){this.setTopPosition().forbidScreenCentering()},callback:function(){$("updateReferenceItemForm").action=$("updateReferenceItemForm").action+"?tutorial=on"}};b=[{element:document,eventName:"help:updateShopItem"}];this.helpPanel.registerStep(5,d).registerEventsForStep(6,b);d={contentElement:$("helpTutorialStep56"),targetElementSelector:"#updateShopItemDialog",optionsFunction:function(){this.setTopPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:successUpdateShopItem"}];this.helpPanel.registerStep(6,d).registerEventsForStep(0,b);break;case"6":d={contentElement:$("helpTutorialStep61"),targetElement:$("categories"),optionsFunction:function(){this.setCornerPosition().setTopPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:queryCategory"}];this.helpPanel.registerStep(1,d).registerEventsForStep(2,b);d={contentElement:$("helpTutorialStep62"),targetElement:$("itemListPanel"),optionsFunction:function(){this.forbidScreenCentering()}};b=[{element:document,eventName:"help:displayItemDetailPanel"}];this.helpPanel.registerStep(2,d).registerEventsForStep(3,b);d={contentElement:$("helpTutorialStep63"),targetElement:$("itemDetailPanel"),optionsFunction:function(){this.forbidScreenCentering()}};b=[{element:document,eventName:"help:displayItemFullPanel"}];this.helpPanel.registerStep(3,d).registerEventsForStep(0,b);break;case"7":d={contentElement:$("helpTutorialStep71"),targetElement:$(document.body),optionsFunction:function(){this.disableArrow()}};b=[{element:document,eventName:"help:itemAddedToCart"}];this.helpPanel.registerStep(1,d).registerEventsForStep(2,b);d={contentElement:$("helpTutorialStep72"),targetElementSelector:"#shoppingCartContent a",optionsFunction:function(){this.enableArrow().setCornerPosition().setBottomPosition().forbidScreenCentering()}};b=[{element:document,eventName:"help:cartDisplayed"}];this.helpPanel.registerStep(2,d).registerEventsForStep(0,b);break;case"8":a=$$("#controlsPanel .ShopConfiguration a")[1];d={contentElement:$("helpTutorialStep81"),targetElement:a,optionsFunction:function(){this.setFixedPosition().setTopPosition().setCornerPosition()}};b=[{element:a,eventName:"click"}];this.helpPanel.registerStep(1,d).registerEventsForStep(0,b);break;case"9":a=$$("#controlsPanel .ShopConfiguration a").first();d={contentElement:$("helpTutorialStep91"),targetElement:a,optionsFunction:function(){this.setFixedPosition().setTopPosition().setCornerPosition()}};b=[{element:document,eventName:"help:authenticationDomain"}];this.helpPanel.registerStep(1,d).registerEventsForStep(2,b);b=[{element:document,eventName:"help:readMainConfiguration"}];this.helpPanel.registerEventsForStep(3,b);d={contentElement:$("helpTutorialStep92"),targetElement:$("mainPanel"),optionsFunction:function(){this.setTopPosition()}};b=[{element:document,eventName:"help:readMainConfiguration"}];this.helpPanel.registerStep(2,d).registerEventsForStep(3,b);d={contentElement:$("helpTutorialStep93"),targetElement:$("mainPanel"),optionsFunction:function(){this.disableArrow().setBottomPosition()}};this.helpPanel.registerStep(3,d);break}}};ShopEditorItemController={successReadShopItem:function(c){var b,a;a=$$("#mainPanel > .Dialog").first();if(!$("updateShopItemForm")){a.insert({bottom:c.itemShopItemDialog})}if(c.deleteForm){$("deleteShopItemFormContainer").update(c.deleteForm)}ShopService.clearItemListPanel();ShopService.hideItemListPanel();ShopService.updateMainPanelTitle(localeMessageResolverService.getMessage("js.editor.shopItem.edit.title"));NavigationService.updateNavigationListeners(a);new Autocompleter.Local($("updateShopItemCategoryName"),$("updateShopItemCategoryName").next(".AutoComplete"),ShopCategoryController.obtainCategoryNames());if(this.updateShopItemManager){this.updateShopItemManager.reset($("updateShopItemForm"))}else{this.updateShopItemManager=new FormManager($("updateShopItemForm"))}this.updateShopItemManager.setSuccessCallback(this.successUpdateShopItem.bind(this));this.updateShopItemManager.registerElement($("updateShopItemCategoryName")).setCustomConstraint(this.validateUpdateShopItem,localeMessageResolverService.getMessage("js.errors.shopItem.edit.category.invalid"));if(c.variationsData){this.variationsData=c.variationsData;if($("updateVariationsPanel")){$("updateVariationsPanel").replace(c.variationsData.updateShopItemVariationsDialog)}else{$("hiddenPanels").insert({bottom:c.variationsData.updateShopItemVariationsDialog})}}else{this.updateShopItemManager.registerElement($("updateShopItemPrice")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.shopItem.edit.price.mandatory")).setMinimalConstraint(0,true,localeMessageResolverService.getMessage("js.errors.shopItem.edit.price.float")).setInstantValidation();b=this.updateShopItemManager.registerElement($("updateShopItemStock")).setupAsElementSelector();this.updateShopItemManager.registerElement($("updateShopItemQuantity")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.shopItem.edit.quantity.mandatory")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.shopItem.edit.quantity.positive")).setCheckboxRequired(b).setInstantValidation()}this.updateShopItemManager.registerElement($("updateShopItemId"));this.updateShopItemManager.registerElement($("updateShopItemCategoryId"));this.updateShopItemManager.registerElement($("updateShopItemReferenceItemId"));this.updateShopItemManager.registerElement($("updateShopItemStatus"));this.updateShopItemManager.registerElement($("updateShopItemAdditionalInformation"));this.updateShopItemManager.bindDataToForm(c);if(ShopEditorController.helpTutorialContentsTemplate){template=new Template(ShopEditorController.helpTutorialContentsTemplate);delete (ShopEditorController.helpTutorialContentsTemplate);$("hiddenPanels").insert({bottom:template.evaluate(this)});ShopEditorHelpController.setupTutorialHelp("5");ShopEditorHelpController.helpPanel.executeStep(6);$$("#hiddenPanels > div").last().remove()}document.fire("help:updateShopItem")},validateUpdateShopItem:function(a){var b=ShopCategoryController.getCategoryByName(a.getValue());if(b){$("updateShopItemCategoryId").setValue(b.id);return true}else{return false}},successUpdateShopItem:function(a){ShopService.showItemListPanel();ShopService.hideItemDetailPanel();$$("#mainPanel > .Dialog").first().update(a.resultMessage);ShopBrowsingController.resetCurrentItems();document.fire("help:successUpdateShopItem")},successDeleteShopItem:function(a){ShopService.showItemListPanel();ShopService.hideItemDetailPanel();ShopBrowsingController.resetCurrentItems();$$("#mainPanel > .Dialog").first().update(a.resultMessage)},updateVariations:function(){var a=$("updateVariationsPanel");new Panel(a,document.body).enable();NavigationService.updateNavigationListeners(a);if(this.updateShopItemVariationsManager){this.updateShopItemVariationsManager.reset($("updateShopItemVariationsForm"))}else{this.updateShopItemVariationsManager=new FormManager($("updateShopItemVariationsForm"))}checkbox=this.updateShopItemVariationsManager.registerElement($("updateShopItemVariationsCommonPrice")).setupAsElementSelector({callback:this.toggleVariationsCommonPriceCheckbox.bind(this)});this.updateShopItemVariationsManager.registerElement($("updateShopItemVariationsPrice")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.shopItem.edit.price.mandatory")).setMinimalConstraint(0,true,localeMessageResolverService.getMessage("js.errors.shopItem.edit.price.float")).setCheckboxRequired(checkbox).setInstantValidation().setCustomCallback(this.changeCommonPrice.bind(this));this.updateShopItemVariationsManager.registerElement($("updateShopItemVariationsStock")).setInstantValidation().setCustomCallback(this.toggleVariationsStockCheckbox.bind(this));checkbox=this.updateShopItemVariationsManager.registerElement($("updateShopItemVariationsCommonQuantity")).setupAsElementSelector({callback:this.toggleVariationsQuantityCheckbox.bind(this)});this.updateShopItemVariationsManager.registerElement($("updateShopItemVariationsQuantity")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.shopItem.edit.quantity.mandatory")).setPositiveConstraint(localeMessageResolverService.getMessage("js.errors.shopItem.edit.quantity.positive")).setCheckboxRequired(checkbox).setInstantValidation().setCustomCallback(this.changeCommonQuantity.bind(this));this.updateShopItemVariationsManager.bindDataToForm(this.variationsData)},toggleVariationsCommonPriceCheckbox:function(){if($("updateShopItemVariationsCommonPrice").checked){$("updateShopItemVariationsPrice").up().show();this.changeCommonPrice()}else{$("updateShopItemVariationsPrice").up().hide()}},toggleVariationsQuantityCheckbox:function(){if($("updateShopItemVariationsCommonQuantity").checked){$("updateShopItemVariationsQuantity").up().show();this.changeCommonQuantity()}else{$("updateShopItemVariationsQuantity").up().hide()}},toggleVariationsStockCheckbox:function(){if($("updateShopItemVariationsStock").checked){$$("#updateShopItemVariationsForm .StockChecked").first().show();$$(".VariationQuantityColumn").invoke("show")}else{$$("#updateShopItemVariationsForm .StockChecked").first().hide();$$(".VariationQuantityColumn").invoke("hide")}},changeCommonPrice:function(){$$(".VariationPrice").invoke("setValue",$F("updateShopItemVariationsPrice"))},changeCommonQuantity:function(){$$(".VariationQuantity").invoke("setValue",$F("updateShopItemVariationsQuantity"))},successProcessReferenceSearch:function(a){ShopService.showOnlyMainPanelDialog();$$("#mainPanel > .Dialog").last().show();$("noReferenceItems").hide();if($("updateShopItemDialog")){$("updateShopItemDialog").remove()}ShopEditorController.items=new Hash();if(undefined!=a.itemsData){a.itemsData.each(function(b){ShopEditorController.items.set(b.rank,new ReferenceItem(b.id,b.name,b.shortDescription,b.description,b.manufacturer,b.model,b.previewImage,b.detailImage))}.bind(this))}if(0==ShopEditorController.items.size()){$("noReferenceItems").show();$("selectReferenceItem").hide();document.fire("help:noReferenceItemsFound")}else{ShopService.showItemListPanel();$("selectReferenceItem").show();ShopEditorController.items.each(function(b){b.value.displayPreview()});this.forceNewReferenceItemNode.show();NavigationService.updateNavigationListeners($("mainPanel"));document.fire("help:referenceItemsFound")}},successReadReferenceItem:function(b){var c,a;this.variationValuesTemplate=b.templateContent;this.variations=b.variations;this.variationsIndex={};ShopService.clearMainPanelDialog();ShopService.showOnlyMainPanelDialog();ShopService.displayMessageAndUpdateNavigationListeners(b.viewContent);ShopService.updateMainPanelTitle(b.captionMessage);if(this.updateReferenceItemManager){this.updateReferenceItemManager.reset($("updateReferenceItemForm"))}else{this.updateReferenceItemManager=new FormManager($("updateReferenceItemForm"))}this.updateReferenceItemManager.registerElement($("updateReferenceItemName")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.general.name.mandatory")).setInstantValidation();this.updateReferenceItemManager.registerElement($("updateReferenceItemManufacturer")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.manufacturer.mandatory")).setInstantValidation();this.updateReferenceItemManager.registerElement($("updateReferenceItemShortDescription")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.shortDescription.mandatory")).setLengthConstraint(0,250,localeMessageResolverService.getMessage("js.errors.referenceItem.shortDescription.length")).setLengthNotification();this.updateReferenceItemManager.registerElement($("updateReferenceItemDescription")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.description.mandatory")).setInstantValidation();checkbox=this.updateReferenceItemManager.registerElement($("updateReferenceItemImmaterial")).setupAsElementSelector({inverse:true});this.updateReferenceItemManager.registerElement($("updateReferenceItemWeight")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.weight.mandatory")).setMinimalConstraint(0,true,localeMessageResolverService.getMessage("js.errors.referenceItem.weight.float")).setInstantValidation().setCheckboxRequired(checkbox);a=this.updateReferenceItemManager.registerElement($("updateReferenceItemImageUploadMethod")).setupAsElementSelector();this.updateReferenceItemManager.registerElement($("updateReferenceItemImageFile")).setRadioButtonRequired(a);this.updateReferenceItemManager.registerElement($("updateReferenceItemImageURL")).setRegularExpression(/^http:\/\//,localeMessageResolverService.getMessage("js.errors.referenceItem.imageURL.regularExpression")).setRadioButtonRequired(a).setInstantValidation();if(b.create){this.updateReferenceItemManager.obtainFormElement($("updateReferenceItemImageFile")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.image.mandatory"));this.updateReferenceItemManager.obtainFormElement($("updateReferenceItemImageURL")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.imageURL.mandatory"))}this.updateReferenceItemManager.addSlaveForm($("variationsContainerForm"));$$("fieldset.VariationInformation div.MultipleSelector").each(function(d){this.updateReferenceItemManager.registerElement(d).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.variations.values.mandatory"))}.bind(this));document.fire("help:readReferenceItem");c=NavigationService.getQueryParameter("section");if(c==undefined||(this["referenceItemSection"+c]==undefined)){c="Main"}this["referenceItemSection"+c]()},referenceItemSectionMain:function(){NavigationService.prepareTabView("Main",NavigationService.obtainTabLink($$("#referenceItemDomain .TabHeader").first(),"Main"))},referenceItemSectionVariation:function(){NavigationService.prepareTabView("Variation",NavigationService.obtainTabLink($$("#referenceItemDomain .TabHeader").first(),"Variation"))},createVariation:function(variation){var b,c,a;b=new Template(this.variationValuesTemplate);if(undefined!=this.variationsIndex[variation]){++this.variationsIndex[variation]}else{this.variationsIndex[variation]=0}c={name:variation,index:this.variationsIndex[variation]};$("variationsContainerForm").insert({bottom:b.evaluate(c)});a=$("variationsContainerForm").select(".VariationInformation").last();multipleSelector=this.updateReferenceItemManager.registerElement(a.down("div.MultipleSelector")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.variations.values.mandatory"));this.variations[variation].each(function(d){multipleSelector.addToSourceElements(d.id,d.value)});this.updateReferenceItemManager.registerElement(a.down("input[type='text']")).setMandatoryConstraint(localeMessageResolverService.getMessage("js.errors.referenceItem.variations.description.mandatory"))},successCreateReferenceItem:function(initialData){if(initialData.referenceItem){this.referenceItem=new ReferenceItem(initialData.referenceItem.id,initialData.referenceItem.name,initialData.referenceItem.shortDescription,initialData.referenceItem.description,initialData.referenceItem.manufacturer,initialData.referenceItem.model,initialData.referenceItem.previewImage,initialData.referenceItem.detailImage);ShopService.displayMessage(initialData.resultMessage);this.referenceItem.displayPreview();this.referenceItem.displayDetailPanel();NavigationService.setupServerCallData("/shopEditorItem/readShopItem",{"reference.id":this.referenceItem.id});NavigationService.processGenericServerCall(true)}},successUpdateReferenceItem:function(initialData){ShopService.displayMessage(initialData.resultMessage)},displayDetailPanel:function(id){isWantedItem=function(a){return(a.value.id==id)};selectedItem=ShopEditorController.items.find(isWantedItem).value;if(selectedItem!=this.currentSelectedItem){selectedItem.displayDetailPanel();this.currentSelectedItem=selectedItem}else{this.eraseDetailPanel()}},eraseDetailPanel:function(){ShopService.hideItemDetailPanel();this.currentSelectedItem=undefined}};