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

function switcharrow(obj) {
	if (obj == 0) {
		document.getElementById('contactarrow').src = '/img/contact_arrow_up.gif';
	} else if (obj == 1) {
		document.getElementById('contactarrow').src = '/img/contact_arrow_right.gif';
	}
}
function showcontcontact() {
	var c = document.getElementById('wrapper');
	var z = document.getElementById('footer');
	var h = document.getElementById('contact');
	var o = document.getElementById('contactcontent');
	var i = document.getElementById('contactarrow');
	var p = document.getElementById('subject');
	var u = document.getElementById('close');
	//alert(o.style.display);
	if (o.style.display == 'none' || o.style.display == '') {
		i.style.visibility = 'hidden';
		u.style.display = 'inline';
		o.style.display = 'inline';
		h.style.backgroundColor = '#e2001a';
		h.style.height = '430px';
		c.style.marginBottom = '0';
		z.style.position = 'static';
		z.style.bottom = 'auto';
		p.focus();
		window.scrollTo(0,50000);
	} else {
		h.style.height = 'auto';
		i.style.visibility = 'visible';
		u.style.display = 'none';
		o.style.display = 'none';
		c.style.marginBottom = '120px';
		z.style.position = 'absolute';
		z.style.bottom = '0';
	}
}
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('subject').value.length == 0) {
		error = 1;
		errcount.push("Betreff fehlt\n");
	}
	if (document.getElementById('msg').value.length < 3) {
		error = 1;
		errcount.push("Ihre Mitteilung fehlt\n");
	}
	if (document.getElementById('email').value.length == 0) {
		error = 1;
		errcount.push("E-Mail Adresse fehlt\n");
	} else {
		if (!validEmail(document.getElementById('email').value)) {
			error = 1;
			errcount.push("E-Mail Adresse nicht korrekt\n");
		}
	}
	if (document.getElementById('firstname').value.length == 0) {
		error = 1;
		errcount.push("Vorname fehlt\n");
	}
	if (document.getElementById('lastname').value.length == 0) {
		error = 1;
		errcount.push("Nachname fehlt\n");
	}
	if (document.getElementById('zip').value.length == 0) {
		error = 1;
		errcount.push("PLZ/Ort fehlt\n");
	}
	if (document.getElementById('accept').checked == false) {
		error = 1;
		errcount.push("Einverständniserklärung 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 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);
	}
}
var openShadowbox = function(elementId) {
	var el = document.getElementById(elementId);
	if(el) Shadowbox.open(el);
};
Shadowbox.init({
    language: 'de-DE',
    players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']
});

