// Global variables
var g_strEmptySubMenu 			= "";				// Stores the empty sub menu value
var g_strActiveSubMenu 			= "";				// Stores the most recent active sub menu
	
var g_strActiveMenuID 			= "";				// Stores the most recent activemenu
	
var g_clMenuActiveColor			= "#0040f0";		// Active menu color
var g_clMenuInactiveColor		= "#0060ff";		// Inactive menu color
var g_clSubMenuActiveColor		= "#ff0000";		// Active sub menu color
var g_clSubMenuInactiveColor	= "#33ffff";		// Inactive submenu color
	
var g_iBlurTimeOut				= 1000;				// Sub menu blur timeout
var g_iBlurTimerID				= -1;				// Sub menu blur timeout id
	
var g_iActivateTimeOut			= 100;				// Activate menu timeout
var g_iActivateTimerID			= -1;				// Activate menu timeout id
				
// Remarks: Puts the menu in the active state
// Parameters:
//		oMenuItem - menu item pointer
//		strSubMenu - menu lable identifier
function Menu_Activate( oMenuItem, strSubMenu )
{
	// Adjust the menu cursor
	oMenuItem.style.cursor="hand";
	
	// Clear the blur timer
	if( g_iBlurTimerID != -1 ) window.clearTimeout( g_iBlurTimerID );
	g_iBlurTimerID = -1;
		
	// Reset the activate timer
	if( g_iActivateTimerID != -1 ) window.clearTimeout( g_iActivateTimerID );
	
	g_iActivateTimerID = window.setTimeout( "Menu_ActivateImpl( '" + oMenuItem.id + "', '" + strSubMenu + "' );", g_iActivateTimeOut );
}	

// Remarks: Puts the menu in the active state
// Parameters:
//		oMenuItem - menu item pointer
//		strSubMenu - menu lable identifier
function Menu_ActivateImpl( oMenuItemID, strSubMenu )
{
	// Deactivate the last active menu item
	if( g_strActiveMenuID != "" )
	{
		// Get the menu item
		var oPrevMenuItem = document.getElementById( g_strActiveMenuID );
			
		// Adjust the background of the menu item
		oPrevMenuItem.style.backgroundColor=g_clMenuInactiveColor; 
	}
		
	// Assign the most recently active menu
	g_strActiveMenuID = oMenuItemID;
	
	// Get the menu item
	var oMenuItem = document.getElementById( oMenuItemID );
			
	// Adjust the background of the menu item
	oMenuItem.style.backgroundColor=g_clMenuActiveColor; 
			
	// Adjust the sub menu area
	Menu_ChangeSubMenu( strSubMenu );
}	

// Remarks: Puts the menu in the deactive state
// Parameters:
//		oMenuItem - menu item pointer
function Menu_Deactivate( oMenuItem )
{
	// Adjust the menu cursor
	oMenuItem.style.cursor="auto";
				
	// Reset the blur timer
	if( g_iBlurTimerID != -1 ) window.clearTimeout( g_iBlurTimerID );
	g_iBlurTimerID = window.setTimeout( "Menu_BlurSubMenu( )", g_iBlurTimeOut );
		
	// Clear the activation timer
	if( g_iActivateTimerID != -1 ) window.clearTimeout( g_iActivateTimerID );
	g_iActivateTimerID = -1;
}
	
// Remarks: Puts the sub menu in the active state
// Parameters:
//		oMenuItem - menu item pointer
function SubMenu_Activate( oSubMenuItem)
{
	// Adjust the menu cursor
	oSubMenuItem.style.cursor="hand";
		
	// Adjust the background of the sub menu item
	oSubMenuItem.style.backgroundColor=g_clSubMenuActiveColor; 
}	

// Remarks: Puts the sub menu in the deactive state
// Parameters:
//		oMenuItem - menu item pointer
function SubMenu_Deactivate( oSubMenuItem )
{
	// Adjust the menu cursor
	oSubMenuItem.style.cursor="auto";
		
	// Adjust the background of the sub menu item
	oSubMenuItem.style.backgroundColor=g_clSubMenuInactiveColor; 
}
	
// Remarks: Puts the seperator menu into the active state
// Parameters:
//		oMenuItem - menu item pointer
function Separator_Activate( oSeparatorItem )
{
	// Adjust the menu cursor
	oSeparatorItem.style.cursor="default";
}	

// Remarks: Puts the seperator menu into the deactive state
// Parameters:
//		oMenuItem - menu item pointer
function Separator_Deactivate( oSeparatorItem )
{
	// Adjust the menu cursor
	oSeparatorItem.style.cursor="auto";
}
	
// Remarks: Changes the sub menu
// Parameters:
//		strSubMenu - menu lable identifier
function Menu_ChangeSubMenu( strSubMenu )
{
	// Only adhust if we have a changed
	if( g_strActiveSubMenu != strSubMenu )
	{
		// Hide the existing sub menu if it exists
		if( g_strActiveSubMenu != "" ) 
		{
			var oActiveSubMenu = document.getElementById( g_strActiveSubMenu );
		
			if( oActiveSubMenu != null )
			{
				oActiveSubMenu.style.display = "none";
			}
		}
			
		// Assign the new submenu
		g_strActiveSubMenu = strSubMenu;
			
		// Show the new sub menu if it exists
		if( g_strActiveSubMenu != "" ) 
		{
			var oActiveSubMenu = document.getElementById( g_strActiveSubMenu );
			if( oActiveSubMenu != null )
			{
				if( oActiveSubMenu.style.display != "block" )
				{
					oActiveSubMenu.style.display = "block";
				}
			}
		}
	}
		
		
	if( g_iBlurTimerID != -1 ) window.clearTimeout( g_iBlurTimerID );
	g_iBlurTimerID = -1;
}
	
// Remarks: Notification that we are over a sub menu area
function SubMenu_OverArea( )
{
	// Clear any timer if it was enabled
	if( g_iBlurTimerID != -1 ) window.clearTimeout( g_iBlurTimerID );
	g_iBlurTimerID = -1;
}
	 
function SubMenu_OutArea( )
{
	// Activate the timer
	if( g_iBlurTimerID != -1 ) window.clearTimeout( g_iBlurTimerID );
	g_iBlurTimerID = window.setTimeout( "Menu_BlurSubMenu( )", g_iBlurTimeOut );
}
	
// Remarks: Blurs the sub menu
function Menu_BlurSubMenu( )
{
	// Assign the most recently active menu
	if( g_strActiveMenuID != "" )
	{
		// Get the menu item
		var oPrevMenuItem = document.getElementById( g_strActiveMenuID );
			
		// Adjust the background of the menu item
		oPrevMenuItem.style.backgroundColor=g_clMenuInactiveColor; 
	}
		
	g_strActiveMenuID = "";
		
	Menu_ChangeSubMenu( g_strEmptySubMenu );
}
	
// Remarks: Assigns the empty sub menu and adjust the visible state of the menus
// Parameters:
//		strEmptySubMenu - the mpty sub menu
//		clMenuActiveColor - Active menu color
//		clMenuInactiveColor - Inactive menu color
//		clSubMenuActiveColor - Active sub menu color
//		clSubMenuInactiveColor - Inactive submenu color
function Menu_Start( strEmptySubMenu, clMenuActiveColor, clMenuInactiveColor,
	clSubMenuActiveColor, clSubMenuInactiveColor )
{
	// Assign the empty submenu
	g_strEmptySubMenu = strEmptySubMenu;
	
	// Assign the global color variables
	if( clMenuActiveColor != "" ) 		g_clMenuActiveColor 		= clMenuActiveColor;
	if( clMenuInactiveColor != "" ) 	g_clMenuInactiveColor	 	= clMenuInactiveColor; 
	if( clSubMenuActiveColor != "" ) 	g_clSubMenuActiveColor  	= clSubMenuActiveColor;
	if( clSubMenuInactiveColor != "" ) 	g_clSubMenuInactiveColor	= clSubMenuInactiveColor;

	// Adjust the sub menu area
	//Menu_ChangeSubMenu( g_strEmptySubMenu );
	g_strActiveSubMenu = g_strEmptySubMenu;
}

// Remarks: Luanches the specified application.
// Parameters:
//		pszApplication - application name
//	
function Execute( pszApplication )
{     
	// Get the shell
	var Shell = new ActiveXObject( "wScript.shell" );
			
	// Create the root directory path
	var pszRootDir = "" + document.location.href;
	
	// Remove the "file:///" header
	pszRootDir = pszRootDir.substr( 8 );
	
	// Replace "%20" with spaces
	while( pszRootDir.indexOf( "%20" ) !=  -1 )
	{
		pszRootDir = pszRootDir.replace( "%20", " " );
	}
	
	// Replace HTML slashes with windows slashes
	while( pszRootDir.indexOf( "index.html" ) !=  -1 )
	{
		pszRootDir = pszRootDir.replace( "index.html", "\\" );
	}
		
	// Remove the file name
	var dwSlashPos = pszRootDir.lastIndexOf( '\\' );
	pszRootDir = pszRootDir.substr( 0, dwSlashPos );
	
	// Handle the "..\" directory specifiers
	var dwDirBackPos =  pszApplication.indexOf( '..\\' );
	while( dwDirBackPos == 0 )
	{
		// Adjust the directory path
		dwSlashPos = pszRootDir.lastIndexOf( '\\' );
		pszRootDir = pszRootDir.substr( 0, dwSlashPos );
		
		// Adjust the application path
		pszApplication = pszApplication.substr( 3 );
		
		// Setup for the next loop
		dwDirBackPos =  pszApplication.indexOf( '..\\' );
	}
	
	// Create the application path
	var pszApplicationPath = '"' + pszRootDir + "\\" + pszApplication + '"';
	
	Shell.Run( pszApplicationPath );
}

// Global variables
var g_bfirstTime 				= true;				// First time the play command is issued
var g_bIsPlaying 				= false;			// are we currently playing

// Remarks: Plays a captivate flash animation
// Parameters:
//		strFlashName - flash obejct's name
function PlayCaptivateFlash( strFlashName )
{
	// Get the flash objects
	var oFlashObject = document.getElementById( strFlashName );
	
	if( g_bfirstTime == false ) 
	{ 
		oFlashObject.SetVariable( '_root.rdcmndPause', '0' );
		oFlashObject.SetVariable( '_root.rdcmndResume', '1' );
	}
	else
	{
		oFlashObject.Play( );
		oFlashObject.SetVariable( '_root.rdcmndPause', '0' );
		oFlashObject.SetVariable( '_root.rdcmndResume', '1' );
		g_bfirstTime = false;
	}
	
	g_bIsPlaying = true;
}

// Remarks: Pauses a captivate flash animation
// Parameters:
//		strFlashName - flash obejct's name
function PauseCaptivateFlash( strFlashName )
{
	// Get the flash objects
	var oFlashObject = document.getElementById( strFlashName );
		
	oFlashObject.SetVariable( '_root.rdcmndResume', '0' );
	oFlashObject.SetVariable( '_root.rdcmndPause', '1' );
	
	g_bIsPlaying = false;
}	

// Remarks: Resets the captivate flash animation
// Parameters:
//		strFlashName - flash obejct's name
function ResetCaptivateFlash( strFlashName )
{	
	// Get the flash objects
	/*var oFlashObject = document.getElementById( strFlashName );
		
	oFlashObject.Rewind( );
	
	g_bfirstTime= true;*/
}

/*
// Remarks: Checks to see if a movie has started
// Returns: True if playback has started, else false
// Parameters:
//		strFlashName - flash obejct's name
function HasCaptivateFlashStarted( strFlashName )
{
	if( g_bfirstTime == true ) return false;
	else return true;
}	

// Remarks: Checks to see if a movie has completed
// Returns: True if playback has completed, else false
// Parameters:
//		strFlashName - flash obejct's name
function HasCaptivateFlashCompleted( strFlashName )
{
	// Get the flash objects
	var oFlashObject = document.getElementById( strFlashName );
	
	if( g_bfirstTime == true ) return false;
	
	var iFrameCount = oFlashObject.GetVariable( '_root.rdinfoFrameCount' );
	var iFrameCurrent = oFlashObject.GetVariable( '_root.rdinfoCurrentFrame' );
	
	if( iFrameCount == iFrameCurrent ) return true;
	else return false;
}	*/
