
	var mblnHideMenu;
	var mastrMenuItem = new Array(3);
	var mablnHideMenu = new Array(3);
	var mastrMenuHeader = new Array(3);
	var mastrMenuTxtColor= new Array(3);
	var mastrMenuBGColor =new Array(3);
	var mastrFontHeader =new Array(3);
	var mbytLevel;
	
	var mstrL2Menu = "";
    
	function Trim(str)
	{
		while (str.substring(0,1) == ' ')
		{
			str = str.substring(1, str.length);
		}
		
		while (str.substring(str.length-1, str.length) == ' ')
		{
			str = str.substring(0,str.length-1);
		}
		
		return str;
	}
       
	function ChangeColor(pstrHeadername, pstrTxtColor, pstrBGColor)
	{
		document.getElementById(pstrHeadername).style.color = pstrTxtColor;
		document.getElementById(pstrHeadername).style.backgroundColor = pstrBGColor;
	}
	
	function ChangeColorForLinkItem (pstrHeadername, pstrTxtColor, pstrBGColor, pstrFontName)		
	{
		if (Trim(pstrTxtColor) != "")
			document.getElementById(pstrFontName).style.color = pstrTxtColor;
		else
			document.getElementById(pstrFontName).style.color = "";
		
		if (Trim(pstrBGColor) != "")
			document.getElementById(pstrHeadername).style.backgroundColor = pstrBGColor;
		else
			document.getElementById(pstrHeadername).style.backgroundColor = "";
	}
	
	function ShowMenu(pstrHeadername,pstrTxtColor, pstrBGColor, pstrMenuName, pbytMenuLayoutType, pbytMenuLevel)
	{
		var intLeft, intTop, objMainMenu;
		var objTable, objTR, objTD;
		if ((pbytMenuLevel == 2) && (Trim(mastrMenuItem[pbytMenuLevel]) != Trim(pstrMenuName))) 
			HideMenu2Later(2);
			
		mablnHideMenu[pbytMenuLevel] = false;
		mastrMenuItem[pbytMenuLevel] = pstrMenuName;
		mastrMenuHeader[pbytMenuLevel] = pstrHeadername;		
		
		mastrMenuTxtColor[pbytMenuLevel] = document.getElementById(pstrMenuName).style.color;			//menu itemlerinin ilk yazı rengini tutar	
		mastrMenuBGColor[pbytMenuLevel] = document.getElementById(pstrMenuName).style.backgroundColor;	//menu itemlerinin ilk zemin rengini tutar	

		ChangeColor(pstrHeadername, pstrTxtColor, pstrBGColor);
		objMainMenu = document.getElementById(pstrHeadername);
		objTD		= objMainMenu.parentElement;
		objTR		= objTD.parentElement;
		objTable	= objTR.parentElement.parentElement;
		
		intLeft = document.getElementById(pstrHeadername).offsetParent.offsetLeft + document.getElementById(pstrHeadername).parentElement.offsetParent.offsetLeft;
		intTop  = objTable.offsetParent.offsetTop + document.getElementById(pstrHeadername).offsetParent.offsetHeight +2;
		if (pbytMenuLayoutType == 0)
		{	
			intLeft =  intLeft + document.getElementById(pstrHeadername).offsetParent.offsetWidth;
			intTop =  objMainMenu.parentElement.offsetParent.offsetTop + objMainMenu.offsetParent.offsetTop;		
		}
						
		document.getElementById(pstrMenuName).style.left		= intLeft;
		document.getElementById(pstrMenuName).style.top		= intTop;
		document.getElementById(pstrMenuName).style.visibility = "visible";
		document.getElementById(pstrMenuName).style.position	= "absolute";
		document.getElementById(pstrMenuName).style.zIndex		= 5000;
	}

	function ShowMenuForLinkItem(pstrHeadername,pstrTxtColor,pstrBGColor,pstrMenuName,pbytMenuLayoutType,pbytMenuLevel,pstrFontName)
	{
		var intLeft, intTop, objMainMenu;
		var objTable, objTR, objTD;
				
		if ( mstrL2Menu != "") 
		{
			document.getElementById(mstrL2Menu).style.visibility = "hidden";
			mstrL2Menu = "";
		}
		
		if ( pbytMenuLevel == 2 ) mstrL2Menu = pstrMenuName;
		
		
		if ((mastrMenuItem[pbytMenuLevel] != undefined) && (Trim(mastrMenuItem[pbytMenuLevel]) != Trim(pstrMenuName))) 
			HideMenu2Later(pbytMenuLevel);

		mablnHideMenu[pbytMenuLevel]   = false;
		mastrMenuItem[pbytMenuLevel]   = pstrMenuName;
		mastrMenuHeader[pbytMenuLevel] = pstrHeadername;
		mastrFontHeader[pbytMenuLevel] = pstrFontName;
		
		mastrMenuTxtColor[pbytMenuLevel] = document.getElementById(pstrFontName).style.color;			// menu itemlerinin ilk yazı rengini tutar	
		mastrMenuBGColor[pbytMenuLevel]  = document.getElementById(pstrMenuName).style.backgroundColor;	// menu itemlerinin ilk zemin rengini tutar	

		ChangeColorForLinkItem (pstrHeadername, pstrTxtColor, pstrBGColor, pstrFontName);
		objMainMenu = document.getElementById(pstrHeadername);
		objTD = objMainMenu.parentNode;
		objTR = objTD.parentNode;
		objTable = objTR.parentNode.parentNode;
		
		intLeft = document.getElementById(pstrHeadername).offsetParent.offsetLeft + document.getElementById(pstrHeadername).parentNode.offsetParent.offsetLeft-50;
		intTop = objMainMenu.parentNode.offsetParent.offsetTop + document.getElementById(pstrHeadername).offsetParent.offsetHeight +2;		
		if (pbytMenuLayoutType == 0)
		{			
			intLeft =  intLeft + document.getElementById(pstrHeadername).offsetParent.offsetWidth;
			intTop =  objMainMenu.parentNode.offsetParent.offsetTop + objMainMenu.offsetParent.offsetTop;		
		}
		
		//Sağ tarafa konulan menülerin alt menüleri açıldığında ekran dışında 
		//görünmesini engellemek için yapılan kontrol.	

		if ((intLeft + document.getElementById(pstrMenuName).offsetWidth) > window.screen.availWidth)
			intLeft = intLeft - document.getElementById(pstrMenuName).offsetWidth - document.getElementById(pstrHeadername).offsetWidth;
		
		document.getElementById(pstrMenuName).style.position	= "absolute";
		document.getElementById(pstrMenuName).style.zIndex		= 5000;
		document.getElementById(pstrMenuName).style.left		= intLeft;
		document.getElementById(pstrMenuName).style.top			= intTop;
		document.getElementById(pstrMenuName).style.visibility  = "visible";	
		document.getElementById(pstrMenuName).style.width	= "185px";
		//document.getElementById(pstrMenuName).style.whiteSpace="nowrap";
		//document.getElementById(pstrMenuName).style.width	= "";
		//document.getElementById(pstrMenuName).width	= "";
	}

	function HideMenu(pbytMenuLevel)
	{		
		mablnHideMenu[pbytMenuLevel] = true;
		
		//document.getElementById(mastrMenuHeader[pbytMenuLevel]).style.color = mastrMenuTxtColor[pbytMenuLevel];			//menu itemlerinin ilk yazı geri verir
		//document.getElementById(mastrMenuHeader[pbytMenuLevel]).style.backgroundColor = mastrMenuBGColor[pbytMenuLevel];	//menu itemlerinin ilk zemin geri verir
		if (pbytMenuLevel == 3) 
			mablnHideMenu[2] = true;
			
		setTimeout("HideMenu2Later(" + pbytMenuLevel + ")", 100);
	}
	
	function HideMenuForLinkItem (pbytMenuLevel)
	{
		mablnHideMenu[pbytMenuLevel] = true;
		if (Trim(mastrMenuTxtColor[pbytMenuLevel]) != "")
			document.getElementById(mastrFontHeader[pbytMenuLevel]).style.color = mastrMenuTxtColor[pbytMenuLevel];	//menu itemlerinin ilk yazı geri verir
		else
			document.getElementById(mastrFontHeader[pbytMenuLevel]).style.color = "";
		
		if (Trim(mastrMenuBGColor[pbytMenuLevel]) != "")
			document.getElementById(mastrMenuHeader[pbytMenuLevel]).style.backgroundColor = mastrMenuBGColor[pbytMenuLevel];	//menu itemlerinin ilk zemin geri verir
		else
			document.getElementById(mastrMenuHeader[pbytMenuLevel]).style.backgroundColor = "";
		
		if (pbytMenuLevel == 3)
			mablnHideMenu[2] = true;
			
		setTimeout("HideMenu2Later(" + pbytMenuLevel + ")", 100);
	}
	
	function HideMenu2Later(pbytMenuLevel)
	{
		var intCntr;	
		if (mablnHideMenu[pbytMenuLevel] == true)			
			document.getElementById(mastrMenuItem[pbytMenuLevel]).style.visibility = "hidden";
		
		if (pbytMenuLevel == 3)
		{
			if (mablnHideMenu[2] == true)
				document.getElementById(mastrMenuItem[2]).style.visibility = "hidden";
		}		
	}

	function ShowMe(pstrMenuName, pbytLevel)
	{
		var intLeft, intTop, objMainMenu;
		mablnHideMenu[pbytLevel] = false;
		if (pbytLevel == 3) 
			mablnHideMenu[2] = false;
		mastrMenuItem[pbytLevel] = pstrMenuName;
		document.getElementById(pstrMenuName).style.visibility = "visible";
	}
	
	function WriteResult(pstrText)
	{
		document.pageMenu.txtResult.value = pstrText + Chr(13) + document.pageMenu.txtResult.value;
	} 
		
	function OpenRelWindowWithStatus(pstrUrl, pstrWindowName, pintHeight, pintWidth, pbytScrool, pbytResizable, pbytFuncButton)
	{ 
		var strFeature;
		var intWidth, intHeight;
		if (pintWidth == -1)
			pintWidth = screen.availWidth - (screen.availWidth / 5);
		if (pintHeight == -1)
			pintHeight = screen.availHeight - (screen.availHeight / 5);

		intLeft = (screen.availWidth - pintWidth) / 2;
		intTop = (screen.availHeight - pintHeight) / 2;

		strFeature = "left=" + intLeft + ",top=" + intTop + ",width=" + pintWidth + ",height=" + pintHeight + ", scrollbars = " + pbytScrool + ", resizable = " + pbytResizable;
		if (pbytFuncButton == "1")
			strFeature = strFeature & ",toolbar=yes,menubar=yes,location=no";
		
		wndOpenRelatedWindow = window.open(pstrUrl, pstrWindowName, strFeature);
		wndOpenRelatedWindow.Focus;		
	}

	function CheckIsNumber()
	{
		if ((window.event.keyCode < 48) || (window.event.keyCode > 59)) window.event.keyCode = 0;
	}
