
	/* ++-- VALIDATOR FÜR KONTAKT --++ */

	function checkContact() { 
		
		var validPage = true;

		if (validRadio('saludation')) { 
			colorNormalText('saludation');
		} else {
			colorErrorText('saludation');	validPage = false;
		}
		
		if (validLength('firstname',1,255)) {
			colorNormalText('firstname'); colorNormalField('firstname');
		} else {
			colorErrorText('firstname'); colorErrorField('firstname'); validPage = false;
		}
		
		if (validLength('lastname',1,255)) {
			colorNormalText('lastname'); colorNormalField('lastname');
		} else {
			colorErrorText('lastname'); colorErrorField('lastname'); validPage = false;
		}
		
		if (validEmail('email')) {
			colorNormalText('email'); colorNormalField('email');
		} else {
			colorErrorText('email'); colorErrorField('email'); validPage = false;
		}
		
		if (validPhone('phone')) {
			colorNormalText('phone'); colorNormalField('phone');
		} else {
			colorErrorText('phone'); colorErrorField('phone'); validPage = false;
		}
		
		if (validArea()) {
			colorNormalText('description'); colorNormalTextArea('description');
		} else {
			colorErrorText('description'); colorErrorTextArea('description'); validPage = false;
		}
		
		if (validPage) {
			document.getElementById("wait").style.display = "block";
			document.getElementById("errorMessage").style.display = "none";
			document.getElementById("formContact").style.display = "none";
			document.getElementById("mailTarget").style.display = "block";
		} else {
			document.getElementById("errorMessage").style.display = "block";
		}
		
		return validPage;
	}
	
	function backToContact() { 
		document.getElementById("errorMessage").style.display = "none";
		document.getElementById("formContact").style.display = "block";
		document.getElementById("mailTarget").style.display = "none";
	}
	
	/* ++-- VALIDATOREN --++ */
	
	function validPhone(phone) {
		var phone = document.getElementById(phone).value; 
		var phoneChar = /^[0-9 ()/-]{3,66}$/i;
		if (phoneChar.test(phone)) { return true; } else { return false; }
  }
	
	function validEmail(email) { 
		var email = document.getElementById(email).value; 
		var emailChar = /^[a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i;
		if (emailChar.test(email)) { return true; } else { return false; }
  }
	
	function validRadio(radio) {
		var el = document.forms[0].elements;
		for(var i=0; i<el.length; ++i) {
	  	if(el[i].type == "radio") {
				var radiogroup = el[el[i].name];
				var itemchecked = false;
	  		for(var j=0; j<radiogroup.length; ++j) {
					if(radiogroup[j].checked) {
						itemchecked = true;
						break;
					}
	  		}
				if(!itemchecked) { //el[i].name;
					return false;
				}
	  	}
	 	}
	 	return true;
	} 
	
	function validArea() {
		var area = document.getElementsByTagName("textarea")[0];
		if (area.value == 0) {
			return false;
		} else {
			return true
	  }
	}
	
	function validLength(field, min, max) {
		var field = document.getElementById(field).value; 
		if (max == 0) {
			if (field.length >= min) { return true; } else { return false; }
		} else {
  		if (field.length >= min && field.length <= max) { return true; } else { return false; }
  	}
  }

  function validDate(day,month,year) {
    month = month - 1;
    var selectedDate = new Date(year,month,day);
    var todayDate = new Date();
    if (year != selectedDate.getFullYear()) { return false; }
    if (month != selectedDate.getMonth())   { return false; }
    if (day != selectedDate.getDate())      { return false; }
    return true;
  }
  
  
  /* ++-- HERVORHEBUNG --++ */
	var classErrorText     = "classErrorText";
	var classErrorField    = "classErrorField";
	var classErrorTextArea = "classErrorTextArea";
	function colorNormalText(id)     { document.getElementById(id + "Text").className = ""; }
	function colorErrorText(id)      { document.getElementById(id + "Text").className = classErrorText; }
	function colorNormalField(id)    { document.getElementById(id).className = "field"; }
	function colorErrorField(id)     { document.getElementById(id).className = "field " + classErrorField; }
	function colorNormalTextArea(id) { document.getElementById(id).className = "textarea"; }
	function colorErrorTextArea(id)  { document.getElementById(id).className = "textarea " + classErrorTextArea; }
  