// JavaScript Document
var currentTags = new Array();
var currentDivs = new Array();
var nav_timeoutTime = 1000;
var nav_timeout = -1;
var num_panels = 3;

function overMain(numID, level)
{
	clearTimeout(nav_timeout);
	 
	while (currentTags.length) dehighlight(currentTags.pop());	
	currentTags.push("main"+numID);
	
	while (currentDivs.length) hideDiv(currentDivs.pop());
	currentDivs.push("sub_"+level+"_"+numID);
	
	showDiv("subpanel_1");
	
	updateMenu();
}

function outMain()
{
	clearTimeout(nav_timeout);
	nav_timeout = setTimeout("menu_reset()", nav_timeoutTime);
}

function menu_reset()
{
	for (i = 0; i < currentTags.length; i++) dehighlight(currentTags[i]);
	for (j = 0; j < currentDivs.length; j++) hideDiv(currentDivs[j]);
	
	hideDiv("subpanel_1");
}

function overSub(numID, level, pid)
{
	clearTimeout(nav_timeout);
	
	while (currentTags.length > level - 1) dehighlight(currentTags.pop());	
	currentTags.push(pid);
	
	while (currentDivs.length > level - 1) hideDiv(currentDivs.pop());
	currentDivs.push("sub_"+level+"_"+numID);
	
	for (i = num_panels; i > level; i--) hideDiv("subpanel_"+i);
	for (j = 0; j <= level; j++) showDiv("subpanel_"+j);

	updateMenu();
}


function updateMenu()
{
	for (i = 0; i < currentTags.length; i++) highlight(currentTags[i]);	
	for (j = 0; j < currentDivs.length; j++) showDiv(currentDivs[j]);

}

function highlight(id)
{
	//setTextColor(id, "rgb(195, 255, 52)");
	//setBackground(id, "rgb(34, 130, 55)");
	setTextColor(id, "rgb(255, 255, 255)");
	setBackground(id, "rgb(109, 1, 0)");
}

function dehighlight(id)
{
	//setTextColor(id, "rgb(255, 255, 255)");
	//setBackground(id, "rgb(69, 177, 93)");
	setTextColor(id, "rgb(255, 255, 255)");
	setBackground(id, "rgb(140, 0, 0)");
}

function showSubmenu(id, subpanel)
{
	showDiv(id);
	showDiv(subpanel);
}

function hideSubmenu(id, subpanel)
{
	hideDiv(id)
	hideDiv(subpanel);
}

function showDiv(id)
{
	var elm = document.getElementById(id);
    if (elm) {
        elm.style.display = "block";
    }
}

function hideDiv(id)
{
    var elm = document.getElementById(id);
    if (elm) {
        elm.style.display = "none";
    }
}

function setBackground(id, rgbVal)
{
    var elm = document.getElementById(id);
    elm.style.backgroundColor = rgbVal;
}

function setTextColor(id, rgbVal)
{
	var elm = document.getElementById(id);
    elm.style.color = rgbVal;
}

function gotoUrl(loc)
{
    document.location.href = loc;
}

function returnMain(numID, level)
{
	clearTimeout(nav_timeout);
	 
	while (currentTags.length) dehighlight(currentTags.pop());	
	currentTags.push("main"+numID);
	
	while (currentDivs.length) hideDiv(currentDivs.pop());
	currentDivs.push("sub_"+level+"_"+numID);
	
	hideDiv("subpanel_1");
	
	updateMenu();
}

function openNewWindow(url_str, w_num, h_num){
		window.open(url_str, "blank", "menubar=no, toolbar=no, resizable=yes, scrollbars=yes, height="+h_num+", width="+w_num+"");
}
