
// function for menu press

function trace(inString) {
	alert("BAD FUNCTION WITH DATA:\n" + inString);
}


function mainMenuPress(whatLink,whatLevel,whatId) {
	if(whatLink == 'submenu') {
		showPress(whatId,0);
		getSubMenu(whatLevel,1);
	} else {
		document.location = whatLink;
	}
}


function showPress(whatId,subMenu) {
		
	for(var pos = 0; pos < mainMenu.length; pos++) {
		var tmpImg = document.getElementById(mainMenu[pos]);
		if(whatId == mainMenu[pos]) {
			tmpImg.src = "/images/intranet/menu/" + mainMenu[pos] + "_on.jpg";
		} else {
			tmpImg.src = "/images/intranet/menu/" + mainMenu[pos] + "_off.jpg";		
		}
	}
	if(subMenu != 0) {
		//alert(reload);
		getSubMenu(subMenu,0);
	}
}

function getWindowHeight() {
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myHeight = parent.parent.window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    	myHeight = parent.parent.document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    	myHeight = parent.parent.document.body.clientHeight;
    }
    
	return myHeight;
}

function getWindowWidth() {
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	myWidth = parent.parent.window.innerWidth;
    } else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    	myWidth = parent.parent.document.documentElement.clientWidth;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    	myWidth = parent.parent.document.body.clientWidth;
    }
    
	return myWidth;
}

function getScrollHeight() {
   var h = document.body.scrollHeight || window.pageYOffset || document.body.scrollTop ||document.documentElement.scrollTop;
    
   return h ? h : 0;
 
}

function showBgFade(state) {
	var bgDiv = document.getElementById("bgFadeBlock");
	var bgFixDiv = document.getElementById("bgFadeBlockFix");
	
	if(state) {
		bgDiv.style.display = "block";
		window.onresize = resizeFunc;
		
		var winHeight = getWindowHeight();
		var scrollHeight = getScrollHeight();
		var bgHeight = 0;
		if(winHeight > scrollHeight) {
			bgHeight = winHeight;
		} else {
			bgHeight = scrollHeight;
		}

		bgDiv.style.height = bgHeight + "px";
		bgFixDiv.style.height = bgHeight + "px";
	} else {
		bgDiv.style.display = "none";
		window.onresize = null;
		
		bgDiv.style.height = "0px";
		bgFixDiv.style.height = "0px";
		
	}
}
