var menuTimerID;
var Hidden = true;
function MainMenuClick(SelectedCell , Left , Right , downL, downR)
{
	unSelectAll();	
	//+++++++++++++==============+++++++++++++++===============
	
	SelectedCell.className = "MainMenubuttonSelected";

	var Menuitems = document.getElementById("Menuitems");
	
	Menuitems.style.left = getLeft(SelectedCell,Left);
	
	Menuitems.style.top = getTop(SelectedCell);
	
	Menuitems.innerHTML = GetItems(parseInt(SelectedCell.item,0),Left , Right , downL, downR);
	
	Menuitems.style.display = 'block';
	Hidden = false;
}
function unSelectAll(){
	document.getElementById("MainMenu1").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu2").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu3").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu4").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu5").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu6").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu7").className = "MainMenubuttonUnSelected";
	document.getElementById("MainMenu8").className = "MainMenubuttonUnSelected";
}
function getTop(obj){
	var y = obj.clientHeight;
	while(obj){
		if (obj.tagName != 'TR' && obj.tagName != 'TBODY')
			y += obj.offsetTop;
		obj = obj.parentElement;
	}
	return y;
}
function getLeft(obj,Left)
{
	var x = 0;
	var Width = obj.offsetWidth;
	while(obj)
	{
		if (obj.tagName != 'TR' && obj.tagName != 'TBODY')
		{
			x += obj.offsetLeft;
		}
		obj = obj.parentElement;
	}
	if(Left == "Right")
		x = x - 195 + Width ; //195 --> SubMenu width 
	
	return x;
}

function GetItems(item,Left,Right,downL,downR){
	var i;
	var output = "<Table cellpadding='0' cellspacing='0' border='0' width='100%' onmouseout='Hide();' onmouseover='CancelHide();'>";
	for(i=0;i<myItem[item].length;i+=2){
		output += "<tr><td background='Images/panel/" + Left +".jpg'>&nbsp;</td><td class='aBlue'><a href='" + myItem[item][i+1] + "' onmouseover='ShowBG(this)' onmouseout='HideBG(this)'>" + myItem[item][i] + "</a></td><td background='Images/panel/" + Right + ".jpg'>&nbsp;</td></tr>";
	}
	output += "<tr><td><IMG src='Images/panel/" + downL +".gif' border='0'></td><td width='100%' background='Images/panel/Down.jpg'</td><td><IMG src='Images/panel/" + downR + ".gif' border='0'></td></tr>";
	output += "</Table>";
	return output;
}
function HideBG(Cell)
{
	Cell.className="";
}
function ShowBG(Cell)
{
	Cell.className = "OnCellMenu";	
}
function Hide(){
	if (!Hidden)
		menuTimerID = setTimeout("DoHide();", 500);
}
function DoHide(){
	var Menuitems = document.getElementById("Menuitems");
	Menuitems.style.display = "none";
	unSelectAll();
	Hidden = true;
}
function CancelHide()
{
	if (menuTimerID > 0)
	{
		clearTimeout(menuTimerID);
		menuTimerID = -1;
	}
}	
function openWindow(link)
{
	window.open(link, "_blank", "resizable=yes,status=no,scrollbars=yes, location=no, menubar=no");
}
function openWindow2(link)
{
	window.open(link);
}