var menu_punkt = null;
var menu = null;
var hideExecute = null;
var submenu_hide_timeout = 0.5;

function menu_start(){
	/*
    buildAll();
	$('menu').descendants().each(function(top) {
	 if((top.hasClassName("popup_menu")) & ("A" == top.tagName)){
	    if(Element.visible(top)) {
	    	top.onmouseover = link_in;
	    }
	 }
	});
    */
}

function checkNewsletterAnmeldung() {
	if (document.forms.newsletter_form.newsletter_anmelden.value.length > 3) {
		document.forms.newsletter_form.submit();
	}
}

function checkNewsletterAbmeldung() {
	if (document.forms.newsletter_form.email.value.length > 3) {
		document.forms.newsletter_form.submit();
	}
}

function link_in(){
	hideAll();
	menu_punkt = Element.extend(this);
	aparent = menu_punkt.up();
	aparent.descendants().each(function(top) {
	 if((top.hasClassName("popup_hover_js")) & ("UL" == top.tagName)){
		menu = top;
		menu.show();
    	menu.onmouseover = menu_in;
		menu.onmouseout = null;
		menu_punkt.onmouseout = link_out;
	 }
	});
	return false;
}

function link_out() {
	menu_punkt.onmouseout = null;
	if (menu.onmouseout == null) submenu_tryhide();
}

function menu_out() {
	menu.onmouseout = null;
	if (menu_punkt.onmouseout == null) submenu_tryhide();
}

function menu_in() {
	menu.onmouseout = menu_out;
}

function submenu_tryhide() {
	if (hideExecute) hideExecute.stop();
	hideExecute = new PeriodicalExecuter(submenu_hide, submenu_hide_timeout);
}

function submenu_hide() {
	if (hideExecute) hideExecute.stop();
	if (!menu.onmouseout && !menu_punkt.onmouseout) {
		menu.onmouseover = null;
		hideAll();
	}
}

function hideAll() {
	$('menu').descendants().each(function(top) {
	 if((top.hasClassName("popup_hover_js")) & ("UL" == top.tagName)){
	    if(Element.visible(top)) {
	    	top.hide();
	    }
	 }
	});
}

function buildAll() {
	$('menu').descendants().each(function(top) {
	 if((top.hasClassName("popup_hover")) & ("UL" == top.tagName)){
    	top.hide();
		top.addClassName("popup_hover_js");
		top.removeClassName("popup_hover");
	 }
	});
}

function mouse_over_menu(index){
    /*$('wappen_menu_'+index).setStyle({
        visibility: 'visible'
    });*/
    var wappen = 'wappen_menu_'+index;
    document.getElementById(wappen).style.visibility = "visible";
}

function mouse_out_menu(index){
    /*$('wappen_menu_'+index).setStyle({
        visibility: 'hidden'
    });*/
    var wappen = 'wappen_menu_'+index;
    document.getElementById(wappen).style.visibility = "hidden";
}

$(document).ready(function() {
	$('#bereichsbild2_change').pictureChanger(5000);
});

script_loaded = true;



