	function getX(e)    {
	    var x = 0;
		    while ( e.offsetParent != null) {
		        x += e.offsetLeft;
		        e = e.offsetParent;
		    }
	    x += e.offsetLeft;
	    return x;
	}
	
	function getY(e)    {
	    var y = 0;
			while ( e.offsetParent != null) {
				y += e.offsetTop;
				e = e.offsetParent;
		    }
		y += e.offsetTop;
		return y;
	}
	
	function ShowPopup(obj) 
	{
		popupmenu = document.getElementById("popup_"+obj.name);
		if (!popupmenu) return;
		
		maxWidth = document.body.scrollLeft + document.body.clientWidth;
		x = getX(obj);
		y = getY(obj);
		if ( (x + popupmenu.offsetWidth) > maxWidth) {
			x = x - (popupmenu.offsetWidth - obj.offsetWidth);
		}

		var MenuFrame = document.getElementById("popup_frame");
		//alert(MenuFrame);
		if (!MenuFrame) return;

		var table = document.getElementById("table_"+obj.name);
		if (!table) return;

		popupmenu.style.width = table.offsetWidth;
		popupmenu.style.height = table.offsetHeight;

		with (popupmenu.style) 
		{	
			left = x + 2;
			top = y + 49;
		} 
		
		with (MenuFrame.style)
		{
			left = x + 2;
			top = y + 49;	
			width = popupmenu.offsetWidth;
			height = popupmenu.offsetHeight;
			visibility = "visible";
			display = "block";
		}

		with (popupmenu.style) 
		{	
			//display="block";
			left = x + 2;
			top = y + 49;
			visibility= "visible";
		} 
	}
	
	function HidePopup(obj) {
		popupmenu = document.getElementById("popup_"+obj.name);
		if (!popupmenu) return;
		
		var MenuFrame = document.getElementById("popup_frame");
		if (!MenuFrame) return;
		
		with (MenuFrame.style)
		{
			visibility = "hidden";
			display = "none";
		}

		with (popupmenu.style) {	
			//display="none";
			visibility= "hidden";
		} 
	}
	
	var oldwhich = 0;
	var tic=0;
	var layerTimer;
	
	//turn on layer and rollover
	function layOver(obj) {
		tic=0;

		if ( (oldwhich != obj.name) && (oldwhich != 0) ) 
		{
			om = document.getElementById(oldwhich);
			//alert('hide'+);
			out(om.name);
			HidePopup(om);
		}
		
		over(obj.name);
		ShowPopup(obj);
		
		oldwhich = obj.name;
		clearTimeout(layerTimer);
		
		return;
	}
	
	//turn off layer and rollover if user is completely off nav 
	function stopOver() {
		if (tic<5) tic++;
		else 
		{
			om = document.getElementById(oldwhich);
			out(om.name);
			HidePopup(om);
			tic=0;
		}
		window.clearTimeout(layerTimer);
		layerTimer = window.setTimeout("stopOver();", 30);
	}
	
	//reset the timer
	function startOver() {
		tic=0;
		clearTimeout(layerTimer);
	}
	
	
	
	function itemOver(img) {
		startOver();
		
		document.images['i'+img].src = over_state['arr'].src;
		td = document.getElementById("t"+img);
		td.style.backgroundColor = "#838BE5";
		td.style.cursor = "pointer";

		window.status = document.all?document.all["a"+img].href:document.getElementById("a"+img).href;		
	}
	
	function itemOut(img) {
		stopOver();
		
		document.images['i'+img].src = out_state['arr'].src;
		td = document.getElementById("t"+img);
		td.style.backgroundColor = "transparent";
		td.style.cursor = "auto";

		window.status = '';
	}

	function itemClick(img)
	{
	        if( document.all != null)
	          document.all["a"+img].click();
	        else
	         window.location = document.getElementById("a"+img).href; 
	}
