annotateControllers = new Array();

function annotateMove(id, e) {
	var IE = document.all?true:false;
  	if (e.clientX) { // grab the x-y pos if browser is IE/Firefox
    	if (document.documentElement && document.documentElement.scrollTop) {
			tempX = Math.max(0, e.clientX + document.documentElement.scrollLeft - 30);
      		tempY = Math.max(0, e.clientY + document.documentElement.scrollTop - 30);
    	}
    	else {
	  		tempX = Math.max(0, e.clientX + document.body.scrollLeft - 30);
	  		tempY = Math.max(0, e.clientY + document.body.scrollTop - 30);
    	}
  	} else {  // grab the x-y pos if browser is NS
  		tempX = e.pageX;
  		tempY = e.pageY;
  	} 
  	document.getElementById("annotate_" + id).style.left = tempX + 'px';
	document.getElementById("annotate_" + id).style.top = tempY + 'px';
}
	
function annotateOver(id, e) {
	if ( document.getElementById("annotate_" + id).style.display != 'block' ) {
		annotateControllers[id] =  window.setTimeout("annotateOn('" + id + "')", 500);
		annotateMove(id, e);
	}
}

function annotateClick(id, e) {
	annotateMove(id, e);
	if ( document.getElementById("annotate_" + id).style.display != 'block' ) {
		annotateOn(id);
	}
}

function annotateOut(id) {
	window.clearTimeout(annotateControllers[id]);
	annotateControllers[id] =  window.setTimeout("annotateOff('" + id + "')", 100);
}

function annotateOn(id) {
	window.clearTimeout(annotateControllers[id]);
	document.getElementById("annotate_" + id).style.display = 'block';
	if ( document.body ) {
		windowWidth = document.body.offsetWidth;
		windowHeight = document.body.offsetHeight;
	}
	else {
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	}
}

function annotateOff(id) {
	document.getElementById("annotate_" + id).style.display = 'none';
}