var timeout;
var timeoutOut;
var timeoutClear;
var currTab = "";
var isOut = "true";
var header_bgr = 'url(/img/T1-andromeda_body.png)';
var header_bgr_over = 'url(/img/T1-andromeda_body.png)';
var hMainControlId;
var delay = 1000;

startList = function()
{
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		navRoot = document.getElementById("nav");
		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", "");
				}
			}
		}
	}
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		navRoot = document.getElementById("navh");
		if (navRoot != null && navRoot.childNodes != null && navRoot.childNodes.length > 0)
		{
			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", "");
					}
				}
			}
		}
	}
}
//window.onload = startList;

function ShowBackground(over)
{
	if (over)
	{
		document.getElementById(hMainControlId).style.backgroundImage = header_bgr_over;
	}
	else
	{
		document.getElementById(hMainControlId).style.backgroundImage = header_bgr;
	}
}

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;
}

// ---------------------------------------------
//	S E C O N D   L E V E L
// ---------------------------------------------
function HideAllSecondLevelItems()
{
	for (i = 1; i <= 20; i++)
	{
		if (document.getElementById('subMenu' + i) != null)
		{
			document.getElementById('subMenu' + i).style.display = 'none';
		}
	}
}
function ClearAllClassNames()
{
	for (i = 1; i <= 20; i++)
	{
		if (document.getElementById('liTab' + i) != null)
		{
			document.getElementById('liTab' + i).className = "";
		}
	}
}
function ClearCurrTab()
{
	currTab = "";
}
function ShowSecondLevel(id, id2)
{
	currTab = id;
	isOut = "false";
	clearTimeout(timeoutOut);
	ClearAllClassNames();
	if (selectedTab != "")
		document.getElementById(selectedTab).className = 'tabCurrentOut';
	if (document.getElementById(id2) != null)
	{
		document.getElementById(id2).className = 'tabSelected';
	}

	var hMain = document.getElementById(hMainControlId);
	if (hMain != null && hMain.style.backgroundImage == header_bgr)
	{
		ShowSecondLevelNow(id, id2);
	}
	else
	{
		timeout = setTimeout("ShowSecondLevelAfterDelay('" + id + "')", 200);
	}
}
function ShowSecondLevelAfterDelay(id)
{
	if (currTab == id)
	{
		isOut = "false";
		clearTimeout(timeoutOut);
		HideAllSecondLevelItems();
		if (document.getElementById(id) != null)
		{
			document.getElementById(id).style.display = 'inline';
		}
		//ShowBackground(true);

		clearTimeout(timeout);
	}
}
function ShowSecondLevelNow(id, id2)
{
	isOut = "false";
	clearTimeout(timeoutOut);
	HideAllSecondLevelItems();
	if (document.getElementById(id) != null)
	{
		document.getElementById(id).style.display = 'inline';
	}
	if (selectedTab != id2)
	{
		ClearAllClassNames();
		if (document.getElementById(id2) != null)
		{
			document.getElementById(id2).className = 'tabSelected';
		}
		if (selectedTab != "")
			document.getElementById(selectedTab).className = 'tabCurrentOut';
		//ShowBackground(true);
	}
}
function ShowCurrentSecondlevel()
{
	if (isOut == "false")
	{
		isOut = "true";
		timeoutOut = setTimeout("ShowCurrentSecondlevelAfterDelay()", delay);
	}
}
function ShowCurrentSecondlevelAfterDelay()
{
	if (isOut == "true")
	{
		clearTimeout(timeoutOut);
		HideAllSecondLevelItems();
		ClearAllClassNames();
		if (selectedSubmenu != "" && selectedTab != "")
		{
			document.getElementById(selectedSubmenu).style.display = "inline";
			document.getElementById(selectedTab).className = "tabCurrent";
		}
		//document.getElementById(hMainControlId).style.backgroundImage = header_bgr;
		//ShowBackground(false);
	}
}
function ShowCurrentSecondlevelNow()
{
	HideAllSecondLevelItems();
	ClearAllClassNames();
	//alert(selectedSubmenu + ' - ' + selectedTab);
	if (selectedSubmenu != "" && selectedTab != "")
	{
		document.getElementById(selectedSubmenu).style.display = "inline";
		document.getElementById(selectedTab).className = "tabCurrent";
	}
	//document.getElementById(hMainControlId).style.backgroundImage = header_bgr;
	//ShowBackground(false);
	clearTimeout(timeoutOut);
}
function ShowCurrentSecondlevelFF()
{
	if (isOut == "false")
	{
		isOut = "true";
		timeoutOut = setTimeout("ShowCurrentSecondlevelFFAfterDelay()", delay);
	}
}
function ShowCurrentSecondlevelFFAfterDelay()
{
	if (isOut == "true")
	{
		clearTimeout(timeoutOut);
		bwGecko = (navigator.userAgent.indexOf('Gecko') != -1) ? "True" : "False";
		if (bwGecko == "False")
		{
			HideAllSecondLevelItems();
			ClearAllClassNames();
			if (selectedSubmenu != "" && selectedTab != "")
			{
				document.getElementById(selectedSubmenu).style.display = "inline";
				document.getElementById(selectedTab).className = "tabCurrent";
			}
			//document.getElementById(hMainControlId).style.backgroundImage = header_bgr;
			//ShowBackground(false);
		}
	}
}
function CancelBubble()
{
	event.cancelBubble = true;
	isOut = "false";
	clearTimeout(timeoutOut);
}


// ---------------------------------------------
//	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 (navigator.appVersion.indexOf("MSIE 6.0") != -1)
	{
		document.getElementById("layers").style.filter = "alpha(opacity=10)";
		document.getElementById(id).style.filter = "none";
	}
	document.getElementById("layers").style.display = "inline";
	if (navigator.appVersion.indexOf("MSIE") != -1)
	{
		document.getElementById("layers").style.height = document.getElementById("page").offsetHeight + "px";
	}
	else
	{
		document.getElementById("layers").style.height = document.getElementById("header").offsetHeight + document.getElementById("main").offsetHeight + document.getElementById("quicklinks").offsetHeight + 20 + "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)
{
	// This script will test up to the following version.
	flash_versions = 20;

	// Initialize variables and arrays
	var flash = new Object();
	flash.installed = false;
	flash.version = '0.0';

	// Dig through Netscape-compatible plug-ins first.
	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;
			}
		}
	}

	// Then, dig through ActiveX-style plug-ins afterwords
	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) { }
		}
	}

	// Create sniffing variables in the following style: flash.ver[x]
	// Modified by mjac
	flash.ver = Array();
	for (i = 4; i <= flash_versions; i++)
	{
		eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
	}

	// show flash object
	if (flash.installed)
	{
		if (navigator.appVersion.indexOf("MSIE 6.0") != -1)
		{
			/*document.getElementById("layers").style.filter = "alpha(opacity=10)";	*/
			document.getElementById(id).style.filter = "none";
		}
		document.getElementById("layers").style.display = "inline";

		// resizing height of PAGE
		/*if (!document.all)
		{
		document.getElementById("layers").style.height = document.documentElement.offsetHeight + 120 + "px";
		}
		else
		{
		document.getElementById("layers").style.height = document.getElementById("page").offsetHeight + 120 + "px";
		}*/

		// moving LAYERS as a child of BODY
		document.getElementsByTagName("body")[0].appendChild(document.getElementById("layers"));
		//document.getElementById("page").style.display = "none";
		//document.getElementById("layers").style.width = "100%";
		//document.getElementById("layers").style.height = "100%";
		if (navigator.appVersion.indexOf("MSIE") != -1)
		{
			document.getElementById("layers").style.height = document.getElementById("page").offsetHeight + "px";
		}
		else
		{
			document.getElementById("layers").style.height = document.getElementById("header").offsetHeight + document.getElementById("main").offsetHeight + document.getElementById("quicklinks").offsetHeight + 20 + "px";
		}
		document.getElementById(id).style.display = "inline";

	}
}
function ShowLayerFullScreen(id)
{
	if (navigator.appVersion.indexOf("MSIE 6.0") != -1)
	{
		/*document.getElementById("layers").style.filter = "alpha(opacity=10)";	*/
		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)
{
	document.getElementById(id).style.display = "inline";
	var PositionSpan = document.getElementById(link_id)
	var left_pos = findPosX(PositionSpan);
	var top_pos = findPosY(PositionSpan) + 10;
	document.getElementById(id).style.top = top_pos + "px";
	document.getElementById(id).style.left = left_pos + "px";
	isOut = "false";
	clearTimeout(timeoutOut);
}
function HideAlts()
{
	for (i = 1; i <= 100; i++)
	{
		if (document.getElementById("alt" + i) != null)
		{
			document.getElementById("alt" + i).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 + 23;
	var leftDiff = 0;
	if (RTL == true)
	{
		leftDiff = left - (235 - idMenu.offsetWidth) + 3;
	}
	else
	{
		leftDiff = left + 2;
	}
	bwIE = (navigator.appVersion.indexOf("MSIE") != -1) ? "True" : "False";
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	bwGecko = (navigator.userAgent.indexOf("Gecko") != -1) ? "True" : "False";
	bwFirefox3 = (navigator.userAgent.indexOf("Firefox/3.0") != -1) ? "True" : "False";
	bwSafari = (navigator.userAgent.indexOf("Safari") != -1) ? "True" : "False";
	bwOpera = (navigator.userAgent.indexOf("Opera") != -1) ? "True" : "False";
	if (bwIE == "False")
	{
		topDiff--;
	}
	if (bwGecko == "True")
	{
		topDiff++;
	}
	if (bwFirefox3 == "True")
	{
		topDiff = topDiff - 3;
		leftDiff = leftDiff - 2;
	}
	if (bwSafari == "True")
	{
		topDiff = topDiff - 3;
		leftDiff = leftDiff - 2;
	}
	if (bwOpera == "True")
	{
		topDiff = topDiff - 3;
		leftDiff = leftDiff - 2;
	}
	if (document.getElementById(id) != null)
	{
		document.getElementById(id).style.top = topDiff + "px";
		document.getElementById(id).style.left = leftDiff + "px";
	}
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "inline";
	}
}
function HideHML3Submenu(idMenu, id)
{
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}
function ShowHML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3Hover";
	}
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "inline";
	}
}
function HideHML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3Normal";
	}
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}
function HideHML3MenuSel(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3Selected";
	}
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	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;
	bwIE = (navigator.appVersion.indexOf("MSIE") != -1) ? "True" : "False";
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	bwGecko = (navigator.userAgent.indexOf("Gecko") != -1) ? "True" : "False";
	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)
{
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}
function ShowML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3VerticalHover";
	}
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "inline";
	}
}
function HideML3Menu(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3VerticalNormal";
	}
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	if (bwIE60 == "True")
	{
		document.getElementById(id).style.display = "none";
	}
}
function HideML3MenuSel(idMenu, id)
{
	if (document.getElementById(idMenu) != null)
	{
		document.getElementById(idMenu).className = "menuLevel3VerticalSelected";
	}
	bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
	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')
	{
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	window.alert('Width = ' + myWidth + ', Height = ' + myHeight);
}



function vindu(url,title,width,height) {
  window.open(url,title,'width=800,height=600,scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes');
}
function vindu_no(url,title,width,height) {
  window.open(url,title,'width='+width+',height='+height+',scrollbars=yes,resizable=yes,menubar=no,status=no,toolbar=no');
}
function popup(url,title,width,height) {
  window.open(url,title,'width='+width+',height='+height+',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
}


