var timeout;
var timeoutOut;
var timeoutClear;
var timeoutAlt;
var currTab = "";
var currAlt = "";
var isOut = "true";
var hMainControlId;
var delay = 1000;

var bwIE = (navigator.appVersion.indexOf("MSIE") != -1) ? "True" : "False";
var bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
var bwIE70 = (navigator.appVersion.indexOf("MSIE 7.0") != -1) ? "True" : "False";
var bwIE80 = (navigator.appVersion.indexOf("MSIE 8.0") != -1) ? "True" : "False";
var bwFF = (navigator.userAgent.indexOf("Firefox") != -1) ? "True" : "False";
var bwGecko = (navigator.userAgent.indexOf("Gecko") != -1) ? "True" : "False";
var bwOpera = (navigator.userAgent.indexOf("Opera") != -1) ? "True" : "False";
var bwSafari = (navigator.userAgent.indexOf("Safari") != -1) ? "True" : "False";
var bwChrome = (navigator.userAgent.indexOf("Chrome") != -1) ? "True" : "False";

startList = function ()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		navRoot = document.getElementById("nav");
		if (navRoot != null)
		{
			for (i = 0; i < navRoot.childNodes.length; i++)
			{
				node = navRoot.childNodes[i];
				if (node.nodeName == "LI")
				{
					node.onmouseover = function ()
					{
						this.className += " over";
					}
					node.onmouseout = function ()
					{
						this.className = this.className.replace(" over", "");
					}
				}
			}
		}
		navRootH = document.getElementById("navh");
		if (navRootH != null)
		{
			if (navRootH != null && navRootH.childNodes != null && navRootH.childNodes.length > 0)
			{
				for (i = 0; i < navRootH.childNodes.length; i++)
				{
					node = navRootH.childNodes[i];
					if (node.nodeName == "LI")
					{
						node.onmouseover = function ()
						{
							this.className += " over";
						}
						node.onmouseout = function ()
						{
							this.className = this.className.replace(" over", "");
						}
					}
				}
			}
		}
	}
}
window.onload = startList;

function getTime()
{
	var currentTime = new Date();
	var hours = currentTime.getHours();
	var minutes = currentTime.getMinutes();
	var seconds = currentTime.getSeconds();
	if (minutes < 10)
		minutes = "0" + minutes;
	if (seconds < 10)
		seconds = "0" + seconds;
	return hours + ":" + minutes + ":" + seconds;
}


// ---------------------------------------------
//	L A Y E R S
// ---------------------------------------------
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function ShowLayer(id, layer_link, width, height)
{
	if (bwIE60 == "True")
	{
		document.getElementById("layers").style.filter = "alpha(opacity=10)";
		document.getElementById(id).style.filter = "none";
	}
	document.getElementById("layers").style.display = "inline";
	if (bwIE == "True")
	{
		document.getElementById("layers").style.height = document.body.scrollHeight + "px";
	}
	else
	{
		if (bwFF == "True")
		{
			document.getElementById("layers").style.height = window.innerHeight + window.scrollMaxY + "px";
		}
		else
		{
			document.getElementById("layers").style.height = document.body.scrollHeight + "px";
		}
	}

	var PositionSpan = document.getElementById(layer_link)
	var left_pos = findPosX(PositionSpan) - 5;
	var top_pos = findPosY(PositionSpan) + 15;

	document.getElementById(id).style.top = top_pos + "px";
	document.getElementById(id).style.left = left_pos + "px";
	if (document.getElementById(id + "_content") != null)
		document.getElementById(id + "_content").style.display = "none";
	if (document.getElementById(id + "_close") != null)
		document.getElementById(id + "_close").style.display = "none";
	document.getElementById(id).style.display = "inline";

	var width_inc = Math.round(width / 5);
	var height_inc = Math.round(height / 5);
	window.setTimeout("ShowLayerDelayed('" + id + "',0," + width_inc + "," + height_inc + ")", 20);
}
function ShowLayerDelayed(id, i, width_inc, height_inc)
{
	document.getElementById(id).style.width = (width_inc * i) + "px";
	document.getElementById(id).style.height = (height_inc * i) + "px";
	i++;
	if (i <= 5)
		window.setTimeout("ShowLayerDelayed('" + id + "'," + i + "," + width_inc + "," + height_inc + ")", 20);
	else
	{
		document.getElementById(id + "_content").style.display = "inline";
		document.getElementById(id + "_close").style.display = "inline";
	}
}
function ShowLayerFullScreenDetection(id)
{
	var flash_versions = 20;
	var flash = new Object();
	flash.installed = false;
	flash.version = '0.0';

	if (navigator.plugins && navigator.plugins.length)
	{
		for (x = 0; x < navigator.plugins.length; x++)
		{
			if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1)
			{
				flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
				flash.installed = true;
				break;
			}
		}
	}

	else if (window.ActiveXObject)
	{
		for (x = 2; x <= flash_versions; x++)
		{
			try
			{
				oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
				if (oFlash)
				{
					flash.installed = true;
					flash.version = x + '.0';
				}
			}
			catch (e) { }
		}
	}

	flash.ver = Array();
	for (i = 4; i <= flash_versions; i++)
	{
		eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
	}

	if (flash.installed)
	{
		if (bwIE60 == "True")
		{
			document.getElementById(id).style.filter = "none";
		}

		if (document.getElementById("layers") != null)
		{
			document.getElementById("layers").style.display = "inline";

			if (document.body == null)
			{
				var body = document.getElementsByTagName("body")[0];
				body.insertBefore(document.getElementById("layers"), document.getElementById("page"));
			}
			else
			{
				var page = document.getElementById("page");
				if (page != null)
				{
					page.parentNode.insertBefore(document.getElementById("layers"), page);
				}
			}

			if (bwIE == "True") { document.getElementById("layers").style.height = document.body.scrollHeight + "px"; }
			else
			{
				if (bwFF == "True") { document.getElementById("layers").style.height = window.innerHeight + window.scrollMaxY + "px"; }
				else
				{
					if (bwOpera == "True") { document.getElementById("layers").style.height = document.getElementById("header").offsetHeight + document.getElementById("body").offsetHeight + document.getElementById("quicklinks").offsetHeight + 100 + "px"; }
					else
					{
						document.getElementById("layers").style.height = document.body.scrollHeight + "px";
					}
				}
			}

			document.getElementById(id).style.display = "inline";
		}
	}
}
function ShowLayerFullScreen(id)
{
	if (bwIE60 == "True")
	{
		document.getElementById("layers").style.width = document.getElementsByTagName("body")[0].offsetWidth + "px";
		document.getElementById(id).style.filter = "none";
	}
	document.getElementById("layers").style.background = "transparent none repeat center center";
	document.getElementById("layers").style.height = document.getElementById("page").offsetHeight + 105 + "px";
	document.getElementById("layers").style.display = "inline";
	document.getElementById(id).style.display = "inline";
}
function HideLayers()
{
	document.getElementById("page").style.display = "block";
	document.getElementById("layers").style.display = "none";
}


// ---------------------------------------------
//	A L T E R N A T E
// ---------------------------------------------
function ShowAlt(id, link_id)
{
	clearTimeout(timeoutAlt);
	if (currAlt != id)
	{
		currAlt = id;
		HideAltsAfterDelay();
	}
	var positionSpan = document.getElementById(link_id)
	if (positionSpan != null)
	{
		var left_pos = findPosX(positionSpan) - 9;
		var top_pos = findPosY(positionSpan) + 17;
		if (bwIE == "True")
		{
			left_pos = left_pos + 1;
		}
		if (bwFF == "True")
		{
			left_pos = left_pos + 2;
		}
		if (bwSafari == "True")
		{
			left_pos = left_pos + 2;
		}
		if (bwOpera == "True")
		{
			left_pos = left_pos + 2;
		}
	}
	if (pageFlow != undefined && pageFlow != null)
	{
		if (pageFlow == "RTL")
		{
			var menuSpan = document.getElementById(link_id);
			var menuWidth = 0;
			if (menuSpan != null)
			{
				var menuWidth = menuSpan.offsetWidth;
			}
			left_pos = left_pos + menuWidth - 230;
		}
	}
	var altDiv = document.getElementById(id);
	if (altDiv != null)
	{
		altDiv.style.top = top_pos + "px";
		altDiv.style.left = left_pos + "px";
		altDiv.style.display = "block";
	}
}
function HideAlts()
{
	timeoutAlt = setTimeout("HideAltsAfterDelay()", 500);
}
function HideAltsAfterDelay()
{
	for (i = 1; i <= 200; i++)
	{
		var alt = document.getElementById("alt" + i);
		if (alt != null)
		{
			alt.style.display = "none";
		}
	}
}


// ----------------------------------------------------
//	S U B M E N U   L E V E L   3   H O R I Z O N T A L
// ----------------------------------------------------
function ShowHML3Submenu(idMenu, id, RTL)
{
	var navigation = document.getElementById("navh");
	var topNav = findPosY(navigation);
	var left = findPosX(idMenu);
	var topDiff = topNav + 30;
	var leftDiff = 0;
	if (RTL == true)
	{
		leftDiff = left + idMenu.offsetWidth - 236;
	}
	else
	{
		leftDiff = left;
	}
	if (document.getElementById(id) != null)
	{
		var style = document.getElementById(id).style;
		style.top = topDiff + "px";
		style.left = leftDiff + "px";
		style.display = "inline";	

	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "inline";
	}
}
function HideHML3Submenu(idMenu, id)
{
	//if (bwIE60 == "True")
	//{
		document.getElementById(id).style.display = "none";
	//}
}
function ShowHML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3Hover";
	}
	//if (bwIE60 == "True")
	//{
		document.getElementById(id).style.display = "inline";
	//}
}
function HideHML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3Normal";
	}
	//if (bwIE60 == "True")
	//{
		document.getElementById(id).style.display = "none";
	//}
}
function HideHML3MenuSel(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3Selected";
	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}

// ---------------------------------------------
//	S U B M E N U   L E V E L   3
// ---------------------------------------------
function ShowML3Submenu(idMenu, id)
{
	var navigation = document.getElementById("nav");
	var topNav = findPosY(navigation);
	var top = findPosY(idMenu);
	var topDiff = top - topNav - 1;
	if (bwIE == "False")
	{
		topDiff = topDiff - 1;
	}
	if (bwGecko == "True")
	{
		topDiff = topDiff + 1;
	}
	if (document.getElementById(id) != null)
	{
		document.getElementById(id).style.top = topDiff + "px";
	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "inline";
	}
}
function HideML3Submenu(idMenu, id)
{
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}
function ShowML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3VerticalHover";
	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "inline";
	}
}
function HideML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3VerticalNormal";
	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}
function HideML3MenuSel(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3VerticalSelected";
	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}





// -------------------------------------
//	HELP FUNCTIONS
// -------------------------------------
function info()
{
	str = ""

	if (document.body.clientWidth)
	{
		str += "\ndocument.body.clientHeight = " + document.body.clientHeight
	}
	if (document.body.offsetWidth)
	{
		str += "\ndocument.body.offsetHeight = " + document.body.offsetHeight
	}
	if (window.innerWidth)
	{
		str += "\nWindow.innerHeight = " + window.innerHeight
	}
	if (window.outerWidth)
	{
		str += "\nWindow.outerHeight = " + window.outerHeight
	}
	if (document.getElementsByTagName)
	{
		str += "\ndocument.getElementsByTagName('body')[0].offsetHeight = " + document.getElementsByTagName('body')[0].offsetHeight
	}
	if (document.documentElement)
	{
		str += "\ndocument.documentElement.offsetHeight = " + document.documentElement.offsetHeight
	}
	if (document.body.clientHeight)
	{
		str += "\ndocument.body.clientHeight = " + document.body.clientHeight
	}

	alert(str);

	alertSize();

}

function alertSize()
{
	var myWidth = 0, myHeight = 0;
	if (typeof (window.innerWidth) == 'number')
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	window.alert('Width = ' + myWidth + ', Height = ' + myHeight);
}
