if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}

xMousePos = 0;
yMousePos = 0;
xMousePosMax = 0;
yMousePosMax = 0;
xWindowWidth = 0;

function captureMousePosition(e) {
    if (document.layers) {
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        xWindowWidth = window.innerWidth;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
        yMousePos = window.event.y+document.body.scrollTop;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
        xWindowWidth = document.body.clientWidth;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset;
        yMousePosMax = window.innerHeight+window.pageYOffset;
        xWindowWidth = window.innerWidth;
    }
}

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,obj2,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)

  	if ((obj=MM_findObj(args[i]))!=null) {
		obj2 = obj;
		v=args[i+2];
	    if (obj.style) {
			obj=obj.style;
			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
		}
	    obj.visibility=v;
	}

	// adjust position so it doesn't go off the edge of the browser page
	if (xMousePos+250 > xMousePosMax) {
	    xMousePos = xMousePosMax - 250;
	}
	if (yMousePos+100 > yMousePosMax) {
	    yMousePos = yMousePosMax - 100;
	}
	
	document.getElementById(args[0]).style.pixelLeft = xMousePos + 5;
	document.getElementById(args[0]).style.pixelTop = yMousePos + 5;
	document.getElementById(args[0]).style.left = xMousePos + 5;
	document.getElementById(args[0]).style.top = yMousePos + 5;

/*	
	if (args[0]=="PW_1" || args[0]=="PW_2" || args[0]=="PW_3" || args[0]=="PW_4") {
		xMousePos = 400;
	} else {
		xMousePos = xMousePos + 150;
	}
	
	if (args[0]=='PW_speciesbooklet' || args[0]=='PW_speciesreport' || args[0]=='PW_databasequery' ) {
		document.getElementById(args[0]).style.pixelLeft = 160;
		document.getElementById(args[0]).style.pixelTop = 175;
		document.getElementById(args[0]).style.left = 160;
		document.getElementById(args[0]).style.top = 175;
	} else {
		document.getElementById(args[0]).style.pixelLeft = xWindowWidth - 300;
		document.getElementById(args[0]).style.pixelTop = 253;
		document.getElementById(args[0]).style.left = xWindowWidth - 300;
		document.getElementById(args[0]).style.top = 253;
	}
*/
	document.body.focus();

}
