// JavaScript Document
var mmActive='';
var HideTimeOut=300;
var mmHideMenuTimer=false;
function MM_clearTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
	mmDHFlag = false;
}

function MM_startTimeout() {
	if( mmActive.length>0 ) {
		mmStart = new Date();
		mmDHFlag = true;
		mmHideMenuTimer = setTimeout("mmDoHide()",HideTimeOut);
	}
	//alert('mmDoHide');
}

function mmDoShow(id,mnuid)
{
	var newX = findPosX(document.getElementById(mnuid));
	var newY = findPosY(document.getElementById(mnuid));
	var newWidth	=document.getElementById(mnuid).offsetWidth;
	var newHeight	=document.getElementById(mnuid).offsetHeight;
	
//	dump("**** Menu - "+mnuid+" *****\n ");
//	dump("X="+newX+" Y="+newY+"\n");
//	dump("W="+newWidth+" H="+newHeight+"\n");
	newY=newY-(newHeight);
	newX=newX+newWidth;
//	dump("Y -"+newHeight+"="+newY+"\n");
//	dump("X +"+newWidth+"="+newX+"\n");
	if(document.all)
	{
		ScreenWidth=document.body.clientWidth+265; // screen.width+255;
		ScreenHeight=document.body.clientHeight; //screen.height;
	}
	else
	{
		ScreenWidth=window.innerWidth+265;
		ScreenHeight=window.innerHeight;
		//ScreenWidth=screen.availWidth+265;
		//ScreenHeight=screen.availHeight;
	}
		
	if(id !=mmActive)
	{
		mmDoHide();
		document.getElementById(id).style.left=newX+'px';//(((ScreenWidth-760)/2));
		document.getElementById(id).style.top= newY +'px'; //mouseY;
		document.getElementById(id).style.visibility='visible';
		mmActive=id;
	}
	else
		document.getElementById(id).style.visibility='visible';
	MM_clearTimeout();
}

function mmDoHide()
{
	if(mmActive.length>0)
	{
		document.getElementById(mmActive).style.visibility='hidden';	
		mmActive="";
		//alert('mmDoHide');
	}
	MM_clearTimeout();
}
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    mouseX = event.clientX + document.body.scrollLeft
    mouseY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    mouseX = e.pageX
    mouseY = e.pageY
  }  
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  return true
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	window.status = printstring;
	return curtop;
}
