//
//	Last change (dd-mm-yy hh:ii): 24-12-02 22:30
//
//================================================================
//	Edit
//================================================================

//	Suppress default 'ToolTip Link' statusbar messages

	var hideStatus     = true;

//	Default ToolTip padding

	var tooltipPadding = 8;

//	Default ToolTip borderWidth

	var tooltipBorder  = 0;

//	Position of ToolTip relative to MousePosition

	var toolTipShiftX  =  16;
	var toolTipShiftY  = -20;

//	Delay in milliseconds before Tips 'on hold' will be hidden

	var toolTipTimeOut = 500;

//================================================================


var PopBoxes = new Object();
var PopLayer = null, popSysLoaded = false;
var popTOut  = null;

var uas, dom, dmc, ope, op7, ns4, ie4, knq;
var oHTML, oBODY, w_scroll, h_scroll, b_scroll;
var w_size, h_size, b_size, d_size;
var docMsPosX, docMsPosY;
var lockedPopLayer = false;

function aToolTip(id, iHTML, hold, cName) {
	var o   = PopBoxes[id] = new Object();
	o.id    = id;
	o.html  = iHTML;
	o.hold  = (typeof hold=='boolean') ? hold : false;
	o.cName = (typeof hold=='string')  ? hold : (typeof cName=='string') ? cName : 'tooltip';
}

function getPopBoxStr(o) {
	var s = '<div id="' + o.id +'" class="popBoxContainer"><table id="';
	s += o.id +'Tbl" cellspacing="0" cellpadding="' + tooltipPadding + '" border="' + tooltipBorder;
	s += '"><tr><td class="' + o.cName + '">';
	s += o.html;
	s += '</td></tr></table></div>\n';
	return s;
}

function br_strCat() {
	if (arguments.join) return arguments.join('<br>\n');
	var s = '';
	for (var i=0; i<arguments.length; i++) s += arguments[i] + '<br>\n';
	return s;
}

function ToolTipInit() {

var d    = document;
uas      = navigator.userAgent.toLowerCase();
dom      = d.documentElement?true:false;
dmc      = d.getElementById?true:false;
ope      = (window.opera&&!dom)?true:false;
op7      = (window.opera&&dom)?true:false;
ns4      = d.layers?true:false;
ie4      = d.all?true:false;
knq      = (uas.indexOf('konqueror')>-1) ? true : false;

oHTML    = dom ? d.documentElement : null;
oBODY    = d.body ? d.body : null;

w_scroll = (typeof window.pageYOffset=='number');
h_scroll = (oHTML && (typeof oHTML.scrollTop=='number'));
b_scroll = (oBODY && (typeof oBODY.scrollTop=='number'));
w_size   = (typeof self.innerWidth=='number');
h_size   = (oHTML && (typeof oHTML.clientWidth=='number') && oHTML.clientWidth);
b_size   = (oBODY && (typeof oBODY.clientWidth=='number') && oBODY.clientWidth);
d_size   = (typeof d.width=='number');


if (ns4) {
	g_StyleObj=function(o){return o;}
	pObj.prototype.show = function(){this.o.visibility='show';}
	pObj.prototype.hide = function(){this.o.visibility='hide';}
}
else {
	g_StyleObj=function(o){return o.style;}
	pObj.prototype.show = function(){this.s.visibility='visible';}
	pObj.prototype.hide = function(){this.s.visibility='hidden';}
}

if (ns4) g_Obj=function(id){return document.layers[id];}
else if (dmc) g_Obj = function(id){return document.getElementById(id);}
else if (ie4) g_Obj = function(id){return document.all[id];}

if (ns4) {
	pObj.prototype.getWidth  = function(){return this.o.document.width;}
	pObj.prototype.getHeight = function(){return this.o.document.height;}
}
else if (ope) {
	pObj.prototype.getWidth  = function(){return this.s.pixelWidth;}
	pObj.prototype.getHeight = function(){return this.s.pixelHeight;}
}
else {
	pObj.prototype.getWidth  = function(){return this.o.offsetWidth;}
	pObj.prototype.getHeight = function(){return this.o.offsetHeight;}
}

if (ope) {
	pObj.prototype.setPos    = function(x,y){this.s.pixelLeft=x;this.s.pixelTop=y;}
	pObj.prototype.setWidth  = function(xs)  {this.s.pixelWidth=xs;}
	pObj.prototype.setHeight = function(ys)  {this.s.pixelHeight=ys;}
}
else if (dmc) {
	pObj.prototype.setPos    = function(x,y){this.s.left=x+'px';this.s.top=y+'px';}
	pObj.prototype.setWidth  = function(xs)  {this.s.width=xs+'px';}
	pObj.prototype.setHeight = function(ys)  {this.s.height=ys+'px';}
}
else if (ie4) {
	pObj.prototype.setPos    = function(x,y){this.s.pixelLeft=x;this.s.pixelTop=y;}
	pObj.prototype.setWidth  = function(xs)  {this.s.pixelWidth=xs;}
	pObj.prototype.setHeight = function(ys)  {this.s.pixelHeight=ys;}
}
else if (ns4) {
	pObj.prototype.setPos    = function(x,y){this.o.moveTo(x,y);}
	pObj.prototype.setWidth  = function(xs)  {this.o.clip.width=xs;}
	pObj.prototype.setHeight = function(ys)  {this.o.clip.height=ys;}
}

document.onmousemove = msHandler;

if (ns4) {
	window.onmousemove = msHandler;
	window.captureEvents(Event.MOUSEMOVE);
	origWidth = innerWidth; origHeight = innerHeight;
	onresize = function(){if (innerWidth!=origWidth||innerHeight!=origHeight) location.reload();}
}


for (var i in PopBoxes) {
	var e = PopBoxes[i].e = g_pObj(i);
	var t = ns4 ? null : g_pObj(i+'Tbl');
	if (t) e.setWidth(t.getWidth());
	if (PopBoxes[i].hold) {
		e.o.onmouseover = keepPopLayer;
		e.o.onmouseout  = hidePopLayer;
	}
}

if (hideStatus) window.defaultStatus = ' ';
popSysLoaded = true;

}

//--------------

function pObj(o) {this.o=o;this.s=g_StyleObj(o)}
function g_pObj(id) {return new pObj(g_Obj(id))}

function msHandler(e) {
	if (window.event) e = window.event;
	if (typeof e.pageX=='number') {
		docMsPosX = e.pageX; docMsPosY = e.pageY;
	}
	else if (typeof e.clientX=='number') {
		docMsPosX = e.clientX;
		docMsPosY = e.clientY;
		if (!(ope||knq)) {
			docMsPosX += winXOfs();
			docMsPosY += winYOfs();
		}
	}
	if (PopLayer && !PopLayer.hold) PositionBox();
}

function clWidth() {
return (ope||knq) ? self.innerWidth :
	b_size ? oBODY.clientWidth :
	h_size ? oHTML.clientWidth :
	!w_size ? 0 :
	!d_size ? (self.innerWidth-20) :
	(document.height>self.innerHeight) ? (self.innerWidth-20) :
	self.innerWidth;
}

function clHeight() {
return (ope||knq) ? self.innerHeight :
	b_size ? oBODY.clientHeight :
	h_size ? oHTML.clientHeight :
	!w_size ? 0 :
	!d_size ? (self.innerHeight-20) :
	(document.width>self.innerWidth) ? (self.innerHeight-20) :
	self.innerHeight;
}

function winXOfs() {
	return w_scroll ? self.pageXOffset :
	Math.max((h_scroll?oHTML.scrollLeft:0), (b_scroll?oBODY.scrollLeft:0));
}

function winYOfs() {
	return w_scroll ? self.pageYOffset :
	Math.max((h_scroll?oHTML.scrollTop:0), (b_scroll?oBODY.scrollTop:0));
}

function hidePopLay() {
	lockedPopLayer = false;
	if (PopLayer) {
		PopLayer.e.hide();
		PopLayer = null;
	}
}

function hidePopLayer() {
	if (PopLayer && !lockedPopLayer) {
		if (PopLayer.hold) popTOut = setTimeout('hidePopLay()', toolTipTimeOut);
		else hidePopLay();
	}
}

function keepPopLayer() {
	if (popTOut) {
		clearTimeout(popTOut);
		popTOut = null;
	}
}

function lockPopLayer() {
	keepPopLayer();
	lockedPopLayer = true;
}

function unlockPopLayer() {
	if (lockedPopLayer) {
		lockedPopLayer = false;
		hidePopLayer();
	}
}

function PositionBox() {
	var x   = docMsPosX + toolTipShiftX;
	var w   = PopLayer.e.getWidth();
	var x2  = x+w;
	var y   = Math.max(docMsPosY+toolTipShiftY, 2);
	var h   = PopLayer.e.getHeight();
	var y2  = y+h;

	var wx1 = winXOfs(), wy1 = winYOfs();
	var wx2 = wx1 + clWidth(), wy2 = wy1 + clHeight();

	if (x2>=wx2) x = Math.max(docMsPosX-w-toolTipShiftX, wx1+2);
	if (y2>=wy2) y = Math.max(wy2-h-2, wy1+2);
	if (docMsPosY>=y && docMsPosY<y2 && docMsPosX>=x && docMsPosX<x2)
		y = ((wy2-docMsPosY)>(docMsPosY-wy1)) ? (docMsPosY+8) : (docMsPosY-h-8);
	PopLayer.e.setPos(x,y);
}

function putPopLayer(id) {
	if (popSysLoaded) {
		keepPopLayer();

		if (PopLayer != PopBoxes[id]) {
			hidePopLay();
			PopLayer = PopBoxes[id];
			PositionBox();
			PopLayer.e.show();
			if (PopLayer.e.o.focus) PopLayer.e.o.focus();
		}
	}
}

function clickToolTip(id, hideTipOnClick) {
	if (PopLayer != PopBoxes[id]) {
		putPopLayer(id);
		lockPopLayer();
		if (hideTipOnClick) PopLayer.e.o.onclick = hidePopLay;
	}
	else
		hidePopLay();
	return false;
}

function overToolTip(a, id) {
	a.title = '';
	if (a.href.charAt(a.href.length-1)=='#') {
		if (!a.onclick) a.onclick = function() { return false; }
		if (op7) a.href = 'tip:';
	}
	if (!a.onmouseout) a.onmouseout = hidePopLayer;
	putPopLayer(id);
	return hideStatus;
}

