var tim;
var tim2;
var tim3;
var previousLayer = "";
var open_sub_layer = "";
var timeout_time = 300;

function showLayer(id) 
{
	var div = returnDiv(id);
	div.visibility = "visible";
}

function hideLayer(id) 
{
	var div = returnDiv(id);
	div.visibility = "hidden";
}
   

function mouseOutOfLayer(id)
{
	func = "hideLayer('"+id+"');previousLayer = \"\";";
	tim = setTimeout(func, timeout_time);
}
 
function mouseIntoLayer(id)
{
	if(tim)
		clearTimeout(tim);

	if(id.indexOf("sub_") >= 0)
	{  // we're mousing into a sub_layer
		if(open_sub_layer != id && open_sub_layer != "")
			hideLayer(open_sub_layer);
		clearTimeout(tim3);
		showLayer(id);
		showLayer(previousLayer);
		open_sub_layer = id;
	}
	else
	{  // we're just mousing into a regular layer
		if(previousLayer != id && previousLayer != "")
			hideLayer(previousLayer);
		showLayer(id);
		previousLayer = id;
	}
}

function returnDiv(id) {
	if (document.all) // IE
	{
		var div = document.all(id).style;
	}
	else if (document.layers) // NS4
	{
		var div = document.layers[id];
	}
	else if (document.getElementById) // NS6
	{
		var div = document.getElementById(id).style;
	}
	return div;
}

// BEGIN subnav LAYER SCRIPT
// var sections = new Array(4,0); // set the number of sublayers per section
var timeout_time = 800; // set the timeout time

var sub_tim;
var sub_tim2;
var sub_tim3;
// var previousSubLayer = "";
var open_sub_layer = "";

var previousSection = "-1";

function mouseIntoSection(section)
{
	if(sub_tim)
		clearTimeout(sub_tim);

	if(section != previousSection)
	{
		if(previousSection != "-1")
			hideSection(previousSection);
		for(i=0; i<sections[section]; i++)
			showLayer("subnav_" + section + "_" + i);
	}
	previousSection = section;
}

function mouseOutOfSection(section)
{
	func = "hideSection('"+section+"')";
	sub_tim = setTimeout(func, timeout_time);
}

function hideSection(section)
{
	for(i=0; i<sections[section]; i++)
		hideLayer("subnav_" + section + "_" + i);
		
	previousSection = "-1";
}

function mouseOverSubnavLayer(layerID)
{
	if(document.all)
	{
		var div = returnDiv("subnav_" + layerID);
		div.bgColor = "#101084";
		div.backgroundColor = "#101084";
		div.color = "#ffffff";
	}
}

function mouseOutOfSubLayer(layerID)
{
	if (document.all)
	{
		var div = returnDiv("subnav_" + layerID);
		div.bgColor = "#C6C7C6";
		div.backgroundColor = "#C6C7C6";
		div.color = "#000000";
	}
}
