
function THints (o_cfg, items) {
	this.top = o_cfg.top ? o_cfg.top : 0;
	
	this.left = o_cfg.left ? o_cfg.left : 0;
	this.n_dl_show = o_cfg.show_delay;
	this.n_dl_hide = o_cfg.hide_delay;
	this.b_wise = o_cfg.wise;
	this.b_follow = o_cfg.follow;
	this.x = 0;
	this.y = 0;
	this.divs = [];
	this.show  = TTipShow;
	this.showD = TTipShowD;
	this.show2  = TTipShow2;
	this.showD2 = TTipShowD2;	
	this.hide = TTipHide;
	this.hide2 = TTipHide2;
	this.move = TTipMove;
	if (document.layers) return;
	var b_IE = navigator.userAgent.indexOf('MSIE') > -1,
	s_tag = ['<div id="TTip%name%" style="visibility:hidden;position:absolute;top:0px;left:0px;',   b_IE ? 'width:1px;height:1px;' : '', o_cfg['z-index'] != null ? 'z-index:' + o_cfg['z-index'] : '', '"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="', o_cfg.css, '" nowrap>%text%</td></tr></table></div>'].join('');


	this.getElem = 
		function (id) { return document.all ? document.all[id] : document.getElementById(id); };
	this.showElem = 
		function (id, hide) { this.divs[id].o_css.visibility = hide ? 'hidden' : 'visible'; };
	this.getWinSz = window.innerHeight != null 
		? function (b_hight) { return b_hight ? innerHeight : innerWidth; }
		: function (b_hight) { return document.body[b_hight ? 'clientHeight' : 'clientWidth']; };	
	this.getWinSc = window.innerHeight != null 
		? function (b_hight) { return b_hight ? pageYOffset : pageXOffset; }
		: function (b_hight) { return document.body[b_hight ? 'scrollTop' : 'scrollLeft']; };	
	if (window.opera) {
		this.getSize = function (id, b_hight) { 
			return this.divs[id].o_css[b_hight ? 'pixelHeight' : 'pixelWidth']
		};
		document.onmousemove = function () {
			myHint.x = event.clientX;
			myHint.y = event.clientY;
			if (myHint.b_follow && myHint.visible) myHint.move(myHint.visible)
			return true;
		};
	}
	else {
		this.getSize = function (id, b_hight) { 
			return this.divs[id].o_obj[b_hight ? 'offsetHeight' : 'offsetWidth'] 
		};
		document.onmousemove = b_IE
		? function () {
			myHint.x = event.clientX + document.body.scrollLeft;
			myHint.y = event.clientY + document.body.scrollTop;
			if (myHint.b_follow && myHint.visible) myHint.move(myHint.visible)
			return true;
		} 
		: function (e) {
			myHint.x = e.pageX;
			myHint.y = e.pageY;
			if (myHint.b_follow && myHint.visible) myHint.move(myHint.visible)
			return true;
		};
	}
	for (i in items) {
		document.write (s_tag.replace(/%text%/, items[i]).replace(/%name%/, i));
		this.divs[i] = { 'o_obj' : this.getElem('TTip' + i) };
		this.divs[i].o_css = this.divs[i].o_obj.style;
	}
}

function TTipShow (id) {
	if (document.layers) return;
	this.hide();
	if (this.divs[id]) {
		if (this.n_dl_show) this.divs[id].timer = setTimeout("myHint.showD(" + id + ")", this.n_dl_show);
		else this.showD(id);
		this.visible = id;
	}
}

function TTipShow2 (id, obiectTHint) {
	if (document.layers) return;
	this.hide();
	if (this.divs[id]) {
		if (this.n_dl_show) this.divs[id].timer = setTimeout(obiectTHint + ".showD2(" + id + ", '" + obiectTHint + "')", this.n_dl_show);
		else this.showD2(id, obiectTHint);
		this.visible = id;
	}
}

function TTipShowD (id) {
	this.move(id);
	this.showElem(id);
	if (this.n_dl_hide) this.timer = setTimeout("myHint.hide()", this.n_dl_hide);
}

function TTipShowD2 (id, obiectTHint) {
	this.move(id);
	this.showElem(id);
	if (this.n_dl_hide) this.timer = setTimeout(obiectTHint + ".hide2(" + id + ", '" + obiectTHint + "')", this.n_dl_hide);	
}

function TTipMove (id) {
	var n_x = myHint.x + this.left, n_y = myHint.y + this.top;
	if (this.b_wise) {
		var n_w = this.getSize(id), n_h = this.getSize(id, true),
		n_win_w = this.getWinSz(), n_win_h = this.getWinSz(true),
		n_win_l = this.getWinSc(), n_win_t = this.getWinSc(true);
		if (n_x + n_w > n_win_w + n_win_l) n_x = n_win_w + n_win_l - n_w-50;
		if (n_x < n_win_l) n_x = n_win_l;
		if (n_y + n_h > n_win_h + n_win_t) n_y = n_win_h + n_win_t - n_h-40;
		if (n_y < n_win_t) n_y = n_win_t;
	}
	this.divs[id].o_css.left = n_x + 'px';
	this.divs[id].o_css.top = n_y + 'px';
}

function TTipHide () {
	if (this.timer) clearTimeout(this.timer);
	if (this.visible != null) {
		if (this.divs[this.visible].timer) clearTimeout(this.divs[this.visible].timer);
		setTimeout("myHint.showElem(" + this.visible + ", true)", 10);
		this.visible = null;
	}
}

function TTipHide2 (id, obiectTHint) {
	if (this.timer) clearTimeout(this.timer);
	if (this.visible != null) {
		if (this.divs[this.visible].timer) clearTimeout(this.divs[this.visible].timer);
		setTimeout(obiectTHint + ".showElem(" + this.visible + ", true)", 10);
		this.visible = null;
	}
}

function stm(t,s) {
	myHint.show(t)
}
function htm(){
	myHint.hide()
}


function uncheckRadioButton(rbs_name)
{
 
	var rbs=document.forms[0].elements[rbs_name];
	
	for (i=0; i<rbs.length; i++)
	{
			if (!rbs[i].onclick)
			{
				rbs[i].checked=true;
				rbs[i].focus();
			}
	}
}

// 2nd tooltip library : radu
function getMouseX(e){ 
  if (!e) e = window.event;
  if (e){ 
    if (e.pageX || e.pageY){
      return e.pageX;
    } else if (e.clientX || e.clientY){ 
        return e.clientX + document.body.scrollLeft;
    }  
  }
}

function getMouseY(e){ 
  if (!e) e = window.event;
  if (e){ 
    if (e.pageY){
      return e.pageY;
    } else if (e.clientY){ 
        return e.clientY + document.body.scrollTop;
    }  
  }
}

function creatediv(id, html) {
    var newdiv = document.createElement('div');
    newdiv.innerHTML = html;   
    newdiv.setAttribute('id', id);
    newdiv.style.visibility="hidden";       
    newdiv.style.position = "absolute";
    newdiv.style.top = "0";
    newdiv.style.left = "0";
    newdiv.style.font = "normal 8pt sans-serif"; 
    newdiv.style.padding = "1px"; 
    newdiv.style.border = "solid 1px";
    newdiv.style.background = "#FFFFE7";    
    document.body.appendChild(newdiv);
} 

function xstooltip_show(parentId, event, tip){
    var tooltipId = parentId + "TipLayer";    
    var it = document.getElementById(tooltipId);
    if(!it){
        creatediv(tooltipId, tip);
        it = document.getElementById(tooltipId);
    }    
    it.style.visibility = 'visible'; 
    xstooltip_move(parentId,event);
}

function xstooltip_move(parentId, event){
    var it = document.getElementById(parentId + "TipLayer");
    if(!it){ return; }
    var mouseX = getMouseX(event);
    var mouseY = getMouseY(event);    
    var x = mouseX + 10;
    var y = mouseY + 10;    
    it.style.top = y + 'px';
    it.style.left = x + 'px';    
    return;
}

function xstooltip_hide(parentId){
    var tooltipId = parentId + "TipLayer";
    it = document.getElementById(tooltipId); 
    it.style.visibility = 'hidden'; 
}

