
function DomAdapter(){var A="";if("undefined"!=typeof ActiveXObject){A="MS"}else{if("undefined"!=typeof document&&document.implementation&&document.implementation.createDocument&&"undefined"!=typeof DOMParser){A="default"}}switch(A){case"MS":return new (function(){this.createDocument=function(){var D=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(var B in D){try{return new ActiveXObject(D[B])}catch(C){}}throw new Error("Unable to create DOMDocument")};this.serialize=function(B){return B.xml};this.parseXml=function(B){var C=this.createDocument();if(!C.loadXML(B)){throw new Error("Parse error")}return C};this.loadXml=function(B){var C=this.createDocument();C.async=false;if(!C.load(B)){throw new Error("Load error")}return C};this.selectValue=function(C,D,B){return D.selectNodes(C)[0].childNodes[0].nodeValue||B}})();case"default":return new (function(){this.createDocument=function(){return document.implementation.createDocument("","",null)};this.serialize=function(B){return new XMLSerializer().serializeToString(B)};this.parseXml=function(B){var C=new DOMParser().parseFromString(B,"text/xml");if("parsererror"==C.documentElement.nodeName){throw new Error("Parse error")}return C};this.loadXml=function(B){var E;try{E=this.createDocument();E.async=false;E.load(B)}catch(D){var C=new XMLHttpRequest();C.open("GET",B,false);C.send(null);E=C.responseXML}return E};this.selectValue=function(D,F,B){try{var C=F.evaluate(D,F,null,XPathResult.ANY_TYPE,null);return C.iterateNext().childNodes[0].nodeValue||B}catch(E){}}})();default:throw new Error("Unable to select the DOM adapter")}};

Ext.BLANK_IMAGE_URL="/assets/images/s.gif";Ext.SSL_SECURE_URL="https://www.ebucket.net"+Ext.BLANK_IMAGE_URL;var domAdapter=DomAdapter();var xmlDoc=domAdapter.loadXml("/assets/xml/eBucketDriveSimpleCalculator.xml");var productDescription=domAdapter.selectValue("//productDescription",xmlDoc,"");var monthlyPrice=Number(domAdapter.selectValue("//monthlyPrice",xmlDoc,0));var prepaidValue=domAdapter.selectValue("//prepaidValue",xmlDoc,0);var minValue=domAdapter.selectValue("//minValue",xmlDoc,0);var maxValue=domAdapter.selectValue("//maxValue",xmlDoc,0);var dataStorage={prepaidValue:domAdapter.selectValue("//dataStorage/prepaidValue",xmlDoc,0),unitCost:domAdapter.selectValue("//dataStorage/unitCost",xmlDoc,0)};var dataIn={prepaidValue:domAdapter.selectValue("//dataIn/prepaidValue",xmlDoc,0),unitCost:domAdapter.selectValue("//dataIn/unitCost",xmlDoc,0)};var dataOut={prepaidValue:domAdapter.selectValue("//dataOut/prepaidValue",xmlDoc,0),unitCost:domAdapter.selectValue("//dataOut/unitCost",xmlDoc,0)};function resetSliders(){Ext.getCmp("slider-dataStorage").setValue(prepaidValue);Ext.getCmp("slider-dataIn").setValue(prepaidValue);Ext.getCmp("slider-dataOut").setValue(prepaidValue)}Ext.onReady(function(){Ext.state.Manager.setProvider(new Ext.state.CookieProvider());var A=new Ext.ux.SliderTip({getText:function(C){return String.format("<b>{0}Gb</b>",C.getValue())}});Ext.get("monthlyPrice").update(Ext.util.Format.usMoney(monthlyPrice));Ext.get("productDescription").update(productDescription);var B=Ext.get("custom-slider").getWidth();new Ext.ux.SliderStateful({id:"slider-dataStorage",renderTo:"slider-dataStorage-ct",cost:dataStorage.unitCost,prepaidValue:dataStorage.prepaidValue,text:"Storage",width:B,value:dataStorage.prepaidValue,increment:1,minValue:minValue,maxValue:maxValue,plugins:A});new Ext.ux.SliderStateful({id:"slider-dataIn",renderTo:"slider-dataIn-ct",cost:dataIn.unitCost,prepaidValue:dataIn.prepaidValue,text:"Data Transfer-in",width:B,value:dataIn.prepaidValue,increment:1,minValue:minValue,maxValue:maxValue,plugins:A});new Ext.ux.SliderStateful({id:"slider-dataOut",renderTo:"slider-dataOut-ct",cost:dataOut.unitCost,prepaidValue:dataOut.prepaidValue,text:"Data Transfer-out",width:B,value:dataOut.prepaidValue,increment:1,minValue:minValue,maxValue:maxValue,plugins:A})});Ext.ux.SliderStateful=Ext.extend(Ext.Slider,{stateEvents:["change"],stateful:true,getState:function(){return{selectedValue:this.getValue()}},applyState:function(C){var B=this;try{setTimeout(function(){B.setValue(C.selectedValue)},150)}catch(A){}}});Ext.ux.SliderTip=Ext.extend(Ext.Tip,{minWidth:10,offsets:[0,-10],init:function(A){A.on("change",this.onChange,this);A.on("drag",this.onSlide,this);A.on("dragend",this.hide,this);A.on("destroy",this.destroy,this);A.on("render",this.onChange,this)},onChange:function(A){this.onSlide(A);this.hide()},onBeforeChange:function(B,C,A){},onSlide:function(C){var D=C.getValue();this.show();this.body.update(this.getText(C));this.doAutoWidth();this.el.alignTo(C.thumb,"b-t?",this.offsets);Ext.get(C.id+"-Usage").update(D);Ext.get(C.id+"-Cost").update(Ext.util.Format.usMoney(this.getCost(D,prepaidValue,C.cost)));var F=monthlyPrice;var E=Ext.getCmp("slider-dataStorage");if(E){F+=this.getCost(Ext.getCmp("slider-dataStorage").getValue(),E.prepaidValue,E.cost)}var B=Ext.getCmp("slider-dataIn");if(B){F+=this.getCost(B.getValue(),B.prepaidValue,B.cost)}var A=Ext.getCmp("slider-dataOut");if(A){F+=this.getCost(Ext.getCmp("slider-dataOut").getValue(),B.prepaidValue,A.cost)}Ext.get("totalCost").update(Ext.util.Format.usMoney(F))},getCost:function(A,C,B){if(A>C){return(A-C)*B}return 0},getText:function(A){return A.getValue()}});