/* JavaScript Document - Cascading menu functions

author: Carol Thomson, cthomson@firestreammedia.com
*/

var isNS4	= (document.layers) ? true : false;
var isIE4	= (document.all && !document.getElementById) ? true : false;
var isIE5	= (document.all && document.getElementById) ? true : false;
var isNS6	= (!document.all && document.getElementById) ? true : false;

//menu colors
var dark = "#2669ab";  /* dk blue */
var light = "#5e9ddb";  /* lt blue */

var timerId;
var cit_numMenus = 2;  //total number of top-level menus for the citizen subsite
var pro_numMenus = 1;  //total number of top-level menus for the provider subsite
var menuNum = -1;  //global for menu timeout

function showPage(page, ext) {

	document.location = page;
    /*
	if (ext == "url") {
		document.location = page;
	}
	else {
		if (ext == null) { 
			ext = "html";
		}
		document.location = path + page + "." + ext;
	}
    */
}

function hlItem(div) {
	//  highlight the menu item 
	//	div is the menu item div
	
	//set the highlight background color for the menu item
	if (div != null) { 
		div.style.backgroundColor = dark;	
		div.style.backgroundPosition = "bottom left";  
	}
	
}

function rstItem(div) {
	/*  restore the menu item 
		div is the menu item div
    */
	if (div != null) {
		//restore the menu item
		div.style.backgroundColor = light;	
		div.style.backgroundPosition = "top left";
	}
}

function highlightItemById(id,num) {hlItem(getElement(id),num);}

function restoreItemById(id,num) {rstItem(getElement(id),num);}

function restoreMainItem(num) {
	//restore background color on main menu item
	div = getElement('item'+num);
	if (div != null) {
		div.style.backgroundColor = light;
	}
}

function showMenu(num, subsite) {
	//display the top level menu and hide any menus that are open
	//alert("show " + num);
    
    if (subsite == 'cit') numMenus = cit_numMenus;
    else numMenus = pro_numMenus;
	
	div = getElement("item"+num);
	
	for (var i=1; i<=numMenus; i++) {
		if (i != num) { 
			hideDiv('menu'+i);
			//restoreMainItem(i);
		}
	}
	showDiv('menu'+num);
}

function hideMenus() {
	hideDiv('menu'+menuNum);
	//restoreMainItem(menuNum);
}

function startTimer(num) {
	menuNum = num;
	timerId = setTimeout("hideMenus()", 500);	
}

function stopTimer() {clearTimeout(timerId);}

function swapDivs(showDivName, hideDivName) {
	hideDiv(hideDivName);
	showDiv(showDivName);
}

function hideDiv(divName) {
	getElement(divName).style.display = "none";
}

function showDiv(divName) {
	//alert("show " + divName);
	getElement(divName).style.display = "block";
}

function getElement(id) {
	//return a reference to an element (div, image, form, etc) given is id
	var elem;
	if (id == "") { return null; }
	if (isNS4) {												   // NS4 is not supported
	} 
	else if (isNS6) {											   // Netscape 6 +
		elem = document.getElementById(id);
	} 
	else {													   // IE and everything else
		elem = document.all[id];
	}

	return elem;
}


