var popup;
var subnav_top_zugeklappt = 110;

function galerie_bild_anzeigen(bild, titel)
{
	// var html = document.getElementById(bild).innerHTML + "<br /><br />" + titel;
	var html = document.getElementById(bild).innerHTML;
	html = "<a id='a_schliessen' href='javascript:popup_schliessen()'></a><div class='content galerie'>" + html + "</div>";

   	// Div entfernen falls schon vorhanden
	popup_schliessen();

	

  	// Div dynamisch erzeugen
	popup = document.createElement("div");
   	popup.id = "popup";
   	popup.className = "galerie";

    popup_width = 940;
    popup_height = 560;

	var scrolltop = window.pageYOffset;
	if (scrolltop == null) scrolltop = document.documentElement.scrollTop;
	if (scrolltop == null) scrolltop = document.body.scrollTop;
    if (scrolltop == null) scrolltop = 0;
	popup.style.left = (get_window_width() / 2) - (popup_width / 2) - 25 + "px";
   	popup.style.top = (get_window_height() / 2) - (popup_height / 2) + scrolltop - 25 + "px";

   	popup.innerHTML = html;
   	document.getElementsByTagName("body")[0].appendChild(popup);
}


function popup_anzeigen(html)
{
	document.getElementById("body").style.cursor = "wait";
   	popup_schliessen();

   	// Div dynamisch erzeugen
	popup = document.createElement("div");
   	popup.id = "popup";

    popup_width = 940;
    popup_height = 700;

	var scrolltop = window.pageYOffset;
	if (scrolltop == null) scrolltop = document.documentElement.scrollTop;
	if (scrolltop == null) scrolltop = document.body.scrollTop;
    if (scrolltop == null) scrolltop = 0;

	popup.style.left = (get_window_width() / 2) - (popup_width / 2) + "px";
   	popup.style.top = (get_window_height() / 2) - (popup_height / 2) + scrolltop + "px";

   	document.getElementById("body").appendChild(popup);
	
	html = "<div class='content galerie'><img src='" + html + "' alt='' /></div><br /><a id='a_schliessen' href='javascript:popup_schliessen()'>PopUp schließen</a>";
	popup.innerHTML = html;
	document.getElementById("body").style.cursor = "auto";	
}

function popup_schliessen()
{
	// Div entfernen
	if (document.getElementById("popup") != null)
	{
		document.getElementById("body").removeChild(popup);
    	popup = null;

    	// Transparenz aufheben
    	/*
		document.getElementById('page').style.opacity = '1';
        document.getElementById('page').style.MozOpacity = '1';
        document.getElementById('page').style.KHTMLOpacity = '1';
        document.getElementById('page').style.filter = 'alpha(opacity:100)';
		*/
	}
}

function page_schatten()
{
	if (get_window_width() > 1000)
	{
		document.getElementById("page").style.width = "1010px";
		document.getElementById("page").style.height = "660px";
		document.getElementById("oben").style.width = "993px";
		document.getElementById("mitte").style.width = "993px";
		document.getElementById("unten").style.width = "993px";
		document.getElementById("unten").style.height = "420px";
	}
}

function get_window_width()
{
    if (document.documentElement.clientWidth)
		window_width = document.documentElement.clientWidth;
	else
	if (document.body.offsetWidth)
		window_width = document.body.offsetWidth;
	else
		window_width = window.innerWidth;
	return window_width;
}

function get_window_height()
{
    if (document.documentElement.clientHeight)
		window_height = document.documentElement.clientHeight;
	else
	if (document.body.offsetHeight)
		window_height = document.body.offsetHeight;
	else
		window_height = window.innerHeight;
	return window_height;
}

function subnav_ein(id)
{
	subnav_alle_aus();
	nav = document.getElementById("nav" + id);
	subnav = document.getElementById("subnav" + id);
	subnav.style.marginLeft = nav.offsetLeft + "px";
	subnav.style.display = "block";
}

function subnav_aus(id)
{
	subnav_alle_aus();
	subnav = document.getElementById("subnav" + id);
	subnav.style.display = "none";
}

function subnav_alle_aus()
{
	elements = document.getElementsByTagName("ul");
	for (i = 0; i < elements.length; i++)
		if (elements[i].className == "nav_sub") elements[i].style.display = "none";
	elements = document.getElementsByTagName("li");
	for (i = 0; i < elements.length; i++)
		if (elements[i].offsetTop != subnav_top_zugeklappt)
		{
			if (elements[i].className == "aktiv")
			{
				new Effect.Move(elements[i], { x: 0, y: +36, mode: 'relative', duration: 0.3 });		
				elements[i].className = "";
			}
		}
		else
			elements[i].className = "";
}
