if (window.Event) 
// need this for Netscape since no onClick event is available
{
    document.captureEvents(Event.MOUSEDOWN); 
    document.onmousedown = statusPopUpMenu; 
	//may need to add xPos and yPos later
}       

function initialize() 
//need this since IE doesn't initially recognize hidden from styles above; 
//eg. the first click didn't bring up a menu without the initialize; 
//kept Netscape coding for completeness
{
	if(document.all)
	{
		document.all.myPopUp.style.visibility = "hidden";
   	}
	else if(document.layers)
	{
		document.layers.myPopUp.visibility = "hide";
   	}
}

function statusPopUpMenu(e) // e is the event object
{                            
    if (document.all) //code for IE
	{
        var mouseX = event.clientX-10;  //this gives the mouse cursor positions
        var mouseY = event.clientY+110;
        
        //if ((mouseX+220) > (document.body.clientWidth)) 
        if ((mouseX) > (document.body.clientWidth)) 
		{
			//mouseX = document.body.clientWidth-210; 
			mouseX = document.body.clientWidth; 
			//if click near edges, displays menu in view
			//checks coordinates of mouseclick against screen display dimensions
		}
        
		//if ((mouseY+130) > (document.body.clientHeight)) 
		if ((mouseY) > (document.body.clientHeight)) 
		{
			//mouseY = document.body.clientHeight-125;
			mouseY = document.body.clientHeight;
		}
        
        if (document.all.myPopUp.style.visibility == "hidden") 
		//check whether menu open or closed
		{
			document.all.myPopUp.style.visibility = "visible"; 
			//open popUp Menu
			document.all.myPopUp.style.left = mouseX + document.body.scrollLeft;
			//display menu where cursor clicked even if scrolled down
			document.all.myPopUp.style.top = mouseY + document.body.scrollTop;                
        }            
        else 
		{
			document.all.myPopUp.style.visibility = "hidden"; 
			//close popUp Menu
		}
    }           
    
    if (document.layers) 
	//code for Netscape
	{ 
	//check whether mouseclicked near edge of screen and correct to display if so
        //if (e.pageX+240 > (window.innerWidth + window.pageXOffset)) 
        if (e.pageX > (window.innerWidth + window.pageXOffset)) 
		{
			//e.pageX = (window.innerWidth + window.pageXOffset)-230;
			e.pageX = (window.innerWidth + window.pageXOffset);

		}

        //if (e.pageY+150 > (window.innerHeight + window.pageYOffset)) 
       if (e.pageY > (window.innerHeight + window.pageYOffset)) 
		{
			//e.pageY = (window.innerHeight + window.pageYOffset)-145;
			e.pageY = (window.innerHeight + window.pageYOffset);
		}
        
        if (document.layers.myPopUp.visibility == "hide") 
		//check whether menu open or closed
		{
			document.layers.myPopUp.visibility = "show"; 
			//open popUp Menu
			document.layers.myPopUp.left = e.pageX;
			document.layers.myPopUp.top =  e.pageY;
        }            
        else 
		{
			document.layers.myPopUp.visibility = "hide"; 
			//close popUp Menu
		}
    }
    return true;
}

