// JavaScript Document - neue vermoegen template javascripts


/* elp - display subnavi on tab rollover  - uses scriptaculous */

var fade_duration = 0.2;
var subnavi_count = 4;
var subnavi_entries = "subnavi_";	// div with subnavi items
var subnavi_tab_image = "subnavi_active_tab_"; // div with active tab image

function Show_Subnavi(id) {
    // hide all other tabs 
    for (i= 1; i <= subnavi_count; i++) {
        if (i != id) {
            $(subnavi_entries + i).hide();
            $(subnavi_tab_image + i).hide();
        }
    }
    // show current event tab 
    /*
		new Effect.Appear(subnavi_tab_image + id, { duration: 0 }, { queue: 'front' });
		new Effect.Appear(subnavi_entries + id, { duration: fade_duration }, { queue: 'end' });
		*/
    $(subnavi_entries + id).show();
    $(subnavi_tab_image + id).show();
}

/* elp - hide subnavi on mouseout - */
function Hide_Subnavi(id){
    $(subnavi_tab_image + id).hide();
    $(subnavi_entries + id).hide();
	
}	

function Show_ActiveTab(id) {
    if (!$(subnavi_tab_image + id))
        return;
    $(subnavi_tab_image + id).show();
    $(subnavi_entries + id).show();
}


/* elp - top thema ajax loader - for template, just show / hide */
function loadTab(id){
    var tabPrfx = "topthema_";
    var tabContentPrfx = "tabcontent_";
    var maxTabs = 5;
    var classNotActive = "tab";
    var classActive = "tab_active";
	
    for (i= 1; i <= maxTabs; i++) {
        if ($(tabContentPrfx + i) != null) {
            if (i != id) {
                $(tabContentPrfx + i).hide();
                $(tabPrfx + i).removeClassName(classActive);
                $(tabPrfx + i).addClassName(classNotActive);
            }	
        }
    }
    // show active tab
    $(tabContentPrfx + id).show();
    $(tabPrfx + id).removeClassName(classNotActive);
    $(tabPrfx + id).addClassName(classActive);
	
}


/* elp - location tab - for template, just show / hide */
function loadLocationTab(id, tabPrfx, tabContentPrfx, maxTabs, mapLoading){
	var classNotActive = "tab";
	var classActive = "tab_active";
	
	for (i= 1; i <= maxTabs; i++) {
		if ($(tabContentPrfx + i) != null) {
			if (i != id) {
				$(tabContentPrfx + i).hide();
				$(tabPrfx + i).removeClassName(classActive);
				$(tabPrfx + i).addClassName(classNotActive);
			}	
		}
	}
	// show active tab
	$(tabContentPrfx + id).show();
	$(tabPrfx + id).removeClassName(classNotActive);
	$(tabPrfx + id).addClassName(classActive);
	
	if (mapLoading == true) {
	 // defined in map template
		loadMap();
	}

}


function submitLocation(selectID) {
    var selection = document.getElementById(selectID);
    if (selection.options[selection.selectedIndex].value != '') {
        window.location.href = selection.options[selection.selectedIndex].value;
    }
}




function swapMainNavigation(index) {
    $$("div#nav_" + index + ' img').each(function(element) {
              
             element.observe("mouseover", function() {
                 this.src = "fileadmin/nv_website/templates/images/navigation/nav_" + index +"_active.jpg";
                 Show_Subnavi(index);  
                 
             });
             element.observe("mouseout", function() {
                 this.src = "fileadmin/nv_website/templates/images/navigation/nav_" + index +"_basic.jpg";
             });
         });    
}



/* elp - initNavigation js */
function initNavigation() {
    var j;
  
    for (j = 1; j <= 4; j++) {
         $$("#subnavi_active_tab_" + j).each(function(element) { element.hide() }); 
         $$("#subnavi_" + j).each(function(element) { element.hide() });     
         swapMainNavigation(j);  
    }
}
 



