var itemcount = 0; function validateFormContact(theForm) {	document.getElementById('formErrors').style.display = "none";	var reason = "";  	reason += validateLegalChars(theForm.name, "Name");  	reason += validateEmail(theForm.email, "Email");        	if (reason != "") {  		document.getElementById('formErrors').style.display = "block";  		document.getElementById('formErrors').innerHTML = reason ;    	return false;  	}  	return true;  	}function validateErimaOrder(theForm) {	document.getElementById('formErrors').style.display = "none";	var reason = "";  	reason += validateLegalChars(theForm.name, "Name");  	reason += validateEmpty(theForm.address, "Adresse");  	reason += validateNumber(theForm.zip, "Postleitzahl");  	reason += validateLegalChars(theForm.city, "Ort");  	reason += validateEmail(theForm.email, "Email");  	reason += validatePhone(theForm.phone, "Telefon");  	reason += validateOrder();        	if (reason != "") {  		document.getElementById('formErrors').style.display = "block";  		document.getElementById('formErrors').innerHTML = reason ;    	return false;  	}  	return true;}function validateFormPerson(theForm) {	document.getElementById('formErrors').style.display = "none";	var reason = "";  	reason += validateLegalChars(theForm.firstname, "Vorname");  	reason += validateLegalChars(theForm.street, "Strasse");  	reason += validateLegalChars(theForm.lastname, "Nachnamen");  	reason += validateLegalChars(theForm.city, "Ort");  	reason += validateEmail(theForm.email, "Email");  	reason += validatePhone(theForm.phone, "Telefon");  	reason += validateNumber(theForm.zip, "Postleitzahl");  	reason += validateList(theForm.birthdate_day, "Geburtsdatum (Tag)");  	reason += validateList(theForm.birthdate_month, "Geburtsdatum (Monat)");  	reason += validateList(theForm.birthdate_year, "Geburtsdatum (Jahr)");  	reason += validateDatelist("campdate[]", "Campdaten");        	if (reason != "") {  		document.getElementById('formErrors').style.display = "block";  		document.getElementById('formErrors').innerHTML = reason ;    	return false;  	}  	return true;}function validateFormYoungPerson(theForm) {	document.getElementById('formErrors').style.display = "none";	var reason = "";  	reason += validateLegalChars(theForm.firstname, "Vorname");  	reason += validateLegalChars(theForm.street, "Strasse");  	reason += validateLegalChars(theForm.lastname, "Nachnamen");  	reason += validateLegalChars(theForm.city, "Ort");  	reason += validateEmail(theForm.email, "Email");  	reason += validatePhone(theForm.phone, "Telefon");  	reason += validateNumber(theForm.zip, "Postleitzahl");  	reason += validateList(theForm.birthdate_day, "Geburtsdatum (Tag)");  	reason += validateList(theForm.birthdate_month, "Geburtsdatum (Monat)");  	reason += validateList(theForm.birthdate_year, "Geburtsdatum (Jahr)");  	reason += validateDatelist("campdate[]", "Campdaten");  	reason += validateCheckbox(theForm.camprules, "Camprules");        	if (reason != "") {  		document.getElementById('formErrors').style.display = "block";  		document.getElementById('formErrors').innerHTML = reason ;    	return false;  	}  	return true;}function validateFormTeam(theForm) {	document.getElementById('formErrors').style.display = "none";	var reason = "";  	reason += validateLegalChars(theForm.teamname, "Teamname");  	reason += validateNumber(theForm.number_of_players, "Anzahl Spielerinnen");  	reason += validateLegalChars(theForm.firstname, "Vorname");  	reason += validateLegalChars(theForm.lastname, "Nachnamen");  	reason += validateLegalChars(theForm.street, "Strasse");  	reason += validateLegalChars(theForm.city, "Ort");  	reason += validateEmail(theForm.email, "Email");  	reason += validatePhone(theForm.phone, "Telefon");  	reason += validateNumber(theForm.zip, "Postleitzahl");  	reason += validateList(theForm.birthdate_day, "Geburtsdatum (Tag)");  	reason += validateList(theForm.birthdate_month, "Geburtsdatum (Monat)");  	reason += validateList(theForm.birthdate_year, "Geburtsdatum (Jahr)");  	reason += validateDatelist("campdate[]", "Campdaten");        	if (reason != "") {  		document.getElementById('formErrors').style.display = "block";  		document.getElementById('formErrors').innerHTML = reason ;    	return false;  	}  	return true;  	}function trim(s) {  return s.replace(/^\s+|\s+$/, '');}function validateOrder() {    var error = "";    	if (itemcount == 0) { error = "Sie haben <strong>keinen Artikel</strong> bestellt.<br/>"; }    return error;  }// check if e.g. for camprulesfunction validateCheckbox(fld, fldAlias) {    var error = "";     if (!(fld.checked)) {        error = "Sie m&uuml;ssen unsere <strong>" + fldAlias + " akzeptieren<\/strong> um sich anzumelden.<br/>";    }     return error; }function validateDatelist(fld, fldAlias) {    var error = "";    var count = 0;        set = document.theForm.elements[fld];        for (var j=0; j<set.length; j++) {      if (set[j].checked) { count++ ; }    }	if (count == 0) { error = "Bitte w&auml;hlen sie mindestens ein Element aus der Liste <strong>" + fldAlias + "<\/strong>.<br/>"; }    return error;  }// validate if list element is chosen e.g. year of birthfunction validateList(fld, fldAlias) {    var error = "";     if (fld.value == "DEFAULT") {        fld.style.background = '#FBE3E4';         error = "Bitte w&auml;hlen sie ein Element aus der Liste <strong>" + fldAlias + "<\/strong> .<br/>";    } else {        fld.style.background = '#ffffff';    }    return error;  }function validateEmpty(fld, fldAlias) {    var error = "";     if (fld.value.length == 0) {        fld.style.background = '#FBE3E4';         error = "Das Feld <strong>" + fldAlias + "<\/strong> darf nicht leer sein.<br/>";    } else {        fld.style.background = '#ffffff';    }    return error;  }function validateLegalChars(fld, fldAlias) {    // mehr als zwei Zeichen, weniger als 100 keine Nummern    var error = "";    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');        reg = /\d/; 	    if (fld.value == "") {        fld.style.background = '#FBE3E4';         error = "Das Feld <strong> " + fldAlias + "<\/strong> darf nicht leer sein.<br/>";    } else if ((fld.value.length < 2) || (fld.value.length > 100)) {        fld.style.background = '#FBE3E4';         error = "Die Eingabe im Feld <strong>" + fldAlias + "<\/strong> ist zu kurz oder zu lang.<br/>";    } else if (reg.test(stripped)) {        fld.style.background = '#FBE3E4';         error = "Im Feld <strong>" + fldAlias + "<\/strong> wurden ung&uuml;ltige Zeichen eingegeben.<br/>";    } else {        fld.style.background = '#ffffff';    }    return error;}function validateEmail(fld, fldAlias) {    var error = "";    var tfld = trim(fld.value);	// value of field with whitespace trimmed off    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;       if (fld.value == "") {        fld.style.background = '#FBE3E4';        error = "Sie müssen eine <strong> " + fldAlias + "-Adresse<\/strong> angeben.<br/>";    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters        fld.style.background = '#FBE3E4';        error = "Bitte geben sie eine g&uuml;ltige <strong> " + fldAlias + "-Adresse<\/strong> ein.<br/>";    } else if (fld.value.match(illegalChars)) {        fld.style.background = '#FBE3E4';        error = "Das eingegebene <strong> " + fldAlias + "-Adresse<\/strong> enthält ungültige Zeichen.<br/>";    } else {        fld.style.background = '#ffffff';    }    return error;}function validateNumber(fld, fldAlias) {    var error = "";        if (fld.value == "") {        error = "Das Feld <strong> " + fldAlias + "<\/strong> darf nicht leer sein.<br/>";        fld.style.background = '#FBE3E4';    } else if (isNaN(fld.value)) {        error = "Das Feld <strong> " + fldAlias + "<\/strong> darf nur Zahlen beinhalten.<br/>";        fld.style.background = '#FBE3E4';    } else {        fld.style.background = '#ffffff';    }    return error;}function validatePhone(fld, fldAlias) {    var error = "";    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');       if (fld.value == "") {        error = "Das Feld <strong> " + fldAlias + "<\/strong> darf nicht leer sein.<br/>";        fld.style.background = '#FBE3E4';    } else if (isNaN(stripped)) {        error = "Das Feld <strong> " + fldAlias + "<\/strong> darf nur Zahlen beinhalten.<br/>";        fld.style.background = '#FBE3E4';    } else {        fld.style.background = '#ffffff';    }    return error;}function addRow(iNo, iName, iSize, iCount){         if (!document.getElementsByTagName) return;         // address the right table!         tabBody = document.getElementsByTagName("TBODY").item(1);         row = document.createElement("TR");                  cell1 = document.createElement("TD");         cell2 = document.createElement("TD");         cell3 = document.createElement("TD");         cell4 = document.createElement("TD");         cell5 = document.createElement("TD");                  textnode1 = document.createTextNode(iNo);         textnode2 = document.createTextNode(iName);         textnode3 = document.createTextNode(iSize);         textnode4 = document.createTextNode(iCount);                  el = document.createElement('input');         el.type = 'button';  		 el.name = 'del'; 		 el.id = 'del'; 		 el.value = 'entfernen'; 		 el.onclick = new Function('F','removeItem(this)'); 		  		 elNo = document.createElement('input');         elNo.type = 'hidden';  		 elNo.name = 'iNo[]'; 		 elNo.value = iNo; 		  		 elName = document.createElement('input');         elName.type = 'hidden';  		 elName.name = 'iName[]'; 		 elName.value = iName; 		  		 elSize = document.createElement('input');         elSize.type = 'hidden';  		 elSize.name = 'iSize[]'; 		 elSize.value = iSize; 		  		 elCount = document.createElement('input');         elCount.type = 'hidden';  		 elCount.name = 'iCount[]'; 		 elCount.value = iCount;                  cell1.appendChild(textnode1);         cell1.appendChild(elNo);         cell2.appendChild(textnode2);         cell2.appendChild(elName);         cell3.appendChild(textnode3);         cell3.appendChild(elSize);         cell4.appendChild(textnode4);         cell4.appendChild(elCount);         cell5.appendChild(el);                  row.appendChild(cell1);         row.appendChild(cell2);         row.appendChild(cell3);         row.appendChild(cell4);         row.appendChild(cell5);                  tabBody.appendChild(row);}function addItem(theForm) {	document.getElementById('orderErrors').style.display = "none";	document.getElementById('items').style.display = "block";	 	var reason = ""; 	 	reason += validateEmpty(theForm.item_no, "Artikelnummer"); 	reason += validateEmpty(theForm.item_name, "Artikelname"); 	reason += validateEmpty(theForm.item_size, "Grösse"); 	reason += validateNumber(theForm.item_count, "Anzahl"); 			if (reason != "") {  		document.getElementById('orderErrors').style.display = "block";  		document.getElementById('orderErrors').innerHTML = reason ;  	}	else {			itemcount++;				// hide first row		//document.getElementById("no_item").style.display = "none";				// add row to table		addRow(theForm.item_no.value, theForm.item_name.value, theForm.item_size.value, theForm.item_count.value);		  		// empty fields  		theForm.item_no.value = '';  		theForm.item_name.value = '';  		theForm.item_size.value = '';  		theForm.item_count.value = '';  		// add hidden fields   			}}function removeItem(r) {		itemcount--;		var i = r.parentNode.parentNode.rowIndex;	document.getElementById('items').deleteRow(i);		if (itemcount == 0)  document.getElementById("items").style.display = "none"; }