var req = false;


var IE = document.all?true:false;
if (!IE){
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove=getMouseXY;
}else{
document.attachEvent('mousemove','getMouseXY');
//document.onmousemove=getMouseXY;
}

var tempX = getPosition('theCalendar','left'); //Currently this function does not work.
var tempY = getPosition('theCalendar','top');
//document.onclick = document.getElementById('eventInfo').style.visibility="hidden";
function getPosition(useElementLoc,XorY){
	var styledObj = getStyleObject(useElementLoc);
	if(XorY == 'left'){
		if(IE){
			return styledObj.left+Math.round(styledObj.width/2);
		}  
		return styledObj.left + Math.round(styledObj.width/2);
	}else{
		if(IE){
			return styledObj.top+Math.round(styledObj.height/2);
		}
		return styledObj.top + Math.round(styledObj.height/2);
	}

}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
  alert('HEre I am');
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
    alert(tempX);
  } 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
 // document.Show.MouseX.value = tempX
 // document.Show.MouseY.value = tempY
  return true;
}

function callServer(theURL,eID,BusyMsg){
	try{
	   req = new XMLHttpRequest(); /* e.g. FireFox */
	   } catch (e) {
	      try{
		     req = new ActiveXObject("Msxml2.XMLHTTP"); /* some versions of IE */
			 
			 } catch (e) {
			    try{
				   req = new ActiveXObject("Microsoft.XMLHTTP"); /* some versions of IE */
				 
				   } catch (e) {
				      req=false;
					  }
				}
			}
			req.onreadystatechange = function() {responseMsg(eID);};
			req.open("GET",theURL,true);
			req.send(null);
			return true;
		}
		
function responseMsg(eID){
		var output='';
		if(req.readyState == 1){
		document.getElementById(eID).innerHTML = "Step 1...";
		}else if(req.readyState == 2){
		document.getElementById(eID).innerHTML = "Step 2...";
		}else if(req.readyState == 3){
		document.getElementById(eID).innerHTML = "Step 3...";
		}else if(req.readyState == 4){
			if(req.status == 200){
				output=req.responseText;
				var closeLink='<p align="right"><a href="#" onclick="return !changeObjectVisibility('+"'"+eID+"'"+','+"'hidden'"+');">close</a></p>';
				document.getElementById(eID).innerHTML = output+closeLink;
				getMouseXY;
				
				if(IE){
					var divStyle = getStyleObject(eID);
					document.getElementById(eID).currentStyle['top']=tempY+"px";
					document.getElementById(eID).currentStyle['left']=tempX+"px";
					document.getElementById(eID).currentStyle['visibility']="visible";
				}else{ 
					var divStyle = getStyleObject(eID);
					divStyle.top=tempY+"px";
					divStyle.left=tempX+"px";
					divStyle.visibility="visible";
				}
			}
		}
	}
		// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
//
// ************************
// layer utility routines *
// ************************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject
