var last_tip_id = "";
var can_hide_tip = true;
var cursor_on_tip = "";

document.onmousemove = function(e) { mCur = mousePageXY(e); };

function showtip_control (v, this_handler) 
{	
	if (document.getElementById(v)) 
	{
		document.getElementById(v).style.zIndex = 100;

		var sw = document.body.clientWidth;
		var sh = document.body.clientHeight;
		var dw = document.getElementById(v).clientWidth;
		var dh = document.getElementById(v).clientHeight;
		
		var pos = getElementPosition(this_handler);
		cx = pos.left + pos.width;
		cy = pos.top - document.body.scrollTop;
		
		if (sw < cx+dw+10) cx=sw-dw-10;
		if (sh < cy+dh+10) cy=sh-dh-10;
		
		document.getElementById(v).style.top=cy+document.body.scrollTop+5;
		document.getElementById(v).style.left=cx+document.body.scrollLeft+5;

		document.getElementById(v).style.visibility = 'visible';
	}
}

function showtip (v, sec_param, this_handler, mode) 
{	
	var thisTip = document.getElementById(v);
	
	if (thisTip) 
	{
		thisTip.style.zIndex = 100;
		
		var sw = document.body.clientWidth;
		var sh = document.body.clientHeight;
		var dw = thisTip.clientWidth;
		var dh = thisTip.clientHeight;
		
		if (isNetscape4 || isMozilla) {
			var cx = mousex;
			var cy = mousey/*  - document.body.scrollTop */;
		}
		else {
			var cx = self.event.clientX;
			var cy = self.event.clientY;
		}
		
		//if (sw < cx+dw+10) cx=sw-dw-10;
		//if (sh < cy+dh+10) cy=sh-dh-10;
				
		//thisTip.style.top = cy + document.body.scrollTop + 5 + "px";
		//thisTip.style.left = cx + document.body.scrollLeft + 5 + "px";
		
		if (sw < cx+dw+10) cx=sw-dw-10;
		if (sh < cy+dh) cy=cy-dh-10;

		cx = mCur.x;
		cy = mCur.y;
		
		thisTip.style.top = cy + "px";
		thisTip.style.left = cx + "px";

		thisTip.style.visibility = 'visible';
	}

	if (sec_param)	{
		this_handler.href = sec_param;
	}
}

function mousePageXY(e)
{
  var x = 0, y = 0;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
	x = e.pageX;
	y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
	x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
	y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }

  return {"x":x, "y":y};
}

function showtip_firm (v, sec_param, this_handler, mode, delay) 
{	
	var thisTip = document.getElementById(v);
	
	// alert("X:"+mCur.x+" - Y:"+mCur.y);
	
	cursor_on_tip = v;
	if ( last_tip_id != "" )
	{
		if (document.getElementById(last_tip_id)) 
		{
			document.getElementById(last_tip_id).style.visibility='hidden';
		}
	}
	
	if (thisTip) 
	{
		thisTip.style.zIndex = 100;
		
		var sw = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
		var sh = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
		
		var dw = thisTip.clientWidth;
		var dh = thisTip.clientHeight;
		
		if (isNetscape4 || isMozilla) {
			var cx = mousex;
			var cy = mousey  - document.body.scrollTop;
		}
		else {
			var cx = self.event.clientX;
			var cy = self.event.clientY;
		}
		
		if (sw < cx+dw+10) cx=sw-dw-10;
		if (sh < cy+dh) cy=cy-dh-10;
		
		//if ( mode == 'search' )	thisTip.style.top = cy + document.body.scrollTop - 75 + 'px';
		//else					thisTip.style.top = cy + document.body.scrollTop + 5 + 'px';
		
		cx = mCur.x;
		cy = mCur.y;
		
		thisTip.style.top = cy + 'px';
		thisTip.style.left = cx + 'px';
		
		setTimeout('showtip_firm_internal2("'+v+'")', delay);
	}

	if (sec_param)
	this_handler.href = sec_param;
	
	last_tip_id = v;
}

function showtip_firm_internal2(v) 
{
	if ( cursor_on_tip == v )
	document.getElementById(v).style.visibility='visible';
}

function hidetip (v) 
{	
	if (document.getElementById(v)) {
		document.getElementById(v).style.visibility='hidden';
	}
}

function hidetip_firm (v) 
{	
	cursor_on_tip = "";
	setTimeout('hidetip_new("'+v+'")', 250);
	//hidetip_new(v);
}

function hidetip_new (v) 
{
	if (document.getElementById(v)) {
		if ( can_hide_tip == true )
		document.getElementById(v).style.visibility='hidden';
	}
}

function hide_deny() {
	can_hide_tip = false;
}

function hide_allow( tid ) {
	can_hide_tip = true;
	setTimeout('hidetip_new("'+tid+'")', 500);
}

function tip_move()
{
	
}
