//
// Function Menu
//
	var menuWaitGIF
	var menuGIF
	var	menuWaitMsg = ""
	var menuDeleteMsg = ""
	var functionMenuURL = ""
	var functionMenuPath = ""
    var myFunctionMenu
    var x
    var y

	if ( NS4 )
	{
		var appContainer
	}
	
	function beforeMenuPop()
	{
		window.status = ""
	}
	
	function showFunctionMenu( moreParam, id, e, theTarget )
	{
	    var myItem

	    if ( !pageLoaded )
	    {
	    	return
	    }

		myItem = "x" + id
		document.images[ myItem ].src = menuWaitGIF

		window.status = menuWaitMsg
		    
		getObjectAndXY( e )
		
		if ( typeof( theTarget ) == "undefined" )
			theTarget = ""

		if ( myFunctionMenu.showWithTarget( x, y, id, moreParam, theTarget ) == "" )
		{
		}
		document.images[ myItem ].src = menuGIF
		
		window.status = ""
	}
	
	function showFunctionMenuAdv( theURL, id, e, theTarget )
	{
	    var myItem

	    if ( !pageLoaded )
	    {
	    	return
	    }

        id = "" + id
		myItem = "x" + id
		document.images[ myItem ].src = menuWaitGIF

		window.status = menuWaitMsg
		    
		getObjectAndXY( e )
		
		if ( typeof( theTarget ) == "undefined" )
			theTarget = ""

		if ( myFunctionMenu.showAdv( x, y, id, theURL, theTarget ) == "" )
		{
		}
		
		document.images[ myItem ].src = menuGIF
		
		window.status = ""
	}
	
	function getObjectAndXY( e )
	{
		if ( NS4 )
		{			
			if ( !appContainer )
			{
				appContainer = eval( 'document.appletContainer' )
			}

			//alert(e.pageX + " " + e.pageY + " appContainer.x=" + appContainer.x + " appContainer.y=" + appContainer.y )
    		if ( NS7 )
			{
				x = e.pageX - appContainer.x
				y = e.pageY - appContainer.y
			}
    		else if ( NS6 || useLayers )
			{
				x = e.pageX
				y = e.pageY
			}
			else
			{
				x = e.pageX - appContainer.x
				y = e.pageY - appContainer.y //window.pageYOffset
			}
		}
		else
		{
			window.divFM.style.top=document.body.scrollTop
			window.divFM.style.left=document.body.scrollLeft

			x = e.clientX
			y = e.clientY
		}

		if ( useLayers )
			myFunctionMenu = window.document.outerLayerNS.document.innerLayerNS.document.applets.FunctionMenu
		else
			myFunctionMenu = window.document.applets.FunctionMenu
			
		//window.status = y + " clientY=" + e.clientY  + " screenY=" + e.screenY + " scrollTop=" + document.body.scrollTop + " clientHeight=" + document.body.clientHeight + " menuTop=" + menuTop
	}

	function onLoadFunctionMenu( argMenuGif, argMenuWaitGif )
	{
		pageLoaded = true

		if ( useLayers )
		{
			with (window.document.outerLayerNS.document.innerLayerNS.document)
			{
	      		open();
	 			write( '&nbsp;<APPLET NAME="FunctionMenu" CODEBASE="' + functionMenuPath + '" CODE="com.opentext.applet.FunctionMenu" ARCHIVE="llheader.jar" WIDTH="1" HEIGHT="1" MAYSCRIPT>' )
		    	write( '<PARAM NAME="cabbase" VALUE="llheader.cab">' )
		    	write( '<PARAM NAME="callback" VALUE="popup_callback">' )
				write( '<PARAM NAME="functionsURL" VALUE="' + functionMenuURL + '">' )
				write( '<PARAM NAME="nextURL" VALUE="' + escape( window.location ) + '">' )			
				write( '</APPLET>' )
	      		close();
	    	}
   		}
  
	    menuGIF = argMenuGif
	    menuWaitGIF = argMenuWaitGif
	    
	    var waitImg = new Image()
	    waitImg.src = menuWaitGIF									
	}

    function popup_callback( theURL, theTarget )
    {
	    if ( !pageLoaded )
	    {
	    	return
	    }

		if ( __LeavePage == "" || ( eval( __LeavePage + "( '" + theURL + "', '" + theTarget + "')" ) ) )
		{
		    if ( -1 == theURL.indexOf( 'objAction=delete' ) )
		    {
				if ( IE && ( theURL.indexOf( 'objAction=download' ) > 0 ) )
  				{
  					// fix to situation where the image sometimes does not draw.
 					var kludgeWindow = window.open( '', '', 'width=1,height=1,top=0,left=0' )
					kludgeWindow.close();

					topFrame = getLLTop(self)
					
					if ( topFrame == self )
 						openURL( theURL, theTarget )
 					else
 						topFrame.location.href = theURL
   				}
  				else
 	            	openURL( theURL, theTarget )
 	            
		    }
		    else
		    {
		        if ( confirm( menuDeleteMsg ) )
		        {
		            openURL( theURL, theTarget )
		        }
	        }
		}
    }
