//-------------------------------------------------------//
//-														-//
//-		All the scripts are written by Can Olcek		-//
//-														-//
//-		Copyright 2005, All rights are reserved			-//
//-														-//
//-		Using any part of this file without a			-//
//-		permission is illegal. Please contact with		-//
//-		Can Olcek from colcek@yahoo.com	if you			-//
//-		want to use it.									-//
//-														-//
//-------------------------------------------------------//

	var highlightedRow=-1;
	
	function prepareMenu(id)
	{
		var menu=xMenu.getElementsByTagName('menu');
		var menuDiv=document.getElementById('menu');
		menuDiv.innerText="";
		
		var func="loadPage";
		if(locationOfMenu==0)
			func="loadSubPage";
		var html="<table CELLPADDING=\"2\" CELLSPACING=\"0\" ";
		html+="class=\"menu\" onmouseover=\"highlightRow(event)\" id=\"menuTable\">\n";
		for(var y=0;y<menu.item(id-1).childNodes.length;y++)
		{
			var node=menu.item(id-1).childNodes.item(y);
			if(node.nodeName=="link")
			{
				html+="<tr><td class=\"menu_tr\" onclick=\""+func+"('"+node.getAttribute("sublink")+"');\" nowrap>";
				html+="&nbsp;"+node.getAttribute("name");
				html+="&nbsp;</td></tr>\n";
			}
		}
		html+="</table>";

		//menuDiv.insertAdjacentHTML("afterBegin",html);
		menuDiv.innerHTML=html;
		menuDiv.style.left=((id-1)*95)+"px";

	}

	function highlightRow(e)
	{
		if(!e) e=window.event;
//		elm=e.srcElement;
		var elm = (e.target) ? e.target : e.srcElement;
		if(elm.tagName=="TD")
		{
			if(highlightedRow>-1)
			{
				var row=elm.parentNode.parentNode.rows.item(highlightedRow);
				row.style.backgroundColor="transparent";
				row.cells.item(0).style.color="#000000";
			}
			elm.parentNode.style.backgroundColor="#486AA8";//"#0000ff";
			elm.style.color="#ffffff";
			highlightedRow=elm.parentNode.rowIndex;
		}
	}

	function changeMenuState(id,state)
	{
		if(state=="show")
		{
//			loadPage(id);
			prepareMenu(id);
			document.getElementById('menu').style.visibility="visible";
		}
		else
		{
			document.getElementById('menu').style.visibility="hidden";
			if(highlightedRow>-1)
			{
				var row=document.getElementById("menuTable").rows.item(highlightedRow);
				row.style.backgroundColor="transparent";
				row.cells.item(0).style.color="#000000";
			}
			highlightedRow=-1;
		}
	}

	function loadSubPage(link)
	{
		window.location.href="icerik.php?link="+link;
	}