function validateFormLogin() {
	var tf = document.form_login;
	var err = false;
	var ef = false;
	
	//check for errors
	ef = tf.inp_username;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "inp-promotoren-err";
	} else {
		ef.className = "inp-promotoren";
	} //end if
	
	ef = tf.inp_password;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "inp-promotoren-err";
	} else {
		ef.className = "inp-promotoren";
	} //end if
	
	
	//if error exists take action, else submit
	if(err) {
		err.focus();
		document.getElementById("err-field").className = "form-info-err";
	} else {
		document.getElementById("err-field").className = "form-info";
		// tf.action = "agentur_promotoren_login.php";
		tf.submit();
	} //end if
} //end function validateFormLogin()





function validateFormKontakt() {
	var tf = document.form_kontakt;
	var err = false;
	var ef = false;
	
	//check for errors
	ef = tf.inp_vorname;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_nachname;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_email;
	if(validateEmail(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if

	ef = tf.inp_nachricht;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if

	//if error exists take action, else submit
	if(err) {
		err.focus();
		document.getElementById("err-field").className = "form-info-err";
	} else {
		document.getElementById("err-field").className = "form-info";
		tf.submit();
	} //end if
	
} //function validateFormKontakt()


function validateFormBewerbung() {
	var tf = document.form_bewerbung;
	var err = false;
	var ef = false;
	
	//check for errors
	ef = tf.inp_vorname;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_nachname;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_strasse;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_nummer;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_plz;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_ort;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_email;
	if(validateEmail(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if

	ef = tf.inp_datum_tt;
	if(validateString(ef.value) || validateString(tf.inp_datum_mm.value) || validateString(tf.inp_datum_jjjj.value)) {
		if(!err) err = ef; ef.className = "err"; tf.inp_datum_mm.className = "err"; tf.inp_datum_jjjj.className = "err";
	} else {
		ef.className = ""; tf.inp_datum_mm.className = ""; tf.inp_datum_jjjj.className = "";
	} //end if
	
	ef = tf.inp_telefon;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_mobiltelefon;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if
	
	ef = tf.inp_nachricht_1;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if

	ef = tf.inp_nachricht_2;
	if(validateString(ef.value)) {
		if(!err) err = ef; ef.className = "err";
	} else {
		ef.className = "";
	} //end if

	
	//if error exists take action, else submit
	if(err) {
		err.focus();
		document.getElementById("err-field").className = "form-info-err";
	} else {
		document.getElementById("err-field").className = "form-info";
		tf.submit();
	} //end if
	
} //function validateFormBewerbung()






/* ------------------------ */
/* Validation functions 	*/
/* ------------------------ */
function validateString(what) {
	//check if string empty
	if (what != "")
		return false;
	else
		return true;
}
function compareString(what1, what2) {
	//compare 2 strings
	if (what1 == what2)
		return false;
	else
		return true;
}
function stringLength(tString, tLength1, tLength2) {
	//check if string length is in range
	if ((tString.length >= tLength1) && (tString.length <= tLength2))
		return false;
	else
		return true;
}
function validateEmail(what) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(what)) 
		return false;
	else 
		return true;
}
