/*
 * menuDropdown.js - implements an dropdown menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 * Modified: By Adrian Angelov (e-mail: adrian.angelov@gmail.com)
 * Date modified: 27.Apr.2005
 */

var currentMenu = null;
var currentList = null;

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // I'm too tired

    actuator.onmouseover = function() {
        if (currentMenu) {
            currentMenu.style.visibility = "hidden";
			this.showMenu();
	        }
		if (currentList) {
			currentList.style.visibility = "hidden";
			this.showList();
			}
    }
  
    actuator.onclick = function() {
        if (currentMenu == null) {
            this.showMenu();
        }
        else {
            currentMenu.style.visibility = "hidden";
            currentMenu = null;
        }

        return false;
    }

    actuator.showMenu = function() {
        menu.style.left = this.offsetLeft + "px";
        menu.style.top = this.offsetHeight + "px";
		menu.style.visibility = "visible";
        currentMenu = menu;
    }
}

function initializeList(listId, moderatorId) {
    var list = document.getElementById(listId);
    var moderator = document.getElementById(moderatorId);

    if (list == null || moderator == null) return;

    //if (window.opera) return; // I'm too tired
	
	moderator.onmouseover= function() {
        if (currentList) {
            currentList.style.visibility = "hidden";
            this.showList();
        }
    }

    moderator.onclick = function() {
        if (currentList == null) {
            this.showList();
        }
        else {
            currentList.style.visibility = "hidden";
            currentList = null;
        }

        return false;
    }

	moderator.showList = function() {
        list.style.left = this.offsetLeft + this.offsetWidth + "px";
        list.style.top = this.offsetTop + "px";
		list.style.width = 200 + "px";
        list.style.visibility = "visible";
        currentList = list;
    }
}
	
window.onload = function() {
            initializeMenu("aboutMenu", "aboutActuator");
            initializeMenu("bulMenu", "bulActuator");
            initializeMenu("kuwMenu", "kuwActuator");
            initializeMenu("oppMenu", "oppActuator");
            initializeMenu("serMenu", "serActuator");
			initializeMenu("linksMenu", "linksActuator");
			initializeMenu("newsMenu", "newsActuator");
			initializeMenu("subMenu", "estabActuator");
			initializeList("bulList", "bulModerator");
			initializeList("bgprofList", "bgprofModerator");
			initializeList("bgecoList", "bgecoModerator");
			initializeList("bultradeList", "bgtradeModerator");
			initializeList("k8profList", "k8profModerator");
			initializeList("k8ecoList", "k8ecoModerator");
			initializeList("k8estList", "k8estModerator");
			initializeList("k8tradeList", "k8tradeModerator");
			initializeList("oppList","oppbgModerator");
			initializeList("oppk8List","oppk8Moderator");
        }
		
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
