/*===========================================================================
	menu.js
	
	$Id:$
	
	xixnet.com menu
	
	Copyright (C) 2003 - xixnet.com, All rights reserved.
	
	$Revision:$
	$State:$
  ============================================================================*/
	
	var ns4up = (document.layers) ? 1 : 0;  // browser sniffer
	var ie4up = (document.all) ? 1 : 0;
	var ns6up = (document.getElementById&&!document.all) ? 1 : 0;
	
	var theBorderColor	= '#999999';
	var saveColor 			= 'black';
	var saveFont;

	var currentBt = -1;	
	var currentColor;
	
	var btColor 		= 'black';
	var btUpHover 	= 'DarkRed';
	var btDownColor = 'yellow';
	var	aTarget;
	var saveMenuDesc;
	
	function reloadMenu( aMenu )
	{
			if( aMenu == -1 )	// Reload All Menu Frames
					i = 0;
			else
					i = aMenu;
					
			for( ; otherMenus[i] != 0; i++ )
			{
				if( otherMenus[i][1] != " " )
				{
					aTarget = otherMenus[i][1];			
					if (ns4up||ns6up)
						window.parent.frames[aTarget].location = otherMenus[i][2];
					else
						window.parent.frames(aTarget).location = otherMenus[i][2];
				}
				if( aMenu != -1 )
				{
					break;
				}
			}
	}
	
	function buttonDown( aElement ) 
	{
		aHref = aElement.id + '-a';
		// Change the old current back to it's color
		if( currentBt != -1 )
		{
			curHref=currentBt.id + '-a';
			
			if (ns4up||ns6up)
			{
				document.links[curHref].style.color = currentColor;		
				currentBt.style.background = btUpImage;
				currentBt.style.border = 'outset';
				currentBt.style.borderColor = theBorderColor;
			}
			else
			{
				document.links(curHref).style.color = currentColor;		
				currentBt.style.background = btUpImage;
				currentBt.style.border = 'outset';
				currentBt.style.borderColor = theBorderColor;
			}
		}
		else
		{
			// It the first time a button was pressed - reload the other menu frame 
			// so it's active button gets cleared.
			reloadMenu( 0 );
		}

		// Save the new element and it's color
	  //!?!framechgcolor
		currentBt = aElement;
		currentColor = aElement.style.color;
		
		aElement.style.background = btDnImage;
		aElement.style.border = 'inset';
		aElement.style.borderColor = theBorderColor;
		if (ns4up||ns6up) 
			document.links[aHref].style.color = btDownColor;		
		else
			document.links(aHref).style.color = btDownColor;		
	}
	
	function buttonUp( aElement ) 
	{
//		aHref = aElement.id + '-a';	
//		aElement.style.background = btUpImage;
//		aElement.style.border = 'outset';
//		aElement.style.borderColor = theBorderColor;
		
		// !?! We don't change the color back - so the user knows which screen they are on
		// So by commenting out the 4 lines below the color of the button will stay until
		// another button is pushed.
		// BUT NOTE: if you press a button on another menu. In another frame - this one has NO
		// way of knowing. So it's color stays the same. This will be confusing so I'm not doing
		// this until I find a way to change another frame's button color.
		// Look for !?!framechgcolor for other places this need handling
//		if (ns4up||ns6up)
//			document.links[aHref].style.color = btUpHover;	// menu a:hover color
//		else
//			document.links(aHref).style.color = btUpHover;	// menu a:hover color
	}

	function menuOnClick( aElement, aLoadFade  ) 
	{
		aHref = aElement.id + '-a';
		if (ns4up||ns6up)
		{
			aUrl = document.links[aHref].href;
			aTarget = document.links[aHref].target;
			window.parent.frames[aTarget].location = aUrl;
		}
		else
		{
			aUrl = document.links(aHref).href;
			aTarget = document.links(aHref).target;
			window.parent.frames(aTarget).location = aUrl;
		}
		
		if( aLoadFade == 1 )
			loadWhiteFade(0);
		if( aLoadFade == 2 )
			loadBeigeFade(0);
	
		// frames[] is 0 based			
//		if( aElement.target == "main" )
//			window.parent.frames["main"].location=aDes;
//		else
//			window.parent.frames[0].location=aDes;
	}

	function movein( aElement, aDesc) 
	{
		// Get the name of the TD and add '-a' to get the 'a href'
		aHref=aElement.id + '-a';

		if( currentBt != aElement )
		{
			aElement.style.backgroundImage = btOverImage;
			//aElement.style.background='url(/res/ButtonBack-c-100-3.gif)';
			saveColor = aElement.style.color;
		}
		
		/*#######################################################
		 # Note: You must reset the border color after setting
		 # the .style.color var.
		 <td bgcolor="Teal"></td>
		 #######################################################*/
		//aElement.style.color='#FFF2BF';
		//aElement.style.color='#800040';
		if (ns4up||ns6up) 
		{
	  //!?!framechgcolor
		if( currentBt != aElement )
				document.links[aHref].style.color = btUpHover;	// menu a:hover color
			window.status=document.links[aHref].href;		
		}
		else
		{
		  //!?!framechgcolor			
			if( currentBt != aElement )
					document.links(aHref).style.color = btUpHover;	// menu a:hover color
			window.status = document.links(aHref).href;		
		}

		//aElement.style.textDecorationBlink='1';
		//aElement.style.textDecorationUnderline='1';
		//aElement.style.border='inset';
		aElement.style.borderColor = theBorderColor;
		
		if (document.getElementById)
		{
			saveMenuDesc = document.getElementById("boxdescription").innerHTML;
			document.getElementById("boxdescription").innerHTML = aDesc;
		}
		else
		{
			saveMenuDesc = boxdescription.innerHTML;
			boxdescription.innerHTML = aDesc;
		}
	}

	function moveout(aElement) 
	{
		// Get the name of the TD and add '-a' to get the 'a href'
		aHref = aElement.id + '-a';

	  //!?!framechgcolor		
		if( currentBt != aElement )
		{
			//aElement.style.background='bisque';
			aElement.style.background = btImage;
			aElement.style.color = saveColor;
		
			if (ns4up||ns6up)
				document.links[aHref].style.color = saveColor;		
			else
				document.links(aHref).style.color = saveColor;

			window.status = '';

			aElement.style.border = 'outset';
			aElement.style.borderColor = theBorderColor;
		}

		if (document.getElementById)
			document.getElementById("boxdescription").innerHTML = saveMenuDesc;
		else
			boxdescription.innerHTML = saveMenuDesc;
	}
