var popup;

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(url)
{
	document.getElementById("body").style.cursor = "wait";
   	popup_schliessen();

   	// Div dynamisch erzeugen
	popup = document.createElement("div");
   	popup.id = "popup";

    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) + "px";
   	popup.style.top = (get_window_height() / 2) - (popup_height / 2) + scrolltop + "px";

   	document.getElementById("body").appendChild(popup);

	if (urls_optimieren == 1) url = root_verzeichnis + url;
	
	new Ajax.Request(url,
	{
        method: 'get',
        onSuccess: function(transport)
    	{
    		var html = transport.responseText;
        	popup.innerHTML = html;
		  	document.getElementById("body").style.cursor = "auto";
    	},
    	onFailure: function(){ alert('Error') }
    });
}

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";
}
