function preloadReferencePics()
{
	var maxPics = 6;
	for(var i = 1; i <= maxPics; i ++)
	{
		var img = new Image();
		img.src="../img/referenzen0" + i + ".jpg";
	}
}

function showDiv(divname, imageNum)
{
	var picWidth;
	var width = 850;
	
	if(imageNum == 1) picWidth = 300;
	if(imageNum == 2) picWidth = 264;
	if(imageNum == 3) picWidth = 335;
	if(imageNum == 4) picWidth = 257;
	if(imageNum == 5) picWidth = 253;
	if(imageNum == 6) picWidth = 577;
	
	var image = document.getElementById("referencePic");
	image.src = "../img/referenzen0" + imageNum + ".jpg";
	var element = document.getElementById(divname);
	element.style.width = picWidth + 40 + "px";
	element.style.left = (width / 2 - picWidth / 2 - 20) + "px";
	element.style.visibility = "visible";
}

function hideDiv(divname)
{
	var element = document.getElementById(divname);
	element.style.visibility = "hidden";
}

function checkContactData()
{
	var f = document.formular;
	var msg = "";
	var mailerror = false;
	var fillerror = false;

	if(!f.name.value.length || !f.email.value.length || !f.telefon.value.length || !f.comment.value.length) fillerror = true;
	if(f.email.value.length > 0 && !validate(f.email.value)) mailerror = true;
	
	
	if(fillerror) msg += "Bitte füllen Sie alle Pflichtfelder aus.\n";
	if(mailerror) msg += "Bitte prüfen Sie Ihre E-Mail-Adresse.\n";
	
	if(msg != "")
	{
		alert(msg);
		return;
	} else {
		f.submit();
	}
}

function validate(email)
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(!reg.test(email)) return false;
	return true;
}
