// JavaScript Document



function switchLang (lang) {
	document.cookie = "lang" + "=" + lang;
	window.location.reload();
}

function enter (lang) {
	document.cookie = "lang" + "=" + lang;
}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

function trim( value ) {
	value = RTrim(value);
	value = LTrim(value);
	return value;
}

function UnCryptMailto( s ) {
	var n = 0;
	var r = "";
	for( var i = 0; i < s.length; i++) {
		n = s.charCodeAt( i );
		if( n >= 8364 ) {
			n = 128;
		}
		r += String.fromCharCode( n - 1 );
	}
	return r;
}

function linkTo_UnCryptMailto( s ) {
	location.href = UnCryptMailto( s );
}


function reset_KontaktForm() {
	document.getElementById("errorName").style.display = "none";
	document.getElementById("errorEmail").style.display = "none";
	document.getElementById("errorBetreff").style.display = "none";
	document.getElementById("errorNachricht").style.display = "none";
	document.getElementById("errorTel").style.display = "none";
}

function check_KontaktForm() {
	reset_KontaktForm();
	var mail = trim(document.KontaktForm.email.value);
	if ( trim(document.KontaktForm.name.value).length < 1){
		document.getElementById("errorName").style.display = "inline";
		document.KontaktForm.name.value = '';
		document.KontaktForm.name.focus();
		return false;
	} else if (mail.length < 5 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1){
		document.getElementById("errorEmail").style.display = "inline";
		document.KontaktForm.email.value = '';
		document.KontaktForm.email.select();
		return false;
	} else if ( trim(document.KontaktForm.tel.value).length < 1){
		document.getElementById("errorTel").style.display = "inline";
		document.KontaktForm.tel.value = '';
		document.KontaktForm.tel.focus();
		return false;
	} else if ( trim(document.KontaktForm.betreff.value).length < 1){
		document.getElementById("errorBetreff").style.display = "inline";
		document.KontaktForm.betreff.value = '';
		document.KontaktForm.betreff.focus();
		return false;
	} else if ( trim(document.KontaktForm.nachricht.value).length < 1){
		document.getElementById("errorNachricht").style.display = "inline";
		document.KontaktForm.nachricht.value = '';
		document.KontaktForm.nachricht.focus();
		return false;
	}
	return true;
}


function reset_FeedbackForm() {
	document.getElementById("errorName").style.display = "none";
	document.getElementById("errorEmail").style.display = "none";
	document.getElementById("errorNachricht").style.display = "none";
	document.getElementById("errorTel").style.display = "none";
}

function check_FeedbackForm() {
	reset_FeedbackForm();
	var mail = trim(document.FeedbackForm.email.value);
	if ( trim(document.FeedbackForm.name.value).length < 1){
		document.getElementById("errorName").style.display = "inline";
		document.FeedbackForm.name.value = '';
		document.FeedbackForm.name.focus();
		return false;
	} else if (mail.length < 5 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1){
		document.getElementById("errorEmail").style.display = "inline";
		document.FeedbackForm.email.value = '';
		document.FeedbackForm.email.select();
		return false;
	} else if ( trim(document.FeedbackForm.tel.value).length < 1){
		document.getElementById("errorTel").style.display = "inline";
		document.FeedbackForm.tel.value = '';
		document.FeedbackForm.tel.focus();
		return false;
	} else if ( trim(document.FeedbackForm.nachricht.value).length < 1){
		document.getElementById("errorNachricht").style.display = "inline";
		document.FeedbackForm.nachricht.value = '';
		document.FeedbackForm.nachricht.focus();
		return false;
	}
	return true;
}

function reset_EmpfehlenForm() {
	document.getElementById("errorName").style.display = "none";
	document.getElementById("errorEmail").style.display = "none";
	document.getElementById("errorEmpfEmail").style.display = "none";
}

function check_EmpfehlenForm() {
	reset_EmpfehlenForm();
	var mail = trim(document.EmpfehlenForm.email.value);
	var empfmail = trim(document.EmpfehlenForm.empfEmail.value);
	if ( trim(document.EmpfehlenForm.name.value).length < 1){
		document.getElementById("errorName").style.display = "inline";
		document.EmpfehlenForm.name.value = '';
		document.EmpfehlenForm.name.focus();
		return false;
	} else if (mail.length < 5 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1){
		document.getElementById("errorEmail").style.display = "inline";
		document.EmpfehlenForm.email.value = '';
		document.EmpfehlenForm.email.select();
		return false;
	} else if (empfmail.length < 5 || empfmail.indexOf ('@',0) == -1 || empfmail.indexOf ('.',0) == -1){
		document.getElementById("errorEmail").style.display = "inline";
		document.EmpfehlenForm.empfEmail.value = '';
		document.EmpfehlenForm.empfEmail.select();
		return false;
	}
	return true;
}

function reset_NewsletterBestellenForm() {
	document.getElementById("errorName").style.display = "none";
	document.getElementById("errorEmail").style.display = "none";
	document.getElementById("errorTel").style.display = "none";
}

function check_NewsletterBestellenForm() {
	reset_NewsletterBestellenForm();
	var mail = trim(document.NewsletterBestellenForm.email.value);
	if ( trim(document.NewsletterBestellenForm.name.value).length < 1){
		document.getElementById("errorName").style.display = "inline";
		document.NewsletterBestellenForm.name.value = '';
		document.NewsletterBestellenForm.name.focus();
		return false;
	} else if (mail.length < 5 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1){
		document.getElementById("errorEmail").style.display = "inline";
		document.NewsletterBestellenForm.email.value = '';
		document.NewsletterBestellenForm.email.select();
		return false;
	} else if ( trim(document.NewsletterBestellenForm.tel.value).length < 1){
		document.getElementById("errorTel").style.display = "inline";
		document.NewsletterBestellenForm.tel.value = '';
		document.NewsletterBestellenForm.tel.focus();
		return false;
	}
	return true;
}

function reset_NewsletterAbBestellenForm() {
	document.getElementById("errorEmail").style.display = "none";
}

function check_NewsletterAbBestellenForm() {
	reset_NewsletterAbBestellenForm();
	var mail = trim(document.NewsletterAbBestellenForm.email.value);
	if (mail.length < 5 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1){
		document.getElementById("errorEmail").style.display = "inline";
		document.NewsletterAbBestellenForm.email.value = '';
		document.NewsletterAbBestellenForm.email.select();
		return false;
	}
	return true;
}


	function rauf(item) {
			item.style.backgroundColor="#eaeaaf";
	}
	function runter(item) {

			item.style.backgroundColor="#FFFFFF";
	}
