﻿/// <reference path="jquery-1.3.2-vsdoc.js">

var objDivToolTip;

function ToolTip(txt) {

	if (objDivToolTip == null)
		objDivToolTip = new DivToolTip();

	var str = "<div style='border:solid 1px gray; background-color:White; padding:5px; white-space:nowrap;'><span>" + txt + "</span></div>";

	objDivToolTip.Show(event.srcElement, str);
};

function DivToolTip() {
	this.divToolTip = null;
	this.isToolTipMove = false;
	this.divToolBackground = null;
	this.divToolTipArea = null;
	this.target = null;

	this.divToolTip = document.createElement("<div style='position:absolute; display:none;'></div>");
	document.forms[0].appendChild(this.divToolTip);

	this.divToolBackground = document.createElement("<iframe style='position:relative;' frameborder='0'></iframe>");
	this.divToolTip.appendChild(this.divToolBackground);

	this.divToolTipArea = document.createElement("<div style='position:absolute; top:0px; left:0px;'></div>");
	this.divToolTip.appendChild(this.divToolTipArea);
}

DivToolTip.prototype.Show = function(obj, str, pos) {

	this.target = obj;

	if (str != null)
		this.divToolTipArea.innerHTML = str;

	this.isToolTipMove = true;

	var tmpThis = this;

	obj.attachEvent("onmousemove", function() { tmpThis.Draw(pos); });
	obj.attachEvent("onmouseout", function() { tmpThis.Hide(); });
	obj.attachEvent("onclick", function() { tmpThis.Hide(); });
};


DivToolTip.prototype.Draw = function(pos) {

	if (this.isToolTipMove) {

		this.divToolTip.style.display = '';

		if(pos == null)
			pos = GetClickLayerPos(event, this.divToolTip);
			
		this.divToolTip.style.pixelLeft = pos.x;
		this.divToolTip.style.pixelTop = pos.y;

		this.divToolBackground.style.width = this.divToolTipArea.offsetWidth + "px";
		this.divToolBackground.style.height = this.divToolTipArea.offsetHeight + "px";
	}
};

DivToolTip.prototype.Hide = function() {
	this.isToolTipMove = false;
	this.divToolTip.style.display = 'none';
};

