$__mytimer ="";

$__createdmenu = 0;

function menuinit()

{

	hideAll()

}







function hideAll()

{

	// we will initalize all teh menu it

	for($count =0;$count < $__menu.length;$count++)

	{

		$k = document.getElementById($__menu[$count]);

		$k.style.position = "absolute";

		$k.style.display = "none";

		

	} // end of the for loop

	$__createdmenu = 0;

}





function clearMenu()

{

	hideAll()

}

/* Thsi will create a menu*/

function makeMenu(object,$menu)

{

	// his fnction open up the main junction to the upload application of the system

	clearTimeout($__mytimer);

	this.element = object;	

	

	// function for getting left

	this.getLeft = function()

	{

	    var x = 0;

	    var elm;



	    p_elm = this.element;

	    if(typeof(p_elm) == "object"){

	      elm = p_elm;

	    } else {

	      elm = document.getElementById(p_elm);

	    }

	    while (elm != null) {

	      x+= elm.offsetLeft;

	      elm = elm.offsetParent;

	    }

	    return parseInt(x);

	

	}

	

	// function for getting left

	this.getWidth = function()

	{

	    var x = 0;

	    var elm;

	    

	    p_elm = this.element;

	    if(typeof(p_elm) == "object"){

	      elm = p_elm;

	    } else {

	     elm = document.getElementById(p_elm);

	    }

	    return parseInt(elm.offsetWidth);

	

	}

	

	// get the top co-ordinte of the component

	this.getTop = function() 

	{

		var y = 0;

		var elm;

	    	p_elm = this.element;



		if(typeof(p_elm) == "object"){

			elm = p_elm;

		} else {

			elm = document.getElementById(p_elm);

		}

		while (elm != null) {

			y+= elm.offsetTop;

			elm = elm.offsetParent;

		}

		return parseInt(y);

	}

	

	

	// get the top co-ordinte of the component

	this.getHeight = function() 

	{

		var y = 0;

		var elm;

	    	p_elm = this.element;



		if(typeof(p_elm) == "object"){

			elm = p_elm;

		} else {

			elm = document.getElementById(p_elm);

		}

		return parseInt(elm.offsetHeight);



	}

	// got the id

	



	hideAll()

	

	this.menu = document.getElementById($menu);


	$data = this.menu.getElementsByTagName("TD");
	for($_count =0;$_count < $data.length;$_count++)
	{

		$data[$_count].onmouseover = function () 
		{ 
				this.className = "hover";
		} 

		$data[$_count].onmouseout = function () 
		{ 
				this.className = "normal";
		} 

		$data[$_count].onclick = function () 
		{ 
				$k = this.getElementsByTagName("A");
				if($k.length > 0)
				{
					location.href=$k[0].href;
				}

		} 
		$data[$_count].className = "normal";
	}

	this.menu.style.display = "block";

	this.menu.style.top = (this.getTop() + this.getHeight()) + "px";

	this.menu.style.left = this.getLeft() + "px";
	this.menu.style.marginTop = "8px";
	this.menu.style.marginLeft = "-8px";
	this.menu.style.zIndex = 1000;

	

	$__createdmenu = 1;

	

	

} // end of the function











// loading on window load

window.onload = menuinit;

document.onclick = function ()

{

	if($__createdmenu == 1)

	{

		$__mytimer = setTimeout("clearMenu()",100);

	}

}
