/* ----------------------- */
/* Copyright by Marc Wolf  */
/* ----------------------- */
/* http://www.marcwolf.net */
/* ----------------------- */

function warnung(objLink, strHREF, text) {
    if(confirm(text)) {
        objLink.location = strHREF;
    }
}
function validEmail(email) {
	var strReg = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
	var regex = new RegExp(strReg);
	return(regex.test(email));
}
function checkfields() {
	var error = 0;
	var errcount = new Array();
	var allerrors = "";
	
	errcount.push("Das Formular hat folgende Fehler:\n\n");
	
	if (document.getElementById('cfirstname').value.length == 0) {
		error = 1;
		errcount.push("Vorname fehlt\n");
	}
	if (document.getElementById('csurname').value.length == 0) {
		error = 1;
		errcount.push("Nachname fehlt\n");
	}
	if (document.getElementById('cemail').value.length == 0) {
		error = 1;
		errcount.push("E-Mail Adresse fehlt\n");
	} else {
		if (!validEmail(document.getElementById('cemail').value)) {
			error = 1;
			errcount.push("E-Mail Adresse nicht korrekt\n");
		}
	}
	if (document.getElementById('cquestion').value.length < 3) {
		error = 1;
		errcount.push("Mitteilung fehlt\n");
	}
	
	if (error == 1) {
		errcount.push("\nBitte korrigieren Sie diese!\nVielen Dank.");
		
		for (var i = 0; i < errcount.length; i++) {
			allerrors += errcount[i];
		}
		alert(allerrors);
		return false;
	} else {
		return true;
	}
}
function go(t) {
    window.location.href = t;
}
function countDown() {
	time--;
	if (time > -1) {
		gett("container").innerHTML = time;
	}
	if (time == -1) {
		window.location = page;
	}
}
function gett(id) {
	if(document.getElementById) return document.getElementById(id);
	if(document.all) return document.all.id;
	if(document.layers) return document.layers.id;
	if(window.opera) return window.opera.id;
}
function init() {
	if (gett('container')) {
		setInterval(countDown, 1000);
		gett("container").innerHTML = time;
	} else {
		setTimeout(init, 50);
	}
}
