function ErrMessage(errStr)
{
	if (errStr.length > 2)
		alert(errStr);
}

function noSpam()
{
	if (document.getElementById)
	{
		var at = "@";
		var id = document.getElementById("mail");
		var mail = id.firstChild; var domain = id.lastChild;
		mail.nextSibling.firstChild.innerHTML = at;
		id.href = "mailto:" + mail.data + at + domain.data;
	}
}
function ActivateMenue(Nr)
{
	document.getElementById("menue"+Nr).style.backgroundColor = "#646467";
}

function mouseOver(obj)
{
	if (obj.style.backgroundColor != "#646467")
		obj.style.backgroundColor = "#646464";
}

function mouseOut(obj)
{
	if (obj.style.backgroundColor != "#646467")
		obj.style.backgroundColor = "";
}

function ChangeImages(NewImageSrc1)
{
	document.getElementById("image").src = "img/"+NewImageSrc1;
}

function OpenReferenz(ID)
{
	var width = 600;
	var height= 430;
	var win = window.open("refdetails.php?ID="+ID, "Referenzen", "width="+width+",height="+height+",scrollbars=no");
	win.moveTo((screen.width - width)/2, (screen.height-height)/2);
}

function OpenGalerie(projektID)
{
	var width = 798;
	var height= 620;
	var win = window.open("service_galerie_details.php?projektID="+projektID, "_blank", "width="+width+",height="+height+",resizable=yes,scrollbars=yes");
	win.moveTo((screen.width - width)/2, (screen.height-height)/2);
}

function OpenInfo(ID)
{
	var width = 440;
	var height= 620;
	var win = window.open("shopInfo.php?ID="+ID, "Artikelinformation"+ID, "width="+width+",height="+height+",scrollbars=yes");
	win.moveTo((screen.width - width)/2, (screen.height-height)/2);
}

function OpenProjekt(projektID)
{
	var width = 798;
	var height= 620;
	var win = window.open("referenzen_details.php?projektID="+projektID, "_blank", "width="+width+",height="+height+",resizable=yes,scrollbars=yes");
	win.moveTo((screen.width - width)/2, (screen.height-height)/2);
}

//
// Bild in neuem Fenster öffnen
//
function OpenImage(image, title, text, breite, hoehe)
{
	if (arguments.length == 1)
	{
		window.open("openimage.php?img="+image, "_blank", "scrollbars=yes,resizable=yes");
	}
	else
	{
		var left = (screen.width - breite) / 2;
		var top	 = (screen.height - hoehe) / 2;
		
		if (text != "")
			hoehe += 100;
		
		var win;
		if (text.length > 340)
		{
			breite += 20;
			win = window.open(image,"_blank","width="+breite+",height="+hoehe+",left="+left+",top="+top+",location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=no");
		}
		else
			win = window.open(image,"_blank","width="+breite+",height="+hoehe+",left="+left+",top="+top+",location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no");
		win.document.writeln("<html><head><title>Bildergalerie</title>");
		win.document.writeln("<link rel='stylesheet' type='text/css' href='styles.css'></head>");
		win.document.writeln("<body>");
		win.document.writeln("<table border='0' cellpadding='0' cellspacing='0'><tr><td align='center' valign='top' bgcolor='#96A5A8'>");
		win.document.writeln("<a href='javascript:window.close()'><img src='" + image + "' border='0'></a></td></tr>");
		win.document.writeln("<tr><td align='left' bgcolor='#96A5A8' height='18'><div style='padding-left:10px;padding-right:10px'><font class='bildtitel'>" + title + "</font></div></td></tr>");
		win.document.writeln("<tr><td align='left' valign='top'><div style='padding-top:5px;padding-left:10px;padding-right:10px'><font class='bild'>" + text + "</font></div></td></tr>");
		win.document.writeln("</table>");
		win.document.writeln("</body></html>");
	}
}

function OpenWebsite(url)
{
	var width = 686;
	var height= 650;
	var win = window.open(url, "_blank", "width="+width+",height="+height+",scrollbars=yes");
	win.moveTo((screen.width-width)/2, (screen.height-height)/2);
}

////////////////////////////////////////////////////////////////////////////
// Beginn POPUP-Menue
////////////////////////////////////////////////////////////////////////////

var breite;
var aktiv;
var SubPopupaktiv;

function hidealllayer()
{
	document.getElementById("popmenue1").style.visibility="hidden";
	document.getElementById("popmenue2").style.visibility="hidden";
	document.getElementById("popmenue3").style.visibility="hidden";
	document.getElementById("popmenue4").style.visibility="hidden";
	document.getElementById("popmenue5").style.visibility="hidden";
	document.getElementById("popmenue8").style.visibility="hidden";
}

////////////////////////////////////////////
// [x][y]-Position eines Objekts zurückgeben
////////////////////////////////////////////
function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function show_layer(x)
{
	if (document.getElementById)
	{
		hidealllayer();

		pos = findPos(document.getElementById(x));
		//if (x == "menue1") hoehe = pos[1] - ((1 + Anzahl_Unternehmen) * 19 + 1);
		//if (x == "menue2")  hoehe = pos[1] - ((1 + Anzahl_Einsatzgebiete) * 19 + 1);
		//if (x == "menue3") hoehe = pos[1] - ((3) * 19 + 1);
		//if (x == "menue4") hoehe = pos[1] - ((6) * 19 + 1);
		//if (x == "menue5") hoehe = pos[1] - ((3) * 19 + 1);
		//if (x == "menue8")  hoehe = pos[1] - ((1 + Anzahl_Produkte) * 19 + 1);
		breite = pos[0] - 1;
		hoehe  = pos[1] + 19;
		
		window.document.getElementById("pop"+x).style.top = hoehe /* + window.document.body.scrollTop */+"px";
		window.document.getElementById("pop"+x).style.left= breite /*+ window.document.body.scrollLeft */+"px";
		
		window.document.getElementById("pop"+x).style.visibility="visible";

		window.clearTimeout(aktiv);
		aktiv = window.setTimeout("hidealllayer()",15000); // Das Menue automatisch nach 15s schließen
	}
}

function menuOut(s)
{
	if( s == 0)
	{
		window.clearTimeout(aktiv);
		aktiv=window.setTimeout("hidealllayer()",1000);
	}
	else
		window.clearTimeout(aktiv);
}

////////////////////////////////////////////////////////////////////////////
// Ende POPUP-Menue
////////////////////////////////////////////////////////////////////////////

function SubPopup_hidealllayer()
{
	for (i=1; i<50; i++)
	{
		if (document.getElementById("kat"+i))
			document.getElementById("kat"+i).style.visibility="hidden";
	}
}

function SubPopup(kat, ID, katID)
{
	SubPopup_hidealllayer();
	
	kat = kat.replace(/\s/, "_");
	pos = findPos(document.getElementById("popupLink"+ID));
	breite = 190; //pos[0] - 1;
	hoehe  = pos[1] - 200;
	document.getElementById("kat"+katID).style.top = hoehe /* + window.document.body.scrollTop */+"px";
	document.getElementById("kat"+katID).style.left= breite /*+ window.document.body.scrollLeft */+"px";
	document.getElementById("kat"+katID).style.visibility = "visible";

	window.clearTimeout(SubPopupaktiv);
	SubPopupaktiv = window.setTimeout("SubPopup_hidealllayer()",15000); // Das Menue automatisch nach 15s schließen
}

function SubPopupOut(s)
{
	if( s == 0)
	{
		window.clearTimeout(SubPopupaktiv);
		SubPopupaktiv=window.setTimeout("SubPopup_hidealllayer()",1000);
	}
	else
		window.clearTimeout(SubPopupaktiv);
}

function SubPopup_hidealllayerTeichbau()
{
	for (i=1; i<50; i++)
	{
		if (document.getElementById("teichbau"+i))
			document.getElementById("teichbau"+i).style.visibility="hidden";
	}
}

function SubPopupTeichbau(kat, ID, katID)
{
	SubPopup_hidealllayerTeichbau();
	
	kat = kat.replace(/\s/, "_");
	pos = findPos(document.getElementById("popupLinkTeichbau"+ID));
	breite = 190; //pos[0] - 1;
	hoehe  = pos[1] - 200;
	document.getElementById("teichbau"+katID).style.top = hoehe /* + window.document.body.scrollTop */+"px";
	document.getElementById("teichbau"+katID).style.left= breite /*+ window.document.body.scrollLeft */+"px";
	document.getElementById("teichbau"+katID).style.visibility = "visible";

	window.clearTimeout(SubPopupaktiv);
	SubPopupaktiv = window.setTimeout("SubPopup_hidealllayerTeichbau()",15000); // Das Menue automatisch nach 15s schließen
}


function SubPopupOutTeichbau(s)
{
	if( s == 0)
	{
		window.clearTimeout(SubPopupaktiv);
		SubPopupaktiv=window.setTimeout("SubPopup_hidealllayerTeichbau()",1000);
	}
	else
		window.clearTimeout(SubPopupaktiv);
}

function SubPopup_hidealllayerProdukte()
{
	for (i=1; i<50; i++)
	{
		if (document.getElementById("produkte"+i))
			document.getElementById("produkte"+i).style.visibility="hidden";
	}
}

function SubPopupProdukte(kat, ID, katID)
{
	SubPopup_hidealllayerProdukte();
	
	kat = kat.replace(/\s/, "_");
	pos = findPos(document.getElementById("popupLinkProdukte"+ID));
	breite = 190; //pos[0] - 1;
	hoehe  = pos[1] - 200;
	document.getElementById("produkte"+katID).style.top = hoehe /* + window.document.body.scrollTop */+"px";
	document.getElementById("produkte"+katID).style.left= breite /*+ window.document.body.scrollLeft */+"px";
	document.getElementById("produkte"+katID).style.visibility = "visible";

	window.clearTimeout(SubPopupaktiv);
	SubPopupaktiv = window.setTimeout("SubPopup_hidealllayerProdukte()",15000); // Das Menue automatisch nach 15s schließen
}

function SubPopupOutProdukte(s)
{
	if( s == 0)
	{
		window.clearTimeout(SubPopupaktiv);
		SubPopupaktiv=window.setTimeout("SubPopup_hidealllayerProdukte()",1000);
	}
	else
		window.clearTimeout(SubPopupaktiv);
}

