

// JScript source code

function showmenu1(e,which){

//clearhidemenu();
mainmenuobj=document.all.popmenu;
mainmenuobj.thestyle= mainmenuobj.style ;
menuobj=document.all.popmenu1 ;
menuobj.thestyle= menuobj.style ;
//alert("oo")
menuobj.innerHTML=which;
//alert("pp")
menuobj.contentwidth= menuobj.offsetWidth ;
menuobj.contentheight= menuobj.offsetHeight; 
eventX=event.clientX;//mainmenuobj.contentwidth+ mainmenuobj.thestyle.left
eventY=event.clientY ;

//Find out how close the mouse is to the corner of the window
var rightedge=document.body.clientWidth-eventX ;
var bottomedge=document.body.clientHeight-eventY; 

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (menuobj.contentwidth>rightedge){
//move the horizontal position of the menu to the left by it's width
menuobj.thestyle.left=document.body.scrollLeft+eventX-menuobj.contentwidth ;
}
else
{
//position the horizontal position of the menu where the mouse was clicked
menuobj.thestyle.left=document.body.scrollLeft+eventX ;
}

//same concept with the vertical position
if (menuobj.contentheight>bottomedge)
{
menuobj.thestyle.top=document.body.scrollTop+eventY-menuobj.contentheight ;
}
else
{
menuobj.thestyle.top=document.body.scrollTop+event.clientY ;
}

menuobj.thestyle.visibility="visible";

return false;
}

function showmenu(e,which,x,y){

clearhidemenu();

menuobj=document.all.popmenu ;
menuobj.thestyle= menuobj.style ;

menuobj.innerHTML=which;

menuobj.contentwidth= menuobj.offsetWidth ;
menuobj.contentheight= menuobj.offsetHeight; 
eventX=event.clientX ;
eventY=event.clientY ;

//Find out how close the mouse is to the corner of the window
var rightedge=document.body.clientWidth-eventX ;
var bottomedge=document.body.clientHeight-eventY; 

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (menuobj.contentwidth>rightedge){
//move the horizontal position of the menu to the left by it's width
menuobj.thestyle.left=document.body.scrollLeft+eventX-menuobj.contentwidth ;
}
else
{
//position the horizontal position of the menu where the mouse was clicked
menuobj.thestyle.left=document.body.scrollLeft+eventX ;
}

//same concept with the vertical position
if (menuobj.contentheight>bottomedge)
{
menuobj.thestyle.top=document.body.scrollTop+eventY-menuobj.contentheight ;
}
else
{
menuobj.thestyle.top=document.body.scrollTop+event.clientY ;
}
menuobj.thestyle.left=x;
menuobj.thestyle.top=y;

menuobj.thestyle.visibility="visible";

return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.thestyle.visibility="hidden"
}

function dynamichide(e){
if (!menuobj.contains(e.toElement))
	hidemenu();
}

function delayhidemenu(){

delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
	clearTimeout(delayhide)
}

function highlightmenu(e,state){
	
	source_el=event.srcElement

	if (source_el.className=="menuitem")
	{
	
		source_el.id=(state=="on")? "mouseoverstyle" : ""
	}
	else
	{
	
		while(source_el.id!="popmenu")
		{
			
			source_el= source_el.parentNode 
			
			if (source_el.className=="menuitem")
				{
				
					source_el.id=(state=="on")? "mouseoverstyle" : ""
				}
		}
	}
}

document.onclick=hidemenu;



