//////////////////////////////////////////////////////////////


var cookie_exp   = 365;
var unbekannt = ""

// Cookie-Routinen
//////////////////////////////////////////////////////////////


function getCookie(name) {
  var index = document.cookie.indexOf(name + "=");
  if (index == -1) return null;
  index = document.cookie.indexOf("=", index) + 1;
  var endstr = document.cookie.indexOf(";", index);
  if (endstr == -1) endstr = document.cookie.length;
  return unescape(document.cookie.substring(index, endstr));
}


function setCookie(name, value) {
	var today = new Date();
	var expiry = new Date(today.getTime() + 24 * 60 * 60 * 1000 * cookie_exp);
	if (value != null && value != "")
    document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
}


// Formulardaten setzen und auslesen
//////////////////////////////////////////////////////////////

function setName(name,email) { 
	data = name+ '|' +email;
	setCookie("equiberique_pers_Name", data);
}

function getName() {
	temp = new String(getCookie("equiberique_pers_Name"));
	if (temp == "null") return unbekannt;
	else {
		data = temp.split("|");
		if (data[0] == "") return unbekannt;
		else return ', ' + data[0];
	}
}

function getForm() {
	temp = new String(getCookie("equiberique_pers_Name"));
	if (temp == "null") null;
	else {
		data = temp.split("|");
		document.contactform.Name.value    = data[0];
		document.contactform.email.value   = data[1];	
	
	}
}

//////////////////////////////////////////////////////////////

function getCount(name) {
	temp = new String(getCookie(name));
	if (temp == "null") {
		setCookie(name, 1);
		counter = 1;
	}
	else {
		neu = parseInt(temp)+1;
		setCookie(name, neu);
		counter = neu;
	}
	return counter;
}


//////////////////////////////////////////////////////////////

function checkStart() {
	temp = new String(getCookie("pers_Start"));
	if (temp == "ja") document.pers.start.checked = true;	
}

function setStart() {
	temp = new String(getCookie("pers_Start"));
	if (temp == "ja") setCookie("pers_Start", "nein");
	else  setCookie("pers_Start", "ja");
}


//////////////////////////////////////////////////////////////
function Formtest_Deutsch() {
	if (document.contactform.Name.value == "") {
	alert("Bitte tragen Sie Ihren Namen ein.");
	document.contactform.Name.focus();
	return false;
	}
	if (document.contactform.email.value.indexOf("@") == "-1"  || document.contactform.email.value == "") {
	alert("Bitte prüfen Sie Ihre email-Adresse.");
	document.contactform.email.focus();
	return false;
	}
setName(document.contactform.Name.value,document.contactform.email.value)
}

function Formtest_French() {
	if (document.contactform.Name.value == "") {
	alert("Nous vous prions de nous indiquer votre nom.");
	document.contactform.Name.focus();
	return false;
	}
	if (document.contactform.email.value.indexOf("@") == "-1"  || document.contactform.email.value == "") {
	alert("Nous vous prions de vérifier votre adresse de courrier electronique.");
	document.contactform.email.focus();
	return false;
	}
setName(document.contactform.Name.value,document.contactform.email.value)
}

function Formtest_English() {
	if (document.contactform.Name.value == "") {
	alert("Please tell us your name.");
	document.contactform.Name.focus();
	return false;
	}
	if (document.contactform.email.value.indexOf("@") == "-1"  || document.contactform.email.value == "") {
	alert("Please submit your email-adress, we would like to answer your mail.");
	document.contactform.email.focus();
	return false;
	}
setName(document.contactform.Name.value,document.contactform.email.value)
}

