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 = true;
var clamp = false;
var eyelet = true;
var ring = false;
var whmt = false;
var profiles;
var connector = 0;
var tconnector = 0;
var proftext;
var proflen;
var indFields = new Object();
var tkosten = false;
var moduleCount = 1;
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;
var productData = new Object();

$(document).ready(function() {
    $.get('/fileadmin/data/monsterframetool.xml', function(data) {
        $(data).find('item').each(function(i) {
            productData[$(this).find('id').text()] = parseFloat($(this).find('preis').text());
        });
    });
//    productData['MFP6500AL'] = 96.20;
});

function fclick(param) {
	var altEl = document.datapart.altezza;
	var larghEl1 = document.datapart.larghezza;
	var larghEl2 = document.datapart.larghezza2;
	var larghEl3 = document.datapart.larghezza3;
	var larghEl4 = document.datapart.larghezza4;
	var larghEl5 = document.datapart.larghezza5;
	var larghEl6 = document.datapart.larghezza6;
	var lieferung = document.getElementById("lieferung");
	var pacchetto = true;
	var dataMissing = false;
	switch (param) {
		case "ext":
			ext = true;
			break;
		case "multiframe":
			if (document.datapart.multiframe.checked) {
			    document.getElementById('multiframetxt').style.display="block";
			    document.getElementById('multiframe2').style.display="block";
			    document.datapart.moduleCount[0].checked = false;
	            document.datapart.moduleCount[1].checked = true;
                document.datapart.moduleCount[2].checked = false;
                document.datapart.moduleCount[3].checked = false;
                document.datapart.moduleCount[4].checked = false;
                document.datapart.moduleCount[5].checked = false;
                moduleCount = 2;
                fclick('modulecount');
			}
			else {
			    document.getElementById('multiframetxt').style.display="none";
			    document.getElementById('multiframe2').style.display="none";
			    document.datapart.moduleCount[0].checked = true;
                document.datapart.moduleCount[1].checked = false;
                document.datapart.moduleCount[2].checked = false;
                document.datapart.moduleCount[3].checked = false;
                document.datapart.moduleCount[4].checked = false;
                document.datapart.moduleCount[5].checked = false;
                moduleCount = 1;
                fclick('modulecount');
			}
			break;
		case "banner":
			ext = false;
			break;
		case "corda":
			ring = false;
			corda = true;
			ganci = false;
			clamp = false;
			eyelet = true;
			break;
		case "ganci":
			ring = false;
			corda = false;
			ganci = true;
			clamp = false;
			eyelet = true;
			break;
		case "cordaganci":
			ring = false;
			corda = false;
			ganci = true;
			clamp = true;
			eyelet = false;
			break;
		case "cordaclamp":
			ring = false;
			corda = true;
			ganci = false;
			clamp = true;
			eyelet = false;
			break;
		case "elclamp":
			ring = true;
			corda = false;
			ganci = false;
			clamp = true;
			eyelet = false;
			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;
		case "tconnector":
			tkosten = false;
		break;
		case "altezza":
		case "larghezza":
		case "larghezza2":
		case "larghezza3":
		case "larghezza4":
		case "larghezza5":
		case "larghezza6":
			if (ext != "empty" && altEl.value * 10 != Number.NaN && larghEl1.value * 10 != Number.NaN && altEl.value != "" && larghEl1.value != "") {
			    dataMissing = false;
			    for (var i = 2; i <= moduleCount; i++) {
			        if (eval('larghEl' + i + '.value') * 10 == Number.NaN || eval('larghEl' + i + '.value') == "") dataMissing = true;
			    }
			    if (!dataMissing) {
			        document.getElementById("result1").style.display = "block";
			        document.getElementById("result2").style.display = "block";
			    }
			}
			break;
		case "modulecount":
		    document.getElementById("moduleWidth2").style.display = "none";
		    document.getElementById("moduleWidth3").style.display = "none";
		    document.getElementById("moduleWidth4").style.display = "none";
		    document.getElementById("moduleWidth5").style.display = "none";
		    document.getElementById("moduleWidth6").style.display = "none";
		    document.getElementById("result1").style.display = "none";
			document.getElementById("result2").style.display = "none";
			if (document.getElementById('moduleCount1').checked) {
			    moduleCount = 1;
			    document.getElementById("labelLarghezza").style.display = "none";
			}
			if (document.getElementById('moduleCount2').checked) {
			    moduleCount = 2;
			    document.getElementById("moduleWidth2").style.display = "block";
			    document.getElementById("labelLarghezza").style.display = "inline";
			}
			if (document.getElementById('moduleCount3').checked) {
			    moduleCount = 3;
			    document.getElementById("moduleWidth2").style.display = "block";
			    document.getElementById("moduleWidth3").style.display = "block";
			    document.getElementById("labelLarghezza").style.display = "inline";
			}
			if (document.getElementById('moduleCount4').checked) {
			    moduleCount = 4;
			    document.getElementById("moduleWidth2").style.display = "block";
			    document.getElementById("moduleWidth3").style.display = "block";
			    document.getElementById("moduleWidth4").style.display = "block";
			    document.getElementById("labelLarghezza").style.display = "inline";
			}
			if (document.getElementById('moduleCount5').checked) {
			    moduleCount = 5;
			    document.getElementById("moduleWidth2").style.display = "block";
			    document.getElementById("moduleWidth3").style.display = "block";
			    document.getElementById("moduleWidth4").style.display = "block";
			    document.getElementById("moduleWidth5").style.display = "block";
			    document.getElementById("labelLarghezza").style.display = "inline";
			}
			if (document.getElementById('moduleCount6').checked) {
			    moduleCount = 6;
			    document.getElementById("moduleWidth2").style.display = "block";
			    document.getElementById("moduleWidth3").style.display = "block";
			    document.getElementById("moduleWidth4").style.display = "block";
			    document.getElementById("moduleWidth5").style.display = "block";
			    document.getElementById("moduleWidth6").style.display = "block";
			    document.getElementById("labelLarghezza").style.display = "inline";
			}
			if (ext != "empty" && altEl.value * 10 != Number.NaN && larghEl1.value * 10 != Number.NaN && altEl.value != "" && larghEl1.value != "") {
			    dataMissing = false;
			    for (var i = 2; i <= moduleCount; i++) {
			        if (eval('larghEl' + i + '.value') * 10 == Number.NaN || eval('larghEl' + i + '.value') == "") dataMissing = true;
			    }
			    if (!dataMissing) {
			        document.getElementById("result1").style.display = "block";
			        document.getElementById("result2").style.display = "block";
			    }
			}
		break;
		default:
			indFields[param] = document.ordernow[param].value;
		break;
	}
	//calculate all
	var spaceBetween = -50;
	var diff = corda ? 400 : 200;
	var diff = ext ? -diff : 0;
	var breitenText = new String(Math.round(larghEl1.value) + diff);
	var altAussen = Math.round(altEl.value);
	document.getElementById("altezzabanner").innerHTML = new String(altAussen + diff) ;
	if (ext) diff -= spaceBetween;
    if (moduleCount > 1) breitenText += ', ' + (Math.round(larghEl2.value) + diff);
    if (moduleCount > 2) breitenText += ', ' + (Math.round(larghEl3.value) + diff);
    if (moduleCount > 3) breitenText += ', ' + (Math.round(larghEl4.value) + diff);
    if (moduleCount > 4) breitenText += ', ' + (Math.round(larghEl5.value) + diff);
    if (moduleCount > 5) breitenText += ', ' + (Math.round(larghEl6.value) + diff);
    document.getElementById("larghezzabanner").innerHTML = breitenText;
    var larghAussen = Math.round(larghEl1.value);
    if (moduleCount > 1) larghAussen += Math.round(larghEl2.value);
    if (moduleCount > 2) larghAussen += Math.round(larghEl3.value);
    if (moduleCount > 3) larghAussen += Math.round(larghEl4.value);
    if (moduleCount > 4) larghAussen += Math.round(larghEl5.value);
    if (moduleCount > 5) larghAussen += Math.round(larghEl6.value);
	document.getElementById("totalpricetd").innerHTML = '<span id="totalprice" ></span>';
	
	diff = corda ? 400 : 200;
	diff = ext ? 0 : diff;
	
	larghAussen = larghAussen + moduleCount * diff;
	if (!ext) larghAussen += (moduleCount - 1) * spaceBetween;
	altAussen = altAussen + diff;
	document.getElementById("altezzaprofilo").firstChild.nodeValue = new String(altAussen);
	document.getElementById("larghezzaprofilo").firstChild.nodeValue = new String(larghAussen);
	
	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 />');
    proftext[2] = new String('<br />');
    proftext[3] = new String('<br />');
    proftext[4] = new String('<br />');
    proftext[5] = new String('<br />');
    proftext[6] = new String('<br />');
    proflen = new Array();
    proflen[0] = 0;
    proflen[1] = 0;
    proflen[2] = 0;
    proflen[3] = 0;
    proflen[4] = 0;
    proflen[5] = 0;
    proflen[6] = 0;
	var cc = 0;
	var pieces = 0;
	var morePieces = 0;
	document.getElementById("alerttexts").style.display = "block";
	
	diff = corda ? 300 : 100;
	diff = ext ? -100 : diff;
	for (i = 0; i < moduleCount + 1; i++) {
		var prof = (i == 0) ? altAussen - 100 : Math.round(eval('larghEl' + i + '.value')) + diff;
		if (i > 1 && ext) prof += 50; 
		proflen[i] = prof;
		var pp = 0;
        for (var j in profiles) {
            pp += profiles[j];
        }
		if (prof > 15300) { // changed from 19200
		    document.getElementById("alerttexts").style.display = "none";
			var profrest = prof % 10300; // changed from 12800
			if (profrest > 5100) { // changed from 6400
				cc = 4 * Math.floor(prof / 10200); // changed from 12800
				profiles['5100'] += cc; // changed from 6500
				proftext[i] += (cc / 2) + " x 5100 (MFP5100AL)<br />"; // changed from 6400, 6500
				//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;
					if (profrest != 2100) proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + profrest + "<br />";
					else proftext[i] += "1 x 2100 (MFP2100AL)<br />";
				}
				else if (profrest > 0) {
					profiles['1100'] += 2;
					if (profrest != 1100) proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + profrest + "<br />";
					else proftext[i] += "1 x 1100 (MFP1100AL)<br />";
				}
			}
			else if (profrest > 600) {
				cc = 4 * Math.floor(prof / 10200); // changed from 12800
				profiles['5100'] += cc; // changed from 6500
				proftext[i] += (cc / 2) + " x 5100 (MFP5100AL)<br />"; // changed from 6400, 6500
				//if (profrest > 5100) {
				//	profiles['6500'] += 2;
				//	proftext[i] += "1 x 6400 (MFP6500AL) " + cut + " " + profrest + "<br />";
				//}
				// else if (profrest > 4100) {
				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 / 10300 - 1); // chaged from 12800
				profiles['5100'] += cc; //changed from 6500
				proftext[i] += (cc / 2) + " x 5100 (MFP5100AL)<br />"; // changed from 6400, 6500
				profrest += 2100; // changed from 2600
				profiles['4100'] += 4; // changed from 5100
				proftext[i] += "2 x 4100 (MFP4100AL)<br />"; // changed from 5100, 5100
				//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 />";
// 				}
				/* ADDED */
				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 />";
					}
				}
				/* ADDED END */
			}
			else {
				// profiles['6500'] += 2;
				// proftext[i] += "1 x 6400 (MFP6500AL) " + cut + " " + prof + "<br />";
				/* ADDED */
				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 />";
				}
                /* ADDED END */
			}
		}
		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;
			if (prof != 3100) proftext[i] += "1 x 3100 (MFP3100AL) " + cut + " " + prof + "<br />";
			else proftext[i] += "1 x 3100 (MFP3100AL)<br />";
		}
		else if (prof > 1100) {
			profiles['2100'] += 2;
			if (prof != 2100) proftext[i] += "1 x 2100 (MFP2100AL) " + cut + " " + prof + "<br />";
			else proftext[i] += "1 x 2100 (MFP2100AL)<br />";
		}
		else {
			profiles['1100'] += 2;
			if (prof != 1100) proftext[i] += "1 x 1100 (MFP1100AL) " + cut + " " + prof + "<br />";
			else proftext[i] += "1 x 1100 (MFP1100AL)<br />";
		}
		pp = -2-pp;
		for (var j in profiles) {
            pp += profiles[j];
            if (i==0) {
                profiles[j] = profiles[j] / 2 * (moduleCount + 1);
            }
        }
        pieces += pp;
        if (i==0) {
            morePieces = pieces / 2 * (moduleCount - 1);
        }
	}
	pieces += morePieces;
	altProf = proflen[0];
	var altProfCalc = proflen[0] * (moduleCount + 1) / 2;
	larghProf = proflen[1] + proflen[2] + proflen[3] + proflen[4] + proflen[5] + proflen[6];
	if (!indFields.connector) connector = Math.ceil(pieces / 2);
	else connector = indFields.connector;
	tconnector = moduleCount - 1;
	pz = Math.ceil((altProfCalc / 2000) + (larghProf / 2000)) * 2;
	if (altProfCalc <= 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*moduleCount*2/300/20 + 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*moduleCount*2/300/50 + larghProf*2/300/50);
	else box50 = indFields.eyelet;
	
	cordlen = corda ? (altProf * moduleCount + larghProf * 2 - 1200 * moduleCount) : (altProf * moduleCount + larghProf * 2 - 400 * moduleCount);
	if (!indFields.corda) cordlen = Math.ceil(cordlen / 50000);
	
	else cordlen = indFields.corda;
	if (proftext[2] == '<br />') proftext[2] = '';
    if (proftext[3] == '<br />') proftext[3] = '';
    if (proftext[4] == '<br />') proftext[4] = '';
    if (proftext[5] == '<br />') proftext[5] = '';
    if (proftext[6] == '<br />') proftext[6] = '';
	document.getElementById("rahmenOben").innerHTML = proftext[1] + proftext[2] + proftext[3] + proftext[4] + proftext[5] + proftext[6];
	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.getElementById("tconn").style.display = (moduleCount > 1) ? "table-row" : "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.tconnector.value = tconnector;
	document.ordernow.suppset.value = set;
	document.ordernow.clips.value = boxclips;
	document.ordernow.eyelet.value = box50;
	sendmail();
}

function fsubmit() {
	var location = new String('http://' + shopdomain + "/kunstduengerShop/"+langid+"/AddProductToBasketBySku/cid.html?");
	for (var i in profiles) {
		if (profiles[i] != 0) {
			if (i == '6500') { // should never happen!
			    location += "&product_add_list=MFP6500AL";
				location += "&product_quantity_list=" + profiles[i];
			}
			else if (i == '5100') {
				location += "&product_add_list=MFP5100AL";
				location += "&product_quantity_list=" + profiles[i];
			}
			else if (i == '4100') {
				location += "&product_add_list=MFP4100AL";
				location += "&product_quantity_list=" + profiles[i];
			}
			else if (i == '3100') {
				location += "&product_add_list=MFP3100AL";
				location += "&product_quantity_list=" + profiles[i];
			}
			else if (i == '2100') {
				location += "&product_add_list=MFP2100AL";
				location += "&product_quantity_list=" + profiles[i];
			}
			else if (i == '1100') {
				location += "&product_add_list=MFP1100AL";
				location += "&product_quantity_list=" + profiles[i];
			}
			else {
				alert("error!");
			}
		}
	}
	location += "&product_add_list=MFA110AR";
	location += "&product_quantity_list=1";
	if (whmt) {
	    location += "&product_add_list=MFWH01AL";
	    location += "&product_quantity_list=" + set;
	}
	else {
	    location += "&product_add_list=MFWH03AL";
	    location += "&product_quantity_list=" + set;
	}
	location += "&product_add_list=MFTP22GR";
	location += "&product_quantity_list=" + boxclips;
	if (clamp) {
		location += "&product_add_list=ACL3540WE";
	    location += "&product_quantity_list=" + boxclamp;
	}
	if (eyelet) {
		location += "&product_add_list=AEY3012TR";
	    location += "&product_quantity_list=" + box50;
	}
    if (ring) {
		location += "&product_add_list=AGK60TR";
	    location += "&product_quantity_list=" + boxschlaufe;
	}
	if (connector > 0) {
		location += "&product_add_list=MFV400AL";
	    location += "&product_quantity_list=" + connector;
	}
	if (tconnector > 0) {
		location += "&product_add_list=MFTANG02";
	    location += "&product_quantity_list=" + tconnector;
	}
	if (corda) {
		location += "&product_add_list=MFGK06GR";
	    location += "&product_quantity_list=" + cordlen;
	}
	if (ganci) {
		location += "&product_add_list=AGK30GR";
	    location += "&product_quantity_list=" + boxganci;
	}
	location += "&basket_comment=MONSTERFRAME:" + '%0A-->' 
	+ proftext[1].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;')
	+ proftext[2].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;')
	+ proftext[3].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;')
	+ proftext[4].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;')
	+ proftext[5].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;')
	+ proftext[6].replace(/<br.?\/>/g, '%0A').replace(/ /g,'+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;')
	+ '%0A-->' + proftext[0].replace(/<br.?\/>/g, '%0A').replace(/ /g, '+').replace(/&ocirc;/g, "%26ocirc;").replace(/&eacute;/g, '%26eacute;').replace(/&agrave;/g, '%26agrave;');
	location = location.replace(/%0A%0A/g, '%0A');
	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";
   	    if (moduleCount > 1) alertString += ",%20" + document.datapart.larghezza2.value + "mm%20";
   	    if (moduleCount > 2) alertString += ",%20" + document.datapart.larghezza3.value + "mm%20";
   	    if (moduleCount > 3) alertString += ",%20" + document.datapart.larghezza4.value + "mm%20";
   	    if (moduleCount > 4) alertString += ",%20" + document.datapart.larghezza5.value + "mm%20";
   	    if (moduleCount > 5) alertString += ",%20" + document.datapart.larghezza6.value + "mm%20";
   	}
   	else {
   	    alertString += bannerdim + ":%20%20%20" + document.datapart.altezza.value + "mm%20x%20" + document.datapart.larghezza.value + "mm%20";
   	    if (moduleCount > 1) alertString += ",%20" + document.datapart.larghezza2.value + "mm%20";
   	    if (moduleCount > 2) alertString += ",%20" + document.datapart.larghezza3.value + "mm%20";
   	    if (moduleCount > 3) alertString += ",%20" + document.datapart.larghezza4.value + "mm%20";
   	    if (moduleCount > 4) alertString += ",%20" + document.datapart.larghezza5.value + "mm%20";
   	    if (moduleCount > 5) alertString += ",%20" + document.datapart.larghezza6.value + "mm%20";
	}
	var larghProfTxt = proflen[1] + 'mm';
	if (moduleCount > 1) larghProfTxt += ",%20" + proflen[2] + 'mm';
	if (moduleCount > 2) larghProfTxt += ",%20" + proflen[3] + 'mm';
	if (moduleCount > 3) larghProfTxt += ",%20" + proflen[4] + 'mm';
	if (moduleCount > 4) larghProfTxt += ",%20" + proflen[5] + 'mm';
	if (moduleCount > 5) larghProfTxt += ",%20" + proflen[6] + 'mm';
	alertString += "( => " + internaldim + ":%20%20%20" + altProf + "mm%20x%20" + larghProfTxt + ")%0A%0A";
   	for (var i in profiles) {
   		if (profiles[i] != 0) {
   			if (i == '6500') { // should never happen!
   				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) {
   	    alertString += cordlen + "%20x%20MFGK06GR%20(50m)%0A"; 	
   	}
   	if (connector > 0) {
   		alertString += connector + "%20x%20MFV400AL%20(set02)%0A";	
   	}
   	if (tconnector > 0) {
   	    alertString += tconnector + "%20x%20MFTANG02%20(set02)%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").replace(/&ocirc;/g, "o").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a') + "%0A" 
   	+ proftext[1].replace(/<br \/>/g, "%0A").replace(/ /g,"%20").replace(/&ocirc;/g, "o").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a')
   	+ proftext[2].replace(/<br \/>/g, "%0A").replace(/ /g,"%20").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a')
   	+ proftext[3].replace(/<br \/>/g, "%0A").replace(/ /g,"%20").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a')
   	+ proftext[4].replace(/<br \/>/g, "%0A").replace(/ /g,"%20").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a')
   	+ proftext[5].replace(/<br \/>/g, "%0A").replace(/ /g,"%20").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a')
   	+ proftext[6].replace(/<br \/>/g, "%0A").replace(/ /g,"%20").replace(/&eacute;/g, 'e').replace(/&agrave;/g, 'a') + "%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') { //should never happen
				addprice = profiles[i]*productData['MFP6500AL'];
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP6500AL (€ " + productData['MFP6500AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + addprice.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '5100') {
				addprice = profiles[i]*productData['MFP5100AL'];
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP5100AL (€ " + productData['MFP5100AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + addprice.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '4100') {
				addprice = profiles[i]*productData['MFP4100AL'];
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP4100AL (€ " + productData['MFP4100AL'].toFixed(2).replace('.',',') + "0)</td><td align='right'>€ " + addprice.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '3100') {
				addprice = profiles[i]*productData['MFP3100AL'];
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP3100AL (€ " + productData['MFP3100AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + addprice.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '2100') {
				addprice = profiles[i]*productData['MFP2100AL'];
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP2100AL (€ " + productData['MFP2100AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + addprice.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
			}
			else if (i == '1100') {
				addprice = profiles[i]*productData['MFP1100AL'];
				totalprice += addprice;
				alertString += "<tr><td>" + profiles[i] + " x MFP1100AL (€ " + productData['MFP1100AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + addprice.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
			}
			else {
				alert("error!");
			}
		}
	}
	totalprice += productData['MFA110AR']; //cornerset
	alertString += "<tr><td>" + "1 x MFA110AR (set04   € " + productData['MFA110AR'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + productData['MFA110AR'].toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	if (whmt) {
	   totalprice += set * productData['MFWH01AL']; //suppset metall
	   val = set * productData['MFWH01AL'];
	   alertString += "<tr><td>" + set + " x MFWH01AL (set02   € " + productData['MFWH01AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	else {
	   totalprice += set * productData['MFWH03AL'];
	   val = set * productData['MFWH03AL'];
	   alertString += "<tr><td>" + set + " x MFWH03AL (set02   € " + productData['MFWH03AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	totalprice += boxclips * productData['MFTP22GR']; //clipsset  
	val = boxclips * productData['MFTP22GR'];
	alertString += "<tr><td>" + boxclips + " x MFTP22GR (box20    € " + productData['MFTP22GR'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";	
	if (clamp) {
		totalprice += boxclamp * productData['ACL3540WE'];
		val = boxclamp * productData['ACL3540WE'];
		alertString += "<tr><td>" + boxclamp + " x ACL3540WE (box20   € " + productData['ACL3540WE'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	if (eyelet) {
		totalprice += box50 * productData['AEY3012TR'];
		val = box50 * productData['AEY3012TR'];
		alertString += "<tr><td>" + box50 + " x AEY3012TR (box50   € " + productData['AEY3012TR'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
    if (ring) {
		totalprice += boxschlaufe * productData['AGK60TR'];
		val = boxschlaufe * productData['AGK60TR'];
		alertString += "<tr><td>" + boxschlaufe + " x AGK60TR (box20    € " + productData['AGK60TR'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	if (connector > 0) {
		totalprice += connector * productData['MFV400AL'];
		val = connector * productData['MFV400AL'];
		alertString += "<tr><td>" + connector + " x MFV400AL (set02    € " + productData['MFV400AL'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	if (tconnector > 0) {
		totalprice += tconnector * productData['MFTANG02'];
		val = tconnector * productData['MFTANG02'];
		alertString += "<tr><td>" + tconnector + " x MFTANG02 (set02    € " + productData['MFTANG02'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	if (corda) {
		totalprice += cordlen * productData['MFGK06GR'];
		val = cordlen * productData['MFGK06GR'];
		alertString += "<tr><td>" + cordlen + " x MFGK06GR (50m    € " + productData['MFGK06GR'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</td><td>&nbsp;</td></tr>";
	}
	if (ganci) {
		totalprice += boxganci * productData['AGK30GR'];
		val = boxganci * productData['AGK30GR'];
		alertString += "<tr><td>" + boxganci + " x AGK30GR (box20     € " + productData['AGK30GR'].toFixed(2).replace('.',',') + ")</td><td align='right'>€ " + val.toFixed(2).replace('.',',') + "</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).replace('.',',') + "</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).replace('.',',') + "</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).replace('.',',');
}

function resetAll() {
	connector = 0;
	larghProf = 0;
	altProf = 0;
	pz = 0;
	set = 0;
	boxganci = 0;
	boxclamp = 0;
	boxschlaufe = 0;
	boxclips = 0;
	box50 = 0;
	cordlen = 0;
	ext = "empty";
	corda = false;
	ganci = true;
	clamp = false;
	ring = false;
	eyelet = true;
	moduleCount = 1;
	connector = 0;
	tconnector = 0;
    whmt = false;
    document.datapart.multiframe.checked = false;
	document.datapart.cordaclamp[0].checked = true;
	document.datapart.cordaclamp[1].checked = false;
	document.datapart.cordaclamp[2].checked = false;
	document.datapart.extbanner[0].checked = false;
	document.datapart.extbanner[1].checked = true;
	document.datapart.moduleCount[0].checked = true;
	document.datapart.moduleCount[1].checked = false;
	document.datapart.moduleCount[2].checked = false;
	document.datapart.moduleCount[3].checked = false;
	document.datapart.moduleCount[4].checked = false;
	document.datapart.moduleCount[5].checked = false;
	document.datapart.altezza.value = "";
	document.datapart.larghezza.value = "";
	document.datapart.larghezza2.value = "";
	document.datapart.larghezza3.value = "";
	document.datapart.larghezza4.value = "";
	document.datapart.larghezza5.value = "";
	document.datapart.larghezza6.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("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";
    fclick('banner');
}

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();

