//<!--


function openPUWin(url, refName, style) {
    ModifyWindow = window.open(url,refName,'height=800,width=600,resizable=yes,status=no,scrollbars=yes');
    ModifyWindow.focus();
	//alert(url);
}

function openModalPUWin(url, refName, style) {
    ModifyWindow = window.open(url,refName,'height=400,width=600,resizable=yes,status=no,scrollbars=no');
    ModifyWindow.focus();
}



//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar

var display_url=0
var MenuURLs= new Array();

var ie5=null;
var ns6=null;
var menuobj=null;

if(document)
{
    ie5=document.all&&document.getElementById
    ns6=document.getElementById&&!document.all
}
if (ie5||ns6){
   if(document)
   	menuobj=document.getElementById("helpmenu")
}

function openModWnd(url, refName, style) {
	ModifyWindow = window.open(url,refName,style);
    ModifyWindow.focus();
}


function showmenuie5(e){
	 if(!menuobj) return;
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX
	var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<menuobj.offsetWidth)
	//move the horizontal position of the menu to the left by it's width
		menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
	else
	//position the horizontal position of the menu where the mouse was clicked
		menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX

	//same concept with the vertical position
	if (bottomedge<menuobj.offsetHeight)
		menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight
	else
		menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY

	menuobj.style.visibility="visible"
	return false
}


function hidemenuie5(e){
	if(!menuobj) return;

	menuobj.style.visibility="hidden"
	menuobj=document.getElementById("helpmenu")
}


function highlightie5(e){
	var firingobj=ie5? event.srcElement : e.target
	if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
		if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node

		firingobj.style.backgroundColor=""
		firingobj.style.color="#990033"
		//if (display_url==1)
		//	window.status=event.srcElement.url
	}
}

function lowlightie5(e){
	var firingobj=ie5? event.srcElement : e.target
	if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
		if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
			firingobj.style.backgroundColor=""
		firingobj.style.color="black"
		window.status=''
	}
}

function jumptoie5(e){
	var firingobj=ie5? event.srcElement : e.target
	if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
		if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode
            var selected=firingobj.getAttribute("place")
            if(selected==0)
            {
                openPUWin(helpfile,'helppop');
            }
            else
            {
                if (firingobj.getAttribute("target")) {
					if(	MenuURLs[selected].length>1) {
						openPUWin(MenuURLs[selected],firingobj.getAttribute("target"));
					}
                    //window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
                    }
                else {
                    window.location=MenuURLs[selected]
                }
            }
	}
}

//lc: placeholder function
function testFunct(s){
	//alert(s);
}

//placeholder function
function handleBrowseItem(arg1, arg2){
	//alert(arg1 + " " +  arg2);
}  

//not called
function getUserLang(){
	thisLang=navigator.language? navigator.language : navigator.userLanguage;
	return thisLang;
}

//context sensitive help for browse only
function doRtClick(dict,uid,depth,menu, hfile){
//hide any previous menus if visible
       if(!menuobj) return;

	menuobj.style.visibility="hidden"

	if (ie5||ns6){
		menuobj=document.getElementById(menu)
	}

//	var ctx_hlp_file = "help/" + ulang + "/" + menu +"/" + hfile + ".htm";
 // 	MenuURLs[0]=ctx_hlp_file;

	/* for browse - left in for reference for now*/
    if(menu=='plain' || menu=='edit' || menu=='admin' || menu=='adminedit' ) {
        MenuURLs[1]="mg-browse.php?Dict_list="+dict+"&node="+uid+"&depth="+depth;

        MenuURLs[2]="mg-details.php?UL="+uid+"&Dict_list="+dict;
        MenuURLs[3]="mg-notes.php?UL="+uid+"&Dict_list="+dict;
        MenuURLs[4]="mg-editnotes.php?UL="+uid+"&Dict_list="+dict;
        if( menu=='edit' || menu == 'adminedit') {
            MenuURLs[5]="mg-addbranch.php?ul="+uid;
            MenuURLs[6]="mg-addleaf.php?ul="+uid;
            MenuURLs[7]="mg-addshoot.php?ul="+uid;

        }
        if( menu=='admin') {
            MenuURLs[5]="mg-auth-url.php?ul="+uid+"&Dict_list="+dict;
        }
        if( menu=='adminedit') {
            MenuURLs[8]="mg-auth-url.php?ul="+uid+"&Dict_list="+dict;
        }
    }
	
	if(menu=='wip' || menu=='wip_no_req') {
		//alert(window.name);
		MenuURLs[1]="mg-browse.php?Dict_list="+dict+"&node="+uid+"&depth="+depth;
        MenuURLs[2]="mg-details.php?UL="+uid+"&Dict_list="+dict;
        MenuURLs[3]="mg-editnotes.php?UL="+uid+"&Dict_list="+dict;
		MenuURLs[4]="mg-edit-entry.php?node="+uid+"&Dict_list="+dict;
		if( menu=='wip_no_req')
			MenuURLs[5]="";
		else
		{
			if(window.name=='Main') //called from the tasks page
				MenuURLs[5]="mg-approve-req.php?from=main&ULtoAuth="+uid;
			else
				MenuURLs[5]="mg-approve-req.php?from=wip&ULtoAuth="+uid;
		}
		MenuURLs[6]="mg-delete.php?ULtoDel="+uid;
	}
	if(menu=='auth_all'|| menu=='auth_vote'|| menu=='auth_auth'|| menu=='auth_none') {
		MenuURLs[1]="mg-browse.php?Dict_list="+dict+"&node="+uid+"&depth="+depth;
		MenuURLs[2]="mg-details.php?UL="+uid+"&Dict_list="+dict;
		MenuURLs[3]="mg-editnotes.php?UL="+uid+"&Dict_list="+dict;
		MenuURLs[4]="mg-edit-entry.php?node="+uid+"&Dict_list="+dict;
		if( menu=='auth_none' || menu=='auth_auth')
			MenuURLs[5]="";
		else
			MenuURLs[5]="mg-vote.php?from=auth&ULtoAuth="+uid+"&Dict_list="+dict;
		if( menu=='auth_none' || menu=='auth_vote')
			MenuURLs[6]="";
		else
			MenuURLs[6]="mg-approve-req.php?from=auth&ULtoAuth="+uid;
	}
}


//lc: for items that have ctx help only
/*
function doLfClick(menu, hfile, ulang){
	var ctx_hlp_file = "help/" + ulang + "/" + menu +"/" + hfile + ".htm";
	openPUWin(ctx_hlp_file,'helppop');
}
*/

//lc: placeholder function
function doRtClick2(menu, hfile, ulang){
	//hide any previous menus if visible
	menuobj.style.visibility="hidden"

	if (ie5||ns6){
		menuobj=document.getElementById(menu)
	}

	var ctx_hlp_file = "help/" + ulang + "/mg-help.php?hfile=" + hfile;
	//alert(ctx_hlp_file);
  	MenuURLs[1]=ctx_hlp_file;
}

function doRtClickFromMenu(menu, hfile, ulang){
	//hide any previous menus if visible
	menuobj.style.visibility="hidden"

	if (ie5||ns6){
		menuobj=document.getElementById(menu)
	}

	var ctx_hlp_file = "../help/" + ulang + "/mg-help.php?hfile=" + hfile;
	//alert(ctx_hlp_file);
  	MenuURLs[1]=ctx_hlp_file;
}


if (ie5||ns6){
/*	comment below to disable rt click */
	menuobj.style.display=''
	if(document)
	{
		document.oncontextmenu=showmenuie5
		document.onclick=hidemenuie5
	}

}

// -->

