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

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

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 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 changePictureNavi(med_id, width, height, name, index){
    var pfade = web_stammverzeichnis + 'galerie/' + med_id + '/' + width + '/' + height + '/' + name;
    document.getElementById("view-bild").src = pfade;
    setTimeout("document.getElementById('view-bild').src = '" + pfade + "';", 1);
    new_tmp_pic = 'text'+index;
    old_tmp_pic = 'text'+set_med_index;
    $(new_tmp_pic).show();
    $(old_tmp_pic).hide();
    new_tmp_pic_head = 'headline'+index;
    old_tmp_pic_head = 'headline'+set_med_index;
    $(new_tmp_pic_head).show();
    $(old_tmp_pic_head).hide();
    set_med_index = index;
    /** $('view-bild-wrap').innerHTML = '<img src="' + web_stammverzeichnis + 'galerie/' + med_id + '/' + width + '/' + height + '/' + name + '" alt="" />'; **/
}


function changePictureNaviOhneText(med_id, width, height, name, index){
    var pfade = web_stammverzeichnis + 'galerie/' + med_id + '/' + width + '/' + height + '/' + name;
    document.getElementById("view-bild").src = pfade;
    setTimeout("document.getElementById('view-bild').src = '" + pfade + "';", 1);
    set_med_index = index;
    /** $('view-bild-wrap').innerHTML = '<img src="' + web_stammverzeichnis + 'galerie/' + med_id + '/' + width + '/' + height + '/' + name + '" alt="" />'; **/
}

function changeLineNavi(way){
    if( way == 'up'){
        if(line != 1){
            new_tmp_line = 'linie'+ (line-1);
            old_tmp_line = 'linie'+ (line+1);
            $(new_tmp_line).show();
            $(old_tmp_line).hide();
            line = line-1;
        }
    }else{
        if((line+1) != maxline){
            new_tmp_line = 'linie'+ (line+2);
            old_tmp_line = 'linie'+ (line);
            $(new_tmp_line).show();
            $(old_tmp_line).hide();
            line = line+1;
        }
    }
}

script_loaded = true;


