
var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4))?true:false;
HIDDEN = (NS4) ? 'hide' : 'hidden';
VISIBLE = (NS4) ? 'show' : 'visible';

var DirTop = 0
var DirLeft = 0
var DirRight = 0
var DirBottom = 0

var FreightTop = 0
var FreightLeft = 0
var FreightRight = 0
var FreightBottom = 0

var MarketTop = 0
var MarketLeft = 0
var MarketRight = 0
var MarketBottom = 0

var KnowTop = 0
var KnowLeft = 0
var KnowRight = 0
var KnowBottom = 0

ServicesArr=new Array()
var CheckVar = false;

function initMenu()
{
	ServicesArr[0]=(NS4) ? document.DirLayer : document.all.DirLayer.style
	ServicesArr[1]=(NS4) ? document.FreightLayer : document.all.FreightLayer.style
	ServicesArr[2]=(NS4) ? document.MarketLayer : document.all.MarketLayer.style
	ServicesArr[3]=(NS4) ? document.KnowLayer : document.all.KnowLayer.style

	DirTop = ServicesArr[0].top;
	DirLeft = ServicesArr[0].left;
	ServicesArr[0].width = 158;
	DirRight = parseInt(DirLeft) + parseInt(ServicesArr[0].width);
	ServicesArr[0].height = 65;
	DirBottom = parseInt(DirTop) + parseInt(ServicesArr[0].height);
	DirTop = parseInt(DirTop) - 35;
	
	FreightTop = ServicesArr[1].top;
	FreightLeft = ServicesArr[1].left;
	ServicesArr[1].width = 160;
	FreightRight = parseInt(FreightLeft) + parseInt(ServicesArr[1].width);
	ServicesArr[1].height = 65;
	FreightBottom = parseInt(FreightTop) + parseInt(ServicesArr[1].height);
	FreightTop = parseInt(FreightTop) - 35;
	
	MarketTop = ServicesArr[2].top;
	MarketLeft = ServicesArr[2].left;
	ServicesArr[2].width = 165;
	MarketRight = parseInt(MarketLeft) + parseInt(ServicesArr[2].width);
	ServicesArr[2].height = 65;
	MarketBottom = parseInt(MarketTop) + parseInt(ServicesArr[2].height);
	MarketTop = parseInt(MarketTop) - 35;
	
	KnowTop = ServicesArr[3].top;
	KnowLeft = ServicesArr[3].left;
	ServicesArr[3].width = 145;
	KnowRight = parseInt(KnowLeft) + parseInt(ServicesArr[3].width);
	ServicesArr[3].height = 80;
	KnowBottom = parseInt(KnowTop) + parseInt(ServicesArr[3].height);
	KnowTop = parseInt(KnowTop) - 35;
	
	//DirRight = parseInt(DirLeft) + parseInt(ServicesArr[0].width);
	//DirBottom = parseInt(DirTop) + parseInt(ServicesArr[0].height);
	CheckVar = true;
}

// These variables will hold the current mouse pointer position.

var mouseX = 0;
var mouseY = 0;

// Set up event capturing.

if (NS4)
  document.captureEvents(Event.MOUSEMOVE);
  
document.onmousemove = popUpMenuGetMousePosition;

function popUpMenuGetMousePosition(e)
{
	if ((parseInt(DirLeft) > 0) && (parseInt(FreightLeft) > 0) && (parseInt(MarketLeft) > 0) && (parseInt(KnowLeft) > 0))
	{
		// Save mouse pointer position.

		if (NS4) {
		  mouseX = e.pageX;
		  mouseY = e.pageY;
		}
		if (IE4) {
		  mouseX = window.event.clientX + document.body.scrollLeft;
		  mouseY = window.event.clientY + document.body.scrollTop;
		}

		if ((mouseX < parseInt(DirLeft)) || (mouseX > parseInt(DirRight)) || (mouseY < parseInt(DirTop)) || (mouseY > parseInt(DirBottom)))
			if (ServicesArr[0].visibility == VISIBLE)
				ServicesArr[0].visibility = HIDDEN;
		
		if ((mouseX < parseInt(FreightLeft)) || (mouseX > parseInt(FreightRight)) || (mouseY < parseInt(FreightTop)) || (mouseY > parseInt(FreightBottom)))
			if (ServicesArr[1].visibility == VISIBLE)
				ServicesArr[1].visibility = HIDDEN;
				
		if ((mouseX < parseInt(MarketLeft)) || (mouseX > parseInt(MarketRight)) || (mouseY < parseInt(MarketTop)) || (mouseY > parseInt(MarketBottom)))
			if (ServicesArr[2].visibility == VISIBLE)
				ServicesArr[2].visibility = HIDDEN;
				
		if ((mouseX < parseInt(KnowLeft)) || (mouseX > parseInt(KnowRight)) || (mouseY < parseInt(KnowTop)) || (mouseY > parseInt(KnowBottom)))
			if (ServicesArr[3].visibility == VISIBLE)
				ServicesArr[3].visibility = HIDDEN;
	}
}

function expandIt(MenuIndex)
{
	if (CheckVar == true)
	{
		if (MenuIndex == 0)
			ServicesArr[0].visibility = VISIBLE;
	
		if (MenuIndex == 1)
			ServicesArr[1].visibility = VISIBLE;
			
		if (MenuIndex == 2)
			ServicesArr[2].visibility = VISIBLE;
	
		if (MenuIndex == 3)
			ServicesArr[3].visibility = VISIBLE;
	}
}