/********************************************************************************************************************************
* Licensed Materials - Property of IBM                                                                                          *
*                                                                                                                               *
* IBM Cognos Products: AGS                                                                                                      *
*                                                                                                                               *
* (C) Copyright IBM Corp. 2005, 2008                                                                                          *
*                                                                                                                               *
* US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
*********************************************************************************************************************************/

//define the summary menu
var summaryBarMenu = null;

/*
 The call to this is done in the onmouseup event only.
 We cannot put in the function below. Because the function
 below can be called by the observer. called when the
 mouseup is fired on the summaryBarMenu drop down
 These functions are called in order:
    removeSummaryBarTasksMenuListener()
    showSummaryBarTasksMenu(event);
    summaryBar_cancelBub(event);
*/
function removeSummaryBarTasksMenuListener() {
    parent.document.body.getWndObserver().removeListener(summaryBarMenu);
}

function showSummaryBarTasksMenu(event) {
    if (!summaryBarMenu) {
        initSummaryMenu();
    }

    if (summaryBarMenu.isVisible()) {
		summaryBarMenu.remove();
		if (parent.document.body.getWndObserver) {
		    parent.document.body.getWndObserver().removeWhenDone(summaryBarMenu);
		}
	} else {
	    //Must always be first to be able to delete the marked observer, before it shows it.
		if (parent.document.body.getWndObserver) {
		    //Notify parent that mouseup occured. This is so that when 
		    //summaryBarMenu drop down is clicked any open menus are closed.
		    parent.document.body.getWndObserver().notify(summaryBarMenu,"mouseup");
		    
            //add summaryBarMenu as a listener so that the top level frame will call
            //this function when it receives a mouseup event   
		    parent.document.body.getWndObserver().addListener(summaryBarMenu, showSummaryBarTasksMenu, "mouseup");
		}
		summaryBarMenu.draw();
		summaryBarMenu.show();
	}
}

function summaryBar_cancelBub(evt)
{
    //get the event in a cross-browser fashion
    evt = (evt) ? evt : ((event) ? event : null);

    //prevent the click from proceeding to other nodes
    if (typeof evt.cancelBubble != 'undefined')
    {
        evt.cancelBubble = true;
    }

    if (typeof evt.stopPropagation != 'undefined')
    {
        evt.stopPropagation();
    }
}