var EC_LithoCalc = {
	product_name: '',
	product_id: 29,
	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=\"MX\">Mexico</option><option value=\"US\" selected>United States</option></select>',
	handling_fee: 0,
	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_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'][29] = 'Small Flyers';
		this.product_name = 'Small Flyers';
	 	this.opts['coating'] = [];
	 	this.opts['color'] = [];
	    	this.opts['paper'] = [];
	 	this.opts['size'] = [];
	 	this.opts['turnaround'] = [];
	 		
	   		this.opts['turnaround'][266] = 'Next Day';
		 		this.opts['color'][8] = '4/0 (Full Color Front Side)';
		  		this.opts['coating'][3] = 'UV 2 Sides (Super Hi-Gloss Coating)';
		  		this.opts['color'][9] = '4/1 (Full Color Front / B&W Back)';
		 		this.opts['size'][104] = '3.5 X 8.5';
		 		this.opts['color'][10] = '4/4 (Full Color Both Sides)';
		 		this.opts['size'][82] = '4.25 X 5.5';
		 		this.opts['paper'][116] = '70# Uncoated Offset Smooth Text';
		 		this.opts['coating'][5] = 'AQ 2 Sides (Semi-Gloss Coating)';
		 		this.opts['size'][64] = '4.25 X 11';
		 		this.opts['coating'][261] = 'Satin AQ 2 Sides (Matte Coating)';
		 		this.opts['turnaround'][211] = '2-3 Day';
		 		this.opts['size'][52] = '5.5 X 8.5';
		 		this.opts['coating'][1] = 'Uncoated';
		 		this.opts['turnaround'][282] = '2-4 Day';
		 		this.opts['paper'][122] = '95# Gloss Cover';
		 		this.opts['paper'][119] = '100# Gloss Text';
		 		this.opts['turnaround'][107] = '5 Day';
		 		this.opts['turnaround'][109] = '5-7 Day';
		 		this.opts['paper'][249] = '100# Uncoated Cover';
		 		
		if (this.product_name == 'Roll Labels') {
			this.opts['die_shapes'] = {};
			
			for (var a in this.opts['size']) {
				if (!isNaN(a)) {
					var item = this.opts['size'][a];
					var items = item.split(' - ');
					if (items.length == 2) {
						this.opts['size'][a] = items[0];
						
						if (this.opts['die_shapes'][items[1]] == undefined) {
							this.opts['die_shapes'][items[1]] = [];
						}
						this.opts['die_shapes'][items[1]].push(a);
					}					
				}
			}
		}
	},
	
	setSkus: function() {
		this.skus = new Hash();
								this.addSKU([29,'104',119,10,5,211], 1127);
												this.addSKU([29,'104',119,8,5,211], 1125);
												this.addSKU([29,'104',119,9,5,211], 1126);
												this.addSKU([29,'82',119,8,5,211], 1128);
												this.addSKU([29,'82',119,9,5,211], 1129);
												this.addSKU([29,'82',119,10,5,211], 1130);
												this.addSKU([29,'64',119,8,5,211], 1131);
												this.addSKU([29,'64',119,9,5,211], 1132);
												this.addSKU([29,'64',119,10,5,211], 1133);
												this.addSKU([29,'52',119,8,5,211], 1134);
												this.addSKU([29,'52',119,9,5,211], 1135);
												this.addSKU([29,'52',119,10,5,211], 1136);
												this.addSKU([29,'104',249,10,1,107], 4626);
												this.addSKU([29,'104',249,9,1,107], 4627);
												this.addSKU([29,'104',249,8,1,107], 4628);
												this.addSKU([29,'82',249,10,1,107], 4632);
												this.addSKU([29,'82',249,9,1,107], 4633);
												this.addSKU([29,'82',249,8,1,107], 4634);
												this.addSKU([29,'64',249,10,1,107], 4638);
												this.addSKU([29,'64',249,9,1,107], 4639);
												this.addSKU([29,'64',249,8,1,107], 4640);
												this.addSKU([29,'52',249,10,1,107], 4644);
												this.addSKU([29,'52',249,9,1,107], 4645);
												this.addSKU([29,'52',249,8,1,107], 4646);
												this.addSKU([29,'104',119,10,3,109], 4714);
												this.addSKU([29,'104',119,9,3,109], 4715);
												this.addSKU([29,'104',119,8,3,109], 4716);
												this.addSKU([29,'82',119,10,3,109], 4720);
												this.addSKU([29,'82',119,9,3,109], 4721);
												this.addSKU([29,'82',119,8,3,109], 4722);
												this.addSKU([29,'64',119,10,3,109], 4726);
												this.addSKU([29,'64',119,9,3,109], 4727);
												this.addSKU([29,'64',119,8,3,109], 4728);
												this.addSKU([29,'52',119,10,3,109], 4732);
												this.addSKU([29,'52',119,9,3,109], 4733);
												this.addSKU([29,'52',119,8,3,109], 4734);
												this.addSKU([29,'104',122,8,5,107], 4738);
												this.addSKU([29,'104',122,9,5,107], 4739);
												this.addSKU([29,'104',122,10,5,107], 4740);
												this.addSKU([29,'82',122,8,5,107], 4744);
												this.addSKU([29,'82',122,9,5,107], 4745);
												this.addSKU([29,'82',122,10,5,107], 4746);
												this.addSKU([29,'64',122,8,5,107], 4750);
												this.addSKU([29,'64',122,9,5,107], 4751);
												this.addSKU([29,'64',122,10,5,107], 4752);
												this.addSKU([29,'52',122,8,5,107], 4756);
												this.addSKU([29,'52',122,9,5,107], 4757);
												this.addSKU([29,'52',122,10,5,107], 4758);
												this.addSKU([29,'104',116,8,1,107], 4770);
												this.addSKU([29,'104',116,9,1,107], 4771);
												this.addSKU([29,'104',116,10,1,107], 4772);
												this.addSKU([29,'82',116,8,1,107], 4776);
												this.addSKU([29,'82',116,9,1,107], 4777);
												this.addSKU([29,'82',116,10,1,107], 4778);
												this.addSKU([29,'64',116,8,1,107], 4782);
												this.addSKU([29,'64',116,9,1,107], 4783);
												this.addSKU([29,'64',116,10,1,107], 4784);
												this.addSKU([29,'52',116,8,1,107], 4788);
												this.addSKU([29,'52',116,9,1,107], 4789);
												this.addSKU([29,'52',116,10,1,107], 4790);
												this.addSKU([29,'104',119,8,5,266], 5286);
												this.addSKU([29,'104',119,9,5,266], 5287);
												this.addSKU([29,'104',119,10,5,266], 5288);
												this.addSKU([29,'82',119,8,5,266], 5292);
												this.addSKU([29,'82',119,9,5,266], 5293);
												this.addSKU([29,'82',119,10,5,266], 5294);
												this.addSKU([29,'64',119,8,5,266], 5298);
												this.addSKU([29,'64',119,9,5,266], 5299);
												this.addSKU([29,'64',119,10,5,266], 5300);
												this.addSKU([29,'52',119,8,5,266], 5304);
												this.addSKU([29,'52',119,9,5,266], 5305);
												this.addSKU([29,'52',119,10,5,266], 5306);
												this.addSKU([29,'104',119,8,261,107], 6954);
												this.addSKU([29,'104',119,10,261,107], 6955);
												this.addSKU([29,'82',119,8,261,107], 6956);
												this.addSKU([29,'82',119,10,261,107], 6957);
												this.addSKU([29,'64',119,8,261,107], 6958);
												this.addSKU([29,'64',119,10,261,107], 6959);
												this.addSKU([29,'52',119,8,261,107], 6960);
												this.addSKU([29,'52',119,10,261,107], 6961);
							},


	setWeights: function() {
		this.weights = [];
				this.weights[1127] =6.50;
				this.weights[1125] =6.50;
				this.weights[1126] =6.50;
				this.weights[1128] =5.50;
				this.weights[1129] =5.50;
				this.weights[1130] =5.50;
				this.weights[1131] =10.50;
				this.weights[1132] =10.50;
				this.weights[1133] =10.50;
				this.weights[1134] =10.50;
				this.weights[1135] =10.50;
				this.weights[1136] =10.50;
				this.weights[4626] =11.00;
				this.weights[4627] =11.00;
				this.weights[4628] =11.00;
				this.weights[4632] =9.00;
				this.weights[4633] =9.00;
				this.weights[4634] =9.00;
				this.weights[4638] =17.00;
				this.weights[4639] =17.00;
				this.weights[4640] =17.00;
				this.weights[4644] =17.00;
				this.weights[4645] =17.00;
				this.weights[4646] =17.00;
				this.weights[4714] =6.50;
				this.weights[4715] =6.50;
				this.weights[4716] =6.50;
				this.weights[4720] =5.50;
				this.weights[4721] =5.50;
				this.weights[4722] =5.50;
				this.weights[4726] =10.50;
				this.weights[4727] =10.50;
				this.weights[4728] =10.50;
				this.weights[4732] =10.50;
				this.weights[4733] =10.50;
				this.weights[4734] =10.50;
				this.weights[4738] =12.00;
				this.weights[4739] =12.00;
				this.weights[4740] =12.00;
				this.weights[4744] =9.50;
				this.weights[4745] =9.50;
				this.weights[4746] =9.50;
				this.weights[4750] =19.00;
				this.weights[4751] =19.00;
				this.weights[4752] =19.00;
				this.weights[4756] =19.00;
				this.weights[4757] =19.00;
				this.weights[4758] =19.00;
				this.weights[4770] =4.50;
				this.weights[4771] =4.50;
				this.weights[4772] =4.50;
				this.weights[4776] =3.50;
				this.weights[4777] =3.50;
				this.weights[4778] =3.50;
				this.weights[4782] =7.00;
				this.weights[4783] =7.00;
				this.weights[4784] =7.00;
				this.weights[4788] =7.00;
				this.weights[4789] =7.00;
				this.weights[4790] =7.00;
				this.weights[5286] =6.50;
				this.weights[5287] =6.50;
				this.weights[5288] =6.50;
				this.weights[5292] =5.50;
				this.weights[5293] =5.50;
				this.weights[5294] =5.50;
				this.weights[5298] =10.50;
				this.weights[5299] =10.50;
				this.weights[5300] =10.50;
				this.weights[5304] =10.50;
				this.weights[5305] =10.50;
				this.weights[5306] =10.50;
				this.weights[6954] =6.50;
				this.weights[6955] =6.50;
				this.weights[6956] =5.50;
				this.weights[6957] =5.50;
				this.weights[6958] =10.50;
				this.weights[6959] =10.50;
				this.weights[6960] =10.50;
				this.weights[6961] =10.50;
			
	},

	setPrices: function() {
		this.prices = new Hash();
				var pr = [];
		var i;
						pr.push({i:1127, ii:21681410, q:250, p:53.66});
				pr.push({i:1127, ii:21681411, q:500, p:61.15});
				pr.push({i:1127, ii:21681412, q:1000, p:78.62});
				pr.push({i:1127, ii:21681413, q:2500, p:106.08});
				pr.push({i:1127, ii:21681414, q:5000, p:133.54});
				pr.push({i:1127, ii:21681415, q:10000, p:222.14});
				pr.push({i:1127, ii:21681416, q:15000, p:314.50});
				pr.push({i:1127, ii:21681417, q:20000, p:383.14});
				pr.push({i:1127, ii:21681418, q:30000, p:635.23});
				pr.push({i:1127, ii:21681419, q:45000, p:904.80});
				pr.push({i:1127, ii:21681420, q:60000, p:1085.76});
								pr.push({i:1125, ii:21681388, q:250, p:31.20});
				pr.push({i:1125, ii:21681389, q:500, p:34.94});
				pr.push({i:1125, ii:21681390, q:1000, p:37.44});
				pr.push({i:1125, ii:21681391, q:2500, p:81.12});
				pr.push({i:1125, ii:21681392, q:5000, p:109.82});
				pr.push({i:1125, ii:21681393, q:10000, p:205.92});
				pr.push({i:1125, ii:21681394, q:15000, p:285.79});
				pr.push({i:1125, ii:21681395, q:20000, p:374.40});
				pr.push({i:1125, ii:21681396, q:30000, p:586.56});
				pr.push({i:1125, ii:21681397, q:45000, p:817.44});
				pr.push({i:1125, ii:21681398, q:60000, p:1060.80});
								pr.push({i:1126, ii:21681399, q:250, p:53.66});
				pr.push({i:1126, ii:21681400, q:500, p:61.15});
				pr.push({i:1126, ii:21681401, q:1000, p:78.62});
				pr.push({i:1126, ii:21681402, q:2500, p:106.08});
				pr.push({i:1126, ii:21681403, q:5000, p:133.54});
				pr.push({i:1126, ii:21681404, q:10000, p:222.14});
				pr.push({i:1126, ii:21681405, q:15000, p:314.50});
				pr.push({i:1126, ii:21681406, q:20000, p:383.14});
				pr.push({i:1126, ii:21681407, q:30000, p:635.23});
				pr.push({i:1126, ii:21681408, q:45000, p:904.80});
				pr.push({i:1126, ii:21681409, q:60000, p:1085.76});
								pr.push({i:1128, ii:21681421, q:250, p:24.96});
				pr.push({i:1128, ii:21681422, q:500, p:27.46});
				pr.push({i:1128, ii:21681423, q:1000, p:29.95});
				pr.push({i:1128, ii:21681424, q:2500, p:61.15});
				pr.push({i:1128, ii:21681425, q:5000, p:68.64});
				pr.push({i:1128, ii:21681426, q:10000, p:156.00});
				pr.push({i:1128, ii:21681427, q:15000, p:215.90});
				pr.push({i:1128, ii:21681428, q:20000, p:280.80});
				pr.push({i:1128, ii:21681429, q:40000, p:586.56});
				pr.push({i:1128, ii:21681430, q:60000, p:804.96});
				pr.push({i:1128, ii:21681431, q:80000, p:1048.32});
								pr.push({i:1129, ii:21681432, q:250, p:41.18});
				pr.push({i:1129, ii:21681433, q:500, p:46.18});
				pr.push({i:1129, ii:21681434, q:1000, p:59.90});
				pr.push({i:1129, ii:21681435, q:2500, p:77.38});
				pr.push({i:1129, ii:21681436, q:5000, p:93.60});
				pr.push({i:1129, ii:21681437, q:10000, p:168.48});
				pr.push({i:1129, ii:21681438, q:15000, p:239.62});
				pr.push({i:1129, ii:21681439, q:20000, p:287.04});
				pr.push({i:1129, ii:21681440, q:40000, p:622.75});
				pr.push({i:1129, ii:21681441, q:60000, p:892.32});
				pr.push({i:1129, ii:21681442, q:80000, p:1073.28});
								pr.push({i:1130, ii:21681443, q:250, p:41.18});
				pr.push({i:1130, ii:21681444, q:500, p:46.18});
				pr.push({i:1130, ii:21681445, q:1000, p:59.90});
				pr.push({i:1130, ii:21681446, q:2500, p:77.38});
				pr.push({i:1130, ii:21681447, q:5000, p:93.60});
				pr.push({i:1130, ii:21681448, q:10000, p:168.48});
				pr.push({i:1130, ii:21681449, q:15000, p:239.62});
				pr.push({i:1130, ii:21681450, q:20000, p:287.04});
				pr.push({i:1130, ii:21681451, q:40000, p:622.75});
				pr.push({i:1130, ii:21681452, q:60000, p:892.32});
				pr.push({i:1130, ii:21681453, q:80000, p:1073.28});
								pr.push({i:1131, ii:21681454, q:250, p:44.93});
				pr.push({i:1131, ii:21681455, q:500, p:48.67});
				pr.push({i:1131, ii:21681456, q:1000, p:53.66});
				pr.push({i:1131, ii:21681457, q:2500, p:101.09});
				pr.push({i:1131, ii:21681458, q:5000, p:126.05});
				pr.push({i:1131, ii:21681459, q:10000, p:249.60});
				pr.push({i:1131, ii:21681460, q:15000, p:364.42});
				pr.push({i:1131, ii:21681461, q:20000, p:482.98});
				pr.push({i:1131, ii:21681462, q:30000, p:804.96});
				pr.push({i:1131, ii:21681463, q:40000, p:1048.32});
								pr.push({i:1132, ii:21681464, q:250, p:78.62});
				pr.push({i:1132, ii:21681465, q:500, p:92.35});
				pr.push({i:1132, ii:21681466, q:1000, p:101.09});
				pr.push({i:1132, ii:21681467, q:2500, p:146.02});
				pr.push({i:1132, ii:21681468, q:5000, p:175.97});
				pr.push({i:1132, ii:21681469, q:10000, p:287.04});
				pr.push({i:1132, ii:21681470, q:15000, p:409.34});
				pr.push({i:1132, ii:21681471, q:20000, p:541.63});
				pr.push({i:1132, ii:21681472, q:30000, p:892.32});
				pr.push({i:1132, ii:21681473, q:40000, p:1073.28});
								pr.push({i:1133, ii:21681474, q:250, p:78.62});
				pr.push({i:1133, ii:21681475, q:500, p:92.35});
				pr.push({i:1133, ii:21681476, q:1000, p:101.09});
				pr.push({i:1133, ii:21681477, q:2500, p:146.02});
				pr.push({i:1133, ii:21681478, q:5000, p:175.97});
				pr.push({i:1133, ii:21681479, q:10000, p:287.04});
				pr.push({i:1133, ii:21681480, q:15000, p:409.34});
				pr.push({i:1133, ii:21681481, q:20000, p:541.63});
				pr.push({i:1133, ii:21681482, q:30000, p:892.32});
				pr.push({i:1133, ii:21681483, q:40000, p:1073.28});
								pr.push({i:1134, ii:21681484, q:250, p:41.18});
				pr.push({i:1134, ii:21681485, q:500, p:42.43});
				pr.push({i:1134, ii:21681486, q:1000, p:49.92});
				pr.push({i:1134, ii:21681487, q:2500, p:97.34});
				pr.push({i:1134, ii:21681488, q:5000, p:122.30});
				pr.push({i:1134, ii:21681489, q:10000, p:245.86});
				pr.push({i:1134, ii:21681490, q:15000, p:364.42});
				pr.push({i:1134, ii:21681491, q:20000, p:482.98});
				pr.push({i:1134, ii:21681492, q:30000, p:720.10});
				pr.push({i:1134, ii:21681493, q:40000, p:957.22});
								pr.push({i:1135, ii:21681494, q:250, p:43.68});
				pr.push({i:1135, ii:21681495, q:500, p:49.92});
				pr.push({i:1135, ii:21681496, q:1000, p:61.15});
				pr.push({i:1135, ii:21681497, q:2500, p:142.27});
				pr.push({i:1135, ii:21681498, q:5000, p:172.22});
				pr.push({i:1135, ii:21681499, q:10000, p:287.04});
				pr.push({i:1135, ii:21681500, q:15000, p:409.34});
				pr.push({i:1135, ii:21681501, q:20000, p:541.63});
				pr.push({i:1135, ii:21681502, q:30000, p:827.42});
				pr.push({i:1135, ii:21681503, q:40000, p:1073.28});
								pr.push({i:1136, ii:21681504, q:250, p:43.68});
				pr.push({i:1136, ii:21681505, q:500, p:49.92});
				pr.push({i:1136, ii:21681506, q:1000, p:61.15});
				pr.push({i:1136, ii:21681507, q:2500, p:142.27});
				pr.push({i:1136, ii:21681508, q:5000, p:172.22});
				pr.push({i:1136, ii:21681509, q:10000, p:287.04});
				pr.push({i:1136, ii:21681510, q:15000, p:409.34});
				pr.push({i:1136, ii:21681511, q:20000, p:541.63});
				pr.push({i:1136, ii:21681512, q:30000, p:827.42});
				pr.push({i:1136, ii:21681513, q:40000, p:1073.28});
								pr.push({i:4626, ii:21681514, q:250, p:110.88});
				pr.push({i:4626, ii:21681515, q:500, p:120.96});
				pr.push({i:4626, ii:21681516, q:1000, p:141.12});
				pr.push({i:4626, ii:21681517, q:2500, p:223.02});
				pr.push({i:4626, ii:21681518, q:5000, p:318.78});
				pr.push({i:4626, ii:21681519, q:10000, p:569.52});
				pr.push({i:4626, ii:21681520, q:15000, p:868.14});
				pr.push({i:4626, ii:21681521, q:20000, p:1125.18});
				pr.push({i:4626, ii:21681522, q:30000, p:1675.80});
				pr.push({i:4626, ii:21681523, q:45000, p:2564.10});
				pr.push({i:4626, ii:21681524, q:60000, p:3313.80});
								pr.push({i:4627, ii:21681525, q:250, p:110.88});
				pr.push({i:4627, ii:21681526, q:500, p:120.96});
				pr.push({i:4627, ii:21681527, q:1000, p:141.12});
				pr.push({i:4627, ii:21681528, q:2500, p:223.02});
				pr.push({i:4627, ii:21681529, q:5000, p:318.78});
				pr.push({i:4627, ii:21681530, q:10000, p:569.52});
				pr.push({i:4627, ii:21681531, q:15000, p:868.14});
				pr.push({i:4627, ii:21681532, q:20000, p:1125.18});
				pr.push({i:4627, ii:21681533, q:30000, p:1675.80});
				pr.push({i:4627, ii:21681534, q:45000, p:2564.10});
				pr.push({i:4627, ii:21681535, q:60000, p:3313.80});
								pr.push({i:4628, ii:21681536, q:250, p:110.88});
				pr.push({i:4628, ii:21681537, q:500, p:120.96});
				pr.push({i:4628, ii:21681538, q:1000, p:141.12});
				pr.push({i:4628, ii:21681539, q:2500, p:223.02});
				pr.push({i:4628, ii:21681540, q:5000, p:318.78});
				pr.push({i:4628, ii:21681541, q:10000, p:569.52});
				pr.push({i:4628, ii:21681542, q:15000, p:868.14});
				pr.push({i:4628, ii:21681543, q:20000, p:1125.18});
				pr.push({i:4628, ii:21681544, q:30000, p:1675.80});
				pr.push({i:4628, ii:21681545, q:45000, p:2564.10});
				pr.push({i:4628, ii:21681546, q:60000, p:3313.80});
								pr.push({i:4632, ii:21681547, q:250, p:84.42});
				pr.push({i:4632, ii:21681548, q:500, p:91.98});
				pr.push({i:4632, ii:21681549, q:1000, p:107.10});
				pr.push({i:4632, ii:21681550, q:2500, p:167.58});
				pr.push({i:4632, ii:21681551, q:5000, p:233.10});
				pr.push({i:4632, ii:21681552, q:10000, p:428.40});
				pr.push({i:4632, ii:21681553, q:15000, p:653.94});
				pr.push({i:4632, ii:21681554, q:20000, p:844.20});
				pr.push({i:4632, ii:21681555, q:40000, p:1663.20});
				pr.push({i:4632, ii:21681556, q:60000, p:2551.50});
				pr.push({i:4632, ii:21681557, q:80000, p:3301.20});
								pr.push({i:4633, ii:21681558, q:250, p:84.42});
				pr.push({i:4633, ii:21681559, q:500, p:91.98});
				pr.push({i:4633, ii:21681560, q:1000, p:107.10});
				pr.push({i:4633, ii:21681561, q:2500, p:167.58});
				pr.push({i:4633, ii:21681562, q:5000, p:233.10});
				pr.push({i:4633, ii:21681563, q:10000, p:428.40});
				pr.push({i:4633, ii:21681564, q:15000, p:653.94});
				pr.push({i:4633, ii:21681565, q:20000, p:844.20});
				pr.push({i:4633, ii:21681566, q:40000, p:1663.20});
				pr.push({i:4633, ii:21681567, q:60000, p:2551.50});
				pr.push({i:4633, ii:21681568, q:80000, p:3301.20});
								pr.push({i:4634, ii:21681569, q:250, p:84.42});
				pr.push({i:4634, ii:21681570, q:500, p:91.98});
				pr.push({i:4634, ii:21681571, q:1000, p:107.10});
				pr.push({i:4634, ii:21681572, q:2500, p:167.58});
				pr.push({i:4634, ii:21681573, q:5000, p:233.10});
				pr.push({i:4634, ii:21681574, q:10000, p:428.40});
				pr.push({i:4634, ii:21681575, q:15000, p:653.94});
				pr.push({i:4634, ii:21681576, q:20000, p:844.20});
				pr.push({i:4634, ii:21681577, q:40000, p:1663.20});
				pr.push({i:4634, ii:21681578, q:60000, p:2551.50});
				pr.push({i:4634, ii:21681579, q:80000, p:3301.20});
								pr.push({i:4638, ii:21681580, q:250, p:163.80});
				pr.push({i:4638, ii:21681581, q:500, p:178.92});
				pr.push({i:4638, ii:21681582, q:1000, p:207.90});
				pr.push({i:4638, ii:21681583, q:2500, p:327.60});
				pr.push({i:4638, ii:21681584, q:5000, p:464.94});
				pr.push({i:4638, ii:21681585, q:10000, p:837.90});
				pr.push({i:4638, ii:21681586, q:15000, p:1282.68});
				pr.push({i:4638, ii:21681587, q:20000, p:1663.20});
				pr.push({i:4638, ii:21681588, q:30000, p:2551.50});
				pr.push({i:4638, ii:21681589, q:40000, p:3301.20});
								pr.push({i:4639, ii:21681590, q:250, p:163.80});
				pr.push({i:4639, ii:21681591, q:500, p:178.92});
				pr.push({i:4639, ii:21681592, q:1000, p:207.90});
				pr.push({i:4639, ii:21681593, q:2500, p:327.60});
				pr.push({i:4639, ii:21681594, q:5000, p:464.94});
				pr.push({i:4639, ii:21681595, q:10000, p:837.90});
				pr.push({i:4639, ii:21681596, q:15000, p:1282.68});
				pr.push({i:4639, ii:21681597, q:20000, p:1663.20});
				pr.push({i:4639, ii:21681598, q:30000, p:2551.50});
				pr.push({i:4639, ii:21681599, q:40000, p:3301.20});
								pr.push({i:4640, ii:21681600, q:250, p:163.80});
				pr.push({i:4640, ii:21681601, q:500, p:178.92});
				pr.push({i:4640, ii:21681602, q:1000, p:207.90});
				pr.push({i:4640, ii:21681603, q:2500, p:327.60});
				pr.push({i:4640, ii:21681604, q:5000, p:464.94});
				pr.push({i:4640, ii:21681605, q:10000, p:837.90});
				pr.push({i:4640, ii:21681606, q:15000, p:1282.68});
				pr.push({i:4640, ii:21681607, q:20000, p:1663.20});
				pr.push({i:4640, ii:21681608, q:30000, p:2551.50});
				pr.push({i:4640, ii:21681609, q:40000, p:3301.20});
								pr.push({i:4644, ii:21681610, q:250, p:163.80});
				pr.push({i:4644, ii:21681611, q:500, p:178.92});
				pr.push({i:4644, ii:21681612, q:1000, p:207.90});
				pr.push({i:4644, ii:21681613, q:2500, p:327.60});
				pr.push({i:4644, ii:21681614, q:5000, p:464.94});
				pr.push({i:4644, ii:21681615, q:10000, p:837.90});
				pr.push({i:4644, ii:21681616, q:15000, p:1282.68});
				pr.push({i:4644, ii:21681617, q:20000, p:1663.20});
				pr.push({i:4644, ii:21681618, q:30000, p:2551.50});
				pr.push({i:4644, ii:21681619, q:40000, p:3301.20});
								pr.push({i:4645, ii:21681620, q:250, p:163.80});
				pr.push({i:4645, ii:21681621, q:500, p:178.92});
				pr.push({i:4645, ii:21681622, q:1000, p:207.90});
				pr.push({i:4645, ii:21681623, q:2500, p:327.60});
				pr.push({i:4645, ii:21681624, q:5000, p:464.94});
				pr.push({i:4645, ii:21681625, q:10000, p:837.90});
				pr.push({i:4645, ii:21681626, q:15000, p:1282.68});
				pr.push({i:4645, ii:21681627, q:20000, p:1663.20});
				pr.push({i:4645, ii:21681628, q:30000, p:2551.50});
				pr.push({i:4645, ii:21681629, q:40000, p:3301.20});
								pr.push({i:4646, ii:21681630, q:250, p:163.80});
				pr.push({i:4646, ii:21681631, q:500, p:178.92});
				pr.push({i:4646, ii:21681632, q:1000, p:207.90});
				pr.push({i:4646, ii:21681633, q:2500, p:327.60});
				pr.push({i:4646, ii:21681634, q:5000, p:464.94});
				pr.push({i:4646, ii:21681635, q:10000, p:837.90});
				pr.push({i:4646, ii:21681636, q:15000, p:1282.68});
				pr.push({i:4646, ii:21681637, q:20000, p:1663.20});
				pr.push({i:4646, ii:21681638, q:30000, p:2551.50});
				pr.push({i:4646, ii:21681639, q:40000, p:3301.20});
								pr.push({i:4714, ii:21681640, q:250, p:46.18});
				pr.push({i:4714, ii:21681641, q:500, p:56.16});
				pr.push({i:4714, ii:21681642, q:1000, p:91.10});
				pr.push({i:4714, ii:21681643, q:2500, p:132.29});
				pr.push({i:4714, ii:21681644, q:5000, p:165.98});
				pr.push({i:4714, ii:21681645, q:10000, p:278.30});
				pr.push({i:4714, ii:21681646, q:15000, p:406.85});
				pr.push({i:4714, ii:21681647, q:20000, p:511.68});
				pr.push({i:4714, ii:21681648, q:30000, p:832.42});
				pr.push({i:4714, ii:21681649, q:45000, p:1108.22});
				pr.push({i:4714, ii:21681650, q:60000, p:1470.14});
								pr.push({i:4715, ii:21681651, q:250, p:46.18});
				pr.push({i:4715, ii:21681652, q:500, p:56.16});
				pr.push({i:4715, ii:21681653, q:1000, p:91.10});
				pr.push({i:4715, ii:21681654, q:2500, p:132.29});
				pr.push({i:4715, ii:21681655, q:5000, p:165.98});
				pr.push({i:4715, ii:21681656, q:10000, p:278.30});
				pr.push({i:4715, ii:21681657, q:15000, p:406.85});
				pr.push({i:4715, ii:21681658, q:20000, p:511.68});
				pr.push({i:4715, ii:21681659, q:30000, p:832.42});
				pr.push({i:4715, ii:21681660, q:45000, p:1108.22});
				pr.push({i:4715, ii:21681661, q:60000, p:1470.14});
								pr.push({i:4716, ii:21681662, q:250, p:37.44});
				pr.push({i:4716, ii:21681663, q:500, p:42.43});
				pr.push({i:4716, ii:21681664, q:1000, p:47.42});
				pr.push({i:4716, ii:21681665, q:2500, p:102.34});
				pr.push({i:4716, ii:21681666, q:5000, p:127.30});
				pr.push({i:4716, ii:21681667, q:10000, p:250.85});
				pr.push({i:4716, ii:21681668, q:15000, p:369.41});
				pr.push({i:4716, ii:21681669, q:20000, p:487.97});
				pr.push({i:4716, ii:21681670, q:30000, p:783.74});
				pr.push({i:4716, ii:21681671, q:45000, p:1070.78});
				pr.push({i:4716, ii:21681672, q:60000, p:1445.18});
								pr.push({i:4720, ii:21681673, q:250, p:46.18});
				pr.push({i:4720, ii:21681674, q:500, p:54.91});
				pr.push({i:4720, ii:21681675, q:1000, p:78.62});
				pr.push({i:4720, ii:21681676, q:2500, p:99.84});
				pr.push({i:4720, ii:21681677, q:5000, p:119.81});
				pr.push({i:4720, ii:21681678, q:10000, p:218.40});
				pr.push({i:4720, ii:21681679, q:15000, p:312.00});
				pr.push({i:4720, ii:21681680, q:20000, p:383.14});
				pr.push({i:4720, ii:21681681, q:40000, p:819.94});
				pr.push({i:4720, ii:21681682, q:60000, p:1183.10});
				pr.push({i:4720, ii:21681683, q:80000, p:1457.66});
								pr.push({i:4721, ii:21681684, q:250, p:46.18});
				pr.push({i:4721, ii:21681685, q:500, p:54.91});
				pr.push({i:4721, ii:21681686, q:1000, p:78.62});
				pr.push({i:4721, ii:21681687, q:2500, p:99.84});
				pr.push({i:4721, ii:21681688, q:5000, p:119.81});
				pr.push({i:4721, ii:21681689, q:10000, p:218.40});
				pr.push({i:4721, ii:21681690, q:15000, p:312.00});
				pr.push({i:4721, ii:21681691, q:20000, p:383.14});
				pr.push({i:4721, ii:21681692, q:40000, p:819.94});
				pr.push({i:4721, ii:21681693, q:60000, p:1183.10});
				pr.push({i:4721, ii:21681694, q:80000, p:1457.66});
								pr.push({i:4722, ii:21681695, q:250, p:28.70});
				pr.push({i:4722, ii:21681696, q:500, p:33.70});
				pr.push({i:4722, ii:21681697, q:1000, p:36.19});
				pr.push({i:4722, ii:21681698, q:2500, p:78.62});
				pr.push({i:4722, ii:21681699, q:5000, p:107.33});
				pr.push({i:4722, ii:21681700, q:10000, p:205.92});
				pr.push({i:4722, ii:21681701, q:15000, p:289.54});
				pr.push({i:4722, ii:21681702, q:20000, p:376.90});
				pr.push({i:4722, ii:21681703, q:40000, p:771.26});
				pr.push({i:4722, ii:21681704, q:60000, p:1095.74});
				pr.push({i:4722, ii:21681705, q:80000, p:1432.70});
								pr.push({i:4726, ii:21681706, q:250, p:88.61});
				pr.push({i:4726, ii:21681707, q:500, p:104.83});
				pr.push({i:4726, ii:21681708, q:1000, p:133.54});
				pr.push({i:4726, ii:21681709, q:2500, p:179.71});
				pr.push({i:4726, ii:21681710, q:5000, p:213.41});
				pr.push({i:4726, ii:21681711, q:10000, p:340.70});
				pr.push({i:4726, ii:21681712, q:15000, p:497.95});
				pr.push({i:4726, ii:21681713, q:20000, p:657.70});
				pr.push({i:4726, ii:21681714, q:30000, p:1183.10});
				pr.push({i:4726, ii:21681715, q:40000, p:1457.66});
								pr.push({i:4727, ii:21681716, q:250, p:88.61});
				pr.push({i:4727, ii:21681717, q:500, p:104.83});
				pr.push({i:4727, ii:21681718, q:1000, p:133.54});
				pr.push({i:4727, ii:21681719, q:2500, p:179.71});
				pr.push({i:4727, ii:21681720, q:5000, p:213.41});
				pr.push({i:4727, ii:21681721, q:10000, p:340.70});
				pr.push({i:4727, ii:21681722, q:15000, p:497.95});
				pr.push({i:4727, ii:21681723, q:20000, p:657.70});
				pr.push({i:4727, ii:21681724, q:30000, p:1183.10});
				pr.push({i:4727, ii:21681725, q:40000, p:1457.66});
								pr.push({i:4728, ii:21681726, q:250, p:53.66});
				pr.push({i:4728, ii:21681727, q:500, p:61.15});
				pr.push({i:4728, ii:21681728, q:1000, p:67.39});
				pr.push({i:4728, ii:21681729, q:2500, p:148.51});
				pr.push({i:4728, ii:21681730, q:5000, p:213.41});
				pr.push({i:4728, ii:21681731, q:10000, p:340.70});
				pr.push({i:4728, ii:21681732, q:15000, p:497.95});
				pr.push({i:4728, ii:21681733, q:20000, p:657.70});
				pr.push({i:4728, ii:21681734, q:30000, p:1095.74});
				pr.push({i:4728, ii:21681735, q:40000, p:1432.70});
								pr.push({i:4732, ii:21681736, q:250, p:88.61});
				pr.push({i:4732, ii:21681737, q:500, p:98.59});
				pr.push({i:4732, ii:21681738, q:1000, p:113.57});
				pr.push({i:4732, ii:21681739, q:2500, p:180.96});
				pr.push({i:4732, ii:21681740, q:5000, p:213.41});
				pr.push({i:4732, ii:21681741, q:10000, p:343.20});
				pr.push({i:4732, ii:21681742, q:15000, p:469.25});
				pr.push({i:4732, ii:21681743, q:20000, p:605.28});
				pr.push({i:4732, ii:21681744, q:30000, p:1183.10});
				pr.push({i:4732, ii:21681745, q:40000, p:1457.66});
								pr.push({i:4733, ii:21681746, q:250, p:88.61});
				pr.push({i:4733, ii:21681747, q:500, p:104.83});
				pr.push({i:4733, ii:21681748, q:1000, p:133.54});
				pr.push({i:4733, ii:21681749, q:2500, p:189.70});
				pr.push({i:4733, ii:21681750, q:5000, p:238.37});
				pr.push({i:4733, ii:21681751, q:10000, p:416.83});
				pr.push({i:4733, ii:21681752, q:15000, p:597.79});
				pr.push({i:4733, ii:21681753, q:20000, p:766.27});
				pr.push({i:4733, ii:21681754, q:30000, p:1183.10});
				pr.push({i:4733, ii:21681755, q:40000, p:1457.66});
								pr.push({i:4734, ii:21681756, q:250, p:53.66});
				pr.push({i:4734, ii:21681757, q:500, p:61.15});
				pr.push({i:4734, ii:21681758, q:1000, p:67.39});
				pr.push({i:4734, ii:21681759, q:2500, p:148.51});
				pr.push({i:4734, ii:21681760, q:5000, p:194.69});
				pr.push({i:4734, ii:21681761, q:10000, p:326.98});
				pr.push({i:4734, ii:21681762, q:15000, p:469.25});
				pr.push({i:4734, ii:21681763, q:20000, p:605.28});
				pr.push({i:4734, ii:21681764, q:30000, p:1095.74});
				pr.push({i:4734, ii:21681765, q:40000, p:1432.70});
								pr.push({i:4738, ii:21681766, q:1000, p:79.10});
				pr.push({i:4738, ii:21681767, q:2500, p:126.07});
				pr.push({i:4738, ii:21681768, q:5000, p:156.97});
				pr.push({i:4738, ii:21681769, q:10000, p:310.24});
				pr.push({i:4738, ii:21681770, q:15000, p:456.08});
				pr.push({i:4738, ii:21681771, q:20000, p:603.17});
				pr.push({i:4738, ii:21681772, q:30000, p:1149.48});
				pr.push({i:4738, ii:21681773, q:45000, p:1773.66});
				pr.push({i:4738, ii:21681774, q:60000, p:2261.88});
								pr.push({i:4739, ii:21681775, q:1000, p:121.13});
				pr.push({i:4739, ii:21681776, q:2500, p:176.75});
				pr.push({i:4739, ii:21681777, q:5000, p:221.24});
				pr.push({i:4739, ii:21681778, q:10000, p:381.92});
				pr.push({i:4739, ii:21681779, q:15000, p:526.54});
				pr.push({i:4739, ii:21681780, q:20000, p:697.10});
				pr.push({i:4739, ii:21681781, q:30000, p:1065.43});
				pr.push({i:4739, ii:21681782, q:45000, p:1643.88});
				pr.push({i:4739, ii:21681783, q:60000, p:2261.88});
								pr.push({i:4740, ii:21681784, q:1000, p:121.13});
				pr.push({i:4740, ii:21681785, q:2500, p:176.75});
				pr.push({i:4740, ii:21681786, q:5000, p:221.24});
				pr.push({i:4740, ii:21681787, q:10000, p:381.92});
				pr.push({i:4740, ii:21681788, q:15000, p:526.54});
				pr.push({i:4740, ii:21681789, q:20000, p:697.10});
				pr.push({i:4740, ii:21681790, q:30000, p:1065.43});
				pr.push({i:4740, ii:21681791, q:45000, p:1643.88});
				pr.push({i:4740, ii:21681792, q:60000, p:2261.88});
								pr.push({i:4744, ii:21681793, q:1000, p:92.70});
				pr.push({i:4744, ii:21681794, q:2500, p:135.96});
				pr.push({i:4744, ii:21681795, q:5000, p:166.86});
				pr.push({i:4744, ii:21681796, q:10000, p:296.64});
				pr.push({i:4744, ii:21681797, q:15000, p:456.08});
				pr.push({i:4744, ii:21681798, q:20000, p:580.92});
				pr.push({i:4744, ii:21681799, q:40000, p:1137.12});
				pr.push({i:4744, ii:21681800, q:60000, p:1761.30});
				pr.push({i:4744, ii:21681801, q:80000, p:2249.52});
								pr.push({i:4745, ii:21681802, q:1000, p:92.70});
				pr.push({i:4745, ii:21681803, q:2500, p:135.96});
				pr.push({i:4745, ii:21681804, q:5000, p:166.86});
				pr.push({i:4745, ii:21681805, q:10000, p:296.64});
				pr.push({i:4745, ii:21681806, q:15000, p:456.08});
				pr.push({i:4745, ii:21681807, q:20000, p:580.92});
				pr.push({i:4745, ii:21681808, q:40000, p:1137.12});
				pr.push({i:4745, ii:21681809, q:60000, p:1761.30});
				pr.push({i:4745, ii:21681810, q:80000, p:2249.52});
								pr.push({i:4746, ii:21681811, q:1000, p:92.70});
				pr.push({i:4746, ii:21681812, q:2500, p:135.96});
				pr.push({i:4746, ii:21681813, q:5000, p:166.86});
				pr.push({i:4746, ii:21681814, q:10000, p:296.64});
				pr.push({i:4746, ii:21681815, q:15000, p:456.08});
				pr.push({i:4746, ii:21681816, q:20000, p:580.92});
				pr.push({i:4746, ii:21681817, q:40000, p:1137.12});
				pr.push({i:4746, ii:21681818, q:60000, p:1761.30});
				pr.push({i:4746, ii:21681819, q:80000, p:2249.52});
								pr.push({i:4750, ii:21681820, q:1000, p:77.87});
				pr.push({i:4750, ii:21681821, q:2500, p:124.84});
				pr.push({i:4750, ii:21681822, q:5000, p:155.74});
				pr.push({i:4750, ii:21681823, q:10000, p:305.29});
				pr.push({i:4750, ii:21681824, q:15000, p:451.14});
				pr.push({i:4750, ii:21681825, q:20000, p:598.22});
				pr.push({i:4750, ii:21681826, q:30000, p:1035.77});
				pr.push({i:4750, ii:21681827, q:40000, p:1383.08});
								pr.push({i:4751, ii:21689288, q:1000, p:129.78});
				pr.push({i:4751, ii:21689289, q:2500, p:187.87});
				pr.push({i:4751, ii:21689290, q:5000, p:226.19});
				pr.push({i:4751, ii:21689291, q:10000, p:386.87});
				pr.push({i:4751, ii:21689292, q:15000, p:527.77});
				pr.push({i:4751, ii:21689293, q:20000, p:698.34});
				pr.push({i:4751, ii:21689294, q:30000, p:1761.30});
				pr.push({i:4751, ii:21689295, q:40000, p:2249.52});
								pr.push({i:4752, ii:21681828, q:1000, p:123.60});
				pr.push({i:4752, ii:21681829, q:2500, p:154.50});
				pr.push({i:4752, ii:21681830, q:5000, p:220.01});
				pr.push({i:4752, ii:21681831, q:10000, p:386.87});
				pr.push({i:4752, ii:21681832, q:15000, p:527.77});
				pr.push({i:4752, ii:21681833, q:20000, p:698.34});
				pr.push({i:4752, ii:21681834, q:30000, p:1117.34});
				pr.push({i:4752, ii:21681835, q:40000, p:1490.62});
								pr.push({i:4756, ii:21681836, q:1000, p:74.16});
				pr.push({i:4756, ii:21681837, q:2500, p:119.89});
				pr.push({i:4756, ii:21681838, q:5000, p:150.79});
				pr.push({i:4756, ii:21681839, q:10000, p:305.29});
				pr.push({i:4756, ii:21681840, q:15000, p:451.14});
				pr.push({i:4756, ii:21681841, q:20000, p:598.22});
				pr.push({i:4756, ii:21681842, q:30000, p:891.16});
				pr.push({i:4756, ii:21681843, q:40000, p:1185.32});
								pr.push({i:4757, ii:21689296, q:1000, p:124.84});
				pr.push({i:4757, ii:21689297, q:2500, p:182.93});
				pr.push({i:4757, ii:21689298, q:5000, p:221.24});
				pr.push({i:4757, ii:21689299, q:10000, p:383.16});
				pr.push({i:4757, ii:21689300, q:15000, p:527.77});
				pr.push({i:4757, ii:21689301, q:20000, p:698.34});
				pr.push({i:4757, ii:21689302, q:30000, p:1065.43});
				pr.push({i:4757, ii:21689303, q:40000, p:1451.06});
								pr.push({i:4758, ii:21681844, q:1000, p:124.84});
				pr.push({i:4758, ii:21681845, q:2500, p:182.93});
				pr.push({i:4758, ii:21681846, q:5000, p:221.24});
				pr.push({i:4758, ii:21681847, q:10000, p:383.16});
				pr.push({i:4758, ii:21681848, q:15000, p:527.77});
				pr.push({i:4758, ii:21681849, q:20000, p:698.34});
				pr.push({i:4758, ii:21681850, q:30000, p:1065.43});
				pr.push({i:4758, ii:21681851, q:40000, p:1451.06});
								pr.push({i:4770, ii:21681852, q:250, p:56.86});
				pr.push({i:4770, ii:21681853, q:500, p:60.56});
				pr.push({i:4770, ii:21681854, q:1000, p:63.04});
				pr.push({i:4770, ii:21681855, q:2500, p:95.17});
				pr.push({i:4770, ii:21681856, q:5000, p:121.13});
				pr.push({i:4770, ii:21681857, q:10000, p:223.72});
				pr.push({i:4770, ii:21681858, q:15000, p:321.36});
				pr.push({i:4770, ii:21681859, q:20000, p:420.24});
				pr.push({i:4770, ii:21681860, q:30000, p:630.36});
				pr.push({i:4770, ii:21681861, q:45000, p:927.00});
				pr.push({i:4770, ii:21681862, q:60000, p:1198.92});
								pr.push({i:4771, ii:21681863, q:250, p:56.86});
				pr.push({i:4771, ii:21681864, q:500, p:60.56});
				pr.push({i:4771, ii:21681865, q:1000, p:63.04});
				pr.push({i:4771, ii:21681866, q:2500, p:95.17});
				pr.push({i:4771, ii:21681867, q:5000, p:121.13});
				pr.push({i:4771, ii:21681868, q:10000, p:223.72});
				pr.push({i:4771, ii:21681869, q:15000, p:321.36});
				pr.push({i:4771, ii:21681870, q:20000, p:420.24});
				pr.push({i:4771, ii:21681871, q:30000, p:630.36});
				pr.push({i:4771, ii:21681872, q:45000, p:927.00});
				pr.push({i:4771, ii:21681873, q:60000, p:1198.92});
								pr.push({i:4772, ii:21681874, q:250, p:56.86});
				pr.push({i:4772, ii:21681875, q:500, p:60.56});
				pr.push({i:4772, ii:21681876, q:1000, p:63.04});
				pr.push({i:4772, ii:21681877, q:2500, p:95.17});
				pr.push({i:4772, ii:21681878, q:5000, p:121.13});
				pr.push({i:4772, ii:21681879, q:10000, p:223.72});
				pr.push({i:4772, ii:21681880, q:15000, p:321.36});
				pr.push({i:4772, ii:21681881, q:20000, p:420.24});
				pr.push({i:4772, ii:21681882, q:30000, p:630.36});
				pr.push({i:4772, ii:21681883, q:45000, p:927.00});
				pr.push({i:4772, ii:21681884, q:60000, p:1198.92});
								pr.push({i:4776, ii:21681885, q:250, p:55.62});
				pr.push({i:4776, ii:21681886, q:500, p:61.80});
				pr.push({i:4776, ii:21681887, q:1000, p:75.40});
				pr.push({i:4776, ii:21681888, q:2500, p:84.05});
				pr.push({i:4776, ii:21681889, q:5000, p:101.35});
				pr.push({i:4776, ii:21681890, q:10000, p:166.86});
				pr.push({i:4776, ii:21681891, q:15000, p:244.73});
				pr.push({i:4776, ii:21681892, q:20000, p:315.18});
				pr.push({i:4776, ii:21681893, q:40000, p:618.00});
				pr.push({i:4776, ii:21681894, q:60000, p:914.64});
				pr.push({i:4776, ii:21681895, q:80000, p:1186.56});
								pr.push({i:4777, ii:21681896, q:250, p:55.62});
				pr.push({i:4777, ii:21681897, q:500, p:61.80});
				pr.push({i:4777, ii:21681898, q:1000, p:75.40});
				pr.push({i:4777, ii:21681899, q:2500, p:84.05});
				pr.push({i:4777, ii:21681900, q:5000, p:101.35});
				pr.push({i:4777, ii:21681901, q:10000, p:166.86});
				pr.push({i:4777, ii:21681902, q:15000, p:244.73});
				pr.push({i:4777, ii:21681903, q:20000, p:315.18});
				pr.push({i:4777, ii:21681904, q:40000, p:618.00});
				pr.push({i:4777, ii:21681905, q:60000, p:914.64});
				pr.push({i:4777, ii:21681906, q:80000, p:1186.56});
								pr.push({i:4778, ii:21681907, q:250, p:55.62});
				pr.push({i:4778, ii:21681908, q:500, p:61.80});
				pr.push({i:4778, ii:21681909, q:1000, p:75.40});
				pr.push({i:4778, ii:21681910, q:2500, p:84.05});
				pr.push({i:4778, ii:21681911, q:5000, p:101.35});
				pr.push({i:4778, ii:21681912, q:10000, p:166.86});
				pr.push({i:4778, ii:21681913, q:15000, p:244.73});
				pr.push({i:4778, ii:21681914, q:20000, p:315.18});
				pr.push({i:4778, ii:21681915, q:40000, p:618.00});
				pr.push({i:4778, ii:21681916, q:60000, p:914.64});
				pr.push({i:4778, ii:21681917, q:80000, p:1186.56});
								pr.push({i:4782, ii:21681918, q:250, p:106.30});
				pr.push({i:4782, ii:21681919, q:500, p:119.89});
				pr.push({i:4782, ii:21681920, q:1000, p:144.61});
				pr.push({i:4782, ii:21681921, q:2500, p:148.32});
				pr.push({i:4782, ii:21681922, q:5000, p:201.47});
				pr.push({i:4782, ii:21681923, q:10000, p:315.18});
				pr.push({i:4782, ii:21681924, q:15000, p:463.50});
				pr.push({i:4782, ii:21681925, q:20000, p:618.00});
				pr.push({i:4782, ii:21681926, q:30000, p:914.64});
				pr.push({i:4782, ii:21681927, q:40000, p:1186.56});
								pr.push({i:4783, ii:21681928, q:250, p:106.30});
				pr.push({i:4783, ii:21681929, q:500, p:119.89});
				pr.push({i:4783, ii:21681930, q:1000, p:144.61});
				pr.push({i:4783, ii:21681931, q:2500, p:148.32});
				pr.push({i:4783, ii:21681932, q:5000, p:201.47});
				pr.push({i:4783, ii:21681933, q:10000, p:315.18});
				pr.push({i:4783, ii:21681934, q:15000, p:463.50});
				pr.push({i:4783, ii:21681935, q:20000, p:618.00});
				pr.push({i:4783, ii:21681936, q:30000, p:914.64});
				pr.push({i:4783, ii:21681937, q:40000, p:1186.56});
								pr.push({i:4784, ii:21681938, q:250, p:106.30});
				pr.push({i:4784, ii:21681939, q:500, p:119.89});
				pr.push({i:4784, ii:21681940, q:1000, p:144.61});
				pr.push({i:4784, ii:21681941, q:2500, p:148.32});
				pr.push({i:4784, ii:21681942, q:5000, p:201.47});
				pr.push({i:4784, ii:21681943, q:10000, p:315.18});
				pr.push({i:4784, ii:21681944, q:15000, p:463.50});
				pr.push({i:4784, ii:21681945, q:20000, p:618.00});
				pr.push({i:4784, ii:21681946, q:30000, p:914.64});
				pr.push({i:4784, ii:21681947, q:40000, p:1186.56});
								pr.push({i:4788, ii:21681948, q:250, p:55.62});
				pr.push({i:4788, ii:21681949, q:500, p:61.80});
				pr.push({i:4788, ii:21681950, q:1000, p:66.74});
				pr.push({i:4788, ii:21681951, q:2500, p:139.67});
				pr.push({i:4788, ii:21681952, q:5000, p:184.16});
				pr.push({i:4788, ii:21681953, q:10000, p:315.18});
				pr.push({i:4788, ii:21681954, q:15000, p:463.50});
				pr.push({i:4788, ii:21681955, q:20000, p:618.00});
				pr.push({i:4788, ii:21681956, q:30000, p:914.64});
				pr.push({i:4788, ii:21681957, q:40000, p:1186.56});
								pr.push({i:4789, ii:21681958, q:250, p:106.30});
				pr.push({i:4789, ii:21681959, q:500, p:119.89});
				pr.push({i:4789, ii:21681960, q:1000, p:122.36});
				pr.push({i:4789, ii:21681961, q:2500, p:148.32});
				pr.push({i:4789, ii:21681962, q:5000, p:201.47});
				pr.push({i:4789, ii:21681963, q:10000, p:315.18});
				pr.push({i:4789, ii:21681964, q:15000, p:463.50});
				pr.push({i:4789, ii:21681965, q:20000, p:618.00});
				pr.push({i:4789, ii:21681966, q:30000, p:914.64});
				pr.push({i:4789, ii:21681967, q:40000, p:1186.56});
								pr.push({i:4790, ii:21681968, q:250, p:106.30});
				pr.push({i:4790, ii:21681969, q:500, p:119.89});
				pr.push({i:4790, ii:21681970, q:1000, p:122.36});
				pr.push({i:4790, ii:21681971, q:2500, p:148.32});
				pr.push({i:4790, ii:21681972, q:5000, p:201.47});
				pr.push({i:4790, ii:21681973, q:10000, p:315.18});
				pr.push({i:4790, ii:21681974, q:15000, p:463.50});
				pr.push({i:4790, ii:21681975, q:20000, p:618.00});
				pr.push({i:4790, ii:21681976, q:30000, p:914.64});
				pr.push({i:4790, ii:21681977, q:40000, p:1186.56});
								pr.push({i:5286, ii:21683162, q:250, p:56.16});
				pr.push({i:5286, ii:21683163, q:500, p:61.15});
				pr.push({i:5286, ii:21683164, q:1000, p:63.65});
				pr.push({i:5286, ii:21683165, q:2500, p:102.34});
				pr.push({i:5286, ii:21683166, q:5000, p:134.78});
				pr.push({i:5286, ii:21683167, q:10000, p:259.58});
				pr.push({i:5286, ii:21683168, q:15000, p:378.14});
				pr.push({i:5286, ii:21683169, q:20000, p:497.95});
				pr.push({i:5286, ii:21683170, q:30000, p:861.12});
				pr.push({i:5286, ii:21683171, q:45000, p:1178.11});
				pr.push({i:5286, ii:21683172, q:60000, p:1473.89});
								pr.push({i:5287, ii:21683184, q:250, p:108.58});
				pr.push({i:5287, ii:21683185, q:500, p:116.06});
				pr.push({i:5287, ii:21683186, q:1000, p:123.55});
				pr.push({i:5287, ii:21683187, q:2500, p:144.77});
				pr.push({i:5287, ii:21683188, q:5000, p:169.73});
				pr.push({i:5287, ii:21683189, q:10000, p:273.31});
				pr.push({i:5287, ii:21683190, q:15000, p:401.86});
				pr.push({i:5287, ii:21683191, q:20000, p:526.66});
				pr.push({i:5287, ii:21683192, q:30000, p:927.26});
				pr.push({i:5287, ii:21683193, q:45000, p:1266.72});
				pr.push({i:5287, ii:21683194, q:60000, p:1508.83});
								pr.push({i:5288, ii:21683173, q:250, p:108.58});
				pr.push({i:5288, ii:21683174, q:500, p:116.06});
				pr.push({i:5288, ii:21683175, q:1000, p:123.55});
				pr.push({i:5288, ii:21683176, q:2500, p:144.77});
				pr.push({i:5288, ii:21683177, q:5000, p:169.73});
				pr.push({i:5288, ii:21683178, q:10000, p:273.31});
				pr.push({i:5288, ii:21683179, q:15000, p:401.86});
				pr.push({i:5288, ii:21683180, q:20000, p:526.66});
				pr.push({i:5288, ii:21683181, q:30000, p:927.26});
				pr.push({i:5288, ii:21683182, q:45000, p:1266.72});
				pr.push({i:5288, ii:21683183, q:60000, p:1508.83});
								pr.push({i:5292, ii:21683195, q:250, p:56.16});
				pr.push({i:5292, ii:21683196, q:500, p:62.40});
				pr.push({i:5292, ii:21683197, q:1000, p:99.84});
				pr.push({i:5292, ii:21683198, q:2500, p:127.30});
				pr.push({i:5292, ii:21683199, q:5000, p:143.52});
				pr.push({i:5292, ii:21683200, q:10000, p:295.78});
				pr.push({i:5292, ii:21683201, q:15000, p:388.13});
				pr.push({i:5292, ii:21683202, q:20000, p:476.74});
				pr.push({i:5292, ii:21683203, q:40000, p:861.12});
				pr.push({i:5292, ii:21683204, q:60000, p:1138.18});
				pr.push({i:5292, ii:21683205, q:80000, p:1456.42});
								pr.push({i:5293, ii:21683217, q:250, p:93.60});
				pr.push({i:5293, ii:21683218, q:500, p:108.58});
				pr.push({i:5293, ii:21683219, q:1000, p:131.04});
				pr.push({i:5293, ii:21683220, q:2500, p:174.72});
				pr.push({i:5293, ii:21683221, q:5000, p:195.94});
				pr.push({i:5293, ii:21683222, q:10000, p:319.49});
				pr.push({i:5293, ii:21683223, q:15000, p:406.85});
				pr.push({i:5293, ii:21683224, q:20000, p:487.97});
				pr.push({i:5293, ii:21683225, q:40000, p:908.54});
				pr.push({i:5293, ii:21683226, q:60000, p:1241.76});
				pr.push({i:5293, ii:21683227, q:80000, p:1491.36});
								pr.push({i:5294, ii:21683206, q:250, p:93.60});
				pr.push({i:5294, ii:21683207, q:500, p:108.58});
				pr.push({i:5294, ii:21683208, q:1000, p:131.04});
				pr.push({i:5294, ii:21683209, q:2500, p:174.72});
				pr.push({i:5294, ii:21683210, q:5000, p:195.94});
				pr.push({i:5294, ii:21683211, q:10000, p:319.49});
				pr.push({i:5294, ii:21683212, q:15000, p:406.85});
				pr.push({i:5294, ii:21683213, q:20000, p:487.97});
				pr.push({i:5294, ii:21683214, q:40000, p:908.54});
				pr.push({i:5294, ii:21683215, q:60000, p:1241.76});
				pr.push({i:5294, ii:21683216, q:80000, p:1491.36});
								pr.push({i:5298, ii:21683228, q:250, p:116.06});
				pr.push({i:5298, ii:21683229, q:500, p:128.54});
				pr.push({i:5298, ii:21683230, q:1000, p:141.02});
				pr.push({i:5298, ii:21683231, q:2500, p:182.21});
				pr.push({i:5298, ii:21683232, q:5000, p:273.31});
				pr.push({i:5298, ii:21683233, q:10000, p:443.04});
				pr.push({i:5298, ii:21683234, q:15000, p:607.78});
				pr.push({i:5298, ii:21683235, q:20000, p:725.09});
				pr.push({i:5298, ii:21683236, q:30000, p:1141.92});
				pr.push({i:5298, ii:21683237, q:40000, p:1456.42});
								pr.push({i:5299, ii:21683278, q:250, p:153.50});
				pr.push({i:5299, ii:21683279, q:500, p:165.98});
				pr.push({i:5299, ii:21683280, q:1000, p:178.46});
				pr.push({i:5299, ii:21683281, q:2500, p:227.14});
				pr.push({i:5299, ii:21683282, q:5000, p:319.49});
				pr.push({i:5299, ii:21683283, q:10000, p:476.74});
				pr.push({i:5299, ii:21683284, q:15000, p:652.70});
				pr.push({i:5299, ii:21683285, q:20000, p:783.74});
				pr.push({i:5299, ii:21683286, q:30000, p:1249.25});
				pr.push({i:5299, ii:21683287, q:40000, p:1490.11});
								pr.push({i:5300, ii:21683268, q:250, p:153.50});
				pr.push({i:5300, ii:21683269, q:500, p:165.98});
				pr.push({i:5300, ii:21683270, q:1000, p:178.46});
				pr.push({i:5300, ii:21683271, q:2500, p:227.14});
				pr.push({i:5300, ii:21683272, q:5000, p:319.49});
				pr.push({i:5300, ii:21683273, q:10000, p:476.74});
				pr.push({i:5300, ii:21683274, q:15000, p:652.70});
				pr.push({i:5300, ii:21683275, q:20000, p:783.74});
				pr.push({i:5300, ii:21683276, q:30000, p:1249.25});
				pr.push({i:5300, ii:21683277, q:40000, p:1490.11});
								pr.push({i:5304, ii:21683238, q:250, p:104.83});
				pr.push({i:5304, ii:21683239, q:500, p:117.31});
				pr.push({i:5304, ii:21683240, q:1000, p:129.79});
				pr.push({i:5304, ii:21683241, q:2500, p:183.46});
				pr.push({i:5304, ii:21683242, q:5000, p:220.90});
				pr.push({i:5304, ii:21683243, q:10000, p:406.85});
				pr.push({i:5304, ii:21683244, q:15000, p:595.30});
				pr.push({i:5304, ii:21683245, q:20000, p:725.09});
				pr.push({i:5304, ii:21683246, q:30000, p:1141.92});
				pr.push({i:5304, ii:21683247, q:40000, p:1456.42});
								pr.push({i:5305, ii:21683258, q:250, p:147.26});
				pr.push({i:5305, ii:21683259, q:500, p:160.99});
				pr.push({i:5305, ii:21683260, q:1000, p:164.74});
				pr.push({i:5305, ii:21683261, q:2500, p:204.67});
				pr.push({i:5305, ii:21683262, q:5000, p:243.36});
				pr.push({i:5305, ii:21683263, q:10000, p:426.82});
				pr.push({i:5305, ii:21683264, q:15000, p:652.70});
				pr.push({i:5305, ii:21683265, q:20000, p:783.74});
				pr.push({i:5305, ii:21683266, q:30000, p:1249.25});
				pr.push({i:5305, ii:21683267, q:40000, p:1490.11});
								pr.push({i:5306, ii:21683248, q:250, p:147.26});
				pr.push({i:5306, ii:21683249, q:500, p:160.99});
				pr.push({i:5306, ii:21683250, q:1000, p:164.74});
				pr.push({i:5306, ii:21683251, q:2500, p:204.67});
				pr.push({i:5306, ii:21683252, q:5000, p:243.36});
				pr.push({i:5306, ii:21683253, q:10000, p:426.82});
				pr.push({i:5306, ii:21683254, q:15000, p:652.70});
				pr.push({i:5306, ii:21683255, q:20000, p:783.74});
				pr.push({i:5306, ii:21683256, q:30000, p:1249.25});
				pr.push({i:5306, ii:21683257, q:40000, p:1490.11});
								pr.push({i:6954, ii:21696108, q:1000, p:74.88});
				pr.push({i:6954, ii:21696109, q:2500, p:102.34});
				pr.push({i:6954, ii:21696110, q:5000, p:127.30});
				pr.push({i:6954, ii:21696111, q:10000, p:215.90});
				pr.push({i:6954, ii:21696112, q:15000, p:302.02});
				pr.push({i:6954, ii:21696113, q:20000, p:370.66});
				pr.push({i:6954, ii:21696114, q:30000, p:622.75});
				pr.push({i:6954, ii:21696115, q:45000, p:892.32});
				pr.push({i:6954, ii:21696116, q:60000, p:1073.28});
								pr.push({i:6955, ii:21696074, q:1000, p:81.12});
				pr.push({i:6955, ii:21696075, q:2500, p:108.58});
				pr.push({i:6955, ii:21696076, q:5000, p:133.54});
				pr.push({i:6955, ii:21696077, q:10000, p:222.14});
				pr.push({i:6955, ii:21696078, q:15000, p:314.50});
				pr.push({i:6955, ii:21696079, q:20000, p:383.14});
				pr.push({i:6955, ii:21696080, q:30000, p:635.23});
				pr.push({i:6955, ii:21696081, q:45000, p:904.80});
				pr.push({i:6955, ii:21696082, q:60000, p:1085.76});
								pr.push({i:6956, ii:21696117, q:1000, p:56.16});
				pr.push({i:6956, ii:21696118, q:2500, p:77.38});
				pr.push({i:6956, ii:21696119, q:5000, p:87.36});
				pr.push({i:6956, ii:21696120, q:10000, p:162.24});
				pr.push({i:6956, ii:21696121, q:15000, p:227.14});
				pr.push({i:6956, ii:21696122, q:20000, p:274.56});
				pr.push({i:6956, ii:21696123, q:40000, p:610.27});
				pr.push({i:6956, ii:21696124, q:60000, p:879.84});
				pr.push({i:6956, ii:21696125, q:80000, p:1060.80});
								pr.push({i:6957, ii:21696083, q:1000, p:62.40});
				pr.push({i:6957, ii:21696084, q:2500, p:83.62});
				pr.push({i:6957, ii:21696085, q:5000, p:93.60});
				pr.push({i:6957, ii:21696086, q:10000, p:168.48});
				pr.push({i:6957, ii:21696087, q:15000, p:239.62});
				pr.push({i:6957, ii:21696088, q:20000, p:287.04});
				pr.push({i:6957, ii:21696089, q:40000, p:622.75});
				pr.push({i:6957, ii:21696090, q:60000, p:892.32});
				pr.push({i:6957, ii:21696091, q:80000, p:1073.28});
								pr.push({i:6958, ii:21696126, q:1000, p:94.85});
				pr.push({i:6958, ii:21696127, q:2500, p:139.78});
				pr.push({i:6958, ii:21696128, q:5000, p:169.73});
				pr.push({i:6958, ii:21696129, q:10000, p:280.80});
				pr.push({i:6958, ii:21696130, q:15000, p:396.86});
				pr.push({i:6958, ii:21696131, q:20000, p:529.15});
				pr.push({i:6958, ii:21696132, q:30000, p:879.84});
				pr.push({i:6958, ii:21696133, q:40000, p:1060.80});
								pr.push({i:6959, ii:21696092, q:1000, p:101.09});
				pr.push({i:6959, ii:21696093, q:2500, p:146.02});
				pr.push({i:6959, ii:21696094, q:5000, p:175.97});
				pr.push({i:6959, ii:21696095, q:10000, p:287.04});
				pr.push({i:6959, ii:21696096, q:15000, p:409.34});
				pr.push({i:6959, ii:21696097, q:20000, p:541.63});
				pr.push({i:6959, ii:21696098, q:30000, p:892.32});
				pr.push({i:6959, ii:21696099, q:40000, p:1073.28});
								pr.push({i:6960, ii:21696134, q:1000, p:94.85});
				pr.push({i:6960, ii:21696135, q:2500, p:139.78});
				pr.push({i:6960, ii:21696136, q:5000, p:169.73});
				pr.push({i:6960, ii:21696137, q:10000, p:280.80});
				pr.push({i:6960, ii:21696138, q:15000, p:396.86});
				pr.push({i:6960, ii:21696139, q:20000, p:529.15});
				pr.push({i:6960, ii:21696140, q:30000, p:879.84});
				pr.push({i:6960, ii:21696141, q:40000, p:1060.80});
								pr.push({i:6961, ii:21696100, q:1000, p:101.09});
				pr.push({i:6961, ii:21696101, q:2500, p:146.02});
				pr.push({i:6961, ii:21696102, q:5000, p:175.97});
				pr.push({i:6961, ii:21696103, q:10000, p:287.04});
				pr.push({i:6961, ii:21696104, q:15000, p:409.34});
				pr.push({i:6961, ii:21696105, q:20000, p:541.63});
				pr.push({i:6961, ii:21696106, q:30000, p:892.32});
				pr.push({i:6961, ii:21696107, q:40000, p:1073.28});
						for (i = 0; i < pr.length; i++) {
			if (this.prices.get(pr[i]['i']) == null) {
				this.prices.set(pr[i]['i'], new Hash());
			}
			this.prices.get(pr[i]['i']).set(pr[i]['q'], new Hash());
			this.prices.get(pr[i]['i']).get(pr[i]['q']).set('i', pr[i]['ii']);
			this.prices.get(pr[i]['i']).get(pr[i]['q']).set('p', pr[i]['p']);
		}
	},

	init: function() {	
		if ($('myForm')) {
			this.order_action = $('myForm').action;
			$('myForm').addEvent('submit', function(event){ if (EC_LithoCalc.flag_form) { new Event(event).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_green_paperText'] = 'Green Paper';				
							this.localText['custom_green_paperText'] = 'Eco Friendly Paper';

		if (window.CustomCalcText) {
			for (var key in CustomCalcText) {
				this.localText[key] = CustomCalcText[key];
			} 
		}
		
		/*
		// define custom labels by adding the following in the page content:

		var CustomCalcText = {paperText: 'Material'};

		*/

		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', '59': 'UPS Second Day Air A.M.', '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', '54': 'UPS Worldwide Express Plus', 'FEDEX_GROUND': 'FedEx Ground', 'FEDEX_EXPRESS_SAVER': 'FedEx Express Saver', 'FEDEX_2_DAY': 'FedEx 2Day', 'STANDARD_OVERNIGHT': 'FedEx Standard Overnight', 'PRIORITY_OVERNIGHT': 'FedEx Priority Overnight', 'FIRST_OVERNIGHT': 'FedEx First Overnight', 'WC': 'Will Call', 'FR': 'Freight', 'DL': 'Delivery', 'RO': 'Recycle Overages'});		
	},
	
	createForm: function(contents) { 
		var design_id = 0;
		if ($('eondesigner_id')) {
			design_id = $('eondesigner_id').value;
		}
		
		this.formContents = '<h3 class="formTitle">' + this.localText['titleText'] + '</h3>';
		/*
		if (this.green == true) {
			this.formContents += '<div id="greenBadge" style="display:none">&nbsp;</div>';
		}
		*/
		this.formContents += '<table>';
		this.formContents += calcFI_TPL('', '<h4 class="formHeading">' + this.localText['headingText'] + '</h4>', '');
		this.formContents += contents;	
		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="' + design_id + '" />';
		$('myForm').setHTML(this.formContents);
		if (window.datePickerController) datePickerController.create();
	},

	createSelect: function(title, name, func, obj, addition) {
		if (window.EC_Mailing && name == 'quantity') {
			func = 'EC_Mailing.setQuantity();' + func;
		}
		var select = '<select id="' + name + '" name="' + name + '" onchange="' + func + '">';
		if (name == 'quantity')
			select += this.createQuantityOptions(obj);
		else if (name == 'folding' && this.folding == true)
			select += this.createFoldingOptions(obj);
		else if (addition)
			select += this.createOptions(obj, true);
		else
			select += this.createOptions(obj);
		select += '</select>';
		
		var className = '';
		var addTD = '';
		
		if ((this.green == true && (this.additionalOpts == undefined || this.additionalOpts.get('custom_green_paper') == undefined) && name == 'paper') || name == 'custom_green_paper') {
			addTD = calcFI_TPL('', '', '', 'greenBadgeTD');
		}
		
		return addTD + calcFI_TPL(title, select, name, className);
	},

	createSizeInput: function(title, name, func) {
		var value = (name == 'width') ? this.widthText : this.heightText;		
		var fractValue = 0;
		var selectedIndex = 0;
	

		
		if (name == 'width' && value < 1) {
			if (this.opts['min_width']) {
				var w = Number(this.opts['min_width']);
				if (w > Math.floor(w)) {
					fractValue = w - Math.floor(w);
					w -= fractValue;
				}
				value = w;
				
			var w = Number(this.opts['min_width']);
			var h = Number(this.opts['min_height']);
			
				this.area = w * h;
				
			} else {
				value = 1;
			}
		}
		
		if (name != 'width' && value < 1) {
			if (this.opts['min_height']) {
				var h = Number(this.opts['min_height']);
				if (h > Math.floor(h)) {
					fractValue = h - Math.floor(h);
					h -= fractValue;
				}
				value = h;
				
			var w = Number(this.opts['min_width']);
			var h = Number(this.opts['min_height']);
			
				this.area = w * h;

			} else {
				value = 1;
			}
		}

		if ($(name + 'Fract')) {
			selectedIndex = $(name + 'Fract').selectedIndex;
		}
		
		var input = '<input type="text" id="' + name + '" name="' + name + '" value="' + value + '" onchange="' + func + '" class="sizeInput" />&nbsp;&nbsp;';
		input += '<select id="' + name + 'Fract" name="' + name + 'Fract" onchange="' + func + '" class="sizeInput">';
		
		for (var i = 0; i < options.length; i++) {
			var option = options[i];
			if (selectedIndex == 0 && fractValue > 0) {
				if (Number(option.value) == fractValue) {
					selectedIndex = i;
				}
			}
			
			var selected = (selectedIndex == i) ? ' selected' : '';
			input += '<option value="' + option.value + '"' + selected + '>' + option.label + '</option>';
		}	
		
		input += '</select>';
		
		return calcFI_TPL(title, input, name);
	},
	
	createDieShapeInput: function(title, name, func) {
		var opts = [];
		var value = false;
		
		for (var key in this.opts['die_shapes']) {
		    if (value == false) {
		    	value = key;
		    }
		    opts.push(key);
		}
		
		if ($(name)) { value = $(name).getValue(); }
		
		
		var select = '<select id="' + name + '" name="' + name + '" onchange="' + func + '">';
		
		for (var i = 0; i < opts.length; i++) {
			var selected = (opts[i] == value) ? ' selected' : '';
			select += '<option value="' + opts[i] + '"' + selected + '>' + opts[i] + '</option>';
		}
		
		select += '</select>';
		
		
		return calcFI_TPL(title, select, name, '');
	},
	
	createTrimSizeInput: function(title, name, func) {
		var value = this.opts['size'][this.sizeID];
		
		if ($(name)) { value = $(name).getValue(); }
		var input = '<input type="text" id="' + name + '" name="' + name + '" value="' + value + '" onblur="' + func + '" class="textInput" />';
		return calcFI_TPL(title, input, name, 'custom_trim_size');
	},

	createOptions: function(obj, addition) { 
		var a, i, len;
		var idArray = [];
		var options = '';
		var choose = '';
		var selected = '';
		var allowed_keys = false;
			
		if (this.currentName == 'size' && this.product_name == 'Roll Labels') {
			var die_shape_value = false;
			for (var key in this.opts['die_shapes']) {
		    if (die_shape_value == false) {
		    	die_shape_value = key;
		    }
			}
			
			if ($('die_shape')) { die_shape_value = $('die_shape').getValue(); }
			
			var tmp_keys = this.opts['die_shapes'][die_shape_value];
			allowed_keys = new Hash();
			
			for (i = 0; i < tmp_keys.length; i++) {
				allowed_keys.set(tmp_keys[i], true);
			}
		}
		
		idArray = obj.keys();
		len = idArray.length; 

		for(i = 0; i < len; i++) {
			a = idArray[i];
			
			if (allowed_keys != false && allowed_keys.hasKey(a) == false) {
				a = false;
			}
		
			if (! isNaN(a) && a != false) { 
				selected = ($(this.currentName) && a == $(this.currentName).getValue()) ? ' selected' : ''; 
				if (this.currentName == 'size' && i == 0) { this.sizeID = a; }
				if (! addition) {
/*
					
// COMMENTED CODE PREVENTS AUTOLOADING
					if ((len > 1 && i == 0 && !$(this.currentName)) || (len > 1 && i == 0 && $(this.currentName).getValue() == 0))
						options += '<option value="0"' + choose + '>' + this.localText['chooseText'] + '</option>';
*/
				} 
				
				var name = (addition) ? this.additionalOpts.get(this.currentName).get(a).get('name') : this.opts[this.currentName][a];
				
				if (this.currentName == 'coating' && name != undefined && name.indexOf('UV 2') != -1 && window.EC_Mailing && this.mailingCanUseUV == false) {
				
				} else {
					options += '<option value="' + a + '"' + selected + '>' + name + '</option>';
				}
				
			};
		};
		
		if (this.currentName == 'custom_green_paper') {
			this.currentName = 'paper';
		}
		
		return options;
	},

	createQuantityOptions: function(obj) { 
		var a;
		var options = '';
		var choose = '';
		var selected = ''; 
		if (obj.length > 0) {
			obj.each(function(a){ 
				if (!isNaN(a)) {
					selected = ($('quantity') && a == $('quantity').getValue()) ? ' selected' : '';
					options += '<option value="' + a + '"' + selected + '>' + a + '</option>'; 
				};
			});
		};
		return options;
	},

	createFoldingOptions: function(obj) { 
		var options = '';
		var selected = '';
		var coverStock = false;
		var indexStock = false;
		if ($('paper')) { 
			var selPaper = $('paper').options[$('paper').selectedIndex].text;
			if (selPaper.indexOf('Cover') != -1)
				coverStock = true;
			if (selPaper.indexOf('Index') != -1)
				indexStock = true;
		}

		obj.each(function(item, index){
			($('folding') && index == $('folding').getValue()) ? selected = ' selected' : selected = '';			
			if (coverStock) {
				if (item.get('name').indexOf('Cover') != -1 || item.get('name').indexOf('None') != -1) 
					options += '<option value="' + index + '"' + selected + '>' + item.get('name') + '</option>';
			} else if (indexStock) {
				if (item.get('name').indexOf('Index') != -1 || item.get('name').indexOf('None') != -1) 
					options += '<option value="' + index + '"' + selected + '>' + item.get('name') + '</option>';
			} else {
				if (item.get('name').indexOf('Cover') == -1 && item.get('name').indexOf('Index') == -1) 
					options += '<option value="' + index + '"' + selected + '>' + item.get('name') + '</option>'; 
			} 
		
		});

		return options;
	},

	updateForm: function() {
		var i = 0;
		var a;
		var func;
		this.formContents = '';
		this.currentSku = this.skus; 
			
		var done = false;
		
			
		for (var i = 0; i < this.names.length; i++) { 
			this.currentName = this.names[i];
			this.currentTitle = this.titles[i]; 
			
			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()');
				}
				func = (this.currentName == 'size' && this.product_name != 'Roll Labels') ? 'EC_LithoCalc.resetTrimSize();' : '';
				this.formContents += this.createSelect(this.currentTitle, this.currentName, func + '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(item, key) {
						if (key == 'custom_green_paper') {
							EC_LithoCalc.currentName = key; 
							EC_LithoCalc.formContents += EC_LithoCalc.createSelect(EC_LithoCalc.localText[key + 'Text'], key, 'EC_LithoCalc.updatePrice()', item, true);
						}
					});
				}

			}

			var j = 0;	
			var retainA = '';
						
			this.currentSku.each(function(val, key) {
				j++;
				if(j == 1)
					retainA = key;
			});
			
			if (this.currentName == 'height') {
				var keys = this.currentSku.keys();
				keys.sort(EC_Base.sortNumber);
				keys.reverse(); 
				keys.each(function(val) { 
					if (EC_LithoCalc.area <= val) {
						retainA = val.toString(); 
						EC_LithoCalc.selectedArea = val;
					}
				});
			}
/*
// COMMENTED CODE PREVENTS AUTOLOADING

			if (j > 1 && !$(this.currentName))
				break;
			else if (j > 1 && $(this.currentName) && $(this.currentName).getValue() == 0)
				break;
				
			else {
*/			
				if ($(this.currentName) && this.currentSku.hasKey($(this.currentName).getValue()))
					this.currentSku = this.currentSku.get($(this.currentName).getValue());
			
				else if (this.currentSku.hasKey(retainA)) 
					this.currentSku = this.currentSku.get(retainA);
			
				else break;
//			};
		};

		if(this.currentSku > 0)
			this.setupQuantities();
		else
			this.createForm(this.formContents);
	},
	
	updateArea: function() {
		if ($('width') && $('height')) {
			var fractValue;
			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 w = Number(this.opts['min_width']);
					if (w > Math.floor(w)) {
						fractValue = w - Math.floor(w);
						w -= fractValue;
					}
					this.widthText = w;
					fractValue = 0;
				} else {
					this.widthText = 1;
				}
			}
			
			if (this.heightText == 'NaN' || this.heightText < 1) {
				if (this.opts['min_height']) {
					var h = Number(this.opts['min_height']);
					if (h > Math.floor(h)) {
						fractValue = h - Math.floor(h);
						h -= fractValue;
					}
					this.heightText = h;
					fractValue = 0;
				} else {
					this.heightText = 1;
				}
			}
			
			var w = Math.floor(Number(this.widthText)) + Number($('widthFract').getValue());
			var h = Math.floor(Number(this.heightText)) + Number($('heightFract').getValue());

			if (isNaN(w)) {
				w = $('width').value = 0;
				$('widthFract').selectedIndex = 0;
			}
			if (isNaN(h)) {
				h = $('height').value = 0;
				$('heightFract').selectedIndex = 0;
			}
					
			fractValue = 0;

			if (w < Number(this.opts['min_width']) && w > 0) {
				alert('The minimum width is ' + this.opts['min_width']);
				this.resetToMinMx('width', this.opts['min_width']);
				return;
			}
			if (h < Number(this.opts['min_height']) && h > 0) {
				alert('The minimum height is ' + this.opts['min_height']);
				this.resetToMinMx('height', this.opts['min_height']);			
				return;
			}
			
			if (w > Number(this.opts['max_width'])) {
				alert('The maximum width is ' + this.opts['max_width']);
				this.resetToMinMx('width', this.opts['max_width']);
				return;
			}
			if (h > Number(this.opts['max_height'])) {
				alert('The maximum height is ' + this.opts['max_height']);
				this.resetToMinMx('height', this.opts['max_height']);
				return;
			}
			

			this.area = w * h;
		}
	},
	
	updateTrimSize: function() {
		if ($('trim_size')) {
			var val = $('trim_size').getValue();
			val = val.replace(/([^0-9. Xx])/g, '');
			var size = $('size').options[$('size').selectedIndex].text;
			size = size.replace(/([^0-9. Xx])/g, '');
			
			var cW = Number(val.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/, '$1'));
			var cH = Number(val.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/, '$3'));
			var sW = Number(size.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/, '$1'));
			var sH = Number(size.replace(/(\d+[.]*\d{0,4})([ Xx]+)(\d+[.]*\d{0,4})/, '$3'));

			cW = (cW > sW) ? sW : cW;
			cH = (cH > sH) ? sH : cH;
			
			if (isNaN(cW) || isNaN(cH) || cW == 0 || cH == 0) {
				$('trim_size').value = size;
			} else {
				$('trim_size').value = cW + ' X ' + cH;
			}
		}
	},
	
	resetTrimSize: function() {
		if ($('trim_size')) {
			$('trim_size').value = $('size').options[$('size').selectedIndex].text;
		}
	},

	setupQuantities: function() {
		var i = 0;
		var price = 0;

		if (this.folding) {					
			this.formContents += this.createSelect(this.localText['foldingText'], 'folding', 'EC_LithoCalc.updatePrice()', this.foldingOpts);
		};

		if (this.additional) { 
			this.additionalOpts.each(function(item, key) {
				if (key != 'custom_green_paper') {
					if (key == 'custom_finishing' && window.EC_Mailing) {
					
					} else {
						EC_LithoCalc.currentName = key; 
						EC_LithoCalc.formContents += EC_LithoCalc.createSelect(EC_LithoCalc.localText[key + 'Text'], key, 'EC_LithoCalc.updatePrice()', item, true);
					}
				}
			});
		};
	
		var quantities = this.prices.get(this.currentSku).keys();
		
		quantities.sort(this.numOrdA);
		
		this.formContents += this.createSelect(this.localText['quantityText'], 'quantity', 'EC_LithoCalc.updatePrice()', quantities);
	
		if ($('quantity')) {
			var q = $('quantity').getValue();		
			
							if (this.prices.get(this.currentSku).hasKey(q))
					price = this.prices.get(this.currentSku).get(q).get('p');
						
						
						
		} else { 
			var keys = this.prices.get(this.currentSku).keys();
			price = this.prices.get(this.currentSku).get(keys[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(price)+'</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.updatePrice();
	},

	updateFolding: function() {
		var myForm = $('myForm'); 
		
		var foldVal = $('folding').getValue();
		if (foldVal == undefined) {
			var vals = this.foldingOpts.keys();
			foldVal = vals[0];
		} 		
		 
		var fp = this.foldingOpts.get(foldVal).get('price');
		var fs = this.foldingOpts.get(foldVal).get('setup');
		var q = ($('quantity').options) ? $('quantity').options[$('quantity').selectedIndex].text : $('quantity').getValue();
				var multiplier = parseInt(q) / 1000;	
				this.foldRate = (Number(fp) * multiplier) + Number(fs);
	},

	updatePrice: function() { 
		this.foldRate = 0;
		if ($('folding') && this.folding == true)
			this.updateFolding();

		if ($('quantity')) {
			this.currentSku = this.skus;

			for (var i = 0; i < EC_LithoCalc.names.length; i++) {			
				this.currentName = EC_LithoCalc.names[i];
				
				if ($(this.currentName) && this.currentName != 'width' && this.currentName != 'height') {
					var lastSku = 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 tmpPrice = this.prices.get(this.currentSku).get($('quantity').value).get('p');
						
						
						
			if (tmpPrice < this.minimum_price) {
				tmpPrice = this.minimum_price;
			}
			var additionalMap = 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(item, key) {
					if ($(key)) { 
						var divide = 1000;
						var short_key = key.replace(/custom_/, '');
						if (additionalMap.hasKey(short_key)) {
							divide = Number(additionalMap.get(short_key));
						}

						var price = Number(EC_LithoCalc.additionalOpts.get(key).get($(key).value).get('price'));
						var setup = Number(EC_LithoCalc.additionalOpts.get(key).get($(key).value).get('setup'));
							tmpPrice += (price * ($('quantity').value / divide)) + setup;
					};
				});
			};
			
			this.printRate = tmpPrice + this.foldRate;
			$('printRate').setHTML(EC_Base.moneyFormat(this.printRate));
			
			if (window.EC_Mailing) {
				EC_Mailing.updatePrice();
			}
			
			if ($('zipcode')) {
				var zip = $('zipcode').getValue();
				if (zip.length == 5) 
					this.getShipRates();
			}
			var totals = {print: this.printRate, folding: this.foldRate, shipping: this.shipRates};
			if (window.EC_Mailing) {				
				totals.setup = Number($('setupRate').getText().replace(/([^0-9.])/, ''));
				totals.inkjet = Number($('inkjetRate').getText().replace(/([^0-9.])/, ''));
				totals.tabbing = Number($('tabbingRate').getText().replace(/([^0-9.])/, ''));
				totals.postage = Number($('postageRate').getText().replace(/([^0-9.])/, ''));
				if ($('listRate')) {
					totals.list = Number($('listRate').getText().replace(/([^0-9.])/, ''));
				}
				totals.total = Number($('totalRate').getText().replace(/([^0-9.])/, ''));
			}
			if ($('totals')) {
				$('totals').value = Json.toString(totals);
			} 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 priceid = this.prices.get(this.currentSku).get($('quantity').getValue()).get('i');
		else {
			var keys = this.prices.keys();
			var priceid = this.prices.get(keys[0]).get($('quantity').getValue()).get('i');
		}
		var myForm = $('myForm');	
		myForm['price_id'].value = priceid;
		
		this.flag_form = false;
		
		if (window.confirmText && confirmText != '') {
			if (!$('disallow_popups') || ($('disallow_popups') && $('disallow_popups').getValue() != '1')) {
				var answer = confirm(confirmText);
				if (answer){
					myForm.submit();
				}
			}
		} else {		
			myForm.submit();
		}
	},

	addSKU: function(ids, val) {
		var a;
		var i;
		var aSku;
		var len = ids.length;

		ids.each(function(item, index) {
   		if (index > 0) {
				aSku = aSku.get(ids[index - 1]);
			} else {
				aSku = EC_LithoCalc.skus;
			}
			
			if (!aSku.hasKey(item)) 
				aSku.set(item, new Hash());			

			if (index == len - 1) 
				aSku.set(item, val);
		});
	},

	setupShipping: function() {
		var ship = calcHR_TPL();
		ship += calcFI_TPL('', '<h4 class="formHeading">' + this.localText['shippingText'] + '</h4>', '');
		if (this.international == 1)
			ship += calcFI_TPL(this.localText['countrycodeText'], this.country_code, '');
		else
			ship += this.country_code;
			
		ship += 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()" />', '');
/*
// THIS IS FOR SHIPPING SELECT

		ship += calcFI_TPL(this.localText['shipmethodText'], this.shipSelect(), '');
		ship += calcFI_TPL(this.localText['shiprateText'], '<div id="shipRate" class="price" />', '');
		
*/
		ship += calcShipGrid_TPL('<br />');
		return ship;
	},
	
	shipSelect: function() {
/*
// THIS IS FOR SHIPPING SELECT

		var sel = '<select id="shipMethod" name="shipMethod" onchange="EC_LithoCalc.changeShipRates()">';
		shipOpts.each(function(val, key) {
			sel += '<option value="' + key + '">' + val + '</option>';
		});
		sel += '</select>';
		return sel;
*/
	},

	getShipRates: function() {
		if (! this.currentSku) {
			this.updateForm();
		}
		var button = $('getRatesBTN');
		var zip = $('zipcode').getValue();
		if (button.disabled)
			return;
			
		var country = $('country_code').getValue();
		
// FIX THIS FOR countries::postal_code_format

		if ((zip.length != 5 || isNaN(zip)) && country == 'US') {
			alert(this.localText['ziperrorText']);
			return;
		}
		button.value = this.localText['pleasewaitText'];
		button.disabled = true;
		this.timer = setTimeout('EC_LithoCalc.stopRates()', 10000); 
		
					this.selWeight = Math.round(((Number($('quantity').getValue()) / 1000) * this.weights[this.currentSku]) * 10) / 10;
				
				
		
				
	
		var url = '/ws/shipping/getRates/zip/' + zip + '/country/' + country + '/weight/' + this.selWeight + '/handling_fee/' + this.handling_fee + '/product_id/' + this.product_id;
		
		if (this.free_ground_shipping) {
			url += '/fgs/1';
		}
		
		var myAjax = new Ajax(url, {method: 'get', onSuccess: function(rates) {
			EC_LithoCalc.shipRates = Json.evaluate(rates);
			EC_LithoCalc.stopRates();
			EC_LithoCalc.changeShipRates();
			if (EC_LithoCalc.shipRates.error) {
				alert(EC_LithoCalc.shipRates.error);
			}
			
			if ($('totals')) {
				var totals = Json.evaluate($('totals').getValue());
				totals.shipping = EC_LithoCalc.shipRates;
				$('totals').value = Json.toString(totals);
			}
		}}).request();
	},

	stopRates: function() {
		var button = $('getRatesBTN');
		button.value = this.localText['ratesText'];
		button.disabled = false;
		clearTimeout(this.timer);
	},

	changeShipRates: function() {
/*
// THIS IS FOR SHIPPING SELECT

		var rate = this.shipRates[$('shipMethod').getValue().toString()];
		if (rate >= 0) {
			$('shipRate').setHTML(EC_Base.moneyFormat(rate));
			var myForm = $('myForm');
			myForm['quote'].value = rate;
		} else { 
			$('shipRate').setHTML(this.localText['pleaseclickText']);
		}
*/

/**/
// THIS IS FOR SHIPPING GRID

		var checked = ' checked';
		$$('input[name=shipMethod]').each(function(item) {
			if (item.checked != false)
				checked = item.value.toString();
		});
		
		$('shipGrid').setHTML('<br />' + this.shipGrid(checked));
		
/**/
	},
	
	shipGrid: function(first) {
		var grid = '<table width="100%">';
		var rate = '';
		var country = $('country_code').getValue();
		var free_delivery = false;
		
		if ($('delivery') && $('delivery_zipcode') && $('delivery_countrycode')) {
			if ($('delivery').getValue() == 1 && 
					($('delivery_zipcode').getValue() == $('zipcode').getValue() || $('delivery_zipcode').getValue() == 'ANY') && 
					country == $('delivery_countrycode').getValue()) {
				free_delivery = true;
			}
		}
		
		shipOpts.each(function(val, key) { 
			if (! val.match(/Recycle/)) {
				var rate = EC_LithoCalc.shipRates[key.toString()];
				if (first == key.toString())
					first = ' checked';
				
				if (rate !== false && !isNaN(rate)) { rate = EC_Base.moneyFormat(rate); }

				if (rate !== false && rate != undefined) { 
					
					if ((key != 'DL' || (key == 'DL' && free_delivery == true)) && key != 'FR') {
						grid += '<tr><td class="ship_desc"><input type="radio" name="shipMethod" value="' + key.toString() + '"' + first + ' />';
						grid += val + '</td><td class="ship_price">' + rate + '</td></tr>';
					}
					else if(key == 'FR') {
												grid += '<tr><td class="ship_desc"><input type="radio" name="shipMethod" value="' + key.toString() + '"' + first + ' />';
						grid += val + '</td><td class="ship_price">' + rate + '</td></tr>';
											}
					if (first == ' checked') first = '';	
				}
			}
		});
		grid += '</table>';

		return grid;
	},

	checkEnter: function(event, func) {
		event = new Event(event);
    if (event.key == 'enter') {
			if (func) { eval(func); }
    	event.stop();
    	this.flag_form = true;
		}
	},
	
	selectByValue: function(el, val) {
		if (typeof(el) === 'string') {
			el = $(el);
		}
		if (el && el.options) {
			for (var i = 0; i < el.options.length; i++) {
				if (el.options[i].value == val) {
	        el.options[i].selected = true;
	        el.options.selectedIndex = i;
	      }
			}
		}
	},
	
	resetToMinMx: function(dimension, value) {
		var fractValue = 0;
		value = Number(value);
		if (value > Math.floor(value)) {
			fractValue = value - Math.floor(value);
			value -= fractValue;
		}
					
		this[dimension + 'Text'] = value;
		$(dimension).value = value;
		if (fractValue == 0) { fractValue = '.0'; }
		this.selectByValue(dimension + 'Fract', fractValue);
		
		var w = Math.floor(Number(this.widthText)) + Number($('widthFract').getValue());
		var h = Math.floor(Number(this.heightText)) + Number($('heightFract').getValue());
		
		
		this.area = w * h;
		this.updatePrice();
	},

	numOrdA: function(a, b){ return (a-b); },

	numOrdD: function(a, b){ return (b-a); },
	
	debug: function(obj, recursive) {
		var out = '';
		if (recursive)
			out = EC_Base.dumpObj(obj, true);
		else
			out = obj;
			
		$('calcDebug').setHTML(out + '<br />=======================================<br /><br />');
	}

};

window.addEvent('domready', function() {
	EC_LithoCalc.init();
});
	