var calc_form = document.getElementById("calc_form");
var aProfilAusfuehrungOptionen = new Array("Ueberfaelztes_Tuerblatt","Stumpfeinschlagendes_Tuerblatt","Doppelfalz","Schattennut","Schattennut_mit_Uebergreifung","Ueberhoehter_Spiegel","Verglasung_1seitig","Verglasung_2seitig","Leibungszarge")
var rpTimeout;
var rmTimeout;

function montageChanged(sel) {
	var selGroupName = calc_form.calc_gruppe.options[calc_form.calc_gruppe.selectedIndex].value;
	var oSelect = calc_form.calc_profilnr;
	var oSelectLen = oSelect.options.length;
	var z_selected = 0;
	
	//Daten einlesen
	/*
	if(oSelect.options[0].value.substr(0,1)!='S')
			return false;
	*/
	
	// Auswahl der Zargen auf 0 stellen
	/*
	for(var i = 0;i < oSelectLen;i++) {
		oSelect.options[0] = null;
	}
	*/
	
	// Montage nicht selektieren oder verstecken
	document.getElementById('div_calc_montage_dbl').style.backgroundColor='transparent';
	document.getElementById('div_calc_montage_dbl').style.color='#000000';
	document.getElementById('div_calc_montage_gkt').style.backgroundColor='transparent';
	document.getElementById('div_calc_montage_gkt').style.color='#000000';
	document.getElementById('div_calc_montage_mwk').style.backgroundColor='transparent';
	document.getElementById('div_calc_montage_mwk').style.color='#000000';
	document.getElementById('div_calc_montage_ren').style.backgroundColor='transparent';
	document.getElementById('div_calc_montage_ren').style.color='#000000';
	document.getElementById('div_calc_montage_san').style.backgroundColor='transparent';
	document.getElementById('div_calc_montage_san').style.color='#000000';
	
	for (var ZargenElement in Zargen) {
		if(Zargen[ZargenElement]["Gruppe"]==selGroupName) {
			z_selected = 0;
			// Überprüfe, ob diese Selektion schon vorhanden ist
			for(var i = oSelectLen-1; i>=0; i--) {
				if (oSelect.options[i].value.substr(0,3)==ZargenElement)
					z_selected = 1;
			}
			// Neue Zarge hinzufügen
			if (z_selected == 0)
				oSelect.options.add(new Option(ZargenElement + ' - ' + Zargen[ZargenElement]["Typ"],ZargenElement));
		}
	}
	
	//Daten filtern
	var oSelectLen = oSelect.options.length;
	for(var i = oSelectLen-1;i>=0;i--) {
		try {
			if(sel == 'ren') {
				if((oSelect.options[i].value.substr(0,1)=='E') || (oSelect.options[i].value.substr(0,1)=='G') || oSelect.options[i].value.substr(0,2)=='F4')
					oSelect.options[i] = null;
			}
			
			if(calc_form.calc_t30.checked) {
				if((oSelect.options[i].value.substr(0,1)=='D') || (oSelect.options[i].value.substr(0,1)=='G') || oSelect.options[i].value.substr(0,1)=='P')
					oSelect.options[i] = null;
			}
			
			if(sel == 'gkt' && calc_form.calc_t30.checked) {
				if(oSelect.options[i].value.substr(0,1)=='E')
					oSelect.options[i] = null;
			}
			
			if(sel == 'san') {
				if(oSelect.options[i].value.substr(0,2)!='S3')
					oSelect.options[i] = null;
			}
			
			if(sel != 'san') {
				if(oSelect.options[i].value.substr(0,2)=='S3')
					oSelect.options[i] = null;
			}
		}
		catch(err) {
		}
	}
	
	// Sanierungszarge
	if(sel == 'san') {
		hideElement('div_Leibungszarge');
	}
	
	if((calc_form.calc_t30.checked) && (calc_form.calc_montage[1].checked) && ( (oSelect.options[oSelect.selectedIndex].value.substr(0,1)=='U') || (oSelect.options[oSelect.selectedIndex].value.substr(0,1)=='B') || ((oSelect.options[oSelect.selectedIndex].value.substr(0,1)=='Z')) ) ) {
		showGroupbox('T-30 mit harter Steinwolle')
	} else {
		hideGroupbox('T-30 mit harter Steinwolle');
		calc_form.calc_t30_steinwolle.checked = false;
		document.getElementById('calc_t30_steinwolle').style.backgroundColor='transparent';
		document.getElementById('calc_t30_steinwolle').style.color='#000000';
	}
	
	if (calc_form.calc_t30.checked) {
		document.getElementById('div_calc_montage_dbl').style.backgroundColor='#cccccc';
		document.getElementById('div_calc_montage_dbl').style.color='#666666';
		document.getElementById('div_calc_montage_ren').style.backgroundColor='#cccccc';
		document.getElementById('div_calc_montage_ren').style.color='#666666';
	}
	
	if (calc_form.calc_montage[0].checked) {
		document.getElementById(calc_form.calc_montage[0].parentNode.id).style.backgroundColor='#8eafc1';
		document.getElementById(calc_form.calc_montage[0].parentNode.id).style.color='#000000';
	}
	if (calc_form.calc_montage[1].checked) {
		document.getElementById(calc_form.calc_montage[1].parentNode.id).style.backgroundColor='#8eafc1';
		document.getElementById(calc_form.calc_montage[1].parentNode.id).style.color='#000000';
	}
	
	document.getElementById('preview_image').src = 'images/zargen/' + oSelect.options[oSelect.selectedIndex].value + '.jpg';
	
	refreshProfileSettings();
}

//Bei der Eingabe muss es sich um eine Zahl (mit 2 Dezimalstellen) handeln
function isFloat(inputField) {
	var cval = parseFloat(inputField.value.replace(/,/,"."));
	if(!inputField.value.length==0) {
		if(!isNaN(cval)) {
			inputField.value = String(cval).replace(/\./,",");
			inputField.backupvalue = inputField.value;
		} else {
			inputField.value = inputField.backupvalue;
		}
	}
}

function kalkulationStarten()
{
	var wo1 = (document.getElementById('warning_profilundmaulweite').style.display == 'block');
	var wo2 = (document.getElementById('warning_profilundmaulweite_min').style.display == 'block');
	
	var wo3 = (document.getElementById('warning_spiegelbreite').style.display == 'block');
	var wo4 = (document.getElementById('warning_spiegelbreite_min').style.display == 'block');
	
	var wo5 = (document.getElementById('warning_stocklichte_breite').style.display == 'block');
	var wo6 = (document.getElementById('warning_stocklichte_breite_min').style.display == 'block');
	
	var wo7 = (document.getElementById('warning_stocklichte_hoehe').style.display == 'block');
	var wo8 = (document.getElementById('warning_stocklichte_hoehe_min').style.display == 'block');
	
	var wo9 = (document.getElementById('warning_durchgangslichte_hoehe').style.display == 'block');
	var wo10 = (document.getElementById('warning_durchgangslichte_hoehe_min').style.display == 'block');
	
	var wo11 = (document.getElementById('warning_durchgangslichte_breite').style.display == 'block');
	var wo12 = (document.getElementById('warning_durchgangslichte_breite_min').style.display == 'block');
	
	var formHasError = (wo1 || wo2 || wo3 || wo4 || wo5 || wo6 || wo7 || wo8 || wo9 || wo10 || wo11 || wo12);
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!')
	} else {
		var formIsNotFiled = false;
		
		if(document.getElementById('groupbox_Profilbreite und Maulweite').style.display == 'block') {
			var iTmp = parseInt(calc_form.calc_maulweite.value);
			if(!formIsNotFiled)
				formIsNotFiled = isNaN(iTmp);
		}
		
		if(document.getElementById('stocklichte').style.display == 'block') {
			var iTmp = parseInt(calc_form.calc_stocklichte_hoehe.value);
			if(!formIsNotFiled)
				formIsNotFiled = isNaN(iTmp);
			var iTmp = parseInt(calc_form.calc_stocklichte_breite.value);
			if(!formIsNotFiled)
				formIsNotFiled = isNaN(iTmp);
		}
		
		if(document.getElementById('groupbox_Spiegelbreite').style.display == 'block') {
			var iTmp = parseInt(calc_form.calc_spiegelbreite.value);
			if(!formIsNotFiled)
				formIsNotFiled = isNaN(iTmp);
		}
		
		if(document.getElementById('durchgangslichte').style.display == 'block') {
			var iTmp = parseInt(calc_form.calc_durchgangslichte_breite.value);
			if(!formIsNotFiled)
				formIsNotFiled = isNaN(iTmp);
			var iTmp = parseInt(calc_form.calc_durchgangslichte_hoehe.value);
			if(!formIsNotFiled)
				formIsNotFiled = isNaN(iTmp);
		}
		
		if(formIsNotFiled) {
			alert('Es wurden nicht alle relevanten Daten ausgefüllt.\n\Vervollständigen Sie Ihre Eingaben!')
		} else {
			calc_form.submit()
		}
	}
}

function recalcGlasflaechen() {
	var gf = (parseInt(calc_form.calc_kaempfer_vertikal.value)+1) * (parseInt(calc_form.calc_kaempfer_horizontal.value)+1);
	var output = document.getElementById('info_glasflaechen');
	
	output.innerHTML = '<img align="absmiddle" src="images/main/icon_info.png">&nbsp;d.h. die Glasfläche ist ' + gf + '-teilig.';
}

function refreshProfiles() {
	if (calc_form.calc_id == "") {
		calc_form.calc_t30.checked = false;
		document.getElementById('calc_t30').style.backgroundColor='transparent';
		document.getElementById('calc_t30').style.color='#000000';
	}
	t30montage(false);
	
	var selGroupName = calc_form.calc_gruppe.options[calc_form.calc_gruppe.selectedIndex].value;
	var oSelect = calc_form.calc_profilnr;
	var oSelectLen = oSelect.options.length;
	
	//Daten einlesen
	for(var i = 0;i < oSelectLen;i++) {
		oSelect.options[0] = null;
	}
	
	for (var ZargenElement in Zargen) {
		if(Zargen[ZargenElement]["Gruppe"]==selGroupName) {
			oSelect.options.add(new Option(ZargenElement + ' - ' + Zargen[ZargenElement]["Typ"],ZargenElement));
		}
	}
	
	//Daten filtern
	var oSelectLen = oSelect.options.length;
	for(var i = oSelectLen-1;i>=0;i--) {
		// Vorauswahl ändern, wenn Sanierungszarge gewählt
		if (radioWert(calc_form.calc_montage) == "san") {
			if(oSelect.options[i].value.substr(0,2) != 'S3')
				oSelect.options[i] = null;
		} else {
			if(oSelect.options[i].value.substr(0,2)=='S3')
				oSelect.options[i] = null;
		}
	}
	
	//T30 Brandschutz
	calc_form.calc_t30.disabled = (selGroupName!='Türzargen')
	if(calc_form.calc_t30.disabled) {
		document.getElementById('sel_t30montage').style.backgroundColor='transparent';
		document.getElementById('sel_t30montage').style.color='#000000';
		calc_form.calc_t30.checked = false;
		showElement('info_t30montage');
		hideElement('sel_t30montage');
	} else {
		hideElement('info_t30montage');
		showElement('sel_t30montage');
	}
	
	calc_form.calc_montage[0].checked = true;
	document.getElementById(calc_form.calc_montage[0].parentNode.id).style.backgroundColor='#8eafc1';
	document.getElementById(calc_form.calc_montage[0].parentNode.id).style.color='#000000';
	
	//Gruppen nur für Schiebetürelemente
	if(selGroupName=='Schiebetürelemente') {
		calc_form.calc_montage[2].disabled = true;
		document.getElementById(calc_form.calc_montage[2].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_montage[2].parentNode.id).style.color='#666666';
		showElement('div_Leibungszarge');
		hideElement('div_calc_montage_ren');
		showElement('div_calc_montage_san');
		showElement('stocklichte_schiebetueren');
		showGroupbox('Seitenbestimmung');
	} else {
		calc_form.calc_montage[2].disabled = false;
		document.getElementById(calc_form.calc_montage[2].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_montage[2].parentNode.id).style.color='#000000';
		hideElement('div_Leibungszarge');
		hideElement('div_calc_montage_san');
		showElement('div_calc_montage_ren');
		hideElement('stocklichte_schiebetueren');
		hideGroupbox('Seitenbestimmung');
		document.getElementById('calc_schiebetueren_anz_links').value='0';
		document.getElementById('calc_schiebetueren_anz_rechts').value='0';
	}
	
	//Gruppen nur für Fensterzargen
	if(selGroupName=='Fensterzargen') {
		hideGroupbox('Türblatt');
		hideGroupbox('Bodeneinstand');
		showGroupbox('Verglasung');
		showGroupbox('Kämpfer');
		//showGroupbox('Stocklichte');
		hideGroupbox('Durchgangslichte');
		showGroupbox('Glaslichte');
		showElement('stocklichte');
		hideElement('durchgangslichte');
		showGroupbox('Spiegelbreite');
		if(calc_form.calc_spiegelbreite.value == 0) {
			calc_form.calc_spiegelbreite.value = spiegelbreite_temp;
		}
	} else {
		showGroupbox('Türblatt');
		showGroupbox('Bodeneinstand');
		hideGroupbox('Verglasung');
		hideGroupbox('Kämpfer');
		//hideGroupbox('Stocklichte');
		showGroupbox('Durchgangslichte');
		hideGroupbox('Glaslichte');
		hideElement('stocklichte');
		showElement('durchgangslichte');
		hideGroupbox('Spiegelbreite');
		spiegelbreite_temp = calc_form.calc_spiegelbreite.value;
		calc_form.calc_spiegelbreite.value = 0;
	}
	
	//Gruppen nur für Türzargen
	if(selGroupName=='Türzargen') {
		showGroupbox('Bandaufnahmen');
		showGroupbox('Bandaufnahmen Seitenbestimmung');
	} else {
		hideGroupbox('Bandaufnahmen');
		hideGroupbox('Bandaufnahmen Seitenbestimmung');
	}
	
	if(selGroupName=='Türzargen' && ((oSelect.options[oSelect.selectedIndex].value.substr(0,1)!='D') && (oSelect.options[oSelect.selectedIndex].value.substr(0,1)!='G') && (oSelect.options[oSelect.selectedIndex].value.substr(0,1)!='P')) ) {
		showGroupbox('Zusätzliche Glaslichten');
		showGroupbox('Einbruchhemmend');
		showGroupbox('Anschlagschienen');
		showGroupbox('Zusätzliche Sonderaufnahmen');
		showGroupbox('Bandaufnahmen Seitenbestimmung');
	} else {
		hideGroupbox('Zusätzliche Glaslichten');
		hideGroupbox('Einbruchhemmend');
		hideGroupbox('Anschlagschienen');
		hideGroupbox('Zusätzliche Sonderaufnahmen');
		hideGroupbox('Bandaufnahmen Seitenbestimmung');
	}
	
	for(var e = 0;e<document.getElementsByTagName('div').length;e++) {
		if(document.getElementsByTagName('div')[e].className=='warning')
			document.getElementsByTagName('div')[e].style.display = 'none';
	}
	
	//Montage Renovierungszarge 2-teilig
	/*
	var ren_state = (oSelect.value.substr(0,2)=='F4') || (oSelect.value.substr(0,1)=='G') || (oSelect.value.substr(0,1)=='E')
	calc_form.calc_montage[3].disabled = ren_state;
	*/
	
	// Ausbleden von 'Überhöhter Gegenspiegel' bei F3x und F4x
	if (oSelect.value.substr(0,2) == 'F3' || oSelect.value.substr(0,2) == 'F4') {
		hideElement('div_Ueberhoehter_Spiegel');
	} else {
		showElement('div_Ueberhoehter_Spiegel');
	}
	
	refreshProfileSettings();
	adoptMinMaxDefValues(selGroupName,oSelect.value);
}

function showGroupbox(gpid) {
	try {
		document.getElementById('groupbox_'+gpid).style.display = 'block';
	}
	catch(err) {
		alert("Fehler beim Versuch, die Gruppe " + gpid + " einzublenden.");
	}
}

function hideGroupbox(gpid) {
	try {
		document.getElementById('groupbox_'+gpid).style.display = 'none';
	}
	catch(err) {
		alert("Fehler beim Versuch, die Gruppe " + gpid + " auszublenden.");
	}
}

function showElement(elemId) {
	try {
		document.getElementById(elemId).style.display = 'block';
	}
	catch(err) {
		alert("Fehler beim Versuch, das Element " + elemId + " einzublenden.");
	}
}

function hideElement(elemId) {
	try {
		document.getElementById(elemId).style.display = 'none';
	}
	catch(err) {
		alert("Fehler beim Versuch, das Element " + elemId + " auszublenden.");
	}
}

function refreshProfilausfuehrung() {
	var oSelect = calc_form.calc_profilnr;
	var profilNr = oSelect.options[oSelect.selectedIndex].value;
	var sZargenProfil = Zargen[profilNr]["Profil"];
	var F4correction = 0;
	if(profilNr.substr(0,2)=='F4')
		F4correction = 30;
	
	if((!calc_form.Stumpfeinschlagendes_Tuerblatt.checked && !calc_form.Ueberfaelztes_Tuerblatt.checked) && !(!calc_form.Stumpfeinschlagendes_Tuerblatt.disabled || !calc_form.Ueberfaelztes_Tuerblatt.disabled || calc_form.Ueberfaelztes_Tuerblatt.disabled)) {
		calc_form.Ueberfaelztes_Tuerblatt.checked = true;
		document.getElementById("div_Ueberfaelztes_Tuerblatt").style.backgroundColor='#8eafc1';
		document.getElementById("div_Ueberfaelztes_Tuerblatt").style.color='#000000';
	} else {
		if (!calc_form.Ueberfaelztes_Tuerblatt.checked) {
			document.getElementById("div_Ueberfaelztes_Tuerblatt").style.backgroundColor='transparent';
			document.getElementById("div_Ueberfaelztes_Tuerblatt").style.color='#000000';
		} else {
			document.getElementById("div_Ueberfaelztes_Tuerblatt").style.backgroundColor='#8eafc1';
			document.getElementById("div_Ueberfaelztes_Tuerblatt").style.color='#000000';
		}
	}
	
	var aAusgewaehlteOptionen = new Array();
	
	for(var i = 0;i < aProfilAusfuehrungOptionen.length;i++) {
		aAusgewaehlteOptionen[i] = calc_form.elements[aProfilAusfuehrungOptionen[i]].checked;
		/*
			0: Ueberfaelztes_Tuerblatt
			1: Stumpfeinschlagendes_Tuerblatt
			2: Doppelfalz
			3: Schattennut
			4: Schattennut_mit_Uebergreifung
			5: Ueberhoehter_Spiegel
			6: Verglasung_1seitig
			7: Verglasung_2seitig
			8: Leibungszarge
		*/
	}
	
	var sNewProfilNr = sZargenProfil.substr(0,1);
	var vNewProfilNr = 10;
	
	if(sNewProfilNr=='F') {
		// Stumpfeinschlagendes Türblatt
		if(calc_form.Ueberhoehter_Spiegel.checked) {
			vNewProfilNr += 10;
			calc_form.Verglasung_2seitig.checked = false;
			document.getElementById('div_Verglasung_2seitig').style.backgroundColor='transparent';
			document.getElementById('div_Verglasung_2seitig').style.color='#000000';
			calc_form.Verglasung_1seitig.checked = true;
			document.getElementById('div_Verglasung_1seitig').style.backgroundColor='#8eafc1';
			document.getElementById('div_Verglasung_1seitig').style.color='#000000';
		}
		
		// Doppelfalz
		if(calc_form.Verglasung_2seitig.checked) {
			vNewProfilNr = 30;
			document.getElementById("div_Doppelfalz").style.backgroundColor='#8eafc1';
			document.getElementById('div_Doppelfalz').style.color='#000000';
		} else {
			document.getElementById("div_Doppelfalz").style.backgroundColor='transparent';
			document.getElementById('div_Doppelfalz').style.color='#000000';
		}
		
		// F4* Korrekturwert
		if(!calc_form.Ueberhoehter_Spiegel.checked) {
			vNewProfilNr += F4correction;
			document.getElementById("div_Ueberhoehter_Spiegel").style.backgroundColor='#8eafc1';
			document.getElementById('div_Ueberhoehter_Spiegel').style.color='#000000';
		} else {
			document.getElementById("div_Ueberhoehter_Spiegel").style.backgroundColor='transparent';
			document.getElementById('div_Ueberhoehter_Spiegel').style.color='#000000';
		}
	} else {
		// Stumpfeinschlagendes Türblatt
		if(aAusgewaehlteOptionen[1]) {
			vNewProfilNr += 10;
			document.getElementById("div_Stumpfeinschlagendes_Tuerblatt").style.backgroundColor='#8eafc1';
			document.getElementById('div_Stumpfeinschlagendes_Tuerblatt').style.color='#000000';
		} else {
			document.getElementById("div_Stumpfeinschlagendes_Tuerblatt").style.backgroundColor='transparent';
			document.getElementById('div_Stumpfeinschlagendes_Tuerblatt').style.color='#000000';
		}
		
		// Doppelfalz
		if(aAusgewaehlteOptionen[2]) {
			vNewProfilNr += 20;
			document.getElementById("div_Doppelfalz").style.backgroundColor='#8eafc1';
			document.getElementById('div_Doppelfalz').style.color='#000000';
		} else {
			document.getElementById("div_Doppelfalz").style.backgroundColor='transparent';
			document.getElementById('div_Doppelfalz').style.color='#000000';
		}
	}
	
	// Schattennut
	if(aAusgewaehlteOptionen[3]) {
		vNewProfilNr += 2;
		document.getElementById("div_Schattennut").style.backgroundColor='#8eafc1';
		document.getElementById('div_Schattennut').style.color='#000000';
	} else {
		document.getElementById("div_Schattennut").style.backgroundColor='transparent';
		document.getElementById('div_Schattennut').style.color='#000000';
	}
	
	// Schattennut mit Übergreifung
	if(aAusgewaehlteOptionen[4]) {
		vNewProfilNr += 4;
		document.getElementById("div_Schattennut_mit_Uebergreifung").style.backgroundColor='#8eafc1';
		document.getElementById('div_Schattennut_mit_Uebergreifung').style.color='#000000';
	} else {
		document.getElementById("div_Schattennut_mit_Uebergreifung").style.backgroundColor='transparent';
		document.getElementById('div_Schattennut_mit_Uebergreifung').style.color='#000000';
	}
	
	// Ueberhoehter_Spiegel
	if(aAusgewaehlteOptionen[5]) {
		document.getElementById("div_Ueberhoehter_Spiegel").style.backgroundColor='#8eafc1';
		document.getElementById('div_Ueberhoehter_Spiegel').style.color='#000000';
	} else {
		document.getElementById("div_Ueberhoehter_Spiegel").style.backgroundColor='transparent';
		document.getElementById('div_Ueberhoehter_Spiegel').style.color='#000000';
	}
	
	// Leibungszarge
	if(aAusgewaehlteOptionen[8]) {
		vNewProfilNr += 10;
		document.getElementById("div_Leibungszarge").style.backgroundColor='#8eafc1';
		document.getElementById('div_Leibungszarge').style.color='#000000';
	} else {
		document.getElementById("div_Leibungszarge").style.backgroundColor='transparent';
		document.getElementById('div_Leibungszarge').style.color='#000000';
	}
	
	// Sanierungszarge
	if(radioWert(calc_form.calc_montage)=='san') {
		vNewProfilNr += 20;
		if (document.getElementById("div_Sanierungszarge") !== null) {
			document.getElementById("div_Sanierungszarge").style.backgroundColor='#8eafc1';
			document.getElementById('div_Sanierungszarge').style.color='#000000';
		}
	} else {
		if (document.getElementById("div_Sanierungszarge") !== null) {
			document.getElementById("div_Sanierungszarge").style.backgroundColor='transparent';
			document.getElementById('div_Sanierungszarge').style.color='#000000';
		}
	}
	
	// Ueberhoehter_Spiegel
	var selGroupName = calc_form.calc_gruppe.options[calc_form.calc_gruppe.selectedIndex].value;
	
	if(aAusgewaehlteOptionen[5] && selGroupName == 'Türzargen')
		sNewProfilNr = 'B';
	
	if(sNewProfilNr == 'B') {
		calc_form.Ueberhoehter_Spiegel.checked = true;
		document.getElementById("div_Ueberhoehter_Spiegel").style.backgroundColor='#8eafc1';
		document.getElementById('div_Ueberhoehter_Spiegel').style.color='#000000';
	}
	
	sNewProfilNr = sNewProfilNr + vNewProfilNr;
	
	for(var o = 0;o < oSelect.options.length;o++) {
		if(oSelect.options[o].value==sNewProfilNr) {
			oSelect.selectedIndex = o;
			break;
		}
	}
	var profilTyp = sNewProfilNr.substr(0,1);
	
	// Montage Renovierungszarge 2-teilig
	/*
	var ren_state = (oSelect.value.substr(0,2)=='F4') || (oSelect.value.substr(0,1)=='G') || (oSelect.value.substr(0,1)=='E')
	calc_form.calc_montage[3].disabled = ren_state;
	*/
	
	if(sNewProfilNr=='F40' || sNewProfilNr=='F42' || sNewProfilNr=='F44' || profilTyp=='E' || profilTyp=='G')
		hideGroupbox('Profilbreite und Maulweite');
	else
		showGroupbox('Profilbreite und Maulweite');
	
	resetProfilbreiteMaulweite();
	
	document.getElementById('preview_image').src = 'images/zargen/' + sNewProfilNr + '.jpg';
	
	// Ausbleden von 'Überhöhter Gegenspiegel' bei F3x und F4x
	if (sNewProfilNr.substr(0,2) == 'F3' || sNewProfilNr.substr(0,2) == 'F4') {
		hideElement('div_Ueberhoehter_Spiegel');
	} else {
		showElement('div_Ueberhoehter_Spiegel');
	}
	
	// Ganzglasbürblätter deaktivieren
	if (((oSelect.value.substr(1,1)!='1') && (oSelect.value!='S20') && (oSelect.value.substr(0,2)!='S3')) || (calc_form.calc_t30.checked == true)) {
		calc_form.calc_tuerblatt[1].disabled = true;
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.color='#666666';
		if(calc_form.calc_tuerblatt[1].checked) {
			calc_form.calc_tuerblatt[0].checked = true;
			document.getElementById(calc_form.calc_tuerblatt[0].parentNode.id).style.backgroundColor='#8eafc1';
			document.getElementById(calc_form.calc_tuerblatt[0].parentNode.id).style.color='#000000';
		}
	} else {
		calc_form.calc_tuerblatt[1].disabled = false;
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.color='#000000';
	}
	
	// Deaktivieren von Simons Tectus 510-3D
	if(calc_form.Stumpfeinschlagendes_Tuerblatt.checked || calc_form.calc_t30.checked) {
		calc_form.calc_baender[4].disabled = false;
		document.getElementById('calc_baender_35').style.backgroundColor='transparent';
		document.getElementById('calc_baender_35').style.color='#000000';
		calc_form.calc_baender[5].disabled = false;
		document.getElementById('calc_baender_5').style.backgroundColor='transparent';
		document.getElementById('calc_baender_5').style.color='#000000';
	} else {
		calc_form.calc_baender[4].disabled = true;
		document.getElementById('calc_baender_35').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_35').style.color='#666666';
		calc_form.calc_baender[5].disabled = true;
		document.getElementById('calc_baender_5').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_5').style.color='#666666';
	}
	
	// Profilbreite / Maulweite an Z-Profile anpassen
	adoptMinMaxDefValues(calc_form.calc_gruppe[calc_form.calc_gruppe.selectedIndex].value, oSelect.value)
}

function refreshProfileSettings() {
	var oSelect = calc_form.calc_profilnr;
	var profilNr = oSelect.options[oSelect.selectedIndex].value;
	var profilTyp = profilNr.substr(0,1);
	
	document.getElementById('preview_image').src = 'images/zargen/' + profilNr + '.jpg';
	
	for(var i = 0;i < aProfilAusfuehrungOptionen.length;i++) {
		calc_form.elements[aProfilAusfuehrungOptionen[i]].checked = Zargen[profilNr][aProfilAusfuehrungOptionen[i]];
		if (Zargen[profilNr][aProfilAusfuehrungOptionen[i]]) {
			if (document.getElementById("div_" + aProfilAusfuehrungOptionen[i]) !== null) {
				document.getElementById("div_" + aProfilAusfuehrungOptionen[i]).style.backgroundColor='#8eafc1';
				document.getElementById("div_" + aProfilAusfuehrungOptionen[i]).style.color='#000000';
			}
		} else {
			if (document.getElementById("div_" + aProfilAusfuehrungOptionen[i]) !== null) {
				document.getElementById("div_" + aProfilAusfuehrungOptionen[i]).style.backgroundColor='transparent';
				document.getElementById("div_" + aProfilAusfuehrungOptionen[i]).style.color='#000000';
			}
		}
	}
	
	var profilNrText = oSelect.options[oSelect.selectedIndex].text;
	profilNrText = profilNrText.substr(2+profilNrText.indexOf("-"),128);
	calc_form.calc_profilnr_typ.value = profilNrText;
	
	if( profilTyp=='P' || profilTyp=='D' || profilTyp=='G' ) {
		hideGroupbox('Zusätzliche Glaslichten');
		hideGroupbox('Einbruchhemmend');
		hideGroupbox('Anschlagschienen');
		hideGroupbox('Zusätzliche Sonderaufnahmen');
		hideGroupbox('Bandaufnahmen Seitenbestimmung');
	}
	
	if( profilTyp=='E' || profilTyp=='U' || profilTyp=='B' || profilTyp=='Z' ) {
		showGroupbox('Zusätzliche Glaslichten');
		showGroupbox('Einbruchhemmend');
		showGroupbox('Anschlagschienen');
		showGroupbox('Zusätzliche Sonderaufnahmen');
		showGroupbox('Bandaufnahmen Seitenbestimmung');
	}
	
	if(profilTyp=='F' || profilTyp=='D' || profilTyp=='G' || profilTyp=='P' || profilTyp=='S') {
		calc_form.calc_t30.checked = false;
		calc_form.calc_t30.disabled = true;
		document.getElementById('sel_t30montage').style.backgroundColor='#cccccc';
		document.getElementById('sel_t30montage').style.color='#666666';
		calc_form.Ueberfaelztes_Tuerblatt.checked = false;
		calc_form.Ueberfaelztes_Tuerblatt.disabled = true;
		document.getElementById('div_Ueberfaelztes_Tuerblatt').style.backgroundColor='#cccccc';
		document.getElementById('div_Ueberfaelztes_Tuerblatt').style.color='#666666';
		calc_form.Stumpfeinschlagendes_Tuerblatt.checked = false;
		calc_form.Stumpfeinschlagendes_Tuerblatt.disabled = true;
		document.getElementById('div_Stumpfeinschlagendes_Tuerblatt').style.backgroundColor='#cccccc';
		document.getElementById('div_Stumpfeinschlagendes_Tuerblatt').style.color='#666666';
		calc_form.Doppelfalz.checked = false;
		calc_form.Doppelfalz.disabled = true;
		document.getElementById('div_Doppelfalz').style.backgroundColor='#cccccc';
		document.getElementById('div_Doppelfalz').style.color='#666666';
		
		if((profilTyp!='P') && (profilTyp!='S')) {
			hideGroupbox('Flügel');
		} else {
			showGroupbox('Flügel');
		}
		
		hideGroupbox('Bandaufnahmen');
		hideElement('div_Ueberfaelztes_Tuerblatt');
		hideElement('div_Stumpfeinschlagendes_Tuerblatt');
		hideElement('div_Doppelfalz');
	} else {
		calc_form.calc_t30.disabled = false;
		document.getElementById('sel_t30montage').style.backgroundColor='transparent';
		document.getElementById('sel_t30montage').style.color='#000000';
		
		showGroupbox('Bandaufnahmen');
		showElement('div_Ueberfaelztes_Tuerblatt');
		showElement('div_Stumpfeinschlagendes_Tuerblatt');
		showElement('div_Doppelfalz');
		calc_form.Ueberfaelztes_Tuerblatt.disabled = false;
//		document.getElementById('div_Ueberfaelztes_Tuerblatt').style.backgroundColor='transparent';
		document.getElementById('div_Ueberfaelztes_Tuerblatt').style.color='#000000';
		calc_form.Stumpfeinschlagendes_Tuerblatt.disabled = false;
//		document.getElementById('div_Stumpfeinschlagendes_Tuerblatt').style.backgroundColor='transparent';
		document.getElementById('div_Stumpfeinschlagendes_Tuerblatt').style.color='#000000';
		calc_form.Doppelfalz.disabled = false;
//		document.getElementById('div_Doppelfalz').style.backgroundColor='transparent';
		document.getElementById('div_Doppelfalz').style.color='#000000';
		showGroupbox('Flügel');
	}
	
	if(profilTyp=='S')
		hideElement('div_Ueberhoehter_Spiegel');
	else
		showElement('div_Ueberhoehter_Spiegel');
	
	if(profilTyp=='F') {
		//hideGroupbox('Durchgangslichte');
		showElement('stocklichte');
		hideElement('durchgangslichte');
	} else {
		//showGroupbox('Durchgangslichte');
		hideElement('stocklichte');
		showElement('durchgangslichte');
	}
	
	if(profilTyp=='G' || profilTyp=='E' || profilNr=='F40' || profilNr=='F42' || profilNr=='F44')
		hideGroupbox('Profilbreite und Maulweite');
	else
		showGroupbox('Profilbreite und Maulweite');
	
	//Montage Renovierungszarge 2-teilig
	/*
	var ren_state = (oSelect.value.substr(0,2)=='F4') || (oSelect.value.substr(0,1)=='G') || (oSelect.value.substr(0,1)=='E')
	calc_form.calc_montage[3].disabled = ren_state;
	*/
	
	//Montage T-30
	calc_form.calc_montage[1].disabled = (calc_form.calc_t30.checked && ( (oSelect.value.substr(0,1)!='B') &&  (oSelect.value.substr(0,1)!='Z') &&  (oSelect.value.substr(0,1)!='U') ));
	
	//Türblätter
	if((oSelect.value.substr(0,1)=='D') || (oSelect.value.substr(0,1)=='G') || (oSelect.value.substr(0,1)=='F'))
		hideGroupbox('Türblatt')
	else
		showGroupbox('Türblatt');
	
	//Deaktivieren von Simons Tectus 510-3D
	if(calc_form.Stumpfeinschlagendes_Tuerblatt.checked) {
		calc_form.calc_baender[4].disabled = false;
		document.getElementById('calc_baender_35').style.backgroundColor='transparent';
		document.getElementById('calc_baender_35').style.color='#000000';
		calc_form.calc_baender[5].disabled = false;
		document.getElementById('calc_baender_5').style.backgroundColor='transparent';
		document.getElementById('calc_baender_5').style.color='#000000';
	} else {
		calc_form.calc_baender[4].disabled = true;
		document.getElementById('calc_baender_35').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_35').style.color='#666666';
		calc_form.calc_baender[5].disabled = true;
		document.getElementById('calc_baender_5').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_5').style.color='#666666';
	}
	
	// Ausbleden von 'Überhöhter Gegenspiegel' bei F3x und F4x
	if (oSelect.value.substr(0,2) == 'F3' || oSelect.value.substr(0,2) == 'F4') {
		hideElement('div_Ueberhoehter_Spiegel');
	} else {
		showElement('div_Ueberhoehter_Spiegel');
	}
	
	//Ganzglastürblätter deaktivieren
	if( ( (oSelect.value.substr(1,1)!='1') && (oSelect.value!='S20') && (oSelect.value.substr(0,2)!='S3')) || (calc_form.calc_t30.checked == true) ) {
		calc_form.calc_tuerblatt[1].disabled = true;
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.color='#666666';
		if(calc_form.calc_tuerblatt[1].checked) {
			calc_form.calc_tuerblatt[0].checked = true;
			document.getElementById(calc_form.calc_tuerblatt[0].parentNode.id).style.backgroundColor='#8eafc1';
			document.getElementById(calc_form.calc_tuerblatt[0].parentNode.id).style.color='#000000';
		}
	} else {
		calc_form.calc_tuerblatt[1].disabled = false;
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.color='#000000';
	}
	
	//Deaktivieren von Optionen bei S20
	var schattennut = (oSelect.value=='S20');
	var schattennut_mit_uebergreifung = (oSelect.value=='S20');
	calc_form.Schattennut.disabled = schattennut;
	calc_form.Schattennut_mit_Uebergreifung.disabled = schattennut_mit_uebergreifung;
	
	//Profilbreite / Maulweite an Z-Profile anpassen
	adoptMinMaxDefValues(calc_form.calc_gruppe[calc_form.calc_gruppe.selectedIndex].value, oSelect.value)
	
	resetProfilbreiteMaulweite();
	
	//Deaktivieren von Simons Tectus 510-3D
	if(calc_form.Stumpfeinschlagendes_Tuerblatt.checked) {
		if(calc_form.calc_t30.checked) {
			calc_form.calc_baender[4].disabled = true;
			document.getElementById('calc_baender_35').style.backgroundColor='#cccccc';
			document.getElementById('calc_baender_35').style.color='#666666';
			calc_form.calc_baender[5].disabled = true;
			document.getElementById('calc_baender_5').style.backgroundColor='#cccccc';
			document.getElementById('calc_baender_5').style.color='#666666';
		} else {
			calc_form.calc_baender[4].disabled = false;
			document.getElementById('calc_baender_35').style.backgroundColor='transparent';
			document.getElementById('calc_baender_35').style.color='#000000';
			calc_form.calc_baender[5].disabled = false;
			document.getElementById('calc_baender_5').style.backgroundColor='transparent';
			document.getElementById('calc_baender_5').style.color='#000000';
		}
	} else {
		calc_form.calc_baender[4].disabled = true;
		document.getElementById('calc_baender_35').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_35').style.color='#666666';
		calc_form.calc_baender[5].disabled = true;
		document.getElementById('calc_baender_5').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_5').style.color='#666666';
	}
	
	//Hinterfüllt mit harter Steinwolle
	if((calc_form.calc_t30.checked) && (calc_form.calc_montage[1].checked) && ( (oSelect.options[oSelect.selectedIndex].value.substr(0,1)=='U') || (oSelect.options[oSelect.selectedIndex].value.substr(0,1)=='B') || ((oSelect.options[oSelect.selectedIndex].value.substr(0,1)=='Z')) ) ) {
		showGroupbox('T-30 mit harter Steinwolle')
	} else {
		hideGroupbox('T-30 mit harter Steinwolle');
		calc_form.calc_t30_steinwolle.checked = false;
	}
}

function refreshPage() {
	window.clearTimeout(rpTimeout);
	rpTimeout = window.setTimeout('refreshPageEx()',750);
}

function refreshPageEx() {
	document.getElementById("calc_form").submit();
}

function refreshMaulweite() {
	window.clearTimeout(rmTimeout);
	rmTimeout = window.setTimeout('refreshMaulweiteEx()',750);
}

function refreshMaulweiteEx() {
	var profilbreite = parseInt(calc_form.calc_profilbreite.value);
	
	if(isNaN(profilbreite)) {
		calc_form.calc_profilbreite.value = '';
		calc_form.calc_maulweite.value = '';
		document.getElementById('div_profilbreite').style.backgroundColor='transparent';
		document.getElementById('div_profilbreite').style.color='#000000';
		document.getElementById('div_maulweite').style.backgroundColor='transparent';
		document.getElementById('div_maulweite').style.color='#000000';
	} else {
		var profiltyp = parseInt(calc_form.calc_profilnr.options[calc_form.calc_profilnr.selectedIndex].value.substr(2,1));
		
		if(profiltyp==0)
			calc_form.calc_maulweite.value = (profilbreite - 20);
		
		if(profiltyp==2)
			calc_form.calc_maulweite.value = profilbreite;
		
		if(profiltyp==4) {
			var blechstaerke = radioWert(calc_form.calc_blech);
			calc_form.calc_maulweite.value = profilbreite - ( 2 * blechstaerke / 10);
		}
		
		//S20 Außnahme: Hier ist Profilbreite gleich Maulweite
		if(calc_form.calc_profilnr.options[calc_form.calc_profilnr.selectedIndex].value=='S20')
			calc_form.calc_maulweite.value = profilbreite;
		
		//Max Warning
		if((calc_form.calc_maulweite.value > parseInt(calc_form.calc_maulweite_maxvalue.value)) || (calc_form.calc_profilbreite.value > parseInt(calc_form.calc_profilbreite_maxvalue.value))) {
			showElement('warning_profilundmaulweite');
			if ((calc_form.calc_profilbreite.value > parseInt(calc_form.calc_profilbreite_maxvalue.value))) {
				calc_form.calc_profilbreite.value = calc_form.calc_profilbreite_maxvalue.value;
				document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
				document.getElementById('div_profilbreite').style.color='#000000';
			}
			if((calc_form.calc_maulweite.value > parseInt(calc_form.calc_maulweite_maxvalue.value))) {
				calc_form.calc_maulweite.value = calc_form.calc_maulweite_maxvalue.value;
				document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
				document.getElementById('div_maulweite').style.color='#000000';
			}
		} else {
			hideElement('warning_profilundmaulweite');
			document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
			document.getElementById('div_profilbreite').style.color='#000000';
			document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
			document.getElementById('div_maulweite').style.color='#000000';
		}
		
		//Min Warning
		if((calc_form.calc_maulweite.value < parseInt(calc_form.calc_maulweite_minvalue.value)) || (calc_form.calc_profilbreite.value < parseInt(calc_form.calc_profilbreite_minvalue.value))) {
			showElement('warning_profilundmaulweite_min');
			if ((calc_form.calc_profilbreite.value < parseInt(calc_form.calc_profilbreite_minvalue.value))) {
				calc_form.calc_profilbreite.value = calc_form.calc_profilbreite_minvalue.value;
				document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
				document.getElementById('div_profilbreite').style.color='#000000';
			}
			if((calc_form.calc_maulweite.value < parseInt(calc_form.calc_maulweite_minvalue.value))) {
				calc_form.calc_maulweite.value = calc_form.calc_maulweite_minvalue.value;
				document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
				document.getElementById('div_maulweite').style.color='#000000';
			}
		} else {
			hideElement('warning_profilundmaulweite_min');
			document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
			document.getElementById('div_profilbreite').style.color='#000000';
			document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
			document.getElementById('div_maulweite').style.color='#000000';
		}
	}
}

function refreshProfilbreite() {
	window.clearTimeout(rpTimeout);
	rpTimeout = window.setTimeout('refreshProfilbreiteEx()',750);
}

function refreshProfilbreiteEx() {
	var maulweite = parseInt(calc_form.calc_maulweite.value);
	
	if(isNaN(maulweite)) {
		calc_form.calc_maulweite.value = '';
		calc_form.calc_profilbreite.value = '';
		document.getElementById('div_profilbreite').style.backgroundColor='transparent';
		document.getElementById('div_profilbreite').style.color='#000000';
		document.getElementById('div_maulweite').style.backgroundColor='transparent';
		document.getElementById('div_maulweite').style.color='#000000';
	} else {
		var profiltyp = parseInt(calc_form.calc_profilnr.options[calc_form.calc_profilnr.selectedIndex].value.substr(2,1));
		
		if(profiltyp==0)
			calc_form.calc_profilbreite.value = (maulweite + 20);
		
		if(profiltyp==2)
			calc_form.calc_profilbreite.value = maulweite;
		
		if(profiltyp==4) {
			var blechstaerke = radioWert(calc_form.calc_blech);
			calc_form.calc_profilbreite.value = maulweite + ( 2 * blechstaerke / 10);
		}
		
		//S20 Außnahme: Hier ist Profilbreite gleich Maulweite
		if(calc_form.calc_profilnr.options[calc_form.calc_profilnr.selectedIndex].value=='S20')
			calc_form.calc_profilbreite.value = maulweite;
		
		//Max Warning
		if((calc_form.calc_maulweite.value > parseInt(calc_form.calc_maulweite_maxvalue.value)) || (calc_form.calc_profilbreite.value > parseInt(calc_form.calc_profilbreite_maxvalue.value))) {
			showElement('warning_profilundmaulweite');
			if ((calc_form.calc_profilbreite.value > parseInt(calc_form.calc_profilbreite_maxvalue.value))) {
				calc_form.calc_profilbreite.value = calc_form.calc_profilbreite_maxvalue.value;
				document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
				document.getElementById('div_profilbreite').style.color='#000000';
			}
			if((calc_form.calc_maulweite.value > parseInt(calc_form.calc_maulweite_maxvalue.value))) {
				calc_form.calc_maulweite.value = calc_form.calc_maulweite_maxvalue.value;
				document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
				document.getElementById('div_maulweite').style.color='#000000';
			}
		} else {
			hideElement('warning_profilundmaulweite');
			document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
			document.getElementById('div_profilbreite').style.color='#000000';
			document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
			document.getElementById('div_maulweite').style.color='#000000';
		}
		
		//Min Warning
		if((calc_form.calc_maulweite.value < parseInt(calc_form.calc_maulweite_minvalue.value)) || (calc_form.calc_profilbreite.value < parseInt(calc_form.calc_profilbreite_minvalue.value))) {
			showElement('warning_profilundmaulweite_min');
			if ((calc_form.calc_profilbreite.value > parseInt(calc_form.calc_profilbreite.minvalue))) {
				calc_form.calc_profilbreite.value = calc_form.calc_profilbreite_minvalue.value;
				document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
				document.getElementById('div_profilbreite').style.color='#000000';
			}
			if((calc_form.calc_maulweite.value > parseInt(calc_form.calc_maulweite.minvalue))) {
				calc_form.calc_maulweite.value = calc_form.calc_maulweite_minvalue.value;
				document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
				document.getElementById('div_maulweite').style.color='#000000';
			}
		} else {
			hideElement('warning_profilundmaulweite_min');
			document.getElementById('div_profilbreite').style.backgroundColor='#8eafc1';
			document.getElementById('div_profilbreite').style.color='#000000';
			document.getElementById('div_maulweite').style.backgroundColor='#8eafc1';
			document.getElementById('div_maulweite').style.color='#000000';
		}
	}
}

function adoptMinMaxDefValues(profilTyp, Profil) {
	var minValue = '';
	var maxValue = '';
	
	switch (profilTyp) {
		case "Türzargen":
			minValue = '80';
			maxValue = '600';
			
			if ( (Profil.substr(0,2)=='Z1') || (Profil.substr(0,2)=='Z2') ) {
				minValue = '150';
				maxValue = '600';
			}
			
			if ( (Profil.substr(0,2)=='Z3') || (Profil.substr(0,2)=='Z4') ) {
				minValue = '200';
				maxValue = '600';
			}
			break;
		
		case "Fensterzargen":
			minValue = '80';
			maxValue = '600';
			break;
		
		case "Schiebetürelemente":
			minValue = '100';
			maxValue = '400';
			if ( (Profil.substr(0,2)=='S3') ) {
				minValue = '70';
			}
			break;
	}
	
	document.getElementById('calc_profilbreite_minvalue').value = minValue;
	document.getElementById('calc_profilbreite_maxvalue').value = maxValue;
	document.getElementById('calc_maulweite_minvalue').value = minValue;
	document.getElementById('calc_maulweite_maxvalue').value = maxValue;
	document.getElementById('warning_profilundmaulweite').innerHTML = '<img align="absmiddle" src="images/main/marker.png"> Der Maximalwert für Profilbreite bzw. Maulweite liegt bei ' + maxValue + ' mm.';
	document.getElementById('warning_profilundmaulweite_min').innerHTML = '<img align="absmiddle" src="images/main/marker.png"> Der Minimalwert für Profilbreite bzw. Maulweite liegt bei ' + minValue + ' mm.';
	document.getElementById('calc_profilbreite_hinweise').innerHTML = '(Min. ' + minValue + ' mm / Max ' + maxValue + ' mm)';
	document.getElementById('calc_maulweite_hinweise').innerHTML = '(Min. ' + minValue + ' mm / Max ' + maxValue + ' mm)';
}

function t30montage(onoff) {
	var mont = radioWert(calc_form.calc_montage);
	if(onoff) {
		calc_form.calc_montage[2].disabled = true;
		document.getElementById('div_calc_montage_dbl').style.backgroundColor='#cccccc';
		document.getElementById('div_calc_montage_dbl').style.color='#666666';
		calc_form.calc_montage[3].disabled = true;
		document.getElementById('div_calc_montage_ren').style.backgroundColor='#cccccc';
		document.getElementById('div_calc_montage_ren').style.color='#666666';
		
		//Lichten bei T-30
		calc_form.calc_lichte[0].checked = true;
		document.getElementById(calc_form.calc_lichte[0].parentNode.id).style.backgroundColor='#8eafc1';
		document.getElementById(calc_form.calc_lichte[0].parentNode.id).style.color='#000000';
		calc_form.calc_lichte[1].disabled = true;
		document.getElementById(calc_form.calc_lichte[1].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_lichte[1].parentNode.id).style.color='#666666';
		calc_form.calc_lichte[2].disabled = true;
		document.getElementById(calc_form.calc_lichte[2].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_lichte[2].parentNode.id).style.color='#666666';
		calc_form.calc_lichte[3].disabled = true;
		document.getElementById(calc_form.calc_lichte[3].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_lichte[3].parentNode.id).style.color='#666666';
		calc_form.calc_lichte[4].disabled = true;
		document.getElementById(calc_form.calc_lichte[4].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_lichte[4].parentNode.id).style.color='#666666';
		calc_form.calc_lichte[5].disabled = true;
		document.getElementById(calc_form.calc_lichte[5].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_lichte[5].parentNode.id).style.color='#666666';
		hideGroupbox('Oberlichte');
		hideGroupbox('Seitenlichte');
		
		//Anpassung Ganzglastürblatt
		calc_form.calc_tuerblatt[0].checked = true;
		document.getElementById(calc_form.calc_tuerblatt[0].parentNode.id).style.backgroundColor='#8eafc1';
		document.getElementById(calc_form.calc_tuerblatt[0].parentNode.id).style.color='#000000';
		calc_form.calc_tuerblatt[1].disabled = true;
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_tuerblatt[1].parentNode.id).style.color='#666666';
		
		//Anpassung Simons Tectus 510-3D
		calc_form.calc_baender[4].disabled = true;
		document.getElementById('calc_baender_35').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_35').style.color='#666666';
		calc_form.calc_baender[5].disabled = true;
		document.getElementById('calc_baender_5').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_5').style.color='#666666';
		
		if(calc_form.calc_baender[4].checked || calc_form.calc_baender[5].checked) {
			calc_form.calc_baender[0].checked = true;
			document.getElementById('calc_baender_1').style.backgroundColor='#8eafc1';
			document.getElementById('calc_baender_1').style.color='#000000';
		}
		
		if(calc_form.calc_montage[1].checked)
			showGroupbox('T-30 mit harter Steinwolle');
	} else {
		hideGroupbox('T-30 mit harter Steinwolle');
		calc_form.calc_t30_steinwolle.checked = false;
		document.getElementById('calc_t30_steinwolle').style.backgroundColor='transparent';
		document.getElementById('calc_t30_steinwolle').style.color='#000000';
		calc_form.calc_montage[2].disabled = false;
		document.getElementById(calc_form.calc_montage[2].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_montage[2].parentNode.id).style.color='#000000';
		calc_form.calc_montage[3].disabled = false;
		document.getElementById(calc_form.calc_montage[3].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_montage[3].parentNode.id).style.color='#000000';
		
		//Lichten bei T-30
		calc_form.calc_lichte[1].disabled = false;
		document.getElementById(calc_form.calc_lichte[1].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_lichte[1].parentNode.id).style.color='#000000';
		calc_form.calc_lichte[2].disabled = false;
		document.getElementById(calc_form.calc_lichte[2].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_lichte[2].parentNode.id).style.color='#000000';
		calc_form.calc_lichte[3].disabled = false;
		document.getElementById(calc_form.calc_lichte[3].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_lichte[3].parentNode.id).style.color='#000000';
		calc_form.calc_lichte[4].disabled = false;
		document.getElementById(calc_form.calc_lichte[4].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_lichte[4].parentNode.id).style.color='#000000';
		calc_form.calc_lichte[5].disabled = false;
		document.getElementById(calc_form.calc_lichte[5].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_lichte[5].parentNode.id).style.color='#000000';
		
		//AnpassungGanzglastürblatt
		calc_form.calc_tuerblatt[1].disabled = false;
		
		//Anpassung Simons Tectus 510-3D & Anpassung Simons Tectus 310-3D
		calc_form.calc_baender[4].disabled = false;
		document.getElementById('calc_baender_35').style.backgroundColor='transparent';
		document.getElementById('calc_baender_35').style.color='#000000';
		calc_form.calc_baender[5].disabled = false;
		document.getElementById('calc_baender_5').style.backgroundColor='transparent';
		document.getElementById('calc_baender_5').style.color='#000000';
	}
	
	if(mont == 'dbl' || mont == 'ren') {
		calc_form.calc_montage[0].checked = true;
		document.getElementById(calc_form.calc_montage[0].parentNode.id).style.backgroundColor='#8eafc1';
		document.getElementById(calc_form.calc_montage[0].parentNode.id).style.color='#000000';
	}
	montageChanged(radioWert(calc_form.calc_montage));
}

function radioWert(rObj) {
	for (var i=0; i<rObj.length; i++) {
		if (rObj[i].checked)
			return rObj[i].value;
	}
	
	return false;
}

function isInteger(oInput) {
	var pattern = /^[0-9]*$/;
	if(pattern.test(oInput.value)==false) {
		alert("Bitte geben Sie eine Ganzzahl ein!");
		try {
			if(!isNaN(oInput.defaultvalue))
				oInput.value = oInput.defaultvalue;
			else
				oInput.value = '';
		}
		catch(err) {
			oInput.value = '';
		}
	}
}

function isIntegerMax(oInput,iMax,sWarning) {
	var pattern = /^[0-9]*$/;
	if(pattern.test(oInput.value)==false) {
		alert("Bitte geben Sie eine Ganzzahl ein!");
		try {
		if(!isNaN(oInput.defaultvalue))
			oInput.value = oInput.defaultvalue;
		else
			oInput.value = '';
		}
		catch(err) {
			oInput.value = '';
		}
	} else {
		var iTmp = parseInt(oInput.value);
		if( (iTmp > iMax) && !isNaN(iTmp)) {
			document.getElementById(sWarning).style.display = 'block';
		} else {
			document.getElementById(sWarning).style.display = 'none';
		}
	}
}

function isIntegerMax2(oInput1,oInput2,iMax,sWarning) {
    var pattern = /^[0-9]*$/;
    if(pattern.test(oInput1.value)==false || pattern.test(oInput2.value)==false)
    {
        alert("Bitte geben Sie eine Ganzzahl ein!");
        try
        {
        if(!isNaN(oInput1.defaultvalue))
            oInput1.value = oInput1.defaultvalue;
        else
            oInput1.value = '';
        }
        catch(err)
        {
        oInput1.value = '';
        }
        try
        {
        if(!isNaN(oInput2.defaultvalue))
            oInput2.value = oInput2.defaultvalue;
        else
            oInput2.value = '';
        }
        catch(err)
        {
        oInput2.value = '';
        }
    }
    else
    {
        var iTmp1 = parseInt(oInput1.value);
        var iTmp2 = parseInt(oInput2.value);
        if((iTmp1+iTmp2) > iMax)
        {
        document.getElementById(sWarning).style.display = 'block';
        }
        else
        {
        document.getElementById(sWarning).style.display = 'none';
        }
    }
}

function isIntegerMin(oInput,iMin,sWarning) {
    var pattern = /^[0-9]*$/;
    if(pattern.test(oInput.value)==false)
    {
        alert("Bitte geben Sie eine Ganzzahl ein!");
        try
        {
        if(!isNaN(oInput.defaultvalue))
            oInput.value = oInput.defaultvalue;
        else
            oInput.value = '';
        }
        catch(err)
        {
        oInput.value = '';
        }
    }
    else
    {
        var iTmp = parseInt(oInput.value);
        if( (iTmp < iMin) && !isNaN(iTmp))
            showElement(sWarning);
        else
            hideElement(sWarning);
    }
}

function isIntegerMin2(oInput1,oInput2,iMax,sWarning) {
    var pattern = /^[0-9]*$/;
    if(pattern.test(oInput1.value)==false || pattern.test(oInput2.value)==false)
    {
        alert("Bitte geben Sie eine Ganzzahl ein!");
        try
        {
        if(!isNaN(oInput1.defaultvalue))
            oInput1.value = oInput1.defaultvalue;
        else
            oInput1.value = '';
        }
        catch(err)
        {
        oInput1.value = '';
        }
        try
        {
        if(!isNaN(oInput2.defaultvalue))
            oInput2.value = oInput2.defaultvalue;
        else
            oInput2.value = '';
        }
        catch(err)
        {
        oInput2.value = '';
        }
    }
    else
    {
        var iTmp1 = parseInt(oInput1.value);
        var iTmp2 = parseInt(oInput2.value);
        if((iTmp1+iTmp2) < iMax)
            showElement(sWarning);
        else
            hideElement(sWarning);
    }
}

function resetProfilbreiteMaulweite() {
	if (calc_form.calc_id == "") {
		calc_form.calc_profilbreite.value = '';
		calc_form.calc_maulweite.value = '';
	}
	document.getElementById('div_profilbreite').style.backgroundColor='transparent';
	document.getElementById('div_maulweite').style.backgroundColor='transparent';
}

function adoptLRVerwendbar() {
	var LRVerwendbar = true;
	var band = radioWert(calc_form.calc_baender);
	
	if((parseInt(band) >= 5) && (calc_form.calc_t30.checked)) {
		band = '1';
		calc_form.calc_baender[0].checked = true;
		document.getElementById('calc_baender_1').style.backgroundColor='#8eafc1';
		document.getElementById('calc_baender_1').style.color='#000000';
		calc_form.calc_baender[4].disabled = true;
		document.getElementById('calc_baender_35').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_35').style.color='#666666';
		calc_form.calc_baender[5].disabled = true;
		document.getElementById('calc_baender_5').style.backgroundColor='#cccccc';
		document.getElementById('calc_baender_5').style.color='#666666';
	}
	
	if(band != '1' && band != '2')
		LRVerwendbar = false;
	
	if(calc_form.calc_fluegel[1].checked) {
		LRVerwendbar = false;
		hideGroupbox('Bandaufnahmen Seitenbestimmung')
	} else {
		showGroupbox('Bandaufnahmen Seitenbestimmung')
	}
	
	if(!LRVerwendbar) {
		calc_form.calc_lrverwendbar.checked = false;
		calc_form.calc_lrverwendbar.disabled = true;
		document.getElementById('div_lrverwendbar').style.backgroundColor='#cccccc';
		document.getElementById('div_lrverwendbar').style.color='#666666';
	} else {
		calc_form.calc_lrverwendbar.disabled = false;
		document.getElementById('div_lrverwendbar').style.backgroundColor='transparent';
		document.getElementById('div_lrverwendbar').style.color='#000000';
	}
}

function adoptLichteneingabe(sel) {
	switch (sel) {
		case "0":
			hideGroupbox('Oberlichte');
			hideGroupbox('Seitenlichte');
			hideElement('div_seitenlichte_breite_zwei');
			break;
		case "1":
			showGroupbox('Oberlichte');
			hideGroupbox('Seitenlichte');
			hideElement('div_seitenlichte_breite_zwei');
			break;
		case "2":
			hideGroupbox('Oberlichte');
			showGroupbox('Seitenlichte');
			hideElement('div_seitenlichte_breite_zwei');
			break;
		case "3":
			hideGroupbox('Oberlichte');
			showGroupbox('Seitenlichte');
			showElement('div_seitenlichte_breite_zwei');
			break;
		case "4":
			showGroupbox('Oberlichte');
			showGroupbox('Seitenlichte');
			hideElement('div_seitenlichte_breite_zwei');
			break;
		case "5":
			showGroupbox('Oberlichte');
			showGroupbox('Seitenlichte');
			showElement('div_seitenlichte_breite_zwei');
			break;
	}
}

function adoptEinbruchhemmend() {
	if(calc_form.calc_lrverwendbar.checked==false) {
		calc_form.calc_einbruchhemmend[2].disabled = false;
		document.getElementById(calc_form.calc_einbruchhemmend[2].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_einbruchhemmend[2].parentNode.id).style.color='#000000';
		calc_form.calc_einbruchhemmend[3].disabled = false;
		document.getElementById(calc_form.calc_einbruchhemmend[3].parentNode.id).style.backgroundColor='transparent';
		document.getElementById(calc_form.calc_einbruchhemmend[3].parentNode.id).style.color='#000000';
		showGroupbox('Bandaufnahmen Seitenbestimmung');
	} else {
		calc_form.calc_einbruchhemmend[0].checked = true;
		document.getElementById(calc_form.calc_einbruchhemmend[0].parentNode.id).style.backgroundColor='#8eafc1';
		document.getElementById(calc_form.calc_einbruchhemmend[0].parentNode.id).style.color='#000000';
		calc_form.calc_einbruchhemmend[2].disabled = true;
		document.getElementById(calc_form.calc_einbruchhemmend[2].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_einbruchhemmend[2].parentNode.id).style.color='#666666';
		calc_form.calc_einbruchhemmend[3].disabled = true;
		document.getElementById(calc_form.calc_einbruchhemmend[3].parentNode.id).style.backgroundColor='#cccccc';
		document.getElementById(calc_form.calc_einbruchhemmend[3].parentNode.id).style.color='#666666';
		hideGroupbox('Bandaufnahmen Seitenbestimmung');
	}
}

function checkBaenderAnz(objA) {
	if(objA.name == 'calc_anz_rechts' || objA == calc_form.calc_anz_rechts) {
		var maxVal = parseInt(calc_form.calc_anz_max.value);
		var objB = calc_form.calc_anz_links;
	}
	if(objA.name == 'calc_anz_links' || objA == calc_form.calc_anz_links) {
		var maxVal = parseInt(calc_form.calc_anz_max.value);
		var objB = calc_form.calc_anz_rechts;
	}
	if(objA.name == 'calc_schiebetueren_anz_rechts' || objA == calc_form.calc_schiebetueren_anz_rechts) {
		var maxVal = parseInt(calc_form.calc_anz_max.value);
		var objB = calc_form.calc_schiebetueren_anz_links;
	}
	if(objA.name == 'calc_schiebetueren_anz_links' || objA == calc_form.calc_schiebetueren_anz_links) {
		var maxVal = parseInt(calc_form.calc_anz_max.value);
		var objB = calc_form.calc_schiebetueren_anz_rechts;
	}
	
	if(objA.value > maxVal) {
		objA.value = maxVal;
		objB.value = 0;
	} else {
		objB.value = maxVal - objA.value;
	}
	
	if(objB.value > maxVal) {
		objA.value = 0;
		objB.value = maxVal;
	} else {
		objA.value = maxVal - objB.value;
	}
}

function setMaxAnz(nV) {
	calc_form.calc_anz_max.value = nV;
	checkBaenderAnz(calc_form.calc_anz_links);
	calc_form.calc_schiebetueren_anz_max.value = nV;
	checkBaenderAnz(calc_form.calc_schiebetueren_anz_links);
}

if (typeof calc_form.zargen_form != 'undefined') {
	if (calc_form.zargen_form.value == 1) {
		refreshProfiles();
		refreshProfileSettings();
		hideGroupbox('Oberlichte');
		hideGroupbox('Seitenlichte');
		hideGroupbox('T-30 mit harter Steinwolle');
	}
}

// Verglasung
function adoptVerglasung (id) {
	change = 0;
	
	if (id == 1) {
		if (!calc_form.Verglasung_1seitig.checked)
			change = 1;
	} else {
		if (calc_form.Verglasung_2seitig.checked)
			change = 1;
		if (calc_form.Ueberhoehter_Spiegel.checked)
			calc_form.Ueberhoehter_Spiegel.checked=false;
	}
	
	if (change) {
		calc_form.Verglasung_1seitig.checked = false;
		document.getElementById('div_Verglasung_1seitig').style.backgroundColor='transparent';
		document.getElementById('div_Verglasung_1seitig').style.color='#000000';
		calc_form.Verglasung_2seitig.checked = true;
		document.getElementById('div_Verglasung_2seitig').style.backgroundColor='#8eafc1';
		document.getElementById('div_Verglasung_2seitig').style.color='#000000';
	} else {
		calc_form.Verglasung_2seitig.checked = false;
		document.getElementById('div_Verglasung_2seitig').style.backgroundColor='transparent';
		document.getElementById('div_Verglasung_2seitig').style.color='#000000';
		calc_form.Verglasung_1seitig.checked = true;
		document.getElementById('div_Verglasung_1seitig').style.backgroundColor='#8eafc1';
		document.getElementById('div_Verglasung_1seitig').style.color='#000000';
	}
	refreshProfilausfuehrung();
}

// Registrierung
function refreshRegisterPasswordFirst ( pfield, warning ) {
	if (pfield.value.length < 6 || pfield.value.length > 20) {
		showElement('warning_' + warning);
		return false;
	} else {
		hideElement('warning_' + warning);
		return true;
	}
}

function refreshRegisterPasswordSecond ( pfield1, pfield2, warning ) {
	if (pfield1.value != pfield2.value) {
		showElement('warning_' + warning);
		return false;
	} else {
		hideElement('warning_' + warning);
		return true;
	}
}

function registerStart() {
	var formHasError = false
	
	if (refreshRegisterEmail( calc_form.register_username, 'registeremail') == false) {
		formHasError = true
	}
	if (refreshRegisterPasswordFirst( calc_form.register_password_first, 'registerpasswordfirst') == false) {
		formHasError = true
	}
	if (refreshRegisterPasswordSecond( calc_form.register_password_first, calc_form.register_password_second, 'registerpasswordsecond') == false) {
		formHasError = true
	}
	if (calc_form.register_company_first.value == "") {
		showElement('warning_registercompany');
		formHasError = true
	}
	if (calc_form.register_address_first.value == "") {
		showElement('warning_registeraddress');
		formHasError = true
	}
	if (calc_form.register_zip.value == "" || calc_form.register_country.value == "") {
		showElement('warning_registerzipcity');
		formHasError = true
	}
	if (calc_form.register_firstname.value == "" || calc_form.register_lastname.value == "") {
		showElement('warning_registername');
		formHasError = true
	}
	if (calc_form.register_phone_first.value == "") {
		showElement('warning_registerphone');
		formHasError = true
	}
	
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!');
		return false;
	} else {
		calc_form.submit();
	}
}

// Kalkulation erneut berechnen
function recalcAnzahl(pfield, Stueckpreis, Faktor, Login) {
	if (parseInt(pfield.value) > 0) {
		hideElement('warning_anzahl');
		var outputnum = document.getElementById('anzahl');
		num = (parseFloat(pfield.value) * parseFloat(Stueckpreis)/10) - parseFloat(Faktor)
		num = Math.floor(num)+","+(100+Math.round((num-Math.floor(num))*100)+"").substr(1,2)
		outputnum.innerHTML = num + " &euro;";
		
		var outputsum = document.getElementById('stueck');
		outputsum.innerHTML = pfield.value;
		
		if (Login == "1") {
			document.calc_loginout.login_calc_anzahl.value = pfield.value;
			document.calc_loginout.login_calc_gesamtpreis.value = num;
		}
	} else {
		showElement('warning_anzahl');
	}
}

// Projekt anlegen
function projektStart() {
	var formHasError = false
	
	if (document.calc_projekt.konto_projektname.value == "") {
		showElement('warning_projektname');
		formHasError = true
	}
	
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!');
		return false;
	} else {
		document.calc_projekt.submit();
	}
}

// Profil bearbeiten: Login
function loginStart() {
	var formHasError = false
	
	if (refreshRegisterEmail( document.calc_profil.profil_username, 'profilemail') == false) {
		formHasError = true
	}
	if (refreshRegisterPasswordFirst( document.calc_profil.profil_password_old, 'profilpasswordold') == false) {
		formHasError = true
	}
	if (refreshRegisterPasswordFirst( document.calc_profil.profil_password_first, 'profilpasswordfirst') == false) {
		formHasError = true
	}
	if (refreshRegisterPasswordSecond( document.calc_profil.profil_password_first, document.calc_profil.profil_password_second, 'profilpasswordsecond') == false) {
		formHasError = true
	}
	
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!');
		return false;
	} else {
		document.calc_profil.submit();
	}
}

// Profil bearbeiten: Firmenangaben
function companyStart() {
	var formHasError = false
	
	if (document.calc_profil.profil_company_first.value == "") {
		showElement('warning_registercompany');
		formHasError = true
	}
	if (document.calc_profil.profil_address_first.value == "") {
		showElement('warning_registeraddress');
		formHasError = true
	}
	if (document.calc_profil.profil_zip.value == "" || document.calc_profil.profil_country.value == "") {
		showElement('warning_registerzipcity');
		formHasError = true
	}
	
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!');
		return false;
	} else {
		document.calc_profil.submit();
	}
}

// Profil bearbeiten: Persönliche Daten
function personalStart() {
	var formHasError = false
	
	if (document.calc_profil.profil_firstname.value == "" || document.calc_profil.profil_lastname.value == "") {
		showElement('warning_registername');
		formHasError = true
	}
	if (document.calc_profil.profil_phone_first.value == "") {
		showElement('warning_registerphone');
		formHasError = true
	}
	
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!');
		return false;
	} else {
		document.calc_profil.submit();
	}
}

// Profil bearbeiten: Neue Adresse
function addressStart() {
	var formHasError = false
	
	if (document.calc_profil.profil_company_first.value == "") {
		showElement('warning_registercompany');
		formHasError = true
	}
	if (document.calc_profil.profil_address_first.value == "") {
		showElement('warning_registeraddress');
		formHasError = true
	}
	if (document.calc_profil.profil_zip.value == "" || document.calc_profil.profil_country.value == "") {
		showElement('warning_registerzipcity');
		formHasError = true
	}
	if (document.calc_profil.profil_firstname.value == "" || document.calc_profil.profil_lastname.value == "") {
		showElement('warning_registername');
		formHasError = true
	}
	if (document.calc_profil.profil_phone_first.value == "") {
		showElement('warning_registerphone');
		formHasError = true
	}
	
	if(formHasError) {
		alert('Es wurden nicht alle Daten korrekt eingegeben.\n\nKorrigieren Sie Ihre Eingaben!');
		return false;
	} else {
		document.calc_profil.submit();
	}
}
/*
function changebg (eName, eID) {
	var eNames = document.getElementsByName(eName);
	for (var i = 0; i < eNames.length; i++) {
		if (eNames[i].style.display != 'none') {
			eNames[i].style.backgroundColor='transparent';
		}
	}
	
	document.getElementById(eName + '_' + eID).style.backgroundColor='#8eafc1';
}
*/
function changebg (eName, eID) {
	var eNames = document.getElementsByName(eName);
	for (var i = 0; i < eNames.length; i++) {
		if (eNames[i].style.display != 'none') {
			eNames[i].style.backgroundColor='transparent';
		}
		if (eNames[i].disabled) {
			eNames[i-1].style.backgroundColor='#cccccc';
			eNames[i-1].style.color='#666666';
		}
	}
	
	document.getElementById(eName + '_' + eID).style.backgroundColor='#8eafc1';
}

function changebgcheck (eName) {
	if (document.getElementById(eName).style.backgroundColor == 'rgb(142, 175, 193)') {
		document.getElementById(eName).style.backgroundColor = 'transparent';
	} else {
		document.getElementById(eName).style.backgroundColor = '#8eafc1';
	}
}

function changebginput (eName) {
	if (document.getElementById("calc_" + eName).value != '') {
		document.getElementById("div_" + eName).style.backgroundColor = '#8eafc1';
	} else {
		document.getElementById("div_" + eName).style.backgroundColor = 'transparent';
	}
}

function checkagb () {
	if (document.calc_order.agb.checked) {
		document.calc_order.btn_register.disabled = false;
	} else {
		document.calc_order.btn_register.disabled = true;
	}
}
