
window.hide_timer = null;
window.menuactive = null;
window.divid_search = "suche";
window.prefix_dropdown = "dropdown-";
window.prefix_menu = "menu-";
window.prefix_image = "img-";
window.hide_timeout = 500;
window.dropdown_yoffset = 121 + 14;
window.dropdown_xoffset = 0;

function dropdown(divid,linkpath) {

	if(!browser.dom) return true;
	
	var divmenu = new divobj(window.prefix_menu+divid);
	var divdropdown = new divobj(window.prefix_dropdown+divid);
	
	if(window.hide_timer) {
		window.clearTimeout(window.hide_timer);
		window.hide_timer = null;
	}
	if(window.menuactive) {
		if(window.menuactive.id == divdropdown.id) return false;
		drophidenow();
	}
	
	// hide search form
	var divsearch = new divobj(window.divid_search);
	if(divsearch.getobject() && divid=="stadtinfos") {
		divsearch.hide();
	}
	
	var posx = divobj_help_posx(divmenu.getobject()) + window.dropdown_xoffset;
	var posy = divobj_help_posy(divmenu.getobject()) + window.dropdown_yoffset;
	
	divdropdown.moveto(posx,posy);
	divdropdown.show();
	if(image = document.getElementById(window.prefix_image+divid)) image.src = "images/home_"+divid+"_a.jpg";
	window.menuactive = divdropdown;
	window.menuactive_id = divid;
	return false;
}

function drophide() {
	window.hide_timer = window.setTimeout("drophidenow()",window.hide_timeout);
}

function drophidenow() {
	if(window.menuactive) {
		window.menuactive.hide();
		window.menuactive = null;

		if(image = document.getElementById(window.prefix_image+window.menuactive_id)) image.src = "images/home_"+window.menuactive_id+".jpg";
		
		// show search form
		var divsearch = new divobj(window.divid_search);
		if(divsearch.getobject()) divsearch.show();
	}
	if(window.hide_timer) {
		window.clearTimeout(window.hide_timer);
		window.hide_timer = null;
	}
}

function onClick() {
	if(window.menuactive) {
		window.menuactive.hide();
		window.menuactive = null;
	}
}


function init() {
	if (browser.dom && (browser.ie4||browser.ns6)) {
		document.onclick=drophidenow;
		
		if( (menu = document.getElementById(window.prefix_menu+"stadtinfos")) && (drop = document.getElementById(window.prefix_dropdown+"stadtinfos")) ) {
			menu.onmouseover = drop.onmouseover = function(event) { dropdown('stadtinfos', '../stadtinfos/'); return false; };
			menu.onmouseout = drop.onmouseout = function(event) { drophide(); };
		}
		
		if( (menu = document.getElementById(window.prefix_menu+"tourismus")) && (drop = document.getElementById(window.prefix_dropdown+"tourismus")) ) {
			menu.onmouseover = drop.onmouseover = function(event) { dropdown('tourismus', '../tourismus/'); return false; };
			menu.onmouseout = drop.onmouseout = function(event) { drophide(); };
		}
		
		if( (menu = document.getElementById(window.prefix_menu+"wirtschaft")) && (drop = document.getElementById(window.prefix_dropdown+"wirtschaft")) ) {
			menu.onmouseover = drop.onmouseover = function(event) { dropdown('wirtschaft', '../wirtschaft/'); return false; };
			menu.onmouseout = drop.onmouseout = function(event) { drophide(); };
		}
		
		if( (menu = document.getElementById(window.prefix_menu+"service")) && (drop = document.getElementById(window.prefix_dropdown+"service")) ) {
			menu.onmouseover = drop.onmouseover = function(event) { dropdown('service', '../service/'); return false; };
			menu.onmouseout = drop.onmouseout = function(event) { drophide(); };
		}
		
		if( (menu = document.getElementById(window.prefix_menu+"kontakt")) && (drop = document.getElementById(window.prefix_dropdown+"kontakt")) ) {
			menu.onmouseover = drop.onmouseover = function(event) { dropdown('kontakt', '../kontakt/'); return false; };
			menu.onmouseout = drop.onmouseout = function(event) { drophide(); };
		}

	}
	
	// Workaround für Netscape 7: Position über dovobj_help_posXY wird ohne Tabellen-Rahmen berechnet:
	if(posdiv = document.getElementById("inhalt-mitte")) {
		if(divobj_help_posy(posdiv)==0) { // "inhalt-mitte" muss einen Abstand nach oben haben durch den Tabellen-Rahmen...
			window.dropdown_yoffset += 10;
			window.dropdown_xoffset += 15;
		}
	} else if(posdiv = document.getElementById("hauptnavigation-links")) {
		if(divobj_help_posy(posdiv)==0) { // "hauptnavigation-links" muss einen Abstand nach oben haben durch den Tabellen-Rahmen...
			window.dropdown_yoffset += 10;
			window.dropdown_xoffset += 15;
		}
	}
	
}

window.onload = init;


