/*
 * menuDropdown.js - implements an dropdown menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

var currentMenu = null;
var menux = 0;
var menuy = 0;
var tempX = 0;
var tempY = 0;
var divOpacity = 0;
var fade=false;
var timerid = null;
var mouseX = 0;
var mouseY= 0;


var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var IE=true;

document.captureEvents(Event.MOUSEMOVE);

			 

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

function fadeinDiv() {
	fade=false;
}

function fadeout() {
		currentMenu.style.visibility = "hidden";
		fade=false;
}	

function fadeoutDiv() {
	fade=true;
		currentMenu.style.visibility = "hidden";
}


function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
		var posx = 0;
		
	  var posy = 0;
		var x=0;
		var y=0;
    IE=false;
				
	  
    if (menu == null || actuator == null) return;
    //menux = this.offsetleft;
		document.onmousemove = function mousepos(e) {
       var posx = 0;
	     var posy = 0;
	     if (!e) var e = window.event;
	     if (e.pageX || e.pageY)
	       {
		     posx = e.pageX;
		     posy = e.pageY;
	       }
	     else if (e.clientX || e.clientY)
	     {
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}
	// posx and posy contain
	// the mouse position relative to the document
	// Do something with this information
		  // posx=mouseX;
		   //posy=mouseY;
			 
	     //document.ee.sd.value = posx+"-"+posy;
			 //document.ee.jp.value = menux+"-"+menuy;
			 //document.ee.jp.value = menux
	   if (currentMenu != null) {
       if (  (posx < menux) || (posx > menux+190) || (posy < menuy-30) || (posy > menuy+220)) {    
			    currentMenu.style.visibility = "hidden";
					   //bubble = document.getElementById("mouseBubble");
         	   //currentMenu.style.display = "none";
					   currentMenu = null;
			   } // range check
		  }
	     } // on mouse move
    //if (window.opera) return; // I'm too tired

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

  
    actuator.onclick = function() {}

    actuator.showMenu = function() {
		   currentMenu = menu;
			 if (navigator.appName =="Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") < 0){IE = true;currentMenu.filters[0].opacity=90;} else {IE=false;}
		   if (IE==true) { 
		      currentMenu.filters[0].opacity=90;
		   } else {
		      currentMenu.style.MozOpacity=0.9;
		//currentMenu.showing = 1;
		   }
		  // fadeinDiv();
		   menux = this.offsetLeft;
			 
       menu.style.left = this.offsetLeft + "px";
       menu.style.top = 135 + "px";
		   menuy = 135;
       menu.style.visibility = "visible";currentMenu.style.visibility="visible";
    }
} //initialize menu
	