// Für Navigation - Drop-Down

var TimeAktiv;
var thumbOpen;

// Wenn Maus ausserhalb vom Menü, alle Layer nach 0,5 Sekunde ausblenden
function CheckMouseOut()
{
	if(TimeAktiv) window.clearTimeout(TimeAktiv);
	TimeAktiv = window.setTimeout('HideSubmenus()',500);
}

// Navigation 1.Ebene - Horizontale Navigation
function DisplayMenu(id)
{
	HideSubmenus();
	if(document.getElementById('submenu' + id))
	{
		document.getElementById('submenu' + id).style.display = 'block';
	}
}

function defineMenuWidth()
{
	//alert(menuId.length);
	for(var i=0; i < menuId.length; i++){
		var mId = menuId[i];
		var elementDiv = document.getElementById('submenu' + mId);
		var elementCell = document.getElementById('menuitem' + mId);
		var elementHeightCell = document.getElementById('menucell' + mId);
		var divWidth = elementDiv.offsetWidth;
		elementCell.style.width = divWidth + 'px';
		var cellWidth = elementCell.offsetWidth - 2;
		var divHeight = elementDiv.offsetHeight;
		var cellHeight = elementHeightCell.offsetHeight;
		if(divHeight < cellHeight)
		{
			var divTopPadding = (cellHeight / 2 - 9);
			elementDiv.style.paddingTop = (cellHeight / 2 - 10) + 'px';
			elementDiv.style.height = (cellHeight-divTopPadding) + 'px';
		}

		/*if(divWidth > cellWidth + 2)
		{
		    //alert('A ' + cellWidth + ' --- ' + divWidth);
			elementCell.style.width = divWidth + 'px';
		}
		else if(cellWidth > divWidth)
		{
		    //alert('B ' + cellWidth + ' --- ' + divWidth);
			elementDiv.style.width = cellWidth + 'px';
		}*/

		elementDiv.style.display = 'none';
	}
}


var popwin;
// PopUps aufrufen
function PopUp(src,w,h)
{
	oversize = 0;
	if(popwin) popwin.close();

	if(w > screen.width-100)
	{
		oversize = 1;
		// h = Math.round((screen.width-100)/w*h); // Verhältnis
		h = parseInt(h)+20; // Scrollbars
		w = (screen.width-100);
	}
	if(h > screen.height-150)
	{
		oversize = 1;
	    	// w = Math.round((screen.height-150)/h*w); // Verhältnis
	    	w = parseInt(w)+20; // Scrollbars
		h = (screen.height-150);
	}

	breite = Math.round((screen.width - w) / 2);
	hoehe = Math.round((screen.height - h) / 2);

	if(oversize == 1)
		popwin = window.open(src,"popwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h+",top="+hoehe+",left="+breite);
	else
		popwin = window.open(src,"popwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h+",top="+hoehe+",left="+breite);
}

function PrintView(src,w,h)
{
	var breite = (screen.width - w) / 2;
	var hoehe = (screen.height - h) / 2;
	window.open(src,"printview","toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+w+",height="+h+",top="+hoehe+",left="+breite);
}

function ClearForm(Formular)
{
	document.forms[Formular].reset(); // Zuerst reset!
	var x = 0;
	while(document.forms[Formular].elements[x])
	{
		if(document.forms[Formular].elements[x].type == "checkbox" || document.forms[Formular].elements[x].type == "radio")
		{
			// Checkboxen + Radiobuttons werden nicht angehakt
			document.forms[Formular].elements[x].checked = false;
		}
		else if(document.forms[Formular].elements[x].type != "hidden" && document.forms[Formular].elements[x].type != "submit" && document.forms[Formular].elements[x].type != "reset" && document.forms[Formular].elements[x].type != "button")
		{
			// Alle, ausser versteckte Felder, dürfen geleert werden
			document.forms[Formular].elements[x].value = "";
		}
		x++;
	}
}

function ScrollToTop()
{
	var y = 0;

	if(window.pageYOffset) y = window.pageYOffset;
	else
	if(document.body && document.body.scrollTop) y=document.body.scrollTop;

	while(y > 0)
	{
		setTimeout("window.scrollBy(0,-20)",10);
		y = y-5;
	}
}

function MakeFavorite(title,url)
{
	if((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
	{
		window.external.AddFavorite(url,title)
	}
	else if(navigator.appName == "Netscape")
	{
		alert("Unsere Homepage können Sie manuell oder\nmit den Tasten STRG+D zu den Favoriten hinzufügen.");
	}
}

/*
Wird nicht mehr benoetigt
function GoToObjects()
{
	var pageid;

	if(document.forms['homeform'].land.value != "") pageid = document.forms['homeform'].land.value;
	if(document.forms['homeform'].stadt.value != "") pageid = document.forms['homeform'].stadt.value;

	if(pageid > 0) location.href = "index.php?id="+pageid;
	//alert(pageid);
}
*/


// PNG-Bilder werden im IE 5.5 oder IE 6 halbtransparent dargestellt, ohne extra Klassen benutzen zu müssen
// vor </body> muss noch folgendes eingebunden werden:
// <script type="text/javascript">
// fixAllPNGs();
// </script>
function fixAllPNGs()
{
	ie = navigator.appVersion.split("MSIE");
	version = parseFloat(ie[1]);

    if((version >= 5.5) && (version < 7) && (document.body.filters))
    {
		for(i=0; i<document.getElementsByTagName('img').length; i++)
		{
			myImage = document.getElementsByTagName('img')[i];

			if(myImage.src.match(/\.png$/) != null)
			{
				var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
				var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
				var imgTitle = (myImage.title) ?
				             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
				var imgStyle = "display:inline-block;" + myImage.style.cssText
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				          + " style=\"" + "width:" + myImage.width
				          + "px; height:" + myImage.height
				          + "px;" + imgStyle + ";"
				          + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				          + "(src=\'" + myImage.src + "\', sizingMethod='image');\"></span>"
				myImage.outerHTML = strNewHTML;
				i--;
			}
		}
	}
}

