
// ==== some debug-related constants: ====
var intDebug = 0;
var intDebugBrowser = 0;
// ==== sniffer code starts here: ====
var isDHTML=0;
var isLayers=0;
var isAll=0;
var isID=0;
var browserVersion="";
if (document.getElementById) {isID=1; isDHTML=1; }
else {
  if (document.all) {isAll=1; isDHTML=1; }
	else {
	  browserVersion = parseInt(navigator.appVersion);
		if ( (navigator.appName.indexOf('Netscape') != -1) && (browserVersion==4) ) { 
		  isLayers=1;
			isDHTML=1;
	  }
	}
}
function findDOM(objectID,withStyle) {
  if (withStyle==1) {
	  if (isID) { return (document.getElementById(objectID).style); 
		}	else {
		  if (isAll) { return (document.all[objectID].style); 
			} else {
			  if (isLayers) { return (document.layers[objectID]); }
			}
		}
	} else {
    if (isID) { return (document.getElementById(objectID));
		} else {
		  if (isAll) { return (document.all[objectID]); 
			} else {
			  if (isLayers) { return (document.layers[objectID]); }
			}
		}
	}
}
function whoAmI(objectID) {
  domStyle=findDOM(objectID,1);
	dom=findDOM(objectID,0);
	if (domStyle.pixelTop!=null) { alert(domStyle.pixelTop); } else { alert(domStyle.top); }
	alert(dom.id);
}
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers
function do_debug(strThis){
  if (intDebug==1) { alert(strThis); }
}
function debug_browser() {
alert("test0b");
alert("browserVersion="+browserVersion);
alert("isLayers="+isLayers); alert("isDHTML="+isDHTML); alert("isAll="+isAll); alert("isID="+isID);
}
if (intDebugBrowser==1) { debug_browser(); }
//
// code inspired by http://www.dynamicdrive.com/
// for the original source code and more DHTML scripts, visit http://www.dynamicdrive.com
// this credit must stay intact for use
//
var linkset=new Array()
//
// next, define the menu sets and their links:
// ====
// ====
function showmenu(e,iNum){
var which=linkset[iNum];
intDebug = 0;
do_debug("test1");
//
// next, if this browser does not have certain capabilities, exit out:
if (!document.all&&!document.getElementById&&!document.layers)
return;
//
// next, perform some cleanup:
clearhidemenu();
//
// next, link menuobj to the "popmenu" object, and set menuobj.thestyle:
menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj
//
// next, set contents of menuobj:
if (isID || isAll) { 
menuobj.innerHTML=which
} else {
menuobj.document.write('<layer name=gui bgColor=#E6E6E6 width=165 onmouseover="clearhidemenu()" onmouseout="hidemenu()">'+which+'</layer>')
menuobj.document.close()
}
do_debug("test2");
//
// next, set contentwidth and contentheight of menuobj:
menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.gui.document.width
menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.gui.document.height
//
// next, determine X and Y of popup menu;
// for IE6 and NN6, we create a link to the "mcell" object;
// for NN4, we just use the mouse pointer's current location:
if (isID || isAll) {
var idCell = "mcell"+iNum;
var domCell = findDOM(idCell,0);
var domCellStyle=findDOM(idCell,1);
eventX = domCell.offsetLeft;
eventY = domCell.offsetTop + 18;			// +18 for NS6 and IE6, but not NS4!
}
if (isLayers) {
eventX=ie4? event.clientX : ns6? e.clientX : e.x
eventY=ie4? event.clientY : ns6? e.clientY : e.y
}
//
// next, create a link to the "mtable" object:
obj_mtable=ie4? document.all.mtable : ns6? document.getElementById("mtable") : ns4? document.mtable : "";
do_debug("test3");
//
// next, find out how close the mouse is to the corner of the window:
var rightedge=ie4? document.body.clientWidth : window.innerWidth
var bottomedge=ie4? document.body.clientHeight : window.innerHeight
rightedge=rightedge-0;      // to prevent creating a horizontal scrollbar
do_debug("test3a");
//
// next, determine X and Y of popup menu (without accounting for falling off page):
var newX = ie4? obj_mtable.offsetLeft+eventX : ns6? window.pageXOffset+eventX : eventX;
var newY = ie4? obj_mtable.offsetTop+eventY : ns6? window.pageYOffset+eventY : eventY;
do_debug("test3b");
//
// next, account for falling off page at right:
if (rightedge<newX+menuobj.contentwidth) { newX=rightedge-menuobj.contentwidth; }
menuobj.thestyle.left=newX;
//
// next, account for falling off page at bottom:
do_debug("test4");
if (bottomedge<newY+menuobj.contentheight) { newY=bottomedge-menuobj.contentheight; }
menuobj.thestyle.top=newY;
menuobj.thestyle.visibility="visible"
return false;
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode) { if ((b = b.parentNode) == a) { return true; } }
return false;
}
function hidemenu(){
if (window.menuobj) { menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide" }
}
function dynamichide(e){
  if (ie4&&!menuobj.contains(e.toElement)) {
    hidemenu()
  } else {
	  if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) {
      hidemenu()
		}
  }
}
function delayhidemenu(){
  if (ie4||ns6||ns4) { delayhide=setTimeout("hidemenu()",500) }
}
function clearhidemenu(){
  if (window.delayhide) { clearTimeout(delayhide) }
}
function highlightmenu(e,state){
	if (document.all) {
		source_el=event.srcElement
	} else {
		if (document.getElementById) { source_el=e.target }
	}
	if (source_el.className=="menuitems") {
		source_el.id=(state=="on")? "mouseoverstyle" : ""
	} else {
		while(source_el.id!="popmenu") {
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems") {
				source_el.id=(state=="on")? "mouseoverstyle" : ""
			}
		}
	}
}
if (ie4||ns6) { document.onclick=hidemenu }

