function isIE56() {
	var detect = navigator.userAgent.toLowerCase();
	var place = detect.indexOf('msie ');
	var version = 0;
	if ( place > 0 ) {
		version = detect.charAt(place + 5);
	}
	return ( version >= 7 || version == 0 ? false : true );
}

function showSearch() {
	show('searchbox');
	show('searchbox_invisibleLyr');
}

function hideSearch() {
	hide('searchbox');
	hide('searchbox_invisibleLyr');
}

var menuStack = new Array();
var menuItemStack = new Array();

function showLNMenu(lyrname, level) {
	//alert(lyrname + " : " + level + " : " + menuStack[level]);
	if ( menuStack[level] != lyrname ) {
		hideLNMenus(level);
	}  else {
		hideLNMenus(level+1);
	}
	
	show(lyrname);
	showInvis();
	menuStack[level] = lyrname;
}

function hideLNMenus(level) {
	if(level == 1) {
		hideInvis();
		
	}

	for ( var i = (menuStack.length -1); i >= level; i-- ) {
		hide(menuStack[i]);
	}
}

function hideInvis(obj) {
	var theObj;
	theObj = getObject("invisible_layer");

	if ( isIE56() ) {
		toggleFormfields('visible');
	}
    
	if (theObj) {
		theObj.visibility = "hidden";
	} 

	// shows the flash content since it's normally displayed last.
	theObj = getObject("flashContent");
    
	if (theObj) {
		theObj.visibility = "visible";
	} 


} 

function showInvis(obj) {
	var theObj;
	theObj = getObject("invisible_layer");

	if ( isIE56() ) {
		toggleFormfields('hidden');
	}

	if (theObj) {
		theObj.visibility = "visible";
	} 
	
	// hides the flash content so that the left nav isn't shown underneath it.
	theObj = getObject("flashContent");

	if (theObj) {
		theObj.visibility = "hidden";
	} 
}

function toggleFormfields(state) {
	var selectElements = document.body.getElementsByTagName('select');
		
	for (var i=0; i < selectElements.length; i++) {
        if (selectElements[i].id != 'businessunit')
        {
               selectElements[i].style.visibility = state;
        }
	}
}


