﻿// Javascript File
		//<!--
	var menuOffsetX = -18;
	var menuOffsetY = 18;
	var hideMenuAfter = 500; //in milliseconds
	var timeOn; //timer variable which gets reset after 
	var IE = document.all?true:false
	var testMode = false;
	function showMenu(divID, thisObj, myEvent)
	{
		hideAllMenus();
		if (IE)	{
			getMouseXY();
			printXYLocation();
		}
		else {
			tempX = myEvent.clientX;
			tempY =  myEvent.clientY;
			printXYLocation();
		}
		
		/*
		msgclear();
		msg('thisObj.innerHTML', thisObj.innerHTML);
		*/
	
	
		var divLayer;
		var myDivID =  divID;
		try {
		    //alert("A: Attempting to find divID:" + myDivID );
		    if (document.getElementById(divID)) 
		        divLayer =document.getElementById(divID);
		    else 
		    {
		        findIDendingWith(divID);
		        myDivID = "Header1_Menu_inhouse1_" +  divID;
		        //alert("A2: Attempting to find divID:" + myDivID );
		        divLayer = document.getElementById(myDivID); 
		    }
		 }
		 catch (err) 
		 {		    
		    myDivID = "Header1_Menu_inhouse1_" +  divID;
		    //alert("B: Attempting to find my divID: " + myDivID);
		    divLayer = document.getElementById(myDivID); //asp.net may changes the ID of the Submenu Div I'm interested in.
		    
		 }
		
		//Don't draw current layer somewhere else if it is already displayed.
		if (divLayer.style.display == "block") return;
		
		//clear timeout so menu keeps showing till user mouses off of it
		clearTimeout(timeOn);
		
		//show menu
		divLayer.style.display = 'block';
		divLayer.style.position = 'absolute';
		//divLayer.style.top = menuOffsetY + 'px'; //(tempY + menuOffsetY) + 'px';
		//divLayer.style.left = (tempX + menuOffsetX) + 'px';
		divLayer.style.left = (findPosX(thisObj) + menuOffsetX) + 'px';
		divLayer.style.top = (menuOffsetY + findPosY(thisObj))+ 'px';
		 
		 /*Show the X and Y positions of the current element*/
		 //msgclear();
		 //msg('findPosX(thisObj)', findPosX(thisObj));
		 //msg('findPosY(thisObj)', findPosY(thisObj));
		 
		 hideComboBoxes();
	}
	
	function findIDendingWith(aDivID)
	{
	    msg("Finding ID of ElementID Ending with", aDivID);
	    msg("Listing All DIVS", "");
	    
	    
	    
	    
	    
	}
	function hideMenu(divID)
	{
			
		var divLayer;
		var myDivID =  divID;
		try {
		    //alert("A: Attempting to find divID:" + myDivID );
		    if (document.getElementById(divID)) 
		        divLayer =document.getElementById(divID);
		    else 
		    {
		        findIDendingWith(divID);
		        myDivID = "Header1_Menu_inhouse1_" +  divID;
		        //alert("A2: Attempting to find divID:" + myDivID );
		        divLayer = document.getElementById(myDivID); 
		    }
		 }
		 catch (err) 
		 {		    
		    myDivID = "Header1_Menu_inhouse1_" +  divID;
		    //alert("B: Attempting to find my divID: " + myDivID);
		    divLayer = document.getElementById(myDivID); //asp.net may changes the ID of the Submenu Div I'm interested in.
		    
		 }
			
			divLayer.style.display = "none";
			showComboBoxes();
	}
	function hideAllMenus()
	{
		hideMenu('SubMenu1');
		hideMenu('SubMenu2');
		hideMenu('SubMenu3');
		hideMenu('SubMenu4');
		hideMenu('SubMenu5');
				
	}
	function hideMenuOnTimeOut()
	{
		timeOn = setTimeout("hideAllMenus()", hideMenuAfter);
	}
	
	function removeTimeout(){
		clearTimeout(timeOn);
	}
	
	
	
	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all?true:false
	// If NS -- that is, !IE -- then set up for mouse capture
	//if (!IE) document.captureEvents(Event.MOUSEMOVE)
	// Set-up to use getMouseXY function onMouseMove
	//document.onmousemove = getMouseXY;
	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0
	var tempY = 0
	
	// Main function to retrieve mouse x-y pos.s
	function getMouseXY(e) {
	  if (IE ) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	  } else  {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	  } 
	  // catch possible negative values in NS4
	  if (tempX < 0){tempX = 0}
	  if (tempY < 0){tempY = 0}  
	  // show the position values in the form named Show
	  // in the text fields named MouseX and MouseY
	
	  return true
	}
	
	function printXYLocation() {
		if (! testMode) return;
		  var msgStr ="";
		  msgStr = "<br/>X: " + tempX;
		  msgStr += "<br/>Y: " + tempY;
		  document.getElementById('MessageDiv').innerHTML = msgStr;
	}
	
	
	function msg(label, msgStr){
		var msgDiv= document.getElementById('MessageDiv');
		  msgDiv.innerHTML += label + ': ' + msgStr + "<br/>";
	}
	function msgclear(){
		var msgDiv= document.getElementById('MessageDiv');
		msgDiv.innerHTML = "";
		
	}
	
	
	 function findPosX(obj)
	  {
	  //http://blog.firetree.net/2005/07/04/javascript-find-position/
		var curleft = 0;
		if(obj.offsetParent)
			while(1) 
			{
			  curleft += obj.offsetLeft;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.x)
			curleft += obj.x;
		return curleft;
	  }
	
	  function findPosY(obj)
	  {
	  //http://blog.firetree.net/2005/07/04/javascript-find-position/
		var curtop = 0;
		if(obj.offsetParent)
			while(1)
			{
			  curtop += obj.offsetTop;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
		return curtop;
	  }
	
	function hideComboBoxes(){
	    implementComboboxAction("hidden");
	    //implementComboboxAction(true);
	}
	
	function showComboBoxes(){
	    implementComboboxAction("visible");
	    //implementComboboxAction(false);
	}
	
	function implementComboboxAction(displayStyle){ //"none" or "block"
    	//hide comboboxes because they will always show up above menu div layers.
    	//this is a work around.
	    var myComboBoxes = document.getElementsByTagName("select");
	    var myStr = new String;
	    myStr = '';
	    var i = new Number;
	    for (i=0; i < myComboBoxes.length; i++)
	    {
	        myStr += myComboBoxes[i].name + ": " + myComboBoxes[i].id  + "<br/>\n";
	        myComboBoxes[i].style.visibility = displayStyle;
	        //myComboBoxes[i].disabled = displayStyle;
	        }
    	    
	    //msgclear();
	    //msg("<h1>" + displayStyle + " Comboboxes</h1>", myStr);
    	
	}
	
	
	 // -->
