// Wll be used for hiding select-fields when div menu expands
// see hideSelects() and showSelects(). The problem to fix is a 
// IE only bug.
var isIE = navigator.userAgent.toLowerCase().indexOf("msie") > 0 ? true : false;

// the submenus ids
var sm = new Array();
sm.push('sn-portrait');
sm.push('sn-qualitaet');
sm.push('sn-service');


function show_sub(src, obj_name) {
	// first reset all menuitem to their normal states
	reset_all();
	stop_auto_reset();
	
	// change className to highlight the src object
	if (src) {
		src.className = (src.className == '') ? 'on' : '';
	}
	
	// furthermore hightlight the other obj 
	// identified by obj_name
	if (obj_name) {
		var obj = document.getElementById(obj_name);
		if (obj) { 
			obj.className = (obj.className == 'submenu') ? 'submenu_shown' : 'submenu';
			// make sure in IE the div will go over probable SELECT-fields
	        hideSelects();
		}
	}
}                              

function reset_all() {
	// walk through the submenu array and reset items
	for (i in sm) {
		obj = document.getElementById(sm[i]);
		if (obj) {
			obj.className = 'submenu';
		}
	}
	
    // make sure the SELECT-fields will be redrawn
    showSelects();
}

// Letting the menus reset automatically..
var timeoutID = null;
function auto_reset(i) {
	i = (isNaN(i)) ? 1000 : i;
	if (timeoutID) {
		window.clearTimeout(timeoutID);
	}
	timeoutID = window.setTimeout('reset_all()', i);
}

function stop_auto_reset() {
	if (timeoutID) {
		window.clearTimeout(timeoutID);
	}
}		


function hideSelects() {
    if (!isIE) return;
	var selects = document.getElementsByTagName("SELECT");
    for (i in selects){
        if ( selects[i].style ) {
            selects[i].style.visibility = "hidden";
        }
    }
}

function showSelects() {
    if (!isIE) return;
	var selects = document.getElementsByTagName("SELECT");
    for (i in selects){
        if ( selects[i].style ) {
            selects[i].style.visibility = "visible";
        }
    }		
}

