/**
* infoView.js - A client side alternative to JToolTip pointer
* Author: Mehdi Nejad
* Description: shows a tooltip type thing off set from the location
* of the mouse pointer.  This is best replaced by CSS alternative, eventually.
**/

this.mouseX = 0;
this.mouseY = 0;
// Update 11/01/06 @ PH, set absolute infoWin object from left
this.infoLeftAbsolute = 55;

function infoView(viewObj) {
	this.isMousedOver = false;
	this.infoWin = viewObj;
	
}

infoView.prototype.setContent = _setContent;
infoView.prototype.startDrawThread = _fnStartDrawThread;
infoView.prototype.stopDrawThread = _fnStopDrawThread;
infoView.prototype.redraw = _fnRedraw;
infoView.prototype.init = _init;
infoView.prototype.placeInfoAtMouse = _placeInfoAtMouse;

function _init() {
	//this.infoWin.style.backgroundColor="#aaff00";
}

function _setContent(str) {
    this.infoWin.innerHTML = str;
    window.status = "click here to navigate to the event itself";
}

function _placeInfoAtMouse(e) {
	this.infoWin.style.left = (infoLeftAbsolute == 0) ? (mouseX + 10) + "px" : infoLeftAbsolute + "px" ;
	// this.infoWin.style.left = (mouseX + 10) + "px";
        this.infoWin.style.top = (mouseY + 10) +"px";
}

function _fnStopDrawThread() {
	this.isMousedOver = false;
	this.infoWin.style.visibility="hidden";
}

function _fnStartDrawThread() {
	this.isMousedOver = true;
	this.infoWin.style.visibility="visible";
	myInfoObj.redraw()
}

function _fnRedraw() {
	if (this.isMousedOver == true) {
		this.placeInfoAtMouse();
		setTimeout ("myInfoObj.redraw()", 0);
	}
}


function dump(obj) {
	document.dbg.ta.value = "dumping " +obj +"\n-----\n";
	for (var xx in obj) {
		document.dbg.ta.value += xx + "\n";
	}
}

var myInfoObj = "";

function recordMousePosition(e) {

	if (document.all) {
		//mouseX = window.event.x+document.body.scrollLeft;
		//mouseY = window.event.y+document.body.scrollTop;
                
                // for XHTML:

                mouseX = window.event.x + document.documentElement.scrollLeft;
                mouseY = window.event.y + document.documentElement.scrollTop;

	} else if (document.getElementById) {
		mouseX=e.pageX;
		mouseY=e.pageY;
	}

}

function startInfoObj() {

	myInfoObj = new infoView (document.getElementById("infoDiv"));
	myInfoObj.init();
	
	if (document.all) { 
		document.onmousemove = recordMousePosition;
	} else if (document.getElementById) {
		document.onmousemove = recordMousePosition;
	}
	
}
