function init() {
  if (window.Event) {
    document.captureEvents(Event.MOUSEMOVE);
  }
  document.onmousemove = getXY;
}

function getXY(e) {
  mouseX = (window.Event) ? e.pageX : event.clientX;
  mouseY = (window.Event) ? e.pageY : event.clientY;
  

  // Use x and y to do what ever you want
}

function mouseX(evt) {

	if (evt.pageX) return evt.pageX;

	else if (evt.clientX)

	   return evt.clientX + (document.documentElement.scrollLeft ?

	   document.documentElement.scrollLeft :

	   document.body.scrollLeft);

	else return null;

}



function mouseY(evt) {

	if (evt.pageY) return evt.pageY;

	else if (evt.clientY)

	   return evt.clientY + (document.documentElement.scrollTop ?

	   document.documentElement.scrollTop :

	   document.body.scrollTop);

	else return null;

}





function ShowBubble(commentN){
	//alert(mouseX +"--"+mouseY);

	document.getElementById(commentN).style.visibility = "visible";
	//document.getElementById(commentN).style.margin = (mouseY)+"pt 10pt 10pt "+(mouseX)+"pt";
	document.getElementById(commentN).style.margin = (mouseY-170)+"px 10px 10px "+(mouseX-700)+"px";

	
	//alert(document.getElementById(xBubble+commentN).style.margin); 
	
	
	

}

   

function HideBubble(commentN){

	document.getElementById(commentN).style.visibility = "hidden";

}


function show(object) {

/* alert(object); */

if (document.getElementById && (document.getElementById(object)!=null)) {

	document.getElementById(object).style.visibility = 'visible';

	}

	

	if (document.getElementById('formselect') != null){		

		document.getElementById('formselect').style.visibility="hidden";		

	}

}



function hide(object) {

//alert(object)

if (document.getElementById && (document.getElementById(object)!=null)) {

	document.getElementById(object).style.visibility = 'hidden';

	}

	

	if (document.getElementById('formselect') != null){		

		document.getElementById('formselect').style.visibility="visible";		

	}

}


function hideAll(){

	document.getElementById('divm1').style.visibility='hidden';

	document.getElementById('divm2').style.visibility='hidden';
	document.getElementById('divm3').style.visibility='hidden';
	document.getElementById('divm4').style.visibility='hidden';

}

var replacingMenu;
function menu(menuid){
	//alert(replacingMenu);
	if (replacingMenu!=null) {
		
		document.getElementById(replacingMenu).style.visibility='hidden';
		document.getElementById(replacingMenu).style.height='0px';
		
		
		
	}
	replacingMenu = menuid;
	//alert(document.getElementById(menuid));
	document.getElementById(menuid).style.visibility='visible';
	document.getElementById(menuid).style.height='20px';
	//document.getElementById(replacingMenu).style.display='inline';
	
	
	//document.getElementById('placeholder').innerHTML=menuPage;
	
}  


//ajax
// submenu: sub menu page
// menuid: menu place id

var xmlHttp;
var display;
function showMenu(submenu,menuid)
{
display = menuid;
alert('menuid:'+menuid);
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url=submenu;
/*
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("POST",url,true);
xmlHttp.send(null);
*/
} 

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


var displayCalendarId;
var busy = false;
function showCalendar(id, url){
	//alert('show calendar:'+id+" | content"+content);
	//window.open('<c:out value="${rootDir}"/>events/events.jsp?date=<%=startDate%
	//alert('date:'+theDate);
	//alert(url);
	if(!busy){
	busy = true;
	displayCalendarId=id;
	xmlHttp = GetXmlHttpObject();
	//var url= aURL+'<c:out value="${rootDir}"/>events/events.jsp?date='+theDate;
	xmlHttp.onreadystatechange=loadEventReady;
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);
	}
	
	
	
	//document.getElementById(id).innerHTML=content;
	
	//document.findByElementId(id).innerHTML=content;

}

function mouseoutCal(){
	busy = false;
}

function loadEventReady() 
{ 
if (xmlHttp.readyState==4)
{ 

var event = xmlHttp.responseText;
//alert('read: '+event);
//document.getElementById(displayCalendarId).innerHTML=event;

$("#"+displayCalendarId).html(event).show("slow");
//alert(content);
//alert('done.');

}else{
	//alert('error');
	document.getElementById(displayCalendarId).innerHTML="";
}
}
