window.load_complete = false;
window.menuactive = null; // momentaner Hauptmenupunkt 
window.prefix_dropdown = "dropdown-"; // Dropdown-Elemente
window.prefix_menu = "menu-"; // Hauptmenuepunkte
window.prefix_image = "bild-";

window.timeout = null;
window.opacity = 1;

// Funktion: Anzeige und Positionierung des Dropdown-Elements 'divid'
// Funktion: Ausblenden evtl. angezeigter weiterer Dropdown-Elemente, Löschen evtl. gesetzter Timer
// Funktion: Aktueller Hauptmenuepunkt wird auf Klasse inaktiv gesetzt
// Aufruf: Handler onmouseover eines Hauptmenuepunkts
function dropdown(divid,linkpath) {
	if(!browser.dom) return true;
	
	var divmenu = new divobj(window.prefix_menu+divid); // momentanter Hauptmenuepunkt
	var divdropdown = new divobj(window.prefix_dropdown+divid); // Dropdown-Element zur Anzeige
		
	if(window.menuactive) { // Wenn bereits ein Dropdown-Element eingeblendet ist
		if(window.menuactive.id == divdropdown.id) return drophidenow(); // Wenn Dropdown-Element dem jetzt einzublendenden entspricht, wieder schließen und Aktion abbrechen
		drophidenow();
	}
	
	//divdropdown.setstyle('opacity','0.2');
	//divdropdown.setstyle('filter','Alpha(opacity=50, finishopacity=50, style=0)');
	divdropdown.displayshow();
	
	//window.opacity = 2;
	//window.timeout = window.setTimeout("incOpacity(2)",200);
	
	window.menuactive = divdropdown;
	
	return false;
}

function incOpacity(inc) {
	window.opacity += inc;
	window.menuactive.setstyle('opacity',(window.opacity>=10)?"1.0":"0."+window.opacity);
	if(window.opacity < 10) window.timeout = window.setTimeout("incOpacity("+inc+")",50);
}


// Funktion: Ausblenden des eingeblendeten Dropdown-Elements
// Funktion: Einblenden des Dropdowns zum aktuellen Hauptmenuepunkt
// Funktion: Löschen evtl. gesetzter Timer
// Aufruf: Timer aus drophide() u.a.
function drophidenow() {
	if(window.menuactive) {
		window.menuactive.displayhide();
		window.menuactive = null;
	}
}


function init() {

	window.load_complete = true;
	
	// Setze onclick
	if (document.getElementById(window.prefix_menu+"service"))
		document.getElementById(window.prefix_menu+"service").onclick = function(event) { dropdown('service'); };
		
	if (document.getElementById(window.prefix_menu+"messe"))
		document.getElementById(window.prefix_menu+"messe").onclick = function(event) { dropdown('messe'); };
		
	if (document.getElementById(window.prefix_menu+"stadthalle"))
		document.getElementById(window.prefix_menu+"stadthalle").onclick = function(event) { dropdown('stadthalle'); };
		
	if (document.getElementById(window.prefix_menu+"abonnement"))
		document.getElementById(window.prefix_menu+"abonnement").onclick = function(event) { dropdown('abonnement'); };
		
	if (document.getElementById(window.prefix_menu+"programm"))
		document.getElementById(window.prefix_menu+"programm").onclick = function(event) { dropdown('programm'); };
	
	// Setze onfocus
	/*if(document.getElementById("menu-main")) {
		var linkobjects = document.getElementById("menu-main").getElementsByTagName("a");
		for(var i=0; i<linkobjects.length; i++) {
			linkobjects[i].onfocus = function(event) { if (this.blur) this.blur() };
		}			
	}*/
	
	if (document.getElementById('bannerwechsel')) {	setTimeout('setbanner()', 5000); }
	if (document.getElementById('bannerhomewechsel')) {	setTimeout('sethomebanner()', 5000); }
}

window.onload = init;
