<!-- code by agentur.net modified by Mathias Lixl -->

var ErrorColor = '#E3DCD7';
var error;
var br = "\x0d";
var errortxt = '';
var SetBgColor = true;

function chkFormularLang(Language){
	if (Language == 'de'){
		errorAnrede = 'Bitte wählen Sie eine Anrede! ';
		errorNName = 'Bitte geben Sie den Nachnamen ein! ';
		errorVName = 'Bitte geben Sie den Vornamen ein! ';
		errorLand = 'Bitte geben Sie ein Land an! ';
		errorOrt = 'Bitte geben Sie einen Ort an! ';
		errorStrasse = 'Bitte geben Sie eine Strasse an! ';
		errorPlz = 'Bitte geben Sie eine Postleitzahl ein! ';
		errorTelefon = 'Bitte geben Sie eine Telefonnummer ein! ';
		errorEmail1 = 'Bitte geben Sie eine Email Adresse ein! ';
		errorEmail2 = 'Bitte geben Sie die Email Adresse ein 2.mal ein! ';
		errorEmail = 'Bitte korrigieren Sie die Email Adressen! ';
		errorBodenart = 'Bitte wählen Sie eine Fussbodenart aus! ';
		errorBodenholzart = 'Bitte wählen Sie eine Holzart! ';
		errorOberflaeche = 'Bitte wählen Sie eine Oberflächenbehandlung aus! ';
		errorMeter = 'Bitte geben Sie die Quadratmeteranzahl ein! ';
		errorBodenfuer = 'Bitte wählen Sie eine Bodenkategorie! ';
		errorPreiskategorie = 'Bitte wählen Sie eine Preiskategorie! ';
		errorKundenstatus = 'Bitte wählen Sie Ihren Kundenstatus aus! ';
		errorBodenkauf = 'Bitte wählen Sie einen Zeitpunkt für den Bodenkauf aus! ';
		errorCheckbox = 'Bitte willigen Sie ein! ';
		errorText = 'Bitte geben Sie einen Text ein! ';
		errorAuswahl = 'Bitte wählen Sie ein Produkt aus! ';
		errorGrund = 'Bitte wählen Sie einen Grund aus! ';
		errorKontaktart = 'Bitte wählen Sie eine Kontaktart aus! ';
		errorKollektion = 'Bitte wählen Sie eine Kollektion aus! ';
		errorToenung = 'Bitte wählen Sie eine Tönung aus! ';
		errorDielenlaenge = 'Bitte wählen Sie eine Dielelänge aus! ';
		errorQM = 'Bitte wählen Sie eine Fläche aus! ';
	};
	
	if (Language == 'en'){
		errorAnrede = 'Please select your title! ';
		errorNName = 'Please enter your last name! ';
		errorVName = 'Please enter your given name! ';
		errorLand = 'Please enter your country! ';
		errorOrt = 'Please enter your town! ';
		errorStrasse = 'Please enter your street ';
		errorPlz = 'Please enter your postcode! ';
		errorTelefon = 'Please enter your telephone number! ';
		errorEmail1 = 'Please enter your email address! ';
		errorEmail2 = 'Please re-enter your email address! ';
		errorEmail = 'Please correct your email address! ';
		errorBodenart = 'Please select a wood floor type! ';
		errorBodenholzart = 'Please select a wood specie! ';
		errorOberflaeche = 'Please select a wood floor finish! ';
		errorMeter = 'Please enter a square meter/square ft.amount! ';
		errorBodenfuer = 'Please select a floor category! ';
		errorPreiskategorie = 'Please select a price category! ';
		errorKundenstatus = 'Please select your client status! ';
		errorBodenkauf = 'Please select the time for your floor purchase! ';
		errorCheckbox = 'Please confirm your consent! ';
		errorText = 'Please enter a text! ';
		errorAuswahl = 'Please select a product! ';
		errorGrund = 'Please select a reason! ';
		errorKontaktart = 'Please select your sales activity type! ';
		errorKollektion = 'Please select a collection! ';
		errorToenung = 'Please select a surface color! ';
		errorDielenlaenge = 'Please select a plank length! ';
		errorQM = 'Please select the No. of m² / No. of surface! ';
		
	}
	
	if (Language == 'it'){
		errorAnrede = 'Le preghiamo di scegliere il titolo! ';
		errorNName = 'Le preghiamo di immettere il cognome! ';
		errorVName = 'Le preghiamo di immettere il nome! ';
		errorLand = 'Le preghiamo di immettere il paese! ';
		errorOrt = 'Le preghiamo di immettere la città! ';
		errorStrasse = 'Le preghiamo di immettere la via! ';
		errorPlz = 'Le preghiamo di immettere il CAP! ';
		errorTelefon = 'Le preghiamo di immettere il telephone! ';
		errorEmail1 = 'Le preghiamo di immettere il E-Mail! ';
		errorEmail2 = 'Le preghiamo di immettere il E-Mail la seconda volta! ';
		errorEmail = 'Le preghiamo di correggere il E-Mail! ';
		errorBodenart = 'Le preghiamo di scegliere il tipo di pavimento! ';
		errorBodenholzart = 'Le preghiamo di scegliere la essenza! ';
		errorOberflaeche = 'Le preghiamo di scegliere il trattamento di superficie! ';
		errorMeter = 'Le preghiamo di immettere la superficie in mq! ';
		errorBodenfuer = 'Le preghiamo di scegliere la categoria del pavimento! ';
		errorPreiskategorie = 'Le preghiamo di scegliere la categoria prezzi! ';
		errorKundenstatus = 'Le preghiamo di scegliere il Suo status del cliente! ';
		errorBodenkauf = 'Le preghiamo di scegliere il Suo previsto di acquistare un pavimento! ';
		errorCheckbox = 'Le preghiamo di autorizzare! ';
		errorText = 'Le preghiamo di immettere un texto! ';
		errorAuswahl = 'Le preghiamo di scegliere un prodotto! ';
		errorGrund = 'Le preghiamo di scegliere un ragione! ';
		errorKontaktart = 'Le preghiamo di scegliere il tipo di contatto! ';
		errorKollektion = 'Le preghiamo di scegliere la collezione! ';
		errorToenung = 'Le preghiamo di scegliere la tonalità! ';
		errorDielenlaenge = 'Le preghiamo di scegliere la lunghezza delle tavole! ';
		errorQM = 'Le preghiamo di scegliere una superficie! ';
		
	}
	if (Language == 'nl'){
		errorAnrede = 'Kies een aanspreektitel aub!';
		errorNName = 'Geef aub de familienaam in! ';
		errorVName = 'Geef aub de voornaam in! ';
		errorLand = 'Geef aub een land in! ';
		errorOrt = 'Geef aub een gemeente (stad) in! ';
		errorStrasse = 'Geef aub een straat in! ';
		errorPlz = 'Geef aub een postnummer in! ';
		errorTelefon = 'Geef aub een telefonnummer in! ';
		errorEmail1 = 'Geef aub een e-mail adres in! ';
		errorEmail2 = 'Geef aub het e-mail adres een tweede keer in! ';
		errorEmail = 'Wil aub de e-mail adressen corrigeren! ';
		errorBodenart = 'Kies aub een vloersoort uit! ';
		errorBodenholzart = 'Kies aub een houtsoort uit! ';
		errorOberflaeche = 'Kies aub een oppervlaktebehandeling uit! ';
		errorMeter = 'Geef aub het aantal vierkante meters in! ';
		errorBodenfuer = 'Kies aub een vloerkategorie! ';
		errorPreiskategorie = 'Kies aub een prijskategorie! ';
		errorKundenstatus = 'Kies aub uw klantstatus! ';
		errorBodenkauf = 'Kies aub een tijdspunt voor de koop van de vloer! ';
		errorCheckbox = 'Wil aub toestemmen! ';
		errorText = 'Geef aub een tekst in! ';
		errorAuswahl = 'Kies aub een produkt uit! ';
		errorGrund = 'Kies aub een reden uit! ';
		errorKontaktart = 'Kies aub een onderwerp uit waarover we u moeten kontakteren! ';
		errorKollektion = 'Kies aub een collectie uit! ';
		errorToenung = 'Kies aub een kleur van de plank uit! ';
		errorDielenlaenge = 'kies aub de planklengte uit! ';
		errorQM = 'kies aub de oppervlakte uit! ';
		
	}
	
	if (Language == 'es'){
		errorAnrede = '¡Seleccione por favor el tratamiento! ';
		errorNName = '¡Introduzca por favor los apellidos! ';
		errorVName = '¡Introduzca por favor el nombre! ';
		errorLand = '¡Indique por favor el país! ';
		errorOrt = '¡Indique por favor el lugar! ';
		errorStrasse = '¡Indique por favor la calle! ';
		errorPlz = '¡Introduzca por favor el código postal! ';
		errorTelefon = 'G¡Introduzca por favor el telephone! ';
		errorEmail1 = '¡Introduzca por favor una dirección e-mail! ';
		errorEmail2 = '¡Introduzca por favor la dirección e-mail por 2ª vez! ';
		errorEmail = '¡Corrija por favor las direcciones e-mail! ';
		errorBodenart = '¡Seleccione por favor el tipo de suelo! ';
		errorBodenholzart = '¡Seleccione por favor el tipo de madera! ';
		errorOberflaeche = '¡Seleccione por favor un tratamiento de superficie! ';
		errorMeter = '¡Introduzca por favor el número de metros cuadrados! ';
		errorBodenfuer = '¡Seleccione por favor una categoría de suelos! ';
		errorPreiskategorie = '¡Seleccione por favor una categoría de precios! ';
		errorKundenstatus = '¡Seleccione por favor su estatus de cliente! ';
		errorBodenkauf = '¡Seleccione por favor el momento de la compra del suelo! ';
		errorCheckbox = '¡Emita por favor su consentimiento! ';
		errorText = '¡Introduzca por favor un texto! ';
		errorAuswahl = '¡Seleccione por favor un producto! ';
		errorGrund = '¡Seleccione por favor un motivo! ';
		errorKontaktart = '¡Seleccione por favor una forma de contacto! ';
		errorKollektion = '¡Seleccione por favor la colección! ';
		errorToenung = '¡Seleccione por favor la tonalidad de la superficie! ';
		errorDielenlaenge = '¡Seleccione por favor el largo de los tablones! ';
		errorQM = '¡Seleccione por favor la superficie de suelo en mq! ';

	}
}	

function clearFormular(){
	for (i=0; i<TheForm.length; i++) {
		TheForm[i].style.backgroundColor = '';
	}
}


function chkFormularFeld(Feldname,errormsg){
	TheForm[Feldname].style.backgroundColor = '';
	if (TheForm[Feldname].value.length < 1) {
		if (!document.layers && SetBgColor) { TheForm[Feldname].style.backgroundColor = ErrorColor;}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}


function chkFormularDrop(Dropname,errormsg){
	TheForm[Dropname].style.backgroundColor = '';
	if (TheForm[Dropname].value == '' ) {
		if (!document.layers && SetBgColor) { TheForm[Dropname].style.backgroundColor = ErrorColor;}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}

function chkFormularDrop2(Dropname,errormsg){
	TheForm[Dropname].style.backgroundColor = '';
	if (TheForm[Dropname].value == '-1' ) {
		if (!document.layers && SetBgColor) { TheForm[Dropname].style.backgroundColor = ErrorColor;}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}

function chkFormularDrop3(Dropname,errormsg,invalidSel){
	TheForm[Dropname].style.backgroundColor = '';
	if (TheForm[Dropname].value == '-1' || TheForm[Dropname].value == invalidSel) {
		if (!document.layers && SetBgColor) { TheForm[Dropname].style.backgroundColor = ErrorColor;}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}

function chkFormularBox(Boxname,errormsg){
	TheForm[Boxname].style.backgroundColor = '';
	if (!TheForm[Boxname].checked) {
		if (!document.layers && SetBgColor) { TheForm[Boxname].style.backgroundColor = ErrorColor;}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}

function chkFormularRadio(Radioname,errormsg) {
	TheRadio = TheForm[Radioname];

	var CheckNr = -1;
	for (i=0; i<TheRadio.length; i++) {
		if (TheRadio[i].checked) { CheckNr = i; }
	}
	if (CheckNr < 0) {
		for (i=0; i<TheRadio.length; i++) {
			TheRadio[i].style.backgroundColor = ErrorColor;
		}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}

function chkFormularReklamation(errormsg) {
	var Auswahlwert = -1;
	for (i=0; i<TheForm.length; i++) {
		if (TheForm[i].value) { Auswahlwert = i; }
	}
	if (Auswahlwert < 0) {
		for (i=0; i<TheForm.length; i++) {
			if (!document.layers && SetBgColor) {TheForm[i].style.backgroundColor = ErrorColor;}
		}
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}


function chkFormularAngebot(errormsg) {
	clearFormular();
	if(!TheForm['Bodenart'].value && !TheForm['Bodenfuer'].value ){
		chkFormularDrop('Bodenart',errorBodenart);
		chkFormularDrop('Bodenfuer',errorBodenfuer);
		errortxt = errormsg;
		return false;		
	}
	if(TheForm['Bodenart'].value && !TheForm['Bodenfuer'].value ){
		chkFormularDrop('Bodenholzart',errorBodenholzart);
		chkFormularDrop('Oberflaeche',errorOberflaeche);
		chkFormularFeld('Meter1', errorMeter);
		return false;
	}
	if(!TheForm['Bodenart'].value && TheForm['Bodenfuer'].value ){
		chkFormularDrop('Preiskategorie',errorPreiskategorie);
		chkFormularFeld('Meter2',errorMeter);
		return false;
	}
}

function chkFormularInfoB2C(errormsg) {
	clearFormular();
	if(!TheForm['Produktfolder'].checked && !TheForm['TechInfo'].checked && !TheForm['Pflegeinfo'].checked && !TheForm['Produktberatung'].checked && !TheForm['Preisinfo'].checked){
		chkFormularBox('Produktfolder',errorAuswahl);
		chkFormularBox('TechInfo',errorAuswahl);
		chkFormularBox('Pflegeinfo',errorAuswahl);
		chkFormularBox('Produktberatung',errorAuswahl);
		chkFormularBox('Preisinfo',errorAuswahl);
		errortxt = errormsg;
		return false;		
	}
	return true;
}

function chkFormularInfoB2BArchitekt(errormsg) {
	clearFormular();
	if(!TheForm['Produktfolder'].checked && !TheForm['TechInfo'].checked && !TheForm['PreiseLieferzeiten'].checked && !TheForm['Produktberatung'].checked && !TheForm['IndividuellesDesign'].checked && !TheForm['OberflaechenEinsatz'].checked){
		chkFormularBox('Produktfolder',errorAuswahl);
		chkFormularBox('TechInfo',errorAuswahl);
		chkFormularBox('PreiseLieferzeiten',errorAuswahl);
		chkFormularBox('Produktberatung',errorAuswahl);
		chkFormularBox('IndividuellesDesign',errorAuswahl);
		chkFormularBox('OberflaechenEinsatz',errorAuswahl);
		errortxt = errormsg;
		return false;		
	}
	return true;
}

function chkFormularInfoB2BVerleger(errormsg) {
	clearFormular();
	if(!TheForm['Produktfolder'].checked && !TheForm['TechInfo'].checked && !TheForm['PreiseLieferzeiten'].checked && !TheForm['Zertifizierung'].checked && !TheForm['Marketing'].checked){
		chkFormularBox('Produktfolder',errorAuswahl);
		chkFormularBox('TechInfo',errorAuswahl);
		chkFormularBox('PreiseLieferzeiten',errorAuswahl);
		chkFormularBox('Zertifizierung',errorAuswahl);
		chkFormularBox('Marketing',errorAuswahl);
		errortxt = errormsg;
		return false;		
	}
	return true;
}

function chkEmail(mail1,mail2,errormsg) {
	var emailident = false;
	if (TheForm[mail1].value == TheForm[mail2].value){ emailident = true;}
	if (emailident == false){
		errortxt = errortxt + errormsg + br;
		return false;
	}
	return true;
}

function chkFormularEcho(errortxt){
	if (errortxt.length) {
			alert(errortxt);
		return false;
	}
	return true;
}
