// JavaScript Document//<!--
/* Author - Chris Sypolt, csypolt@onlinemetals.com  */

var alloysteelArray =  new Array("('Select alloy','',true,true)",
"('4135','0.282')",
"('4140','0.282')",
"('4340','0.282')");
var aluminumArray =  new Array("('Select alloy','',true,true)",
"('1100','0.098')",
"('2024','0.101')",
"('2219','0.103')",
"('3003','0.099')",
"('5052','0.097')",
"('5083','0.096')",
"('5086','0.096')",
"('6013','0.098')",
"('6061','0.098')",
"('6063','0.097')",
"('7050','0.102')",
"('7075','0.101')",
"('7150','0.102')",
"('Alca Max','0.1')",
"('Alca Plus','0.101')",
"('MIC-6','0.101')",
"('QC-7','0.101')");
var brassArray =  new Array("('Select alloy','',true,true)",
"('240 - Low Brass','0.313')",
"('260 - Cartridge Brass','0.308')",
"('353 - Leaded Brass','0.306')",
"('360 - Brass','0.307')",
"('365 - Brass','0.304')",
"('380 - Brass','0.306')",
"('385 - Brass','0.306')",
"('464 - Brass','0.304')");
var bronzeArray =  new Array("('Select alloy','',true,true)",
"('18 - Aluminum Bronze','0.269')",
"('21 - Aluminum Bronze','0.26')",
"('314 - Commercial Bronze','0.306')",
"('425 - Am Bronze','0.316')",
"('485 - Naval Bronze','0.305')",
"('510 - Phos Bronze','0.32')",
"('524 - Phos Bronze','0.317')",
"('532 - Phos Bronze','0.323')",
"('534 - Phos Bronze','0.322')",
"('544 - Phos Bronze','0.32')",
"('613 - Al Bronze','0.287')",
"('614 - Al Bronze','0.285')",
"('623 - Al Bronze','0.276')",
"('624 - Al Bronze','0.269')",
"('625 - Al Bronze','0.26')",
"('630 - Ni-Al Bronze','0.274')",
"('642 - Al-Si Bronze','0.278')",
"('932 - Bearing Bronze','0.322')",
"('954 - Al Bronze','0.269')",
"('Oil-Lite - Bronze','0.37')");
var copperArray =  new Array("('Select alloy','',true,true)",
"('101','0.323')",
"('102','0.323')",
"('103','0.323')",
"('110','0.322')",
"('122','0.323')");
var copperalloyArray =  new Array("('Select alloy','',true,true)",
"('145 - Tellurium Copper','0.323')",
"('194 - Iron Copper','0.322')",
"('195 - Iron Copper','0.322')",
"('172 - Beryllium Copper','0.298')",
"('182 - Class 2','0.321')",
"('655 - Copper-Silicon','0.308')",
"('706 - Copper-Nickel','0.323')",
"('715 - Nickel Silver','0.323')",
"('725 - Nickel Silver','0.321')",
"('735 - Nickel Silver','0.319')",
"('752 - Nickel Silver','0.316')",
"('762 - Nickel Silver','0.31')",
"('770 - Nickel Silver','0.314')",
"('1751 - Class 3','0.317')",
"('1758 - Copper-Nickel','0.323')",
"('Moldmax - Be/Cu','0.302')",
"('Protherm - Be/Cu','0.319')");
var magnesiumArray =  new Array("('Select alloy','',true,true)",
"('AZ31B','0.064')");
var nickelArray =  new Array("('Select alloy','',true,true)",
"('201','0.321')",
"('400','0.319')",
"('210','0.32')",
"('220','0.318')",
"('230','0.316')");
var plasticArray =  new Array("('Select alloy','',true,true)",
"('ABS','0.0394')",
"('Acetal','0.0514')",
"('Acrylic','0.0434')",
"('Acrylic','0.0375')",
"('Benelex','0.0496')",
"('Biton','0.0673')",
"('Buna-N','0.0507')",
"('Butyl','0.0427')",
"('CAB','0.0431')",
"('Cellulose Acetate','0.047')",
"('CPVC','0.0565')",
"('Delrin','0.0514')",
"('Delrin AF','0.0557')",
"('Duraboard','0.0181')",
"('E-CTFE','0.0608')",
"('EPDM','0.0427')",
"('Ertacetel H','0.0514')",
"('Ertalyte','0.0503')",
"('FEP Teflon','0.0778')",
"('Fiber Sheet','0.0503')",
"('Flourosilicone','0.0507')",
"('Glastherm HT','0.0615')",
"('Glastherm S','0.0615')",
"('GPO-1','0.0717')",
"('GPO-2','0.0651')",
"('GPO-3','0.0659')",
"('Gum Rubber','0.0333')",
"('Halar','0.0608')",
"('Haysite EHC-P','0.0724')",
"('Haysite HST-11-P','0.0586')",
"('Hypalan','0.0427')",
"('ICE','0.0326')",
"('Kapton','0.0514')",
"('Kydex','0.0489')",
"('Kynar','0.0633')",
"('Lead','0.4104')",
"('Lexan','0.0434')",
"('Marinete P','0.0326')",
"('Mylar','0.0503')",
"('Natural Rubber','0.0333')",
"('Neoprene','0.047')",
"('Nitrile','0.0362')",
"('Noryl','0.0384')",
"('Nylatron GS','0.042')",
"('Nylon 6/6','0.0413')",
"('Peek','0.0478')",
"('PET','0.0503')",
"('PETG','0.046')",
"('Phenolic CE','0.0413')",
"('Phenolic G-10','0.0659')",
"('Phenolic G-11','0.0659')",
"('Phenolic G-3','0.0651')",
"('Phenolic G-5','0.0706')",
"('Phenolic G-7','0.067')",
"('Phenolic G-9','0.0688')",
"('Phenolic LE','0.0413')",
"('Phenolic N-1','0.0427')",
"('Phenolic XX','0.0485')",
"('Phenyleneoxide','0.0384')",
"('Polyamide','0.0413')",
"('Polyamide-Imide','0.0514')",
"('Polybenzimidazote','0.047')",
"('Polycarbonate','0.0434')",
"('Polyethelene LD','0.0344')",
"('Polyetherimide','0.046')",
"('Polymethylpentene','0.03')",
"('Polymides Grafite','0.0561')",
"('PolyPro Copolymer','0.0326')",
"('Polypro HomoPolymer','0.0329')",
"('Polystyrene','0.038')",
"('Polysulfone','0.0449')",
"('PPO','0.0384')",
"('PVC Type I','0.051')",
"('PVC Type II','0.0489')",
"('Red Sheet','0.0626')",
"('SBR','0.034')",
"('SG-200','0.0615')",
"('Silicone','0.0507')",
"('Silver','0.38')",
"('Styrene','0.038')",
"('Teflon (PTFE)','0.0814')",
"('Torlon','0.0514')",
"('TPX','0.03')",
"('Transite','0.0507')",
"('Transite','0.0615')",
"('UHMW','0.0344')",
"('Ultem','0.046')",
"('Urethane','0.047')",
"('Vespel','0.0518')",
"('Vinyl','0.047')",
"('Vulcanized Fiber','0.0503')",
"('X Link Styrene','0.038')");
var stainlessArray =  new Array("('Select alloy','',true,true)",
"('301','0.287')",
"('302','0.287')",
"('303','0.287')",
"('304','0.287')",
"('305','0.287')",
"('316','0.286')",
"('321','0.285')",
"('409','0.278')",
"('410','0.278')",
"('420','0.28')",
"('430','0.278')",
"('15-5','0.287')",
"('17-4','0.29')");
var steelArray =  new Array("('Select alloy','',true,true)",
"('1010','0.283')",
"('1012','0.283')",
"('1015','0.283')",
"('1018','0.283')",
"('1541','0.283')",
"('4140','0.283')",
"('A-36','0.283')");
var titaniumArray =  new Array("('Select alloy','',true,true)",
"('6Al-4V','0.163')",
"('Grade 2','0.163')",
"('Grade 4','0.163')",
"('Grade 5','0.163')");
var toolsteelArray =  new Array("('Select alloy','',true,true)",
"('S-7','0.283')");
var zincArray =  new Array("('Select alloy','',true,true)",
"('190','0.259')",
"('310','0.258')",
"('320','0.258')",
"('500','0.259')",
"('700','0.259')",
"('720','0.259')",
"('750','0.259')");

function populateAlloy(inForm,selected) {
	var selectedArray = eval(selected + "Array");
	while (selectedArray.length < inForm.alloy.options.length)
		inForm.alloy.options[(inForm.alloy.options.length - 1)] = null;

	for (var i=0; i < selectedArray.length; i++)
		eval("inForm.alloy.options[i]=" + "new Option" + selectedArray[i]);

	if (inForm.material.options[0].value == '')
		inForm.material.options[0]= null;
}

		var focusflag = false;
		var RoundOff = 5;

function ConvertToInch(value,type){
			if(type=="ft")
				value = value*12;
			if(type=="yd")
				value = value*36;
			if(type=="cm")
				value = value/2.54;
			if(type=="m")
				value = (value*100)/2.54;
			if(type== "mm")
				value = (value/10)/2.54;
	return value;
	}

function CalculateWeight(){

		var Param = new Array(5);
		var Units = new Array(4);
		var Convert;
		var FormType;
		var Result;
		var Good;
		var myShape;
		var myPieces;
		var myDensity;
		var myWeight;
		var myPcWeight;
		var totalWeight;
		var dim1;
		var dim2;
		var dim3;
		var dim4;

		myDensity = document.weightcalc.alloy.value;
		dim1 = ConvertToInch(document.weightcalc.dim1.value,document.weightcalc.unitsdim1.value);
		dim2 = ConvertToInch(document.weightcalc.dim2.value,document.weightcalc.unitsdim2.value);
		dim3 = ConvertToInch(document.weightcalc.dim3.value,document.weightcalc.unitsdim3.value);
		dim4 = ConvertToInch(document.weightcalc.dim4.value,document.weightcalc.unitsdim4.value);
				myPieces = document.weightcalc.pieces.value;
		myShape = document.weightcalc.matshape.value;
		document.weightcalc.pcweight.rsize = "4";
		document.weightcalc.totalweight.rsize = "4";

			if(myShape=="round"){
				myWeight=new String(dim1*dim1*9.42*myDensity*(dim2/12));
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}
			if(myShape=="square"){
				myWeight=new String(dim1*dim1*myDensity*dim2);
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}
			if(myShape=="hex"){
				myWeight=new String(dim1*dim1*myDensity*10.4*(dim2/12));
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}

			if(myShape=="flat"){
				myWeight=new String(dim1*dim2*myDensity*dim3);
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}
			if(myShape=="sheet"){
				myWeight=new String(dim1*dim2*myDensity*dim3);
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}
			if(myShape=="rectangle"){
				myWeight=new String(dim1*dim2*myDensity*dim3);
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}
			if(myShape=="plate"){
				myWeight=new String(dim1*dim2*myDensity*dim3);
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			}
			if(myShape=="tube"||myShape=="pipe"){
				myWeight=new String((dim1-dim2)*dim2*myDensity*37.7*(dim3/12));
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			if(myShape=="ring"){
				myWeight=new String((dim2+(dim3-dim2))*(dim3-dim2)*myDensity*37.7*(dim1/12));
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			if(myShape=="rectangle tube"){
				myWeight=new String(((dim1*dim2*12*myDensity)-((dim1-(dim3*2))*(dim2-(dim3*2))*12*myDensity))*(dim4/12));
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			if(myShape=="square tube"){
						myWeight=new String(37.7*myDensity*dim2*(dim1-dim2)*1.27*(dim3/12)*.9605);
						document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			if(myShape=="rebar"){
						myWeight=new String(dim1*dim1*9.434*myDensity*(dim2/12));
						document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			if(myShape=="angle"){
				myWeight=new String((dim1*dim3*dim4*myDensity)+((dim2-dim3)*dim3*dim4*myDensity)*1.02);
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			if(myShape=="channel"||myShape=="ibeam"||myShape=="flange"){
				myWeight=new String(dim2*(dim3/12));
				document.weightcalc.pcweight.value = myWeight.substring(0,myWeight.indexOf(".")+RoundOff);
				}
			myPcWeight=document.weightcalc.pcweight.value;
			totalWeight=new String(myPcWeight*myPieces);
			totalWeight = totalWeight.substring(0,myWeight.indexOf(".")+RoundOff);
			document.weightcalc.totalweight.value=totalWeight;
}

function showimage(){
	var myShape;
	var myPicture;

	myShape=document.weightcalc.matshape.options[document.weightcalc.matshape.selectedIndex].value;

	if (myShape=="round"){
	myPicture="../_images/circle.gif";
	}
	if (myShape=="flat"||myShape=="plate"||myShape=="coil"||myShape=="rectangle"||myShape=="sheet"){
	myPicture="../_images/flat.gif";
	}
	if (myShape=="rectangle tube"){
	myPicture="../_images/rectube.jpg";
	}
	if (myShape=="hex"){
	myPicture="../_images/hexagon.gif";
	}
	if (myShape=="square"){
	myPicture="../_images/square.gif";
	}
	if (myShape=="square tube"){
	myPicture="../_images/sqtube.jpg";
	}
	if (myShape=="tube"){
	myPicture="../_images/tube.gif";
	}
	if (myShape=="ring"){
	myPicture="../_images/tube.gif";
	}
	if (myShape=="pipe"){
	myPicture="../_images/tube.gif";
	}
	if (myShape=="rebar"){
	myPicture="../_images/circle.gif";
	}
	if (myShape=="angle"){
	myPicture="../_images/angle.jpg";
	}
	if (myShape=="channel"){
	myPicture="../_images/channel.jpg";
	}
	if (myShape=="ibeam"){
	myPicture="../_images/ibeam.jpg";
	}
	if (myShape=="flange"){
	myPicture="../_images/ibeam.jpg";
	}
	document.images.pictures.src=myPicture;
	{
	if (!document.images)
	return
	}
}

function ClearFields(){
	if(document.weightcalc.dim1)
		document.weightcalc.dim1.value = "";
	if(document.weightcalc.dim2)
		document.weightcalc.dim2.value = "";
	if(document.weightcalc.dim3)
		document.weightcalc.dim3.value = "";
	if(document.weightcalc.dim4)
		document.weightcalc.dim4.value = "";
	if(document.weightcalc.pcweight)
		document.weightcalc.pcweight.value = "";
	if(document.weightcalc.totalweight)
		document.weightcalc.totalweight.value = "";
	}
function ChangeLabel(){
	var myShape;
	if(document.weightcalc.matshape)
	{
		myShape = document.weightcalc.matshape.value;

		if(myShape=="round"){
			document.weightcalc.dim1label.value = "Diameter:";
			document.weightcalc.dim2label.value = "Length:";
			document.weightcalc.dim3label.value = "";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="square"){
			document.weightcalc.dim1label.value = "Width:";
			document.weightcalc.dim2label.value = "Length:";
			document.weightcalc.dim3label.value = "";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape== "hex"){
			document.weightcalc.dim1label.value = "Diameter:";
			document.weightcalc.dim2label.value = "Length:";
			document.weightcalc.dim3label.value = "";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="flat"||myShape=="sheet"||myShape=="coil"||myShape=="plate"||myShape=="rectangle"){
			document.weightcalc.dim1label.value = "Gauge:";
			document.weightcalc.dim2label.value = "Width:";
			document.weightcalc.dim3label.value = "Length:";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="tube"||myShape=="pipe"){
			document.weightcalc.dim1label.value = "Outer Diameter:";
			document.weightcalc.dim2label.value = "Wall:";
			document.weightcalc.dim3label.value = "Length:";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="circular"){
			document.weightcalc.dim1label.value = "Diameter:";
			document.weightcalc.dim2label.value = "Thickness:";
			document.weightcalc.dim3label.value = "";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="ring"){
			document.weightcalc.dim1label.value = "Thickness:";
			document.weightcalc.dim2label.value = "Outer Diameter:";
			document.weightcalc.dim3label.value = "Inner Diameter:";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="square tube"){
			document.weightcalc.dim1label.value = "Outer Diameter (A):";
			document.weightcalc.dim2label.value = "Wall (B):";
			document.weightcalc.dim3label.value = "Length:";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="rectangle tube"||myShape=="angle"){
			document.weightcalc.dim1label.value = "Height (A):";
			document.weightcalc.dim2label.value = "Width (B):";
			document.weightcalc.dim3label.value = "Wall (C):";
			document.weightcalc.dim4label.value = "Length:";
			}
		if(myShape=="rebar"){
			document.weightcalc.dim1label.value = "Diameter:";
			document.weightcalc.dim2label.value = "Length:";
			document.weightcalc.dim3label.value = "";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="channel"||myShape=="ibeam"||myShape=="flange"){
			document.weightcalc.dim1label.value = "Size (A):";
			document.weightcalc.dim2label.value = "Weight:";
			document.weightcalc.dim3label.value = "Length:";
			document.weightcalc.dim4label.value = "";
			}
		if(myShape=="tee"||myShape=="zee"){
			document.weightcalc.dim1label.value = "";
			document.weightcalc.dim2label.value = "";
			document.weightcalc.dim3label.value = "";
			document.weightcalc.dim4label.value = "";
			}
	}
}
ChangeLabel();
ClearFields();
//-->