function activatePageMenu(submenuId)
{
	if(activePageMenu != null) deactivatePageMenu();

	var element = document.getElementById(submenuId);
	if(element == null){ return; } //If submenu has no sub-submenu
	
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		element.style.display = "block";
	}
	else
	{
		element.style.setProperty("display","block","");
	}
	
	onPage = true;
	activePageMenu = element;
}

function activateSectionMenu(submenuId)
{
	//debug("activate section: " + submenuId);	
	if(activeSectionMenu != null) deactivateSectionMenu();
	
	var element = document.getElementById(submenuId);
	if(element == null){ return; } //If menu has no submenu
	
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		element.style.display = "block";
	}
	else
	{
		element.style.setProperty("display","block","");
	}
	
	onSection = true;
	activeSectionMenu = element;
}
	
/* adds a function to the onload event handler */
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function adjustWrapper()
{
	var wrapper = document.getElementById("wrapper");
	var white_wrapper = document.getElementById("white_wrapper");
	var whHeight = screen.availHeight-133;
	//var contentHolder = document.getElementById("contentHolder");
	//var contentHeight = screen.availHeight-420;
	//var availHeight = wrapper.scrollHeight;
	//var availHeight = mostouter.scrollHeight;
	
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		wrapper.style.height = whHeight+"px";
		white_wrapper.style.height = whHeight+"px";
		//contentHolder.style.min-height = contentHeight+"px";
	}
	else
	{
		wrapper.style.setProperty("height",whHeight+"px","");
		white_wrapper.style.setProperty("height",whHeight+"px","");
		//contentHolder.style.min-height = contentHeight+"px";
	}
}
	
function adjustWrapperMain()
{
	var wrapper = document.getElementById("wrapper");
	var availHeight = wrapper.scrollHeight;
	
	//var content = document.getElementById("contentArea");
	//var contentHeight = content.scrollHeight;
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		wrapper.style.height = availHeight+20+"px";
		//content.style.height = contentHeight+20+"px";
	}
	else
	{
		wrapper.style.setProperty("height",availHeight+20+"px","");
		//content.style.setProperty("height",contentHeight+20+"px","");
	}
}

function adminOpen(whPage,whID) {
	var url = '/connect5' + whPage + '?mode=edit&id=' + whID
	adminWindow = window.open(url,'connect5','');
	adminWindow.focus();
}

function changeClass(element,class_name)
{
	
	//Accept objects and id's of objects
	if(typeof(element) != "object")
		element = document.getElementById(element);
	
	element.className = class_name;
}

function deactivatePageMenu()
{
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		if(activePageMenu != null){activePageMenu.style.display = "none";}
	}
	else
	{
		if(activePageMenu != null){activePageMenu.style.setProperty("display","none","");}
	}
}

function deactivateSectionMenu()
{

	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		if(activeSectionMenu != null) activeSectionMenu.style.display = "none";
	}
	else
	{
		if(activeSectionMenu != null) activeSectionMenu.style.setProperty("display","none","");
	}
}

/*	Detects the browser */
function detectBrowser()
{
	var browser = navigator.appName;
	return browser;
}

function doMarginBottom(marginBottom)
{
	var wrapper = document.getElementById("wrapper");
	
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		wrapper.style.marginBottom = marginBottom+"px";
	}
	else
	{
		wrapper.style.setProperty("margin-bottom",marginBottom+"px","");
	}
}

function fixHeight()
{
	var wrapper = document.getElementById("wrapper");
	var container = document.getElementById("container");
	var h = container.scrollHeight;
	
	if(detectBrowser() == "Microsoft Internet Explorer")
	{
		wrapper.style.height = h+"px";
	}
	else
	{
		wrapper.style.setProperty("height",h+"px","");
	}
}

/* hides a visibility layer onMouseEvent */
function hideDetail(whItem)
{
	document.getElementById(whItem).style.visibility="hidden";
}

function leftSection()
{
	onSection = false;
}

function leftPage()
{
	onPage = false;
}

/* --- Menu Cleaner ---*/
var activeSectionMenu = null;
var activePageMenu = null;
var onSection = false;
var onPage = false;

setInterval("menuCleaner()",500);

function menuCleaner()
{
	if(onSection == false) deactivateSectionMenu();
	if(onPage == false) deactivatePageMenu();
}
	
function overPage()
{
	onPage = true;
}

function overSection()
{
	onSection = true;
}

/* redirect script used with main nav panels */
function redirect(whPage,whTable,whValue) {
	document.location.href=whPage+"?"+whTable+"="+whValue;
}

/* shows message about session expiring */
function sessionWarning() {
	window.open('session_warning.cfm','warning','width=300,height=300');
}

/* shows a visibility layer onClick */
function showDetail(whItem)
{
	document.getElementById(whItem).style.visibility="visible";
}

/* hides/shows a specific dig onChange */
function toggleDiv(whDiv,whValue)
{
	if (whValue == 1)
	{
		document.getElementById(whDiv).style.display = 'none';
	}
	else
	{
		document.getElementById(whDiv).style.display = 'block';
	}
}

