var EC_LithoCalc={product_name:"Letterhead",product_id:9,flag_form:true,opts:false,skus:false,area:0,selectedArea:0,widthText:0,heightText:0,weights:false,extra:false,prices:false,printRate:0,currentSku:"",currentName:"",currentTitle:"",formContents:"",sizeID:0,timer:0,selWeight:0,localText:false,shipOpts:false,shipRates:[],shipTimes:[],foldRate:0,names:false,titles:false,shipVals:false,foldingOpts:false,formContents:"",international:1,country_code:'<select id="country_code" name="country_code" class="textInput" onchange="EC_LithoCalc.updatePrice()"><option value="CA">Canada</option><option value="PR">Puerto Rico</option><option value="US" selected>United States</option></select>',handling_fee:0,order_action:"",green:true,minimum_price:0,minimum_area_for_price:1,quarter_inch_increments:false,mailingCanUseUV:false,custom_trim_size:true,coupon:false,currentPaper:false,folding:false,additional:true,additionalOpts:false,setAdditionalOpts:function(){this.additionalOpts=new Hash();this.additionalOpts.set("custom_green_paper",new Hash());this.additionalOpts.get("custom_green_paper").set(338,new Hash());this.additionalOpts.get("custom_green_paper").get(338).set("name","Print On House Paper");this.additionalOpts.get("custom_green_paper").get(338).set("price","");this.additionalOpts.get("custom_green_paper").get(338).set("setup","0.00");this.additionalOpts.get("custom_green_paper").set(339,new Hash());this.additionalOpts.get("custom_green_paper").get(339).set("name","Print On Go Green Paper");this.additionalOpts.get("custom_green_paper").get(339).set("price","");this.additionalOpts.get("custom_green_paper").get(339).set("setup","0.00");},setOpts:function(){this.opts=[];this.opts.product=[];this.opts.product[9]="Letterhead";this.opts.coating=[];this.opts.color=[];this.opts.paper=[];this.opts.size=[];this.opts.turnaround=[];this.opts.turnaround[282]="2-4 Day";this.opts.paper[920]="70# Uncoated Offset Smooth";this.opts.color[10]="4/4 (Full Color Both Sides)";this.opts.turnaround[266]="Next Day";this.opts.turnaround[109]="5-7 Day";this.opts.turnaround[107]="5 Day";this.opts.color[9]="4/1 (Full Color Front / B&W Back)";this.opts.color[8]="4/0 (Full Color Front Side)";this.opts.coating[5]="AQ 2 Sides (Semi-Gloss Coating)";this.opts.coating[1]="Uncoated";this.opts.paper[116]="70# Uncoated Offset Smooth Text";this.opts.coating[606]="Gloss UV Front, Satin AQ Back";this.opts.paper[452]="70# White Linen Text";this.opts.size[54]="8.5 X 11";this.opts.size[55]="8.5 X 14";if(this.product_name=="Roll Labels"){this.opts.die_shapes={};for(var b in this.opts.size){if(!isNaN(b)){var d=this.opts.size[b];var c=d.split(" - ");if(c.length==2){this.opts.size[b]=c[0];if(this.opts.die_shapes[c[1]]==undefined){this.opts.die_shapes[c[1]]=[];}this.opts.die_shapes[c[1]].push(b);}}}}},setSkus:function(){this.skus=new Hash();this.addSKU([9,"54",116,8,1,107],1343);this.addSKU([9,"54",452,8,1,109],5676);},setWeights:function(){this.weights=[];this.weights[1343]=13.5;this.weights[5676]=13.5;},setPrices:function(){this.prices=new Hash();var b=[];var a;b.push({i:1343,ii:2880,q:250,p:118});b.push({i:1343,ii:2881,q:500,p:149});b.push({i:1343,ii:2882,q:1000,p:150});b.push({i:1343,ii:2883,q:2500,p:208});b.push({i:1343,ii:2878,q:5000,p:276});b.push({i:1343,ii:2879,q:10000,p:505});b.push({i:5676,ii:12735,q:1000,p:180});b.push({i:5676,ii:12736,q:2500,p:347});b.push({i:5676,ii:12737,q:5000,p:508});for(a=0;a<b.length;a++){if(this.prices.get(b[a]["i"])==null){this.prices.set(b[a]["i"],new Hash());}this.prices.get(b[a]["i"]).set(b[a]["q"],new Hash());this.prices.get(b[a]["i"]).get(b[a]["q"]).set("i",b[a]["ii"]);this.prices.get(b[a]["i"]).get(b[a]["q"]).set("p",b[a]["p"]);}},init:function(){if($("myForm")){this.order_action=$("myForm").action;$("myForm").addEvent("submit",function(a){if(EC_LithoCalc.flag_form){new Event(a).stop();}});}this.setLocalVars();this.setOpts();this.setSkus();this.setWeights();this.setPrices();this.setAdditionalOpts();if(window.EC_Mailing){EC_Mailing.init();}this.updateForm();},setLocalVars:function(){this.localText=[];this.localText.titleText="Pricing Calculator";this.localText.headingText="Select A Product";this.localText.priceText="Printing Total";this.localText.productText="Product";this.localText.dieShapeText="Die Shape";this.localText.sizeText="Size";this.localText.trimSizeText="Custom Trim Size (Not Required)";this.localText.widthText="Width";this.localText.heightText="Height";this.localText.paperText="Paper";this.localText.colorText="Color";this.localText.coatingText="Coating";this.localText.pageText="Pages";this.localText.turnaroundText="Turnaround";this.localText.foldingText="Folding";this.localText.quantityText="Quantity";this.localText.orderText="Place Order";this.localText.estimateText="Print Estimate";this.localText.chooseText="Choose Here...";this.localText.shippingText="Estimate Shipping";this.localText.zipcodeText="Zip / Postal Code";this.localText.countrycodeText="Country";this.localText.ratesText="Get Rates";this.localText.shipmethodText="Ship Method";this.localText.shiprateText="Shipping Rate";this.localText.shiptimeText="Shipping Time";this.localText.pleaseclickText="<p>Please Click &quot;Get Rates&quot;</p>";this.localText.ziperrorText="Please Enter A 5 Digit Zip Code.";this.localText.pleasewaitText="Please Wait";this.localText.savePriceText="Coupon ";this.localText.discountPriceText="Discount Price";this.localText.unitPriceText="Unit Price";this.localText.custom_green_paperText="Green Paper";this.localText.greenPaperText="Go Green Paper";this.localText.custom_green_paperText="Go Green Paper";if(window.CustomCalcText){for(var a in CustomCalcText){this.localText[a]=CustomCalcText[a];}}this.names=[];this.titles=[];this.names=["product","size","paper","color","coating","turnaround"];this.titles=[this.localText.productText,this.localText.sizeText,this.localText.paperText,this.localText.colorText,this.localText.coatingText,this.localText.turnaroundText];shipOpts=new Hash({"03":"UPS Ground","12":"UPS Three-Day Select","02":"UPS Second Day Air","01":"UPS Next Day Air","14":"UPS Next Day Air Early A.M.","65":"UPS Worldwide Saver","11":"UPS Worldwide Standard","08":"UPS Worldwide Expedited","07":"UPS Worldwide Express",FR:"Freight",DL:"Free Delivery (Add 1 Day)",RO:"Recycle Overages",UPS_FR_CS:"UPS Freight - No Lift Gate",UPS_FR_LG:"UPS Freight - With Lift Gate",UPS_FR_ID:"UPS Freight - Inside Delivery",CFS:"Call for Shipping Later"});},createForm:function(b){var a=0;if($("eondesigner_id")){a=$("eondesigner_id").value;}this.formContents="<table>";this.formContents+=calcHeading_TPL(this.product_name);this.formContents+=b;this.formContents+="</table>";this.formContents+='<input type="hidden" name="price_id" value="" />';this.formContents+='<input type="hidden" name="quote" value="" />';this.formContents+='<input type="hidden" id="totals" name="totals" value="" />';this.formContents+='<input type="hidden" id="design_id" name="design_id" value="'+a+'" />';if($("myForm")){$("myForm").set("html",this.formContents);(function(){EC_LithoCalc.updatePrice();}).delay(1000);}else{(function(){EC_LithoCalc.createForm(b);}).delay(200);}if(window.datePickerController){datePickerController.create();}},createSelect:function(h,b,d,e,f){if(window.EC_Mailing&&b=="quantity"){d="EC_Mailing.setQuantity();"+d;}var i='<select id="'+b+'" name="'+b+'" onchange="'+d+'">';if(b=="quantity"){i+=this.createQuantityOptions(e);}else{if(b=="folding"&&this.folding==true){i+=this.createFoldingOptions(e);}else{if(f){i+=this.createOptions(e,true);}else{i+=this.createOptions(e);}}}i+="</select>";if(window.hideProduct==1&&b=="product"){var c="";i=i.replace('id="','style="display:none" id="');return calcFI_TPL("",i,"","hidden");}var g="";var a="";if((this.green==true&&(this.additionalOpts==undefined||this.additionalOpts.get("custom_green_paper")==undefined)&&b=="paper")||b=="custom_green_paper"){g="greenTD";h='<h2 class="greenH2">'+this.localText.greenPaperText+"</h2>"+h;}return a+calcFI_TPL(h,i,b,g);},createSizeInput:function(l,a,b){var m=(a=="width")?this.widthText:this.heightText;var j=0;var c=0;if(a=="width"&&m<1){if(this.opts.min_width){var n=Number(this.opts.min_width);if(n>Math.floor(n)){j=n-Math.floor(n);n-=j;}m=n;var n=Number(this.opts.min_width);var g=Number(this.opts.min_height);this.area=n*g;}else{m=1;}}if(a!="width"&&m<1){if(this.opts.min_height){var g=Number(this.opts.min_height);if(g>Math.floor(g)){j=g-Math.floor(g);g-=j;}m=g;var n=Number(this.opts.min_width);var g=Number(this.opts.min_height);this.area=n*g;}else{m=1;}}if($(a+"Fract")){c=$(a+"Fract").selectedIndex;}var k='<input type="text" id="'+a+'" name="'+a+'" value="'+m+'" onchange="'+b+'" class="sizeInput" />&nbsp;&nbsp;';k+='<select id="'+a+'Fract" name="'+a+'Fract" onchange="'+b+'" class="sizeInput">';for(var e=0;e<options.length;e++){var f=options[e];if(c==0&&j>0){if(Number(f.value)==j){c=e;}}var d=(c==e)?" selected":"";k+='<option value="'+f.value+'"'+d+">"+f.label+"</option>";}k+="</select>";return calcFI_TPL(l,k,a);},createDieShapeInput:function(f,b,c){var a=[];var h=false;for(var j in this.opts.die_shapes){if(h==false){h=j;}a.push(j);}if($(b)){h=$(b).value;}var g='<select id="'+b+'" name="'+b+'" onchange="'+c+'">';for(var e=0;e<a.length;e++){var d=(a[e]==h)?" selected":"";g+='<option value="'+a[e]+'"'+d+">"+a[e]+"</option>";}g+="</select>";return calcFI_TPL(f,g,b,"");},createTrimSizeInput:function(e,b,c){var d=this.opts.size[this.sizeID];if($(b)){d=$(b).value;}var a='<input type="text" id="'+b+'" name="'+b+'" value="'+d+'" onblur="'+c+'" class="textInput" />';return calcFI_TPL(e,a,b,"custom_trim_size");},createOptions:function(g,j){var m,h,k;var o=[];var p="";var c="";var f="";var l=false;if(this.currentName=="size"&&this.product_name=="Roll Labels"){var e=false;for(var n in this.opts.die_shapes){if(e==false){e=n;}}if($("die_shape")){e=$("die_shape").value;}var d=this.opts.die_shapes[e];l=new Hash();for(h=0;h<d.length;h++){l.set(d[h],true);}}o=g.getKeys();k=o.length;for(h=0;h<k;h++){m=o[h].replace("a","");if(l!=false&&l.has(m)==false){m=false;}if(!isNaN(m)&&m!=false){f=($(this.currentName)&&m==$(this.currentName).value)?" selected":"";if(this.currentName=="size"&&h==0){this.sizeID=m;}if(!j){}var b=(j)?this.additionalOpts.get(this.currentName).get(m).get("name"):this.opts[this.currentName][m];if(this.currentName=="coating"&&b!=undefined&&b.indexOf("UV 2")!=-1&&window.EC_Mailing&&this.mailingCanUseUV==false){}else{p+='<option value="'+m+'"'+f+">"+b+"</option>";if(this.currentName=="paper"){if(f!=""||k==1){this.currentPaper=b;}}}}}if(this.currentName=="custom_green_paper"){this.currentName="paper";}return p;},createQuantityOptions:function(e){var b;var c="";var f="";var d="";if(e.length>0){e.each(function(g){if(!isNaN(g)){d=($("quantity")&&g==$("quantity").value)?" selected":"";c+='<option value="'+g+'"'+d+">"+g+"</option>";}});}return c;},createFoldingOptions:function(g){var b="";var d="";var e=false;var a=false;if($("paper")){var f=(EC_LithoCalc.currentPaper!=false)?EC_LithoCalc.currentPaper:$("paper").options[$("paper").selectedIndex].text;if(f.indexOf("Cover")!=-1){e=true;}if(f.indexOf("Index")!=-1){a=true;}}else{var c=0;if(this.opts.paper.length>0){this.opts.paper.each(function(i,h){if(i&&c==0){if(i.indexOf("Cover")!=-1){e=true;}if(i.indexOf("Index")!=-1){a=true;}}c++;});}}g.each(function(i,h){($("folding")&&h==$("folding").value)?d=" selected":d="";if(e){if(i.get("name").indexOf("Cover")!=-1||i.get("name").indexOf("None")!=-1){b+='<option value="'+h+'"'+d+">"+i.get("name")+"</option>";}}else{if(a){if(i.get("name").indexOf("Index")!=-1||i.get("name").indexOf("None")!=-1){b+='<option value="'+h+'"'+d+">"+i.get("name")+"</option>";}}else{if(i.get("name").indexOf("Cover")==-1&&i.get("name").indexOf("Index")==-1){b+='<option value="'+h+'"'+d+">"+i.get("name")+"</option>";}}}});return b;},updateForm:function(){var e=0;var c;var g;this.formContents="";this.currentSku=this.skus;var b=false;for(var e=0;e<this.names.length;e++){this.currentName=this.names[e];this.currentTitle=this.titles[e];if(this.currentName=="width"||this.currentName=="height"){this.formContents+=this.createSizeInput(this.currentTitle,this.currentName,"EC_LithoCalc.updateForm()");if(this.currentName=="width"){continue;}}else{if(this.currentName=="green_paper"){}else{if(this.currentName=="size"&&this.product_name=="Roll Labels"){this.formContents+=this.createDieShapeInput(this.localText.dieShapeText,"die_shape","EC_LithoCalc.updateForm()");}g=(this.currentName=="size"&&this.custom_trim_size!=false)?"EC_LithoCalc.resetTrimSize();":"";this.formContents+=this.createSelect(this.currentTitle,this.currentName,g+"EC_LithoCalc.updateForm()",this.currentSku);if(this.currentName=="size"&&this.custom_trim_size!=false){this.formContents+=this.createTrimSizeInput(this.localText.trimSizeText,"trim_size","EC_LithoCalc.updateTrimSize()");}if(this.currentName=="paper"&&this.additionalOpts!=undefined&&this.additionalOpts.get("custom_green_paper")!=undefined){this.additionalOpts.each(function(i,a){if(a=="custom_green_paper"){EC_LithoCalc.currentName=a;EC_LithoCalc.formContents+=EC_LithoCalc.createSelect(EC_LithoCalc.localText[a+"Text"],a,"EC_LithoCalc.updatePrice()",i,true);}});}}}var d=0;var h="";this.currentSku.each(function(i,a){d++;if(d==1){h=a;}});if(this.currentName=="height"){var f=this.currentSku.getKeys();f.sort(EC_Base.sortNumber);f.reverse();f.each(function(a){if(EC_LithoCalc.area<=Number(a.replace("a",""))){h=a.toString();EC_LithoCalc.selectedArea=a;}});}if($(this.currentName)&&this.currentSku.has("a"+$(this.currentName).value)){this.currentSku=this.currentSku.get("a"+$(this.currentName).value);}else{if(this.currentSku.has(h)){this.currentSku=this.currentSku.get(h);}else{break;}}}if(this.currentSku>0){this.setupQuantities();}else{this.createForm(this.formContents);}},updateArea:function(){if($("width")&&$("height")){var b;this.widthText=Math.floor(Number($("width").value)).toString();this.heightText=Math.floor(Number($("height").value)).toString();if(this.widthText=="NaN"||this.widthText<1){if(this.opts.min_width){var a=Number(this.opts.min_width);if(a>Math.floor(a)){b=a-Math.floor(a);a-=b;}this.widthText=a;b=0;}else{this.widthText=1;}}if(this.heightText=="NaN"||this.heightText<1){if(this.opts.min_height){var c=Number(this.opts.min_height);if(c>Math.floor(c)){b=c-Math.floor(c);c-=b;}this.heightText=c;b=0;}else{this.heightText=1;}}var a=Math.floor(Number(this.widthText))+Number($("widthFract").value);var c=Math.floor(Number(this.heightText))+Number($("heightFract").value);if(isNaN(a)){a=$("width").value=0;$("widthFract").selectedIndex=0;}if(isNaN(c)){c=$("height").value=0;$("heightFract").selectedIndex=0;}b=0;if(a<Number(this.opts.min_width)&&a>0){alert("The minimum width is "+this.opts.min_width);this.resetToMinMx("width",this.opts.min_width);return;}if(c<Number(this.opts.min_height)&&c>0){alert("The minimum height is "+this.opts.min_height);this.resetToMinMx("height",this.opts.min_height);return;}if(a>Number(this.opts.max_width)){alert("The maximum width is "+this.opts.max_width);this.resetToMinMx("width",this.opts.max_width);return;}if(c>Number(this.opts.max_height)){alert("The maximum height is "+this.opts.max_height);this.resetToMinMx("height",this.opts.max_height);return;}this.area=a*c;}},updateTrimSize:function(){if($("trim_size")){var e=$("trim_size").value;e=e.replace(/([^0-9. Xx])/g,"");var d=$("size").options[$("size").selectedIndex].text;d=d.replace(/([^0-9. Xx])/g,"");if(d.match(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/)==null){this.resetTrimSize();return;}var a=Number(e.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/,"$1"));var c=Number(e.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/,"$3"));var f=Number(d.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/,"$1"));var b=Number(d.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/,"$3"));a=(a>f)?f:a;c=(c>b)?b:c;if(isNaN(a)||isNaN(c)||a==0||c==0){$("trim_size").value=d;}else{$("trim_size").value=a+" X "+c;}}},resetTrimSize:function(){if($("trim_size")){$("trim_size").value=$("size").options[$("size").selectedIndex].text;}},setupQuantities:function(){var a=0;var c=0;if(this.folding){this.formContents+=this.createSelect(this.localText.foldingText,"folding","EC_LithoCalc.updatePrice()",this.foldingOpts);}if(this.additional){this.additionalOpts.each(function(j,i){if(i!="custom_green_paper"){if(i=="custom_finishing"&&window.EC_Mailing){}else{EC_LithoCalc.currentName=i;EC_LithoCalc.formContents+=EC_LithoCalc.createSelect(EC_LithoCalc.localText[i+"Text"],i,"EC_LithoCalc.updatePrice()",j,true);}}});}var h=this.prices.get(this.currentSku).getKeys();h.sort(this.numOrdA);this.formContents+=this.createSelect(this.localText.quantityText,"quantity","EC_LithoCalc.updatePrice()",h);if($("quantity")){var d=$("quantity").value;if(this.prices.get(this.currentSku).has(d)){c=this.prices.get(this.currentSku).get(d).get("p");}else{var b=this.prices.get(this.currentSku).getKeys();c=this.prices.get(this.currentSku).get(b[0]).get("p");}}else{var b=this.prices.get(this.currentSku).getKeys();c=this.prices.get(this.currentSku).get(b[0]).get("p");}if(window.EC_Mailing){this.formContents+=EC_Mailing.updateForm();}else{this.formContents+=calcHR_TPL();}var g=0;this.formContents+=calcTotalFI_TPL(this.localText.priceText,'<div id="printRate" class="price">'+EC_Base.moneyFormat(c)+"</div>","");if(window.useCoupon&&window.useCoupon===true&&$("coupon")){var f=this.localText.savePriceText;this.coupon=JSON.decode($("coupon").value);if(this.coupon.percentage>0){g=c*(this.coupon.percentage/100);f+=Math.round(this.coupon.percentage)+"% OFF";}if(this.coupon.dollar>0){g=(this.coupon.dollar>c)?c:this.coupon.dollar;}this.formContents+=calcTotalFI_TPL('<div class="coupon">'+f+"</div>",'<div id="couponRate" class="coupon price">'+EC_Base.moneyFormat(g)+"</div>","");this.formContents+=calcTotalFI_TPL(this.localText.discountPriceText,'<div id="discountRate" class="price">'+EC_Base.moneyFormat(c-g)+"</div>","");}if(window.showUnitPrice&&window.showUnitPrice==true){var e=h[0];if($("quantity")){e=$("quantity").value;}this.formContents+=calcTotalFI_TPL(this.localText.unitPriceText,'<div id="unitRate" class="price">'+pennyFormat((c-g)/e)+"</div>","");}if(window.EC_Mailing){this.formContents+=EC_Mailing.totalsForm();}else{this.formContents+=calcHR_TPL();}if($("eondesigner_id")){this.formContents+=calcFI_TPL("",calcBTN_TPL(this.localText.orderText,"EC_LithoCalc.placeOrder()","orderBTN"),"","buttonTD");}else{this.formContents+=calcFI_TPL("",calcBTN_TPL(this.localText.orderText,"EC_LithoCalc.placeOrder()","orderBTN")+calcBTN_TPL(this.localText.estimateText,"EC_LithoCalc.printEstimate()","estimateBTN"),"","buttonTD");}if(!window.EC_Mailing){this.formContents+=this.setupShipping();}else{this.formContents+=postageWarning();}this.createForm(this.formContents);this.updatePrice();},updateFolding:function(){var d=$("myForm");var c=false;if($("folding")){c=$("folding").value;}if(c==false){var f=this.foldingOpts.getKeys();c=f[0];}var b=this.foldingOpts.get(c).get("price");var a=this.foldingOpts.get(c).get("setup");var e=($("quantity").options)?$("quantity").options[$("quantity").selectedIndex].text:$("quantity").value;var g=parseInt(e)/1000;this.foldRate=(Number(b)*g)+Number(a);},updatePrice:function(){this.foldRate=0;if($("folding")&&this.folding==true){this.updateFolding();}if($("quantity")){if(this.currentSku==null){this.currentSku=this.skus;for(var c=0;c<EC_LithoCalc.names.length;c++){this.currentName=EC_LithoCalc.names[c];if($(this.currentName)&&this.currentName!="width"&&this.currentName!="height"){var f=this.currentSku;if(this.currentSku==undefined){EC_LithoCalc.updatePrice.delay(200);return;}this.currentSku=this.currentSku.get("a"+$(this.currentName).value);}if($(this.currentName)&&this.currentName=="height"){this.currentSku=this.skus.get("a"+$("product").value).get("a"+this.selectedArea);}}}var a=this.prices.get(this.currentSku).get($("quantity").value).get("p");if(a<this.minimum_price){a=this.minimum_price;}var e=new Hash({hole_punch:1000,numbering:1000,perforation:1000,print_type:1000,pms_ink:1000,lamination:1000,finishing:1000,shrink_wrapping:1000});if(this.additional){this.additionalOpts.each(function(m,j){if($(j)){var n=1000;var k=j.replace(/custom_/,"");if(e.has(k)){n=Number(e.get(k));}var l=Number(EC_LithoCalc.additionalOpts.get(j).get($(j).value).get("price"));var i=Number(EC_LithoCalc.additionalOpts.get(j).get($(j).value).get("setup"));a+=(l*($("quantity").value/n))+i;}});}this.printRate=a+this.foldRate;$("printRate").set("html",EC_Base.moneyFormat(this.printRate));var h=0;if($("couponRate")&&window.useCoupon&&window.useCoupon===true&&$("coupon")){this.coupon=JSON.decode($("coupon").value);if(this.coupon.percentage>0){h=a*(this.coupon.percentage/100);}if(this.coupon.dollar>0){h=(this.coupon.dollar>a)?a:this.coupon.dollar;}$("couponRate").set("html",EC_Base.moneyFormat(h));$("discountRate").set("html",EC_Base.moneyFormat(a-h+this.foldRate));}if($("unitRate")&&window.showUnitPrice&&window.showUnitPrice==true){var g=$("quantity").value;$("unitRate").set("html",pennyFormat((this.printRate-h)/g));}if(window.EC_Mailing){EC_Mailing.updatePrice();}if($("zipcode")){var d=$("zipcode").value;if(d.length==5){this.getShipRates();}}var b={print:this.printRate,folding:this.foldRate,shipping:this.shipRates};if(window.EC_Mailing&&$("setupRate")){b.setup=Number($("setupRate").get("text").replace(/([^0-9.])/g,""));b.inkjet=Number($("inkjetRate").get("text").replace(/([^0-9.])/g,""));b.tabbing=Number($("tabbingRate").get("text").replace(/([^0-9.])/g,""));b.postage=Number($("postageRate").get("text").replace(/([^0-9.])/g,""));if($("listRate")){b.list=Number($("listRate").get("text").replace(/([^0-9.])/g,""));}b.total=Number($("totalRate").get("text").replace(/([^0-9.])/g,""));}if($("totals")){$("totals").value=JSON.encode(b);}else{EC_LithoCalc.updatePrice.delay(100);return;}}},printEstimate:function(){if(this.order_action==""){alert("This feature is not available right now. Please try again later.");return;}$("myForm").action=estimateURL;$("myForm").target="estimatepopup";estimatePopup($("myForm").target);var a={print:this.printRate,folding:this.foldRate,shipping:this.shipRates};if(window.EC_Mailing&&$("setupRate")){a.setup=Number($("setupRate").get("text").replace(/([^0-9.])/g,""));a.inkjet=Number($("inkjetRate").get("text").replace(/([^0-9.])/g,""));a.tabbing=Number($("tabbingRate").get("text").replace(/([^0-9.])/g,""));a.postage=Number($("postageRate").get("text").replace(/([^0-9.])/g,""));if($("listRate")){a.list=Number($("listRate").get("text").replace(/([^0-9.])/g,""));}a.total=Number($("totalRate").get("text").replace(/([^0-9.])/g,""));}if($("totals")){$("totals").value=JSON.encode(a);}setTimeout(function(){$("myForm").submit();},100);},placeOrder:function(){$("myForm").target="_self";if(this.order_action!=""){$("myForm").action=this.order_action;}if(this.currentSku!=null){var a=this.prices.get(this.currentSku).get($("quantity").value).get("i");}else{var c=this.prices.getKeys();var a=this.prices.get(c[0]).get($("quantity").value).get("i");}var b=$("myForm");b.price_id.value=a;this.flag_form=false;b.submit();},addSKU:function(f,g){var d;var e;var c;var b=f.length;f.each(function(h,a){if(a>0){c=c.get("a"+f[a-1]);}else{c=EC_LithoCalc.skus;}if(!c.has("a"+h)){c.set("a"+h,new Hash());}if(a==b-1){c.set("a"+h,g);}});},setupShipping:function(){if($("eondesigner_id")){return"";}var a=calcHR_TPL();a+=calcFI_TPL("",'<h4 class="formHeading">'+this.localText.shippingText+"</h4>","");if(this.international==1){a+=calcFI_TPL(this.localText.countrycodeText,this.country_code,"");}else{a+=this.country_code;}a+=calcFI_TPL(this.localText.zipcodeText,'<input type="text" class="zipTI" id="zipcode" name="zipcode" onkeyup="EC_LithoCalc.checkEnter(event, \'EC_LithoCalc.getShipRates()\')" /><input id="getRatesBTN" type="button" class="rateBTN" value="'+this.localText.ratesText+'" onclick="EC_LithoCalc.getShipRates()" />',"");a+=calcShipGrid_TPL("<br />");return a;},shipSelect:function(){},getShipRates:function(){if(!this.currentSku){this.updateForm();}var b=$("getRatesBTN");var c=$("zipcode").value;if(b.disabled){return;}var e=$("country_code").value;if(c.length<5){alert(this.localText.ziperrorText);return;}b.value=this.localText.pleasewaitText;b.disabled=true;this.timer=setTimeout("EC_LithoCalc.stopRates()",10000);this.selWeight=Math.round(((Number($("quantity").value)/1000)*this.weights[this.currentSku])*10)/10;var a="/ws/shipping/getRates/zip/"+c+"/country/"+e+"/weight/"+this.selWeight+"/handling_fee/"+this.handling_fee+"/product_id/"+this.product_id;if(this.free_ground_shipping){a+="/fgs/1";}var d=new Request.JSON({url:a,onSuccess:function(g){EC_LithoCalc.shipRates=g;EC_LithoCalc.stopRates();EC_LithoCalc.changeShipRates();if(EC_LithoCalc.shipRates.error){alert(EC_LithoCalc.shipRates.error);}if($("totals")){var f=JSON.decode($("totals").value);f.shipping=EC_LithoCalc.shipRates;$("totals").value=JSON.encode(f);}}}).get();},stopRates:function(){var a=$("getRatesBTN");a.value=this.localText.ratesText;a.disabled=false;clearTimeout(this.timer);},changeShipRates:function(){var a=" checked";$$("input[name=shipMethod]").each(function(b){if(b.checked!=false){a=b.value.toString();}});$("shipGrid").set("html","<br />"+this.shipGrid(a));},shipGrid:function(e){var b='<table width="100%">';var c="";var d=$("country_code").value;var a=false;if($("delivery")&&$("delivery_zipcode")&&$("delivery_countrycode")){if($("delivery").value==1&&($("delivery_zipcode").value==$("zipcode").value||$("delivery_zipcode").value=="ANY")&&d==$("delivery_countrycode").value){a=true;}}shipOpts.each(function(h,f){if(!h.match(/Recycle/)){var g=EC_LithoCalc.shipRates[f.toString()];if(e==f.toString()){e=" checked";}if(g!==false&&!isNaN(g)){g=EC_Base.moneyFormat(g);}if(g!==false&&g!=undefined){if((f!="DL"||(f=="DL"&&a==true))&&f!="FR"){if(EC_LithoCalc.free_ground_shipping&&f!="03"){}else{b+='<tr><td class="ship_desc"><input type="radio" name="shipMethod" value="'+f.toString()+'"'+e+" />";b+=h+'</td><td class="ship_price">'+g+"</td></tr>";}}else{if(f=="FR"){if($("show_freight")){b+='<tr><td class="ship_desc"><input type="radio" name="shipMethod" value="'+f.toString()+'"'+e+" />";b+=h+'</td><td class="ship_price">'+g+"</td></tr>";}}}if(e==" checked"){e="";}}}});b+="</table>";return b;},checkEnter:function(event,func){event=new Event(event);if(event.key=="enter"){if(func){eval(func);}event.stop();this.flag_form=true;}},selectByValue:function(b,c){c=Math.round(c*1000)/1000;if(typeof(b)==="string"){b=$(b);}if(b&&b.options){for(var a=0;a<b.options.length;a++){if(b.options[a].value==c){b.options[a].selected=true;b.options.selectedIndex=a;}}}},resetToMinMx:function(e,d){var b=0;d=Number(d);if(d>Math.floor(d)){b=d-Math.floor(d);d-=b;}this[e+"Text"]=d;$(e).value=d;if(b==0){b=".0";}this.selectByValue(e+"Fract",b);var a=Math.floor(Number(this.widthText))+Number($("widthFract").value);var c=Math.floor(Number(this.heightText))+Number($("heightFract").value);this.area=a*c;this.updatePrice();},numOrdA:function(d,c){return(d-c);},numOrdD:function(d,c){return(c-d);},debug:function(c,b){var a="";if(b){a=EC_Base.dumpObj(c,true);}else{a=c;}$("calcDebug").set("html",a+"<br />=======================================<br /><br />");}};window.addEvent("domready",function(){EC_LithoCalc.init();});
