
function fw_HelpText() {
	this.current = null;
}

fw_HelpText.prototype.AddEvent = function(el, ev, hdl) {
	if (el.addEventListener) {
		el.addEventListener(ev, hdl, null);
		return true;
	}
	el['on'+ev] = hdl;
}

fw_HelpText.prototype.GetPos = function(o) {
	var al	= 0;
	var at	= 0;
	while (o) {
		al	+= o.offsetLeft;
		at	+= o.offsetTop;
		if (o.clientTop)	at	+= o.clientTop;
		if (o.clientLeft)	al	+= o.clientLeft;
		o = o.offsetParent;
	}
	return [al, at];
}

fw_HelpText.prototype.Show = function(n) {
	p = this.GetPos(n);
	this.CreateBox(n);
	n.div.style.left= p[0] - 270 + 'px';
	n.div.style.top	= p[1] + 'px';
	n.div.style.visibility = 'visible';
}

fw_HelpText.prototype.Hide = function(n) {
	n.div.style.visibility = 'hidden';
}

fw_HelpText.prototype.CreateBox = function(n) {
	if (n.div) return;
	n.div = document.createElement('div');
	n.div.style.width			= '250px';
	n.div.style.backgroundColor	= '#FFF';
	n.div.style.position		= 'absolute';
	n.div.style.padding			= '4px';
	n.div.style.border			= '1px solid #C5B2B3';
	n.div.className				= 'helptext';
	n.div.appendChild(document.createTextNode(n.title));
	n.title = '';
	document.getElementsByTagName('body')[0].appendChild(n.div);
}


fw_HelpText.prototype.Go = function() {
	var imgs = document.getElementsByTagName('img');
	for (var i = 0; i < imgs.length; i++) {
		if (imgs[i].className == 'helptext') {
			this.AddEvent(imgs[i], 'mouseover',	function() { fw_helptext.Show(this); })
			this.AddEvent(imgs[i], 'mouseout',	function() { fw_helptext.Hide(this); })
		}
	}
}

var fw_helptext = new fw_HelpText();
fw_helptext.Go();

