var browser
var x = 0;
var y = 0;
var captureMouse = false;
var arLayers = new Array; //array to store the layer names that occur on the page
arLayers[0] = "layerAbout";
arLayers[1] = "layerService";
arLayers[2] = "layerContact";
arLayers[3] = "layerNews";
arLayers[4] = "layerEvents";

if(document.layers)
{
	browser = "NN4";
	document.write("<link rel='stylesheet' href='Scripts/mgt_NN.css' type='text/css'>");
}

if(document.all)
{
	browser = "IE";
	document.write("<link rel='stylesheet' href='Scripts/mgt.css' type='text/css'>");
}

//Set up browser to capture mouse movement coordinates.
function startCapture()
{
	if (!captureMouse)
	{
 		if (browser == "NN4")
		{
			document.captureEvents(Event.MOUSEMOVE);
		}
		document.onmousemove = getMouseXY;
		captureMouse = true;
	}
}

function stopCapture()
{
	if (browser == "NN4")
		document.releaseEvents();
		
	if (browser == "IE")
		document.releaseCapture();

	document.onmousemove = null;
	captureMouse = false;
}

/*Function name: getMouseXY()
  Function purpose: This function captures tha mouse movement coordinates in the browser window.
			If the mouse enters a preset area (270<=x<=760; 86<=y<=290) then the submenu
			layers become hidden.
*/
function getMouseXY(e) 
{
	if (browser == "IE") // grab the x-y pos.s if browser is IE
	{
		x = event.clientX + document.body.scrollLeft;
		y = event.clientY + document.body.scrollTop;

		if (y <= 86 || y >= 290 || x >= 760 || x <= 270)
		{
			if(document.all[arLayers[0]].style.visibility == "visible" || document.all[arLayers[1]].style.visibility == "visible" || document.all[arLayers[2]].style.visibility == "visible" || document.all[arLayers[3]].style.visibility == "visible" || document.all[arLayers[4]].style.visibility == "visible")
				showHideLayers(arLayers[0],'hide', arLayers[1],'hide', arLayers[2],'hide', arLayers[3],'hide', arLayers[4],'hide');
			stopCapture();
		}
	}
	if (browser == "NN4") // grab the x-y pos.s if browser is NN4
	{
		x = e.pageX;
		y = e.pageY;

		if (y <= 86 || y >= 290 || x >= 760 || x <= 270)
		{
			if(document.layers[0].visibility == "show" || document.layers[1].visibility == "show" || document.layers[2].visibility == "show" || document.layers[3].visibility == "show" || document.layers[4].visibility == "show")
				showHideLayers(arLayers[0],'hide', arLayers[1],'hide', arLayers[2],'hide', arLayers[3],'hide', arLayers[4],'hide');
			stopCapture();
		}
	}
	
//	window.status = "X=" + x + "; Y=" + y;

	return true;
}

function MM_preloadImages() 
{
	var d=document;
	
	if(d.images)
	{ 
		if(!d.MM_p) 
			d.MM_p=new Array();
    	var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
		    if (a[i].indexOf("#")!=0)
			{
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
	}
}

/*Function name: swapImages()
  Function purpose: This fucntion creates the mouseover image-swapping effect.
*/
function swapImages(img, source)
{
	document.images[img].src = source;
}

/*Function name: showHideLayers()
  Function purpose: This functions hides/shows layers whose names are passed to it as arguments.
*/
function showHideLayers()
{
	var args = showHideLayers.arguments;
	for (var i = 0; i < args.length; i+=2)
	{
		if (browser == "NN4")
		{
			if(args[i+1] == "show")
				document.layers[args[i]].visibility = "show";
			else
				document.layers[args[i]].visibility = "hide";
		}
		if (browser == "IE")
		{
			if(args[i+1] == "show")
				document.all[args[i]].style.visibility = "visible";
			else
				document.all[args[i]].style.visibility = "hidden";
		}
	}
}


/*Function name: changeStyle()
  Function purpose: This function changes the style (styleName) of an object (id).
*/
function changeStyle(id, styleName)
{
		id.className = styleName;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function fixLayers()
{
	//Fixing layer positions for Netscape 4.x
	if(browser == "NN4")
	{
		for (var i = 0; i <= document.layers.length; i++)
		{
			document.layers[i].top = document.layers[i].top - 7;
		}
	}	
}

MM_reloadPage(true);