	function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
	}

	function calculatethis() {
	// Set Some Variables
	var material = document.calculator.material.options[document.calculator.material.selectedIndex].value;
	var surface = document.calculator.surface.options[document.calculator.surface.selectedIndex].value;
	var size = document.calculator.size.options[document.calculator.size.selectedIndex].value;
	
	if(material != "Choose Material") {
		if(material == "ESD") { var materialAb = 'EBF'; }
		if(material == "Standard") { var materialAb = 'SBF'; }
		if(material == "Nitrile") { var materialAb = 'NBF'; }
		document.getElementById('drop-one').style.backgroundImage="url('./img/buy/icon-1-f2.gif')";
		var barefoot = ' Barefoot';
	} else {
		var barefoot = '';
		var materialAb = "";
		document.getElementById('drop-one').style.backgroundImage="url('./img/buy/icon-1.gif')";
	}
	
	if(surface != "Choose Surface") {
		if(surface == "Solid") { var surfaceAb = 'S'; }
		if(surface == "Drain") { var surfaceAb = 'D'; }
		document.getElementById('drop-two').style.backgroundImage="url('./img/buy/icon-2-f2.gif')";
	} else {
		var surfaceAb = "";
		var surface = "";
		document.getElementById('drop-two').style.backgroundImage="url('./img/buy/icon-2.gif')";
	}
	
	if(size != "Choose Size") {
		var sizeAb = size.replace(" x ", "");
		document.getElementById('drop-three').style.backgroundImage="url('./img/buy/icon-3-f2.gif')";
	} else {
		document.getElementById('drop-three').style.backgroundImage="url('./img/buy/icon-3.gif')";
		var sizeAb = "";
		var size = "";
		document.calculator.sqft.value = "";
		document.calculator.netwt.value = "";
		document.calculator.price.value = "";
		document.calculator.cost.value = "";
	}
		
	if(materialAb == "EBF") { document.calculator.surface.options[2].disabled=true; } else { document.calculator.surface.options[2].disabled=false; }
	if(surfaceAb == "D") { document.calculator.material.options[3].disabled=true; } else { document.calculator.material.options[3].disabled=false; }
	
	if(material != "Choose Material") {
	// Output Part Number and Product Description and Warranty
		document.calculator.partnum.value = materialAb+surfaceAb+sizeAb;
		
		if(surface != "") {
		document.calculator.desc.value = material+barefoot+' '+surface+', '+size;	
		} else {
		document.calculator.desc.value = material+barefoot+' '+size;				
		}
		
		document.calculator.warranty.value = '32,000 hrs. (8 Years)';
	
		if(size != "") {
		// Output Square Feet & Net Weight
			var breaksize = size.split(' x ');
			var squarefeet = breaksize[0]*breaksize[1];
			document.calculator.sqft.value = squarefeet+' Sq. Ft.';
			document.calculator.netwt.value = Math.round((squarefeet*1.35)*1)/1+' lbs.';
			
			// Output Price and Cost Per Hour
			var PriceX = 'N/A';
			if(materialAb+surfaceAb == "SBFS") { var PriceX = '12.65'; }
			if(materialAb+surfaceAb == "SBFD") { var PriceX = '13.53'; }
			if(materialAb+surfaceAb == "NBFS") { var PriceX = '14.41'; }
			if(materialAb+surfaceAb == "NBFD") { var PriceX = '15.29'; }
			if(materialAb+surfaceAb == "EBFS") { var PriceX = '20.90'; }
			if(PriceX != 'N/A') { 
				var ispriceexception = "false";
				if(materialAb+surfaceAb+sizeAb == "SBFS23") { document.calculator.price.value = '$54.56'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "SBFS33") { document.calculator.price.value = '$95.48'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "SBFS34") { document.calculator.price.value = '$109.23'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "SBFD23") { document.calculator.price.value = '$58.52'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "SBFD33") { document.calculator.price.value = '$100.43'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "SBFD34") { document.calculator.price.value = '$117.04'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "NBFS23") { document.calculator.price.value = '$63.69'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "NBFS33") { document.calculator.price.value = '$107.69'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "NBFS34") { document.calculator.price.value = '$127.27'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "NBFD23") { document.calculator.price.value = '$67.98'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "NBFD33") { document.calculator.price.value = '$112.64'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "NBFD34") { document.calculator.price.value = '$135.19'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "EBFS23") { document.calculator.price.value = '$136.29'; var ispriceexception = "true"; }
				else if(materialAb+surfaceAb+sizeAb == "EBFS34") { document.calculator.price.value = '$249.04'; var ispriceexception = "true"; }
				
				var outputPriceUF = squarefeet*PriceX;  
				var outputPrice = outputPriceUF.toFixed(2);
				var outputPrice = addCommas(outputPrice);
				if(ispriceexception == "false") {
					document.calculator.price.value = '$'+outputPrice; 
				}
				var actualCost = Math.round((outputPriceUF/32000)*10000)/10000;
				document.calculator.cost.value = '$'+actualCost;
			}
		}
	} else {
		document.calculator.partnum.value = "";
		document.calculator.desc.value = "";
		document.calculator.sqft.value = "";
		document.calculator.netwt.value = "";
		document.calculator.price.value = "";
		document.calculator.warranty.value = "";
		document.calculator.cost.value = "";
	}
	}
