var EC_LithoCalc={product_name:"",product_id:25,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:0,country_code:'<input type="hidden" id="country_code" name="country_code" value="US" />',handling_fee:10,order_action:"",green:false,minimum_price:0,minimum_area_for_price:1,quarter_inch_increments:false,mailingCanUseUV:false,folding:false,additional:true,additionalOpts:false,setAdditionalOpts:function(){this.additionalOpts=new Hash();this.additionalOpts.set("custom_allow_no_proof",new Hash());this.additionalOpts.get("custom_allow_no_proof").set(210,new Hash());this.additionalOpts.get("custom_allow_no_proof").get(210).set("name","1");this.additionalOpts.get("custom_allow_no_proof").get(210).set("price","0.00");this.additionalOpts.get("custom_allow_no_proof").get(210).set("setup","0.00");this.additionalOpts.get("custom_allow_no_proof").set(209,new Hash());this.additionalOpts.get("custom_allow_no_proof").get(209).set("name","0");this.additionalOpts.get("custom_allow_no_proof").get(209).set("price","0.00");this.additionalOpts.get("custom_allow_no_proof").get(209).set("setup","0.00");this.additionalOpts.set("custom_green",new Hash());this.additionalOpts.get("custom_green").set(226,new Hash());this.additionalOpts.get("custom_green").get(226).set("name","1");this.additionalOpts.get("custom_green").get(226).set("price","");this.additionalOpts.get("custom_green").get(226).set("setup","0.00");this.additionalOpts.get("custom_green").set(225,new Hash());this.additionalOpts.get("custom_green").get(225).set("name","0");this.additionalOpts.get("custom_green").get(225).set("price","");this.additionalOpts.get("custom_green").get(225).set("setup","0.00");this.additionalOpts.set("custom_hole_punch",new Hash());this.additionalOpts.get("custom_hole_punch").set(204,new Hash());this.additionalOpts.get("custom_hole_punch").get(204).set("name","No Hole Punch");this.additionalOpts.get("custom_hole_punch").get(204).set("price","0.00");this.additionalOpts.get("custom_hole_punch").get(204).set("setup","0.00");this.additionalOpts.get("custom_hole_punch").set(205,new Hash());this.additionalOpts.get("custom_hole_punch").get(205).set("name","1/8 inch Hole");this.additionalOpts.get("custom_hole_punch").get(205).set("price","10.00");this.additionalOpts.get("custom_hole_punch").get(205).set("setup","40.00");this.additionalOpts.get("custom_hole_punch").set(206,new Hash());this.additionalOpts.get("custom_hole_punch").get(206).set("name","1/4 inch Hole");this.additionalOpts.get("custom_hole_punch").get(206).set("price","10.00");this.additionalOpts.get("custom_hole_punch").get(206).set("setup","40.00");},setOpts:function(){this.opts=[];this.opts.product=[];this.opts.product[25]="Hang Tags";this.opts.area=[];this.opts.coating=[];this.opts.color=[];this.opts.paper=[];this.opts.turnaround=[];this.opts.area[142]="7.00";this.opts.area[147]="46.75";this.opts.area[149]="93.50";this.opts.min_width="2";this.opts.max_height="18";this.opts.area[145]="24.00";this.opts.area[152]="66.00";this.opts.max_width="36";this.opts.area[151]="14.00";this.opts.area[148]="54.00";this.opts.area[153]="1000000.00";this.opts.min_height="3.5";this.opts.coating[2]="UV 1 Side (High-Gloss)";this.opts.color[8]="4/0 (Full Color Front Side)";this.opts.paper[115]="60# Starliner Gloss Labels";this.opts.coating[3]="UV 2 Sides (High-Gloss)";this.opts.coating[4]="AQ 1 Side (Semi-Gloss)";this.opts.color[10]="4/4 (Full Color Both Sides)";this.opts.turnaround[107]="5 Day";this.opts.turnaround[110]="7 Day";this.opts.paper[127]="14pt C2S Gloss Cover";},setSkus:function(){this.skus=new Hash();this.addSKU([25,"7.00",127,10,2,107],8659);this.addSKU([25,"1000000.00",127,10,3,107],8678);this.addSKU([25,"1000000.00",127,10,2,107],8677);this.addSKU([25,"93.50",127,10,4,107],8676);this.addSKU([25,"93.50",127,10,3,107],8675);this.addSKU([25,"93.50",127,10,2,107],8674);this.addSKU([25,"66.00",127,10,4,107],8673);this.addSKU([25,"66.00",127,10,3,107],8672);this.addSKU([25,"66.00",127,10,2,107],8671);this.addSKU([25,"54.00",127,10,4,107],8670);this.addSKU([25,"54.00",127,10,3,107],8669);this.addSKU([25,"54.00",127,10,2,107],8668);this.addSKU([25,"46.75",127,10,4,107],8667);this.addSKU([25,"46.75",127,10,3,107],8666);this.addSKU([25,"46.75",127,10,2,107],8665);this.addSKU([25,"7.00",127,10,4,107],8661);this.addSKU([25,"7.00",127,10,3,107],8660);this.addSKU([25,"1000000.00",127,10,4,107],8679);},setWeights:function(){this.weights=[];this.weights[8659]=0.5;this.weights[8678]=0.5;this.weights[8677]=0.5;this.weights[8676]=0.5;this.weights[8675]=0.5;this.weights[8674]=0.5;this.weights[8673]=0.5;this.weights[8672]=0.5;this.weights[8671]=0.5;this.weights[8670]=0.5;this.weights[8669]=0.5;this.weights[8668]=0.5;this.weights[8667]=0.5;this.weights[8666]=0.5;this.weights[8665]=0.5;this.weights[8661]=0.5;this.weights[8660]=0.5;this.weights[8679]=0.5;},setPrices:function(){this.prices=new Hash();var b=[];var a;b.push({i:8659,ii:36994,q:1000,p:11.15});b.push({i:8659,ii:36995,q:2500,p:6.79});b.push({i:8659,ii:36996,q:5000,p:4.45});b.push({i:8659,ii:36997,q:10000,p:4.28});b.push({i:8659,ii:36998,q:15000,p:4.4});b.push({i:8659,ii:36999,q:20000,p:4.15});b.push({i:8659,ii:37000,q:25000,p:4.28});b.push({i:8659,ii:37001,q:30000,p:4.14});b.push({i:8659,ii:37002,q:40000,p:4.09});b.push({i:8659,ii:37003,q:50000,p:3.76});b.push({i:8678,ii:37184,q:1000,p:5.77});b.push({i:8678,ii:37185,q:2500,p:2.98});b.push({i:8678,ii:37186,q:5000,p:1.87});b.push({i:8678,ii:37187,q:10000,p:1.48});b.push({i:8678,ii:37188,q:15000,p:1.54});b.push({i:8678,ii:37189,q:20000,p:1.42});b.push({i:8678,ii:37190,q:25000,p:1.44});b.push({i:8678,ii:37191,q:30000,p:1.42});b.push({i:8678,ii:37192,q:40000,p:1.39});b.push({i:8678,ii:37193,q:50000,p:1.4});b.push({i:8677,ii:37174,q:1000,p:5.77});b.push({i:8677,ii:37175,q:2500,p:2.98});b.push({i:8677,ii:37176,q:5000,p:1.87});b.push({i:8677,ii:37177,q:10000,p:1.48});b.push({i:8677,ii:37178,q:15000,p:1.54});b.push({i:8677,ii:37179,q:20000,p:1.42});b.push({i:8677,ii:37180,q:25000,p:1.44});b.push({i:8677,ii:37181,q:30000,p:1.42});b.push({i:8677,ii:37182,q:40000,p:1.39});b.push({i:8677,ii:37183,q:50000,p:1.4});b.push({i:8676,ii:37164,q:1000,p:5.77});b.push({i:8676,ii:37165,q:2500,p:2.98});b.push({i:8676,ii:37166,q:5000,p:1.87});b.push({i:8676,ii:37167,q:10000,p:1.48});b.push({i:8676,ii:37168,q:15000,p:1.54});b.push({i:8676,ii:37169,q:20000,p:1.42});b.push({i:8676,ii:37170,q:25000,p:1.44});b.push({i:8676,ii:37171,q:30000,p:1.42});b.push({i:8676,ii:37172,q:40000,p:1.39});b.push({i:8676,ii:37173,q:50000,p:1.4});b.push({i:8675,ii:37154,q:1000,p:5.77});b.push({i:8675,ii:37155,q:2500,p:2.98});b.push({i:8675,ii:37156,q:5000,p:1.87});b.push({i:8675,ii:37157,q:10000,p:1.48});b.push({i:8675,ii:37158,q:15000,p:1.54});b.push({i:8675,ii:37159,q:20000,p:1.42});b.push({i:8675,ii:37160,q:25000,p:1.44});b.push({i:8675,ii:37161,q:30000,p:1.42});b.push({i:8675,ii:37162,q:40000,p:1.39});b.push({i:8675,ii:37163,q:50000,p:1.4});b.push({i:8674,ii:37144,q:1000,p:5.77});b.push({i:8674,ii:37145,q:2500,p:2.98});b.push({i:8674,ii:37146,q:5000,p:1.87});b.push({i:8674,ii:37147,q:10000,p:1.48});b.push({i:8674,ii:37148,q:15000,p:1.54});b.push({i:8674,ii:37149,q:20000,p:1.42});b.push({i:8674,ii:37150,q:25000,p:1.44});b.push({i:8674,ii:37151,q:30000,p:1.42});b.push({i:8674,ii:37152,q:40000,p:1.39});b.push({i:8674,ii:37153,q:50000,p:1.4});b.push({i:8673,ii:37134,q:1000,p:5.69});b.push({i:8673,ii:37135,q:2500,p:2.96});b.push({i:8673,ii:37136,q:5000,p:1.92});b.push({i:8673,ii:37137,q:10000,p:1.52});b.push({i:8673,ii:37138,q:15000,p:1.66});b.push({i:8673,ii:37139,q:20000,p:1.51});b.push({i:8673,ii:37140,q:25000,p:1.58});b.push({i:8673,ii:37141,q:30000,p:1.49});b.push({i:8673,ii:37142,q:40000,p:1.44});b.push({i:8673,ii:37143,q:50000,p:1.32});b.push({i:8672,ii:37124,q:1000,p:5.69});b.push({i:8672,ii:37125,q:2500,p:2.96});b.push({i:8672,ii:37126,q:5000,p:1.92});b.push({i:8672,ii:37127,q:10000,p:1.52});b.push({i:8672,ii:37128,q:15000,p:1.66});b.push({i:8672,ii:37129,q:20000,p:1.51});b.push({i:8672,ii:37130,q:25000,p:1.58});b.push({i:8672,ii:37131,q:30000,p:1.49});b.push({i:8672,ii:37132,q:40000,p:1.44});b.push({i:8672,ii:37133,q:50000,p:1.32});b.push({i:8671,ii:37114,q:1000,p:5.69});b.push({i:8671,ii:37115,q:2500,p:2.96});b.push({i:8671,ii:37116,q:5000,p:1.92});b.push({i:8671,ii:37117,q:10000,p:1.52});b.push({i:8671,ii:37118,q:15000,p:1.66});b.push({i:8671,ii:37119,q:20000,p:1.51});b.push({i:8671,ii:37120,q:25000,p:1.58});b.push({i:8671,ii:37121,q:30000,p:1.49});b.push({i:8671,ii:37122,q:40000,p:1.44});b.push({i:8671,ii:37123,q:50000,p:1.32});b.push({i:8670,ii:37104,q:1000,p:5.27});b.push({i:8670,ii:37105,q:2500,p:2.76});b.push({i:8670,ii:37106,q:5000,p:1.85});b.push({i:8670,ii:37107,q:10000,p:1.42});b.push({i:8670,ii:37108,q:15000,p:1.55});b.push({i:8670,ii:37109,q:20000,p:1.39});b.push({i:8670,ii:37110,q:25000,p:1.46});b.push({i:8670,ii:37111,q:30000,p:1.38});b.push({i:8670,ii:37112,q:40000,p:1.31});b.push({i:8670,ii:37113,q:50000,p:1.21});b.push({i:8669,ii:37094,q:1000,p:5.27});b.push({i:8669,ii:37095,q:2500,p:2.76});b.push({i:8669,ii:37096,q:5000,p:1.85});b.push({i:8669,ii:37097,q:10000,p:1.42});b.push({i:8669,ii:37098,q:15000,p:1.55});b.push({i:8669,ii:37099,q:20000,p:1.39});b.push({i:8669,ii:37100,q:25000,p:1.46});b.push({i:8669,ii:37101,q:30000,p:1.38});b.push({i:8669,ii:37102,q:40000,p:1.31});b.push({i:8669,ii:37103,q:50000,p:1.21});b.push({i:8668,ii:37084,q:1000,p:5.27});b.push({i:8668,ii:37085,q:2500,p:2.76});b.push({i:8668,ii:37086,q:5000,p:1.85});b.push({i:8668,ii:37087,q:10000,p:1.42});b.push({i:8668,ii:37088,q:15000,p:1.55});b.push({i:8668,ii:37089,q:20000,p:1.39});b.push({i:8668,ii:37090,q:25000,p:1.46});b.push({i:8668,ii:37091,q:30000,p:1.38});b.push({i:8668,ii:37092,q:40000,p:1.31});b.push({i:8668,ii:37093,q:50000,p:1.21});b.push({i:8667,ii:37074,q:1000,p:5.8});b.push({i:8667,ii:37075,q:2500,p:3.02});b.push({i:8667,ii:37076,q:5000,p:1.88});b.push({i:8667,ii:37077,q:10000,p:1.5});b.push({i:8667,ii:37078,q:15000,p:1.57});b.push({i:8667,ii:37079,q:20000,p:1.48});b.push({i:8667,ii:37080,q:25000,p:1.54});b.push({i:8667,ii:37081,q:30000,p:1.45});b.push({i:8667,ii:37082,q:40000,p:1.3});b.push({i:8667,ii:37083,q:50000,p:1.19});b.push({i:8666,ii:37064,q:1000,p:5.8});b.push({i:8666,ii:37065,q:2500,p:3.02});b.push({i:8666,ii:37066,q:5000,p:1.88});b.push({i:8666,ii:37067,q:10000,p:1.5});b.push({i:8666,ii:37068,q:15000,p:1.57});b.push({i:8666,ii:37069,q:20000,p:1.48});b.push({i:8666,ii:37070,q:25000,p:1.54});b.push({i:8666,ii:37071,q:30000,p:1.45});b.push({i:8666,ii:37072,q:40000,p:1.3});b.push({i:8666,ii:37073,q:50000,p:1.19});b.push({i:8665,ii:37054,q:1000,p:5.8});b.push({i:8665,ii:37055,q:2500,p:3.02});b.push({i:8665,ii:37056,q:5000,p:1.88});b.push({i:8665,ii:37057,q:10000,p:1.5});b.push({i:8665,ii:37058,q:15000,p:1.57});b.push({i:8665,ii:37059,q:20000,p:1.48});b.push({i:8665,ii:37060,q:25000,p:1.54});b.push({i:8665,ii:37061,q:30000,p:1.45});b.push({i:8665,ii:37062,q:40000,p:1.3});b.push({i:8665,ii:37063,q:50000,p:1.19});b.push({i:8661,ii:37014,q:1000,p:11.15});b.push({i:8661,ii:37015,q:2500,p:6.79});b.push({i:8661,ii:37016,q:5000,p:4.45});b.push({i:8661,ii:37017,q:10000,p:4.28});b.push({i:8661,ii:37018,q:15000,p:4.4});b.push({i:8661,ii:37019,q:20000,p:4.15});b.push({i:8661,ii:37020,q:25000,p:4.28});b.push({i:8661,ii:37021,q:30000,p:4.14});b.push({i:8661,ii:37022,q:40000,p:4.09});b.push({i:8661,ii:37023,q:50000,p:3.76});b.push({i:8660,ii:37004,q:1000,p:11.15});b.push({i:8660,ii:37005,q:2500,p:6.79});b.push({i:8660,ii:37006,q:5000,p:4.45});b.push({i:8660,ii:37007,q:10000,p:4.28});b.push({i:8660,ii:37008,q:15000,p:4.4});b.push({i:8660,ii:37009,q:20000,p:4.15});b.push({i:8660,ii:37010,q:25000,p:4.28});b.push({i:8660,ii:37011,q:30000,p:4.14});b.push({i:8660,ii:37012,q:40000,p:4.09});b.push({i:8660,ii:37013,q:50000,p:3.76});b.push({i:8679,ii:37194,q:1000,p:5.77});b.push({i:8679,ii:37195,q:2500,p:2.98});b.push({i:8679,ii:37196,q:5000,p:1.87});b.push({i:8679,ii:37197,q:10000,p:1.48});b.push({i:8679,ii:37198,q:15000,p:1.54});b.push({i:8679,ii:37199,q:20000,p:1.42});b.push({i:8679,ii:37200,q:25000,p:1.44});b.push({i:8679,ii:37201,q:30000,p:1.42});b.push({i:8679,ii:37202,q:40000,p:1.39});b.push({i:8679,ii:37203,q:50000,p:1.4});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.custom_allow_no_proofText="Allow No Proof";this.localText.custom_greenText="Green";this.localText.custom_hole_punchText="Hole Punch";this.localText.custom_green_paperText="Eco Friendly Paper";if(window.CustomCalcText){for(var a in CustomCalcText){this.localText[a]=CustomCalcText[a];}}this.names=[];this.titles=[];this.names=["product","width","height","paper","color","coating","turnaround"];this.titles=[this.localText.productText,this.localText.widthText,this.localText.heightText,this.localText.paperText,this.localText.colorText,this.localText.coatingText,this.localText.turnaroundText];shipOpts=new Hash({"03":"UPS Ground","12":"UPS 3 Day Select","02":"UPS 2nd Day","01":"UPS Next Day",WC:"Will Call",FR:"Freight",DL:"Delivery",RO:"Recycle Overages"});},createForm:function(b){var a=0;if($("eondesigner_id")){a=$("eondesigner_id").value;}this.formContents='<h3 class="formTitle">'+this.localText.titleText+"</h3>";this.formContents+="<table>";this.formContents+=calcFI_TPL("",'<h4 class="formHeading">'+this.localText.headingText+"</h4>","");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+'" />';$("myForm").setHTML(this.formContents);if(window.datePickerController){datePickerController.create();}},createSelect:function(h,d,f,g,b){if(window.EC_Mailing&&d=="quantity"){f="EC_Mailing.setQuantity();"+f;}var a='<select id="'+d+'" name="'+d+'" onchange="'+f+'">';if(d=="quantity"){a+=this.createQuantityOptions(g);}else{if(d=="folding"&&this.folding==true){a+=this.createFoldingOptions(g);}else{if(b){a+=this.createOptions(g,true);}else{a+=this.createOptions(g);}}}a+="</select>";var e="";var c="";if((this.green==true&&(this.additionalOpts==undefined||this.additionalOpts.get("custom_green_paper")==undefined)&&d=="paper")||d=="custom_green_paper"){c=calcFI_TPL("","","","greenBadgeTD");}return c+calcFI_TPL(h,a,d,e);},createSizeInput:function(l,a,b){var m=(a=="width")?this.widthText:this.heightText;var j=0;var c=0;var o=[{value:".0",label:'0/0"'},{value:".0625",label:'1/16"'},{value:".125",label:'1/8"'},{value:".1875",label:'3/16"'},{value:".25",label:'1/4"'},{value:".3125",label:'5/16"'},{value:".375",label:'3/8"'},{value:".4375",label:'7/16"'},{value:".5",label:'1/2"'},{value:".5625",label:'9/16"'},{value:".625",label:'5/8"'},{value:".6875",label:'11/16"'},{value:".75",label:'3/4"'},{value:".8125",label:'13/16"'},{value:".875",label:'7/8"'},{value:".9375",label:'15/16"'}];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<o.length;e++){var f=o[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).getValue();}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).getValue();}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").getValue();}var d=this.opts.die_shapes[e];l=new Hash();for(h=0;h<d.length;h++){l.set(d[h],true);}}o=g.keys();k=o.length;for(h=0;h<k;h++){m=o[h];if(l!=false&&l.hasKey(m)==false){m=false;}if(!isNaN(m)&&m!=false){f=($(this.currentName)&&m==$(this.currentName).getValue())?" 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=="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").getValue())?" selected":"";c+='<option value="'+g+'"'+d+">"+g+"</option>";}});}return c;},createFoldingOptions:function(f){var b="";var c="";var d=false;var a=false;if($("paper")){var e=$("paper").options[$("paper").selectedIndex].text;if(e.indexOf("Cover")!=-1){d=true;}if(e.indexOf("Index")!=-1){a=true;}}f.each(function(h,g){($("folding")&&g==$("folding").getValue())?c=" selected":c="";if(d){if(h.get("name").indexOf("Cover")!=-1||h.get("name").indexOf("None")!=-1){b+='<option value="'+g+'"'+c+">"+h.get("name")+"</option>";}}else{if(a){if(h.get("name").indexOf("Index")!=-1||h.get("name").indexOf("None")!=-1){b+='<option value="'+g+'"'+c+">"+h.get("name")+"</option>";}}else{if(h.get("name").indexOf("Cover")==-1&&h.get("name").indexOf("Index")==-1){b+='<option value="'+g+'"'+c+">"+h.get("name")+"</option>";}}}});return b;},updateForm:function(){var e=0;var c;var g;this.formContents="";this.currentSku=this.skus;var b=false;this.updateArea();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.product_name!="Roll Labels")?"EC_LithoCalc.resetTrimSize();":"";this.formContents+=this.createSelect(this.currentTitle,this.currentName,g+"EC_LithoCalc.updateForm()",this.currentSku);if(this.currentName=="size"&&this.product_name!="Roll Labels"){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.keys();f.sort(EC_Base.sortNumber);f.reverse();f.each(function(a){if(EC_LithoCalc.area<=a){h=a.toString();EC_LithoCalc.selectedArea=a;}});}if($(this.currentName)&&this.currentSku.hasKey($(this.currentName).getValue())){this.currentSku=this.currentSku.get($(this.currentName).getValue());}else{if(this.currentSku.hasKey(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").getValue())).toString();this.heightText=Math.floor(Number($("height").getValue())).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").getValue());var c=Math.floor(Number(this.heightText))+Number($("heightFract").getValue());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").getValue();e=e.replace(/([^0-9. Xx])/g,"");var d=$("size").options[$("size").selectedIndex].text;d=d.replace(/([^0-9. Xx])/g,"");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 b=0;var d=0;if(this.folding){this.formContents+=this.createSelect(this.localText.foldingText,"folding","EC_LithoCalc.updatePrice()",this.foldingOpts);}if(this.additional){this.additionalOpts.each(function(h,g){if(g!="custom_green_paper"){if(g=="custom_finishing"&&window.EC_Mailing){}else{EC_LithoCalc.currentName=g;EC_LithoCalc.formContents+=EC_LithoCalc.createSelect(EC_LithoCalc.localText[g+"Text"],g,"EC_LithoCalc.updatePrice()",h,true);}}});}var f=this.prices.get(this.currentSku).keys();f.sort(this.numOrdA);this.formContents+=this.createSelect(this.localText.quantityText,"quantity","EC_LithoCalc.updatePrice()",f);if($("quantity")){var e=$("quantity").getValue();var a=this.prices.get(this.currentSku).get($("quantity").getValue()).get("p");d=a*this.area*(e/1000);}else{var c=this.prices.get(this.currentSku).keys();d=this.prices.get(this.currentSku).get(c[0]).get("p");}if(window.EC_Mailing){this.formContents+=EC_Mailing.updateForm();}else{this.formContents+=calcHR_TPL();}this.formContents+=calcTotalFI_TPL(this.localText.priceText,'<div id="printRate" class="price">'+EC_Base.moneyFormat(d)+"</div>","");if(window.EC_Mailing){this.formContents+=EC_Mailing.totalsForm();}else{this.formContents+=calcHR_TPL();}this.formContents+=calcFI_TPL("",calcBTN_TPL(this.localText.orderText,"EC_LithoCalc.placeOrder()"),"");this.formContents+=calcFI_TPL("",calcBTN_TPL(this.localText.estimateText,"EC_LithoCalc.printEstimate()"),"");if(!window.EC_Mailing){this.formContents+=this.setupShipping();}else{this.formContents+=postageWarning();}this.createForm(this.formContents);this.updateArea();this.updatePrice();},updateFolding:function(){var d=$("myForm");var c=$("folding").getValue();if(c==undefined){var f=this.foldingOpts.keys();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").getValue();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")){this.currentSku=this.skus;for(var d=0;d<EC_LithoCalc.names.length;d++){this.currentName=EC_LithoCalc.names[d];if($(this.currentName)&&this.currentName!="width"&&this.currentName!="height"){var g=this.currentSku;this.currentSku=this.currentSku.get($(this.currentName).value);if(this.currentSku==undefined){EC_LithoCalc.updatePrice.delay(200);return;}}if($(this.currentName)&&this.currentName=="height"){this.currentSku=this.skus.get($("product").value).get(this.selectedArea);}}var b=this.prices.get(this.currentSku).get($("quantity").value).get("p");var a=0;if(this.selectedArea>154){a=b*this.area*($("quantity").value/1000);}else{var a=b*this.selectedArea*($("quantity").value/1000);}if(a<this.minimum_price){a=this.minimum_price;}var f=new Hash({hole_punch:1000,numbering:1000,perforation:1000,print_type:1000,pms_ink:1000,lamination:1000,finishing:1000});if(this.additional){this.additionalOpts.each(function(l,i){if($(i)){var m=1000;var j=i.replace(/custom_/,"");if(f.hasKey(j)){m=Number(f.get(j));}var k=Number(EC_LithoCalc.additionalOpts.get(i).get($(i).value).get("price"));var h=Number(EC_LithoCalc.additionalOpts.get(i).get($(i).value).get("setup"));a+=(k*($("quantity").value/m))+h;}});}this.printRate=a+this.foldRate;$("printRate").setHTML(EC_Base.moneyFormat(this.printRate));if(window.EC_Mailing){EC_Mailing.updatePrice();}if($("zipcode")){var e=$("zipcode").getValue();if(e.length==5){this.getShipRates();}}var c={print:this.printRate,folding:this.foldRate,shipping:this.shipRates};if(window.EC_Mailing){c.setup=Number($("setupRate").getText().replace(/([^0-9.])/,""));c.inkjet=Number($("inkjetRate").getText().replace(/([^0-9.])/,""));c.tabbing=Number($("tabbingRate").getText().replace(/([^0-9.])/,""));c.postage=Number($("postageRate").getText().replace(/([^0-9.])/,""));if($("listRate")){c.list=Number($("listRate").getText().replace(/([^0-9.])/,""));}c.total=Number($("totalRate").getText().replace(/([^0-9.])/,""));}if($("totals")){$("totals").value=Json.toString(c);}else{EC_LithoCalc.updatePrice.delay(100);}}},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);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").getValue()).get("i");}else{var c=this.prices.keys();var a=this.prices.get(c[0]).get($("quantity").getValue()).get("i");}var b=$("myForm");b.price_id.value=a;this.flag_form=false;if(window.confirmText&&confirmText!=""){if(!$("disallow_popups")||($("disallow_popups")&&$("disallow_popups").getValue()!="1")){var d=confirm(confirmText);if(d){b.submit();}}}else{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(f[a-1]);}else{c=EC_LithoCalc.skus;}if(!c.hasKey(h)){c.set(h,new Hash());}if(a==b-1){c.set(h,g);}});},setupShipping:function(){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").getValue();if(b.disabled){return;}var e=$("country_code").getValue();if((c.length!=5||isNaN(c))&&e=="US"){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").getValue())/1000)*this.weights[this.currentSku]*this.area)*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 Ajax(a,{method:"get",onSuccess:function(g){EC_LithoCalc.shipRates=Json.evaluate(g);EC_LithoCalc.stopRates();EC_LithoCalc.changeShipRates();if(EC_LithoCalc.shipRates.error){alert(EC_LithoCalc.shipRates.error);}if($("totals")){var f=Json.evaluate($("totals").getValue());f.shipping=EC_LithoCalc.shipRates;$("totals").value=Json.toString(f);}}}).request();},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").setHTML("<br />"+this.shipGrid(a));},shipGrid:function(e){var b='<table width="100%">';var c="";var d=$("country_code").getValue();var a=false;if($("delivery")&&$("delivery_zipcode")&&$("delivery_countrycode")){if($("delivery").getValue()==1&&($("delivery_zipcode").getValue()==$("zipcode").getValue()||$("delivery_zipcode").getValue()=="ANY")&&d==$("delivery_countrycode").getValue()){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"){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"){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){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").getValue());var c=Math.floor(Number(this.heightText))+Number($("heightFract").getValue());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").setHTML(a+"<br />=======================================<br /><br />");}};window.addEvent("domready",function(){EC_LithoCalc.init();});