// This file should be included in the head of any active frames/ page
	// to make work. It assumes that all the layer ids passed are in the
	// same frame as this file! Got that!?
	
	// Set up static global variables

	// Set up the variables that tell us if we are in NS or IE
	// These work simply by examining the global objects available	
	
	// Only NS uses the layers obj to access CSS layers
	ns = (document.layers) ? true:false;
	// and only IE has the all obj to access CSS layers (amongst other things)
	ie = (document.all) ? true:false;
	
	// Set up variables that control the menu being hidden away
	_openMenu = null;
	_theTimer = null;
	
	function noOp()
	{
	}
	
	function imageSwap(element_, image_, imagePath_)
	{
		var imageFile = imagePath_ + image_;
		
		if (ie)
			{document.all[element_].src = imageFile;}
		else if (ns)
			{document.layers[element_].src = imageFile;}
		else
			{document.getElementsByName(element_)[0].src = imageFile;}
	}

	function closeAllOpenMenus()
	{
		hideLayer('services_submenu');
		hideLayer('mpower_submenu');
		hideLayer('racing_submenu');
		hideLayer('about_submenu');
	}
	
	function hideLayer(id_)
	{
		if (ie)
			{document.all[id_].style.visibility = 'hidden';}
		else if (ns)
			{document.layers[id_].visibility = 'hide';}
		else
			{document.getElementById(id_).style.visibility = 'hidden';}
	}

	function showLayer(id_)
	{
		if (ie) 
			{document.all[id_].style.visibility = 'visible';}
		else if (ns)
			{document.layers[id_].visibility = 'show';}
		else
			{document.getElementById(id_).style.visibility = 'visible';}
	}
	
	function showMenu(name_)
	{
		// Hide all existing menu's first
		closeAllOpenMenus();
		
		// Cancel any existing timer
		clearTimeout(_theTimer);
		
		// Show the one needed and set it up so that it closes correctly later
		_openMenu = name_;
		showLayer(name_);
	}
	
	function keepMenuOpen(name_)
	{
		// Check its the same one we want to keep open, otherwise just let it close
		if (name_ == _openMenu)
		{
			clearTimeout(_theTimer);
		}
	}
	
	function closeMenu(name_)
	{
		if (name_ != _openMenu)
		{
			// Better close that menu too just in case and do it now
			if (null != _openMenu)
			{
				hideLayer(_openMenu);
			}
		}
		
		// Make sure we will actually close the menu we do have open
		_openMenu = name_;
		
		// Don't actually close it, just set up a timer that will close in after a short period of time
		_theTimer = setTimeout('timerCloseMenu();', 500);
	}
	
	function timerCloseMenu()
	{
		hideLayer(_openMenu);
	}
	
	function showGalleryImage(image_, imagePath_)
	{
		imageSwap('disp_image', image_, imagePath_);
		showLayer('image_pane');
		showLayer('close_btn');
	}
	
	function showVideo(vid_src_)
	{
		document.getElementById('vid_frame').src = vid_src_;
		showLayer('vid_pane');
		showLayer('close_vid_btn');
	}
	
	function closeGalleryImage()
	{
		hideLayer('close_btn');
		hideLayer('image_pane');
	}
	
	function closeVideo()
	{
		document.getElementById('vid_frame').src = "";
		hideLayer('close_vid_btn');
		hideLayer('vid_pane');
	}
