////////////////  GLOBAL TOOPTIP CONFIGURATION  /////////////////////
var ttOffsetX      = 0;
var ttOffsetY      = 0;
////////////////////  END OF TOOLTIP CONFIG  ////////////////////////

//////////////  TAGS WITH TOOLTIP FUNCTIONALITY  ////////////////////
// List may be extended or shortened:
var tt_tags = new Array("area");
/////////////////////////////////////////////////////////////////////

///////// DON'T CHANGE ANYTHING BELOW THIS LINE /////////////////////
var tt_obj,                // current tooltip
tt_objW = 0, tt_objH = 0,  // width and height of tt_obj
tt_objX = 0, tt_objY = 0,
tt_offX = 0, tt_offY = 0,
xlim = 0, ylim = 0,        // right and bottom borders of visible client area
tt_sup = false,            // true if T_ABOVE cmd
tt_wait = false,
tt_act = false,            // tooltip visibility flag
tt_sub = false,            // true while tooltip below mousepointer
tt_u = "undefined",
tt_mf,                     // stores previous mousemove evthandler
tt_inputs = new Array(),   // drop-down-boxes to be hidden in IE
// Opera: disable href when hovering <a>
tt_tag = null;             // stores hovered dom node, href and previous statusbar txt

var tt_db = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null,
tt_n = navigator.userAgent.toLowerCase();

// Browser flags
var tt_op = !!(window.opera && document.getElementById),
tt_op6 = tt_op && !document.defaultView,
tt_op7 = tt_op && !tt_op6,
tt_ie = tt_n.indexOf("msie") != -1 && document.all && tt_db && !tt_op,
tt_n4 = (document.layers && typeof document.classes != tt_u),
tt_n6 = (!tt_op && document.defaultView && typeof document.defaultView.getComputedStyle != tt_u),
tt_w3c = !tt_ie && !tt_n6 && !tt_op && document.getElementById;

tt_n = "";


function tt_Int(t_x)
{
	var t_y;
	return isNaN(t_y = parseInt(t_x))? 0 : t_y;
}

function wzReplace(t_x, t_y)
{
	var t_ret = "",
	t_str = this,
	t_xI;
	while((t_xI = t_str.indexOf(t_x)) != -1)
	{
		t_ret += t_str.substring(0, t_xI) + t_y;
		t_str = t_str.substring(t_xI + t_x.length);
	}
	return t_ret+t_str;
}
String.prototype.wzReplace = wzReplace;

function tt_N4Tags(tagtyp, t_d, t_y)
{
	t_d = t_d || document;
	t_y = t_y || new Array();
	var t_x = (tagtyp=="a")? t_d.links : t_d.layers;
	for(var z = t_x.length; z--;) t_y[t_y.length] = t_x[z];
	for(z = t_d.layers.length; z--;) t_y = tt_N4Tags(tagtyp, t_d.layers[z].document, t_y);
	return t_y;
}

function tt_GetSelects()
{
	if (!tt_op6 && !tt_ie) return;
	var t_i, t_s = tt_op6? "input" : "select";
	if (document.all)
	{
		t_i = document.all.tags(t_s).length; while(t_i--)
			tt_inputs[t_i] = document.all.tags(t_s)[t_i];
	}
	else if (document.getElementsByTagName)
	{
		t_i = document.getElementsByTagName(t_s).length; while(t_i--)
			tt_inputs[t_i] = document.getElementsByTagName(t_s)[t_i];
	}
	t_i = tt_inputs.length; while(t_i--)
	{
		tt_inputs[t_i].vis = '';
		tt_inputs[t_i].x = 0;
		tt_inputs[t_i].y = 0;
		var t_o = tt_inputs[t_i];
		while(t_o)
		{
			tt_inputs[t_i].x += t_o.offsetLeft || 0;
			tt_inputs[t_i].y += t_o.offsetTop|| 0;
			t_o = t_o.offsetParent;
		}
	}
}

function tt_Htm(tt, t_id, txt)
{
	var t_y;
	t_y	 = '<div id="'+t_id+'" class="pinpoint_popup" style="position:absolute;z-index:1010;left:0px;top:0px;visibility:'+(tt_n4? 'hide' : 'hidden')+'">';
	t_y += '<div id="pinpoint_popup_banner"><a href="javascript:closewin(\''+t_id+'\');" title="Close">[x] Close<\/a><\/div><div id="pinpoint_popup_body">';
	t_y += txt;
	t_y += '<\/div>';
	t_y	+= '<\/div>';
	return t_y;
}

function tt_EvX(t_e)
{
	var t_y = tt_Int(t_e.pageX || t_e.clientX || 0) + tt_Int(tt_ie? tt_db.scrollLeft : 0) + tt_offX;
	if (t_y > xlim) t_y = xlim;
	var t_scr = tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0);
	if (t_y < t_scr) t_y = t_scr;
	return t_y;
}

function tt_EvY(t_e)
{
	var t_y = tt_Int(t_e.pageY || t_e.clientY || 0) + tt_Int(tt_ie? tt_db.scrollTop : 0);
	if (tt_sup) t_y -= (tt_objH + tt_offY - 15);
	else if (t_y > ylim || !tt_sub && t_y > ylim-24)
	{
		t_y -= (tt_objH + 5);
		tt_sub = false;
	}
	else
	{
		t_y += tt_offY;
		tt_sub = true;
	}
	return t_y;
}

function tt_HideInput()
{
	if (!(tt_ie || tt_op6) || !tt_inputs) return;
	var t_o;
	var t_i = tt_inputs.length; while(t_i--)
	{
		t_o = tt_inputs[t_i];
		if (tt_act && !t_o.vis && tt_objX+tt_objW > t_o.x && tt_objX < t_o.x+t_o.offsetWidth && tt_objY+tt_objH > t_o.y && tt_objY < t_o.y+t_o.offsetHeight)
		{
			t_o.vis = t_o.currentStyle? t_o.currentStyle.visibility : t_o.style.visibility;
			t_o.style.visibility = 'hidden';
		}
		else if (t_o.vis)
		{
			t_o.style.visibility = t_o.vis;
			t_o.vis = '';
		}
	}
}

function tt_GetDiv(t_id)
{
	return(
		tt_n4? (document.layers[t_id] || null)
		: tt_ie? (document.all[t_id] || null)
		: (document.getElementById(t_id) || null)
	);
}

function tt_GetDivW()
{
	return tt_Int(
		tt_n4? tt_obj.clip.width
		: (tt_obj.style.pixelWidth || tt_obj.offsetWidth)
	);
}

function tt_GetDivH()
{
	return tt_Int(
		tt_n4? tt_obj.clip.height
		: (tt_obj.style.pixelHeight || tt_obj.offsetHeight)
	);
}

// Compat with DragDrop Lib: Ensure that z-index of tooltip is lifted beyond toplevel dragdrop element
function tt_SetDivZ()
{
	var t_i = tt_obj.style || tt_obj;
	if (window.dd && dd.z)
		t_i.zIndex = Math.max(dd.z+1, t_i.zIndex);
}

function tt_SetDivPos(t_x, t_y)
{
	var t_i = tt_obj.style || tt_obj;
	var t_px = (tt_op6 || tt_n4)? '' : 'px';
	t_i.left = (tt_objX = t_x) + t_px;
	t_i.top = (tt_objY = t_y) + t_px;
	tt_HideInput();
}

function tt_ShowDiv(t_x)
{
	if (tt_n4) tt_obj.visibility = t_x? 'show' : 'hide';
	else tt_obj.style.visibility = t_x? 'visible' : 'hidden';
	tt_act = t_x;
	tt_HideInput();
}

function tt_OpDeHref(t_e)
{
	if (t_e && t_e.target.hasAttribute("href"))
	{
		tt_tag = t_e.target;
		tt_tag.t_href = tt_tag.getAttribute("href");
		tt_tag.removeAttribute("href");
		tt_tag.style.cursor = "hand";
		tt_tag.onmousedown = tt_OpReHref;
		tt_tag.stats = window.status;
		window.status = tt_tag.t_href;
	}
}

function tt_OpReHref()
{
	if (tt_tag)
	{
		tt_tag.setAttribute("href", tt_tag.t_href);
		window.status = tt_tag.stats;
		tt_tag = null;
	}
}

function tt_Show(t_e, t_id, t_sup, t_left, t_offx, t_offy)
{
	var i = tt_tags.length; while(i--)
	{
		tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
			: document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
			: (!tt_n4 && tt_tags[i]=="a")? document.links
			: 1;
		if (tt_n4 && (tt_tags[i] == "a" || tt_tags[i] == "layer")) tags = tt_N4Tags(tt_tags[i]);
		var j = tags.length; while(j--)
		{
			var div_id="tOoLtIp"+i+j;
			if (div_id==t_id)
			{
				tt_obj = tt_GetDiv(div_id);
				tt_obj.style.display='block';
			}
			else
			{
				other_tt_obj = tt_GetDiv(div_id);
				if (other_tt_obj)
				{
					other_tt_obj.style.display='none';
				}
			}
		}
	}
	
	if (tt_obj) tt_Hide();
	tt_mf = document.onmousemove || null;
	if (window.dd && (window.DRAG && tt_mf == DRAG || window.RESIZE && tt_mf == RESIZE)) return;
	var t_uf = document.onmouseup || null;
	if (tt_mf && t_uf) t_uf(t_e);

	tt_obj = tt_GetDiv(t_id);
	if (tt_obj)
	{
		t_e = t_e || window.event;
		tt_sub = !(tt_sup = t_sup);
		tt_objW = tt_GetDivW();
		tt_objH = tt_GetDivH();
		tt_offX = t_left? -(tt_objW+t_offx) : t_offx;
		tt_offY = t_offy;
		if (tt_op7) tt_OpDeHref(t_e);
		if (tt_n4)
		{
			if (tt_obj.document.layers.length)
			{
				var t_sh = tt_obj.document.layers[0];
				t_sh.clip.height = tt_objH - Math.round(t_sh.clip.width*1.3);
			}
		}
		else
		{
			var t_sh = tt_GetDiv(t_id+'R');
			if (t_sh)
			{
				var t_h = tt_objH - tt_Int(t_sh.style.pixelTop || t_sh.style.top || 0);
				if (typeof t_sh.style.pixelHeight != tt_u) t_sh.style.pixelHeight = t_h;
				else t_sh.style.height = t_h+'px';
			}
		}

		tt_GetSelects();

		xlim = tt_Int((tt_db && tt_db.clientWidth)? tt_db.clientWidth : window.innerWidth) +
			tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0) -
			tt_objW -
			(tt_n4? 21 : 0);
		ylim = tt_Int(window.innerHeight || tt_db.clientHeight) +
			tt_Int(window.pageYOffset || (tt_db? tt_db.scrollTop : 0) || 0) -
			tt_objH - tt_offY;

		tt_SetDivZ();

		tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));

		var t_txt = 'tt_ShowDiv(\'true\');';
	}
}

var tt_area = false;
function tt_Move(t_ev)
{
	if (!tt_obj) return;
	if (tt_n6 || tt_w3c)
	{
		if (tt_wait) return;
		tt_wait = true;
		setTimeout('tt_wait = false;', 5);
	}
	var t_e = t_ev || window.event;
	tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
	if (tt_op6)
	{
		if (tt_area && t_e.target.tagName != 'AREA') tt_Hide();
		else if (t_e.target.tagName == 'AREA') tt_area = true;
	}
}

function tt_Hide()
{
	if (window.tt_obj)
	{
		if (window.tt_rdl) window.clearTimeout(tt_rdl);
		tt_ShowDiv(true);
		tt_obj = null;
		if (typeof window.tt_upFunc != tt_u) document.onmouseup = window.tt_upFunc;
		if (tt_op6 && tt_area) tt_area = false;
		if (tt_op7) tt_OpReHref();
		tt_HideInput();
	}
}

function tt_Init()
{
	if (!(tt_op || tt_n4 || tt_n6 || tt_ie || tt_w3c)) return;

	var htm = tt_n4? '<div style="position:absolute;"><\/div>' : '',
	tags,
	t_tj,
	over,
	esc = 'return escape(';
	var i = tt_tags.length; while(i--)
	{
		tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
			: document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
			: (!tt_n4 && tt_tags[i]=="a")? document.links
			: 1;
		if (tt_n4 && (tt_tags[i] == "a" || tt_tags[i] == "layer")) tags = tt_N4Tags(tt_tags[i]);
		var j = tags.length; while(j--)
		{
			if (typeof (t_tj = tags[j]).onclick == "function" && t_tj.onclick.toString().indexOf(esc) != -1 && !tt_n6 || tt_n6 && (over = t_tj.getAttribute("onclick")) && over.indexOf(esc) != -1)
			{
				if (over) t_tj.onclick = new Function(over);
				var txt = unescape(t_tj.onclick());
				htm += tt_Htm(
					t_tj,
					"tOoLtIp"+i+""+j,
					txt.wzReplace("& ","&")
				);

				t_tj.onclick = new Function('e',
					'tt_Show(e,'+
					'"tOoLtIp' +i+''+j+ '",'+
					(typeof t_tj.T_ABOVE != tt_u)+','+
					(typeof t_tj.T_LEFT != tt_u)+','+
					((typeof t_tj.T_OFFSETX != tt_u)? t_tj.T_OFFSETX : ttOffsetX)+','+
					((typeof t_tj.T_OFFSETY != tt_u)? t_tj.T_OFFSETY : ttOffsetY)+
					');'
				);
				t_tj.onmouseout = tt_Hide;
				if (t_tj.alt) t_tj.alt = "";
				if (t_tj.title) t_tj.title = "";
			}
		}
	}
	document.write(htm);
}

function closewin(t_id)
{
	tt_obj = tt_GetDiv(t_id);
	tt_obj.style.display='none';
}

tt_Init();
