var connector = 0;
var larghProf = 0;
var altProf = 0;
var pz = 0;
var set = 0;
var boxganci = 0;
var boxclamp = 0;
var boxschlaufe = 0;
var boxclips = 0;
var box50 = 0;
var cordlen = 0;
var ext = "empty";
var corda = false;
var ganci = false;
var clamp = false;
var eyelet = false;
var ring = false;
var whmt = false;
var profiles;
var connector = 0;
var proftext;
var indFields = new Object();
var tkosten = false;
var img1act = new Image(85,85);
img1act.src = "/fileadmin/templates/pic/wandschelle_3punkt_MFWH03AL.jpg";
var img2act = new Image(85,85);
img2act.src = "/fileadmin/templates/pic/wandschelle_1punkt_MFWH01AL.jpg";
var img1inact = new Image(85,85);
img1inact.src = "/fileadmin/templates/pic/MFWH03ALinactive.jpg";
var img2inact = new Image(85,85);
img2inact.src = "/fileadmin/templates/pic/MFWH01ALinactive.jpg";
var mailbody = document.getElementById("inputb").href;


function fclick(param) {
	var altEl = document.datapart.altezza;
	var larghEl = document.datapart.larghezza;
	var lieferung = document.getElementById("lieferung");
	var pacchetto = true;
	switch (param) {
		case "ext":
			ext = true;
			document.getElementById("banneresterno").firstChild.nodeValue = bannertext;
			if (corda != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "banner":
			ext = false;
			document.getElementById("banneresterno").firstChild.nodeValue = esternotext;
			if (corda != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "corda":
			ring = false;
			corda = true;
			ganci = false;
			clamp = false;
			eyelet = true;
			if (ext != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "ganci":
			ring = false;
			corda = false;
			ganci = true;
			clamp = false;
			eyelet = true;
			if (ext != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "cordaganci":
			ring = false;
			corda = false;
			ganci = true;
			clamp = true;
			eyelet = false;
			if (ext != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "cordaclamp":
			ring = false;
			corda = true;
			ganci = false;
			clamp = true;
			eyelet = false;
			if (ext != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "elclamp":
			ring = true;
			corda = false;
			ganci = false;
			clamp = true;
			eyelet = false;
			if (ext != "empty") document.getElementById("altlarghdiv").style.display = "block";
			break;
		case "altezza":
			if (ext != "empty" && corda != "empty" && altEl.value * 10 != Number.NaN && larghEl.value * 10 != Number.NaN && altEl.value != "" && larghEl.value != "") {
			   document.getElementById("result1").style.display = "block";
			   document.getElementById("result2").style.display = "block";
			}
			break;
		case "larghezza":
			if (ext != "empty" && corda != "empty" && altEl.value * 10 != Number.NaN && larghEl.value * 10 != Number.NaN && altEl.value != "" && larghEl.value != "") {
			   document.getElementById("result1").style.display = "block";
			   document.getElementById("result2").style.display = "block";
			}
			break;
		case "pacchetto":
			pacchetto = true;
			if (lieferung) {
				document.datapart.transportkosten.disabled = false;
				lieferung.style.color = "white";
			}
			break;
		case "nopacchetto":
			pacchetto = false;
			if (lieferung) {
				document.datapart.transportkosten.disabled = "disabled";
				document.datapart.transportkosten.checked = false;
				tkosten = false;
				lieferung.style.color = "black";
			}
			break;
	    case "tkosten":
			tkosten = true;
			break;
		case "notkosten":
			tkosten = false;
			break;
		case "whpl":
		   var image1 = document.getElementById("whpl");
		   var image2 = document.getElementById("whmt");
		   if (whmt) {
		      image1.src = img1act.src;
		      image2.src = img2inact.src;
		      image2.style.cursor = "pointer";
		      image1.style.cursor = "default";
		      document.getElementById("whpltext").style.display = "inline";
		      document.getElementById("whmttext").style.display = "none";
		      whmt = false;
		   }
		break;
		case "whmt":
		   var image1 = document.getElementById("whpl");
		   var image2 = document.getElementById("whmt");
		   if (!whmt) {
		      image1.src = img1inact.src;
		      image2.src = img2act.src;
		      image2.style.cursor = "default";
		      image1.style.cursor = "pointer";
		      document.getElementById("whpltext").style.display = "none";
		      document.getElementById("whmttext").style.display = "inline";
		      whmt = true;
		   }
		break;
		default:
			indFields[param] = document.ordernow[param].value;
		break;
	}
	//calculate all
	var diff = corda ? 400 : 200;
	var diff = ext ? -diff : diff;
	document.getElementById("altezzabanner").innerHTML = new String(Math.round(altEl.value) + diff) + '<span id="totalprice" ></span>';
	document.getElementById("larghezzabanner").firstChild.nodeValue = Math.round(larghEl.value) + diff;
	diff = corda ? 300 : 100;
	diff = ext ? -100 : diff;
	altProf = Math.round(altEl.value) + diff;
	larghProf = Math.round(larghEl.value) + diff;
	profiles = new Object();
	profiles['6500'] = 0;
	profiles['5100'] = 0;
	profiles['4100'] = 0;
	profiles['3100'] = 0;
	profiles['2100'] = 0;
	profiles['1100'] = 0;
   proftext = new Array();
   proftext[0] = new String(vertical + '<br /><br />');
   proftext[1] = new String(horizontal + '<br /><br />');
	var cc = 0;
	document.getElementById("alerttexts").style.display = "block";
	for (i = 0; i < 2; i++) {
		var prof = (i == 0) ? altProf : larghProf;
		if (prof > 19200) {
		    document.getElementById("alerttexts").style.display = "none";
			var profrest = prof % 12800;
			if (profrest > 6400) {
				cc = 4 * Math.floor(prof / 12800);
				profiles['6500'] += cc;
				proftext[i] += (cc / 2) + " x 6400 (MFP6500AL)<br />";
				if (profrest > 10800) {
					profiles['5100'] += 4;
					proftext[i] += "2 x 5100 (MFP5100AL)<br />";
					profrest -= 10200;
				}
				if (profrest > 8800) {
					profiles['4100'] += 4;
					proftext[i] += "2 x 4100 (MFP4100AL)<br />";
					profrest -= 8200;
				}
				if (profrest > 6800) {
					profiles['3100'] += 4;
					proftext[i] += "2 x 3100 (MFP3100AL)<br />";
					profrest -= 6200;
				}
				if (profrest > 4800) {
					profiles['2100'] += 4;
					proftext[i] += "2 x 2100 (MFP2100AL)<br />";
					profrest -= 4200;
				}
				if (profrest > 2800) {
					profiles['1100'] += 4;
					proftext[i] += "2 x 1100 (MFP1100AL)<br />";
					profrest -= 2200;
				}
				if (profrest > 2100) {
					profiles['3100'] += 2;
					proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 1100) {
					profiles['2100'] += 2;
					proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 0) {
					profiles['1100'] += 2;
					proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + profrest + "<br />";
				}
			}
			else if (profrest > 600) {
				cc = 4 * Math.floor(prof / 12800);
				profiles['6500'] += cc;
				proftext[i] += (cc / 2) + " x 6400 (MFP6500AL)<br />";
				if (profrest > 5100) {
					profiles['6500'] += 2;
					proftext[i] += "1 x 6400 (MFP6500AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 4100) {
					profiles['5100'] += 2;
					proftext[i] += "1 x 5100 (MFP5100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 3100) {
					profiles['4100'] += 2;
					proftext[i] += "1 x 4100 (MFP4100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 2100) {
					profiles['3100'] += 2;
					proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 1100) {
					profiles['2100'] += 2;
					proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + profrest + "<br />";
				}
				else {
					profiles['1100'] += 2;
					proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + profrest + "<br />";
				}
			}
			else {
				cc = 4 * Math.floor(prof / 12800 - 1);
				profiles['6500'] += cc;
				proftext[i] += (cc / 2) + " x 6400 (MFP6500AL)<br />";
				profrest += 2600;
				profiles['5100'] += 4;
				proftext[i] += "2 x 5100 (MFP5100AL)<br />";
				if (profrest > 4100) {
					profiles['5100'] += 2;
					proftext[i] += "1 x 5100 (MFP5100AL) " + cut + " " + profrest + "<br />";
				}
				else {
					profiles['4100'] += 2;
					proftext[i] += "1 x 4100 (MFP4100AL) " + cut + " " + profrest + "<br />";
				}
			}
		}
		else if (prof > 6400) {
			if (pacchetto) {
				profrest1 = prof % 5000;
				profrest2 = prof % 4200;
				if (profrest2 > 2100 && profrest2 <= 2500) {
					cc = 4 * Math.floor(prof / 4200);
					profiles['2100'] += cc;
					proftext[i] += (cc / 2) + " x 2100 (MFP2100AL)<br />";
					profiles['3100'] += 2;
					proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + profrest2 + "<br />";
				}
				else if (profrest2 < 600 && profrest2 > 0) {
					cc = 4 * Math.floor(prof / 5000);
					profiles['3100'] += cc;
					proftext[i] += (cc / 2) + " x 3100 (MFP3100AL) " + cut + " 2500<br />";
					if (profrest1 > 2500) {
						profiles['2100'] += 4;
						proftext[i] += "2 x 2100 (MFP2100AL) " + cut + " " + (profrest1 / 2) + "<br />";
					}
					else if (profrest1 > 2100) {
						profiles['3100'] += 2;
						proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + profrest1 + "<br />";
					}
					else {
						profiles['2100'] += 2;
						proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + profrest1 + "<br />";
					}
				}
				else if (profrest2 <= 2100 && profrest2 > 0) {
					cc = 4 * Math.floor(prof / 4200);
					profiles['2100'] += cc;
					proftext[i] += (cc / 2) + " x 2100 (MFP2100AL)<br />";
					if (profrest2 > 1100) {
						profiles['2100'] += 2;
						proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + profrest2 + "<br />";
					}
					else {
						profiles['1100'] += 2;
						proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + profrest2 + "<br />";
					}
				}
				else {
					cc = 4 * Math.floor(prof / 4200);
					profiles['2100'] += cc;
					proftext[i] += (cc / 2) + " x 2100 (MFP2100AL)<br />";
					if (profrest2 != 0) {
						profiles['2100'] += 4;
						proftext[i] += "2 x 2100 (MFP2100AL) " + cut + " " + (profrest2 / 2) + "<br />";
					}
				}
			}
			else {
				if (prof > 14400) {
					profiles['6500'] += 4;
					proftext[i] += "2 x 6400 (MFP6500AL)<br />";
					profrest = prof - 12800;
				}
				else if (prof > 10800) {
					profiles['5100'] += 4;
					proftext[i] += "2 x 5100 (MFP5100AL)<br />";
					profrest = prof - 10200;
				}
				else if (prof > 8800) {
					profiles['4100'] += 4;
					proftext[i] += "2 x 4100 (MFP4100AL)<br />";
					profrest = prof - 8200;
				}
				else if (prof > 6800) {
					profiles['3100'] += 4;
					proftext[i] += "2 x 3100 (MFP3100AL)<br />";
					profrest = prof - 6200;
				}
				else {
					profiles['2100'] += 4;
					proftext[i] += "2 x 2100 (MFP2100AL)<br />";
					profrest = prof - 4200;
				}
				if (profrest > 4100) {
					profiles['5100'] += 2;
					proftext[i] += "1 x 5100 (MFP5100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 3100) {
					profiles['4100'] += 2;
					proftext[i] += "1 x 4100 (MFP4100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 2100) {
					profiles['3100'] += 2;
					proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + profrest + "<br />";
				}
				else if (profrest > 1100) {
					profiles['2100'] += 2;
					proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + profrest + "<br />";
				}
				else {
					profiles['1100'] += 2;
					proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + profrest + "<br />";
				}
			}
		}
		else if (prof > 5100) {
			if (pacchetto) {
				if (prof > 6300) {
					profiles['3100'] += 2;
					proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " 2500<br />";
					profiles['2100'] += 4;
					proftext[i] += "2 x 2100 (MFP2100AL) " + cut + " " + ((prof - 2500) / 2) + "<br />";
				}
				else if (prof > 5300) {
					profiles['2100'] += 6;
					proftext[i] += "2 x 2100 (MFP2100AL)<br />";
					proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + (prof - 4200) + "<br />";
				}
				else {
					profiles['2100'] += 4;
					proftext[i] += "2 x 2100 (MFP2100AL)<br />";
					profiles['1100'] += 2;
					proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + (prof - 4200) + "<br />";
				}
			}
			else {
				profiles['6500'] += 2;
				proftext[i] += "1 x 6400 (MFP6500AL) " + cut + " " + prof + "<br />";
			}
		}
		else if (prof > 4100) {
			if (pacchetto) {
				if (prof > 5000) {
					profiles['2100'] += 4;
					proftext[i] += "2 x 2100 (MFP2100AL)<br />";
					profiles['1100'] += 2;
					proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + (prof - 4200) + "<br />";
				}
				else if (prof > 4200) {
					profiles['3100'] += 4;
					proftext[i] += "2 x 3100 (MFP3100AL) " + cut + " " + (prof / 2) + "<br />";
				}
				else {
					profiles['2100'] += 4;
					proftext[i] += "2 x 2100 (MFP2100AL) " + cut + " " + (prof / 2) + "<br />";
				}
			}
			else {
				profiles['5100'] += 2;
				proftext[i] += "1 x 5100 (MFP5100AL) " + cut + " " + prof + "<br />";
			}
		}
		else if (prof > 3100) {
			if (pacchetto) {
				profiles['2100'] += 4;
				proftext[i] += "2 x 2100 (MFP2100AL) " + cut + " " + (prof / 2) + "<br />";
			}
			else {
				profiles['4100'] += 2;
				proftext[i] += "1 x 4100 (MFP4100AL) " + cut + " " + prof + "<br />";
			}
		}
		else if (prof > 2500) {
			if (pacchetto) {
				profiles['2100'] += 4;
				proftext[i] += "2 x 2100 (MFP2100AL) " + cut + " " + (prof / 2) + "<br />";
			}
			else {
				profiles['3100'] += 2;
				proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + prof + "<br />";
			}
		}
		else if (prof > 2100) {
			profiles['3100'] += 2;
			proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + prof + "<br />";
		}
		else if (prof > 1100) {
			profiles['2100'] += 2;
			proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + prof + "<br />";
		}
		else {
			profiles['1100'] += 2;
			proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + prof + "<br />";
		}
	}
	var pieces = 0;
	for (var i in profiles) {
		pieces += profiles[i];
	}
	if (!indFields.connector) connector = (pieces - 4) / 2;
	else connector = indFields.connector;
	pz = (Math.ceil(altProf / 2000) + Math.ceil(larghProf / 2000)) * 2;
	if (altProf <= 2000) pz += 2;
	if (larghProf <= 2000) pz += 2;
	if (!indFields.suppset) set = Math.ceil(pz/2);
	else set = indFields.suppset;
	boxschlaufe = boxclamp = boxganci = boxclips = Math.ceil((altProf + larghProf)*2/300/20);
	if (indFields.clips) boxclips = indFields.clips;
	if (indFields.clamp) boxclamp = indFields.clamp;
	if (indFields.ganci) boxganci = indFields.ganci;
	if (indFields.schlaufe) boxschlaufe = indFields.schlaufe;
	if (!indFields.eyelet) box50 = Math.ceil((altProf + larghProf)*2/300/50);
	else box50 = indFields.eyelet; 
	cordlen = corda ? (altProf + larghProf - 600) * 2 : (altProf + larghProf - 200) * 2;
	if (!indFields.corda) cordlen = Math.ceil(cordlen / 50000);
	else cordlen = indFields.corda;
	document.getElementById("altezzaprofilo").firstChild.nodeValue = altProf;
	document.getElementById("larghezzaprofilo").firstChild.nodeValue = larghProf;
	document.getElementById("rahmenOben").innerHTML = proftext[1];
	document.getElementById("rahmenLinks").innerHTML = proftext[0];
	if (tkosten) document.getElementById("totalprice").innerHTML = lieferungcheck + " &euro; " + totalprice();
	else document.getElementById("totalprice").innerHTML = totaltext + totalprice();
	document.getElementById("printtext").style.display = "none";
	document.getElementById("gancitr").style.display = ganci ? "block" : "none";
    document.getElementById("cordatr").style.display = corda ? "block" : "none";
    document.getElementById("clamptr").style.display = clamp ? "block" : "none";
    document.getElementById("eyelettr").style.display = eyelet ? "block" : "none";
	document.getElementById("ringtr").style.display = ring ? "block" : "none";
	document.ordernow.ganci.value = ganci ? boxganci : "";
	document.ordernow.corda.value = corda ? cordlen : "";
	document.ordernow.clamp.value = clamp ? boxclamp : "";
	document.ordernow.schlaufe.value = ring ? boxschlaufe : "";
	document.ordernow.connector.value = connector;
	document.ordernow.suppset.value = set;
	document.ordernow.clips.value = boxclips;
	document.ordernow.eyelet.value = box50;
	sendmail();
}

function fsubmit() {
	var location = new String("http://www.kdshop.it/"+langid+"/basket/products/page.html?C=EUR");
	for (var i in profiles) {
		if (profiles[i] != 0) {
			if (i == '6500') {
				location += "&ttp_basket[12516][quantity]=" + profiles[i];
			}
			else if (i == '5100') {
				location += "&ttp_basket[12522][quantity]=" + profiles[i];
			}
			else if (i == '4100') {
				location += "&ttp_basket[12517][quantity]=" + profiles[i];
			}
			else if (i == '3100') {
				location += "&ttp_basket[12518][quantity]=" + profiles[i];
			}
			else if (i == '2100') {
				location += "&ttp_basket[12519][quantity]=" + profiles[i];
			}
			else if (i == '1100') {
				location += "&ttp_basket[12520][quantity]=" + profiles[i];
			}
			else {
				alert("error!");
			}
		}
	}
	location += "&ttp_basket[12514][quantity]=1";
	if (whmt) location += "&ttp_basket[12513][quantity]=" + set;
	else location += "&ttp_basket[12513][quantity]=" + set;
	location += "&ttp_basket[12515][quantity]=" + boxclips;
	if (clamp) {
		location += "&ttp_basket[12238][quantity]=" + boxclamp;
	}
	if (eyelet) {
		location += "&ttp_basket[12240][quantity]=" + box50;
	}
    if (ring) {
		location += "&ttp_basket[13448][quantity]=" + boxschlaufe;
	}
	if (connector > 0) {
		location += "&ttp_basket[12510][quantity]=" + connector;
	}
	if (corda) {
		location += "&ttp_basket[12509][quantity]=" + cordlen;
	}
	if (ganci) {
		location += "&ttp_basket[12512][quantity]=" + boxganci;
	}
	location += "&basketnote=MONSTERFRAME" + '%3A%0A%0A' + proftext[1].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+') + '%0A' + proftext[0].replace(/<br.?\/>/g, '%0A').replace(/ /g, '+');
	window.open(location);
}

function sendmail() {
   if (mailbody != "") {
   	var alertString = new String("%0A");
   	if (ext) alertString += externaldim + ":%20%20%20" + document.datapart.altezza.value + "mm%20x%20" + document.datapart.larghezza.value + "mm%20";
   	else alertString += bannerdim + ":%20%20%20" + document.datapart.altezza.value + "mm%20x%20" + document.datapart.larghezza.value + "mm%20";
	alertString += "( => " + internaldim + ":%20%20%20" + altProf + "mm%20x%20" + larghProf + "mm )%0A%0A";
   	for (var i in profiles) {
   		if (profiles[i] != 0) {
   			if (i == '6500') {
   				alertString += profiles[i] + "%20x%20MFP6500AL%0A";
   			}
   			else if (i == '5100') {
   				alertString += profiles[i] + "%20x%20MFP5100AL%0A";
   			}
   			else if (i == '4100') {
   				alertString += profiles[i] + "%20x%20MFP4100AL%0A";
   			}
   			else if (i == '3100') {
   				alertString += profiles[i] + "%20x%20MFP3100AL%0A";
   			}
   			else if (i == '2100') {
   				alertString += profiles[i] + "%20x%20MFP2100AL%0A";
   			}
   			else if (i == '1100') {
   				alertString += profiles[i] + "%20x%20MFP1100AL%0A";
   			}
   			else {
   				alert("error!");
   			}
   		}
   	}
   	alertString += "1%20x%20MFA110AR%20(set04)%0A";
   	if (whmt) alertString += set + "%20x%20MFWH01AL%20(set02)%0A";
   	else alertString += set + "%20x%20MFWH03AL%20(set02)%0A";
   	alertString += boxclips + "%20x%20MFTP22GR%20(box20)%0A";	
   	if (clamp) {
   		alertString += boxclamp + "%20x%20ACL3540WE (box20)%0A";
   	}
   	if (eyelet) {
   		alertString += box50 + "%20x%20AEY3012TR (box50)%0A";
   	}
              if (ring) {
   		alertString += boxschlaufe + "%20x%20AGK60TR%20(box20)%0A";
   	}
   	if (corda) {   	}
   	if (connector > 0) {
   		alertString += connector + "%20x%20MFV400AL%20(set02)%0A";

   		alertString += cordlen + "%20x%20MFGK06GR%20(50m)%0A";
   	}
   	if (ganci) {
   		alertString += boxganci + "%20x%20AGK30GR%20(box20)%0A%0A%0A";
   	}
   	alertString += "%0A%0A%0A" + proftext[0].replace(/<br \/>/g, "%0A").replace(/ /g,"%20") + "%0A" + proftext[1].replace(/<br \/>/g, "%0A").replace(/ /g,"%20") + "%0A%0A%0A";
   	alertString += mailtext2 + ":";
   	//alert(alertString);
   	var myhref = new String(mailbody);
   	myhref = myhref.replace(/--request--.*--fill%20in%20here--/, "--" + mailtext1 + "--%0A%0A" + alertString + "%0A%0A%0A--" + mailtext3 + "--");
   	document.getElementById("inputb").href = myhref;
   }
}
	
function totalprice() {
	var totalprice = 0;
	var alertString = new String('<table width="800" align="center"><colgroup><col width="400" /><col width="195"  /><col width="205" /></colgroup>');
	alertString += '<tr><td colspan="3" style="font-weight: bold; padding: 20px 0px 20px 20px;">' + calculationalert + '</td></tr>';
	var addprice = 0;
	for (var i in profiles) {
		if (profiles[i] != 0) {
			if (i == '6500') {
				addprice = profiles[i]*130.00;
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP6500AL (€ 130.00)</td><td align='right'>€ " + addprice.toFixed(2) + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '5100') {
				addprice = profiles[i]*108.00;
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP5100AL (€ 108.00)</td><td align='right'>€ " + addprice.toFixed(2) + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '4100') {
				addprice = profiles[i]*88.00;
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP4100AL (€ 88.00)</td><td align='right'>€ " + addprice.toFixed(2) + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '3100') {
				addprice = profiles[i]*66.00;
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP3100AL (€ 66.00)</td><td align='right'>€ " + addprice.toFixed(2) + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '2100') {
				addprice = profiles[i]*45.00;
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP2100AL (€ 45.00)</td><td align='right'>€ " + addprice.toFixed(2) + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '1100') {
				addprice = profiles[i]*24.00;
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP1100AL (€ 24.00)</td><td align='right'>€ " + addprice.toFixed(2) + "</td><td>&nbsp;</td></tr>";
			}
			else {
				alert("error!");
			}
		}
	}
	totalprice += 37.00; //cornerset
	alertString += "<tr><td>" + "1 x MFA110AR (set04   € 37.00)</td><td align='right'>€ 37.00</td><td>&nbsp;</td></tr>";
	if (whmt) {
	   totalprice += set * 39.50; //suppset metall
	   val = set * 39.50;
	   alertString += "<tr><td>" + set + " x MFWH01AL (set02   € 39.50)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	else {
	   totalprice += set * 47.80;
	   val = set * 47.80;
	   alertString += "<tr><td>" + set + " x MFWH03AL (set02   € 47.80)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	totalprice += boxclips * 7.70; //clipsset  
	val = boxclips * 7.70;
	alertString += "<tr><td>" + boxclips + " x MFTP22GR (box20    € 7.70)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";	
	if (clamp) {
		totalprice += boxclamp * 19.00;
		val = boxclamp * 19.00;
		alertString += "<tr><td>" + boxclamp + " x ACL3540WE (box20   € 19.00)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	if (eyelet) {
		totalprice += box50 * 35.00;
		val = box50 * 35.00;
		alertString += "<tr><td>" + box50 + " x AEY3012TR (box50   € 35.00)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
    if (ring) {
		totalprice += boxschlaufe * 25.00;
		val = boxschlaufe * 25.00;
		alertString += "<tr><td>" + boxschlaufe + " x AGK60TR (box20    € 25.00)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	if (connector > 0) {
		totalprice += connector * 25.45;
		val = connector * 25.45;
		alertString += "<tr><td>" + connector + " x MFV400AL (set02    € 25.45)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	if (corda) {
		totalprice += cordlen * 75.00;
		val = cordlen * 75.00;
		alertString += "<tr><td>" + cordlen + " x MFGK06GR (50m    € 75.00)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	if (ganci) {
		totalprice += boxganci * 45.00;
		val = boxganci * 45.00;
		alertString += "<tr><td>" + boxganci + " x AGK30GR (box20     € 45.00)</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	if (tkosten) {
		val = Math.ceil(totalprice * transportfactor);
		totalprice = totalprice + val;
		alertString += "<tr><td>" + lieferungangebot + "</td><td align='right'>€ " + val.toFixed(2) + "</td><td>&nbsp;</td></tr>";
	}
	alertString += "<tr style='font-weight: bold;'><td align='right' style='padding: 20px 0px 20px 0px;'>" + "total:</td><td align='right' style='padding: 20px 0px 20px 0px;'>€ " + totalprice.toFixed(2) + "</td><td>&nbsp;</td></tr></table>";
	document.getElementById("calculation").style.display = "block";
	document.getElementById("calculation").innerHTML = alertString;
	document.getElementById("calculation").style.display = "none";
	return totalprice.toFixed(2);
}

function resetAll() {
	var connector = 0;
	var larghProf = 0;
	var altProf = 0;
	var pz = 0;
	var set = 0;
	var boxganci = 0;
	var boxclamp = 0;
	var boxschlaufe = 0;
	var boxclips = 0;
	var box50 = 0;
	var cordlen = 0;
	var ext = "empty";
	var corda = false;
	var ganci = false;
	var clamp = false;
	var ring = false;
	var eyelet = false;
	connector = 0;
   whmt = false;
   
	document.datapart.cordaclamp[0].checked = false;
	document.datapart.cordaclamp[1].checked = false;
	document.datapart.cordaclamp[2].checked = false;
	document.datapart.extbanner[0].checked = false;
	document.datapart.extbanner[1].checked = false;	
	document.datapart.altezza.value = "";
	document.datapart.larghezza.value = "";
	document.ordernow.ganci.value = "";
	document.ordernow.corda.value = "";
	document.ordernow.clamp.value = "";
	document.ordernow.schlaufe.value = "";
	document.ordernow.connector.value = "";
	document.ordernow.suppset.value = "";
	document.ordernow.clips.value = "";
	document.getElementById("altezzaprofilo").firstChild.nodeValue = "";
	document.getElementById("larghezzaprofilo").firstChild.nodeValue = "";
	document.getElementById("altezzabanner").firstChild.nodeValue = 0;
	document.getElementById("larghezzabanner").firstChild.nodeValue = 0;
	document.getElementById("gancitr").style.display = "none";
   document.getElementById("cordatr").style.display = "none";
      document.getElementById("eyelettr").style.display = "none";
   document.getElementById("clamptr").style.display = "none";
	document.getElementById("ringtr").style.display = "none";
	document.getElementById("result1").style.display = "none";
	document.getElementById("result2").style.display = "none";
	document.getElementById("altlarghdiv").style.display = "none";
	document.getElementById("calculation").style.display = "none";
	document.getElementById("printtext").style.display = "none";
   var image1 = document.getElementById("whpl");
	var image2 = document.getElementById("whmt");
   image1.src = img1act.src;
   image2.src = img2inact.src;
   image2.style.cursor = "pointer";
   image1.style.cursor = "default";
   document.getElementById("whpltext").style.display = "inline";
   document.getElementById("whmttext").style.display = "none";
}

function pricecalc() {
	totalprice();
	document.getElementById("calculation").style.display = "block";
	document.getElementById("printtext").style.display = "block";
}
	
function printIt() {
	totalprice();
	document.getElementById("calculation").style.display = "block";
	document.getElementById("printtext").style.display = "block";
	window.print();
}

resetAll();
