////////////////////////////////////////////////////////////////////////////////
// BEGIN
//

	var menuTimer;
	var delayedMenuTimer;

	function initMenus()
	{
		var menuElems = document.getElementById( "menus" ).getElementsByTagName( "div" );
		for( var n = 0; n < menuElems.length; n++ )
		{
			// Menu Container
			if( menuElems[n].className == "menu" )
			{
				menuElems[n].onmouseover = function()
				{
					clearHideMenu();	
				}
				menuElems[n].onmouseout = function()
				{
					startHideMenu();	
				}
			}
			
			// Menu Item
			if( menuElems[n].className == "menuItem" )
			{
				menuElems[n].onmouseover = function()
				{
					clearHideMenu();	
				}
			}
		}
		
		if( navigator.appName == "Microsoft Internet Explorer" )
		{
			var menuHack = document.createElement( "div" );
				menuHack.id = "menuHack";
				menuHack.className = "menuHack";
				menuHack.innerHTML = "<img src='images/layout/spacer.gif' style='width: 100%; height: 100%;' usemap='#Map'>";
			
			document.getElementById( "header" ).appendChild( menuHack );
		}
	}

	function showMenu( elemID )
	{
		hideMenu();
		var menuElem = document.getElementById( "menu_" + elemID );
			menuElem.style.visibility = "visible";
			
		clearHideMenu();
	}
	
	function showMenuIE7( elemID )
	{
		showMenu( elemID );
	}
	
	function hideMenu()
	{
		var menuElems = document.getElementById( "menus" ).getElementsByTagName( "div" );
		for( var n = 0; n < menuElems.length; n++ )
		{
			// Menu Container
			if( menuElems[n].className == "menu" )
			{
				menuElems[n].style.visibility = "hidden";
			}
		}		
		
		clearHideMenu();
	}
	
	function startHideMenu()
	{
		clearTimeout( menuTimer );
		menuTimer = setTimeout( "hideMenu()", 2000 );
	}
	
	function clearHideMenu()
	{
		clearTimeout( menuTimer );
	}

	function showImage( path )
	{
		// Canvas
		showCanvas();
		
		var w = document.body.scrollWidth;
		var h = document.body.scrollHeight;
		
		if( myHeight > h )
			h = myHeight;
			
		if( myWidth > w )
			w = myWidth;
		
		// Create Image Container
		var myImageContainerJS = document.createElement( "div" );
			myImageContainerJS.id = "myImageContainer";
			myImageContainerJS.className = "posABS";
			myImageContainerJS.style.visibility = "hidden";
		
		var myImageJS = document.createElement( "img" );
			myImageJS.id = "myImage";
			myImageJS.className = "blackBorder myGalleryImage";
			myImageJS.src = path;
			
			myImageJS.onload = function()
			{
				var myImageContainerJS = document.getElementById( "myImageContainer" );
				
				var objW = this.width;
				var objH = this.height;
				myImageContainerJS.style.top = "225px";
				myImageContainerJS.style.left = ((w-objW) / 2) + "px";
				myImageContainerJS.style.width = (objW+2) + "px";
				myImageContainerJS.style.height = (objH+2) + "px";
				//myImageContainerJS.appendChild( this );	
				myImageContainerJS.style.visibility = "visible";
			}
					
		var myClose = document.createElement( "div" );
			myClose.innerHTML = "X";
			myClose.className = "myClose";
			myClose.style.color = "#FFFFFF";
			myClose.style.backgroundColor = "#000000";
			myClose.onclick = function () { removeImage(); }
			
		
		
		document.body.appendChild( myImageContainerJS );
		myImageContainerJS.appendChild( myClose );
		myImageContainerJS.appendChild( myImageJS );
	}
	
	function removeImage()
	{
		removeCanvas();
		
		var myImageJS = document.getElementById( "myImageContainer" );
			document.body.removeChild( myImageJS );
	}
	
	function showCanvas()
	{
		// Window Size
		windowSize();
		
		var w = document.body.scrollWidth;
		var h = document.body.scrollHeight;
		
		if( myHeight > h )
			h = myHeight;
			
		if( myWidth > w )
			w = myWidth;
		
		// Create Canvas
		var canvas = document.createElement( "div" );
			canvas.id = "canvas";
			canvas.innerHTML = "&nbsp;";
			canvas.className = "canvas";
			//canvas.style.width = w + "px";
			canvas.style.height = h + "px";
			canvas.style.width = "100%";
			//canvas.style.height = "100%";
			canvas.style.visibility = "visible";
			canvas.style.zindex = "10";
			document.body.appendChild( canvas );
	}
	
	function removeCanvas()
	{
		var canvasJS = document.getElementById( "canvas" );
			document.body.removeChild( canvasJS );
	}
	
	var myWidth = 0, myHeight = 0;
	function windowSize()
	{
		if( typeof( window.innerWidth ) == 'number' )
		{
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
	}

//
// END
////////////////////////////////////////////////////////////////////////////////