<!--
	var frmInProcess,flagSupported;
	var cheScelta, cheShow, cheFormula, cheRange, cheWMU;
	var arDiv = new Array(4); 
	var cheDiv = "DimX|DimY|Spessore|Diametro|CheDiametro";

	//peso specifico lega alluminio:
	var ps = 2.7 * 1000;
	//costante per piastre mandorlate:
	var mandConst = 1;

	flagSupported = (document.getElementById)?true:false;

	function FB_populateArDiv(){
		frmInProcess = document.forms["frmPars"].elements;
		if(flagSupported){
			arDiv[0] = document.getElementById("divDimX").innerHTML;
			arDiv[1] = document.getElementById("divDimY").innerHTML;
			arDiv[2] = document.getElementById("divSpessore").innerHTML;
			arDiv[3] = document.getElementById("divDiametro").innerHTML;
			arDiv[4] = document.getElementById("divCheDiametro").innerHTML;
		}
	}

	function FB_setParameters(cheSelect){

		for(var nSel = 1; nSel < 5; nSel++){
			if((nSel != cheSelect) && (frmInProcess["sel" + nSel].selectedIndex != 0)){frmInProcess["sel" + nSel].selectedIndex = 0;}
		}

		cheScelta = "";	
		cheShow = "";	

		for(var nSel = 1; nSel < 5; nSel++){
			if(frmInProcess["sel" + nSel].selectedIndex != 0){cheScelta = frmInProcess["sel" + nSel].options[frmInProcess["sel" + nSel].selectedIndex].value;}
		}			

		switch (cheScelta){
			case "piastre_laminate":
				cheWMU = "Kg";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(DimX / 1000) * (DimY / 1000) * (Spessore / 1000) * 1000 * ps";
				cheRange = "1020mm (b=2020mm)\n1270mm (b=2520mm)\n1520mm (b=3020mm)\n2020mm (b=4020mm)\n2000mm (b=6000mm)|2020mm (a=1020mm)\n2520mm (a=1270mm)\n3020mm (a=1520mm)\n4020mm (a=2020mm)\n6000mm (a=2000mm)|1020x2020: min 5mm, max 600mm\n1270x2520: min 5mm, max 600mm\n1520x3020: min 5mm, max 600mm\n2020x4020: min 8mm, max 30mm\n2000x6000: min 5mm, max 20mm";
				break;
			case "piastre_mandorlate":
				cheWMU = "Kg";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(DimX / 1000) * (DimY / 1000) * (Spessore / 1000) * 1000 * ps * " + mandConst;
				cheRange = "1000mm (b=2000mm)\n1250mm (b=2500mm)\n1500mm (b=3000mm)\n2000mm (b=6000mm)|2000mm (b=1000mm)\n2500mm (b=1250mm)\n3000mm (b=1500mm)\n6000mm (b=2000mm)|1000x2000: min 0,5mm, max 6,5mm\n1250x2500: min 0,5mm, max 6,5mm\n1500x3000: min 0,5mm, max 6,5mm\n2000x6000: min 2mm, max 5mm";
				break;
			case "barre_circolari":
				cheWMU = "Kg/m";
				cheShow = "|Diametro|";
				cheFormula = "(Diametro / 1000) * (Diametro / 1000) * 1000 * ps * " + (Math.PI / 4);
				cheRange = "4mm§500mm";
				break;
			case "barre_quadrate":
				cheWMU = "Kg/m";
				cheShow = "|DimX|";
				cheFormula = "(DimX / 1000) * (DimX / 1000) * 1000 * ps";
				cheRange = "5mm§200mm";
				break;
			case "barre_rettangolari":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|";
				cheFormula = "(DimX / 1000) * (DimY / 1000) * 1000 * ps";
				cheRange = "10mm§330mm|2mm§80mm";
				break;
			case "barre_esagonali":
				cheWMU = "Kg/m";
				cheShow = "|Diametro|CheDiametro|";
				cheFormula = "(Diametro / 1000) * (Diametro / 1000) * 1000 * ps * " + (Math.sqrt(3) / 2) + "|(Diametro / 1000) * (Diametro / 1000) * 1000 * ps * " + ((3 / 8) * Math.sqrt(3)); 				
				cheRange = "5mm(Ch) - 6mm(D)§80mm(Ch) - 92(D)";
				break;
			case "tubi_circolari":
				cheWMU = "Kg/m";
				cheShow = "|Spessore|Diametro|";
				cheFormula = "((Diametro / 1000) - (Spessore / 1000)) * (Spessore / 1000) * 1000 * ps * " + (Math.PI);
				cheRange = "1mm§50mm|6mm§250mm";
				break;
			case "tubi_quadrati":
				cheWMU = "Kg/m";
				cheShow = "|DimX|Spessore|";
				cheFormula = "(Spessore / 1000) * ((DimX / 1000) - (Spessore / 1000)) * 1000 * 4 * ps";
				cheRange = "15mm§120mm|1,5mm§5mm";
				break;
			case "tubi_rettangolari":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(Spessore / 1000) * ((DimX / 1000) + (DimY / 1000) - ((Spessore / 1000) * 2)) * 1000 * 2 * ps";
				cheRange = "10mm§50mm|15mm§150mm|1,5mm§5mm";
				break;
			case "tubi_ovali":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(((Spessore / 1000) * 2 * ((DimY / 1000) - (DimX / 1000))) + (" + Math.PI + " * (Spessore / 1000) * ((DimX / 1000) - (Spessore / 1000)))) * 1000 * ps";
				cheRange = "30mm§70mm|18mm§30mm|1,5mm§3,2mm";
				break;
			case "profili_L_quadrati":
				cheWMU = "Kg/m";
				cheShow = "|DimX|Spessore|";
				cheFormula = "(Spessore / 1000) * (2 * (DimX / 1000) - (Spessore / 1000)) * 1000 * ps";
				cheRange = "10mm§100mm|1,5mm§10mm";
				break;
			case "profili_L_rettangolari":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(Spessore / 1000) * ((DimX / 1000) + (DimY / 1000) - (Spessore / 1000)) * 1000 * ps";
				cheRange = "15mm§120mm|10mm§180mm|2mm§10mm";
				break;
			case "profili_T":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(Spessore / 1000) * ((DimX / 1000) + (DimY / 1000) - (Spessore / 1000)) * 1000 * ps";
				cheRange = "15mm§80mm|15mm§60mm|2mm§5mm";
				break;
			case "profili_U":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(Spessore / 1000) * ((DimX / 1000) + 2 * (DimY / 1000) - 2 * (Spessore / 1000)) * 1000 * ps";
				cheRange = "8mm§200mm|8mm§60mm|1mm§8mm";
				break;
			case "profili_I":
				cheWMU = "Kg/m";
				cheShow = "|DimX|DimY|Spessore|";
				cheFormula = "(Spessore / 1000) * (2 * (DimX / 1000) + (DimY / 1000) - 2 * (Spessore / 1000)) * 1000 * ps";
				cheRange = "70mm§140mm|20mm§135mm|2mm§6mm";
				break;
			default:
				break;
		}

		if(cheScelta != ""){												
			MM_swapImage("imgSchema","","../img/calcolo/" + cheScelta + ".gif",1);												

			if(flagSupported){				
				document.getElementById("divRisultato").innerHTML = "";

				document.getElementById("divDimX").innerHTML = arDiv[0];
				document.getElementById("divDimY").innerHTML = arDiv[1];
				document.getElementById("divSpessore").innerHTML = arDiv[2];
				document.getElementById("divDiametro").innerHTML = arDiv[3];
				document.getElementById("divCheDiametro").innerHTML = arDiv[4];
				
				var arDivs = cheDiv.split("|");
				var arRange = cheRange.split("|");
				var arRanges;
				var imgInProcess, imgHelpInProcess, imgEnabled;
				var imgDisabled = "../img/calcolo/disabled.gif";
				var cheTop = 0;

				for(var nDiv = 0; nDiv < arDivs.length; nDiv++){

					imgInProcess = "img" + arDivs[nDiv];
					imgHelpInProcess = "imgHelp" + arDivs[nDiv];
					imgEnabled = "../img/calcolo/" + arDivs[nDiv] + "_" + cheScelta + ".gif";


					if(cheShow.indexOf("|" + arDivs[nDiv] + "|") >= 0){
						MM_swapImage(imgInProcess,"",imgEnabled,1);														
						if(arDivs[nDiv] == "CheDiametro"){										
							MM_swapImage(imgInProcess + "_inscritto","","../img/calcolo/" + arDivs[nDiv] + "_inscritto_" + cheScelta + ".gif",1);																													
							MM_swapImage(imgInProcess + "_circoscritto","","../img/calcolo/" + arDivs[nDiv] + "_circoscritto_" + cheScelta + ".gif",1);															
						}
						else{
							var arShow = cheShow.split("|");
							arShow = arShow.slice(1,-1);	
							for(var nShow = 0; nShow < arShow.length; nShow++){
								if(arShow[nShow] == arDivs[nDiv]){
									if(arRange[nShow].indexOf("§") >= 0){
										arRanges = arRange[nShow].split("§");
										document.images[imgHelpInProcess].alt = "Dimensioni tipiche:\nmin " + arRanges[0] + "\nmax " + arRanges[1];
										document.images[imgHelpInProcess].title = "Dimensioni tipiche:\nmin " + arRanges[0] + "\nmax " + arRanges[1];
									}
									else{
										document.images[imgHelpInProcess].alt = "Dimensioni tipiche:\n" + arRange[nShow];
										document.images[imgHelpInProcess].title = "Dimensioni tipiche:\n" + arRange[nShow];
									}
								}
							} 
						}	
						
						document.getElementById("div" + arDivs[nDiv]).style.top = cheTop + "px";
					
						cheTop += 38;	
					}
					else{
						MM_swapImage(imgInProcess,"",imgDisabled,1);
						if(arDivs[nDiv] == "CheDiametro"){															
							MM_swapImage(imgInProcess + "_inscritto","",imgDisabled,1);																													
							MM_swapImage(imgInProcess + "_circoscritto","",imgDisabled,1);															
						}														
						document.getElementById("div" + arDivs[nDiv]).innerHTML = "";
					}			
				}

				document.getElementById("divCalculate").style.top = "130px";
			}
			else{alert("            ATTENZIONE!\nCompilare solo i campi con l'etichetta.");}

			MM_showHideLayers("divParameters","","show","divCalculate","","show");
		}
		else{alert("Prego scegliere il prodotto prima di procedere.")}
	}

	function FB_calculateWeight(){
		var nEmpty = 0;
		var nNaN = 0;
		var strErr = "";
		var arFields = cheShow.split("|");
		var cheValue;
		var cheFormulaTemp = cheFormula;
		var expr = "";
		var chePs = 2760;
		
		for(var i=0;i<3;i++){
			if(document.forms[0].elements["ps"][i].checked == true){chePs = document.forms[0].elements["ps"][i].value;}
		}

		cheFormulaTemp = cheFormulaTemp.replace(/ps/g,chePs);

		for(var nField = 0; nField < arFields.length; nField ++){
			//validazione
			if(arFields[nField] != ""){
				cheValue = "";
				expr = "/" + arFields[nField] + "/g";


				if(arFields[nField] != "CheDiametro"){
					cheValue = lTrim(frmInProcess[arFields[nField]].value);
					cheFormulaTemp = cheFormulaTemp.replace(eval(expr),cheValue);
				}
				else{
					cheFormulaTemp = cheFormulaTemp.split("|");
					if(frmInProcess[arFields[nField]][0].checked){
						cheValue = frmInProcess[arFields[nField]][0].value;
						cheFormulaTemp = cheFormulaTemp[0].replace(eval(expr),cheValue);
					}
					else if(frmInProcess[arFields[nField]][1].checked){
						cheValue = frmInProcess[arFields[nField]][1].value;
						cheFormulaTemp = cheFormulaTemp[1].replace(eval(expr),cheValue);
					}
				}				

				if(cheValue == ""){nEmpty += 1;}
				else if(isNaN(cheValue)){nNaN += 1;}
			}
		}

		if((nEmpty > 0) || (nNaN > 0)){
			strErr += "                    ATTENZIONE\n\nImpossibile procedere:\n";
			if(nEmpty > 0){strErr += "- campi non compilati : " + nEmpty + "\n";}
			if(nNaN > 0){strErr += "- campi che non contengono valori numerici: " + nNaN;}
			alert(strErr);
		}
		else{
			//calcolo
			var HTML_RESULT = Math.floor((eval(cheFormulaTemp) / 1000) * 100 + 0.5) / 100;
			if(flagSupported){
				document.getElementById("divRisultato").innerHTML =	"<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\">" +
																		"<tr>" +
																			"<td class=\"Testo\" align=\"center\"><img src=\"../img/calcolo/peso.gif\" width=\"55\" height=\"27\"></td>" +
																			"<td class=\"Testo\">" +				
																				"<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">" +
																					"<tr>" +
																						"<td width=\"2\" height=\"2\"><img src=\"../img/calcolo/top-sx.gif\" width=\"2\" height=\"2\"></td>" +
																						"<td height=\"2\" background=\"../img/calcolo/top.gif\"><img src=\"../img/calcolo/top.gif\" width=\"48\" height=\"2\"></td>" +
																						"<td width=\"2\" height=\"2\"><img src=\"../img/calcolo/top-dx.gif\" width=\"2\" height=\"2\"></td>" +
																					"</tr>" +
																					"<tr>" +
																						"<td width=\"2\" background=\"../img/calcolo/sx.gif\"><img src=\"../img/calcolo/sx.gif\" width=\"2\" height=\"17\"></td>" +
																						"<td><table cellspacing=\"0\" cellpadding=\"1\" border=\"0\"><tr><td><font face=\"Arial\" size=\"2\"><b>" + HTML_RESULT + "</b></font></td></tr></table></td>" +
																						"<td width=\"2\" background=\"../img/calcolo/dx.gif\"><img src=\"../img/calcolo/dx.gif\" width=\"2\" height=\"17\"></td>" +
																					"</tr>" +
																					"<tr>" +
																						"<td width=\"2\" height=\"2\"><img src=\"../img/calcolo/bottom-sx.gif\" width=\"2\" height=\"2\"></td>" +
																						"<td height=\"2\" background=\"../img/calcolo/bottom.gif\"><img src=\"../img/calcolo/bottom.gif\" width=\"48\" height=\"2\"></td>" +
																						"<td width=\"2\" height=\"2\"><img src=\"../img/calcolo/bottom-dx.gif\" width=\"2\" height=\"2\"></td>" +
																					"</tr>" +
																				"</table>" +
																			"</td>" +
																			"<td class=\"Testo\">" + cheWMU + "</td>" +
																		"</tr>" +
																	"</table>";
			}
			else{alert(HTML_RESULT);}
		}
	}
	
	function lTrim(str) {
		var offset = 0;
		while ( str.charAt(offset)==" " ){offset++;}
		str = str.substring(offset,str.length);
		return str;
	}

//-->