
/*
	ToolTips v.2.0
	
	Written by Design Technologist
		- Seth Van Booven [svanbooven@sacbee.com]
	
	Copyright © The Sacramento Bee
	Created by the New Media Department
	Created: April 16, 2006 (sv)  /  Last update: 04/16/06 (sv)
	
	****************************************************
		IF YOU DON'T KNOW WHAT YOU ARE DOING
		THEN YOU DON'T BELONG HERE.
		.........................CLOSE IMMEDIATELY!
	****************************************************
------------------------------------------------------------*/

var toolTip = {
	actDyn : true,
	skin : null,
	Xoffset : 0, // layer Xoffset from link mouseover event
	Yoffset : 0, // layer Yoffset from link mouseover event
	x : 0,
	y : 0,
	timer : null,
	
	show : function(s, p) {
		var obj = document.getElementById('ttip');
		if (!obj || (this.actDyn != true)) return;
		this.skin = obj.style;
		this.skin.visibility = 'visible';
		this.skin.display = 'inline';
		obj.innerHTML = '<span class="ttip">' + s + '</span>';
		if (p != undefined) {
			obj.className = 't2';
			this.Yoffset = -40 - (p * 16);
		} else {
			obj.className = '';
			this.Yoffset = 20;
		}
		var el = (document.addEventListener) ? document : event.srcElement;
		el.onmousemove = this.move;
		timer = setTimeout("toolTip.hide()", 4000);
	},
	hide : function() {
		if (!this.skin) return;
		this.skin.visibility = 'hidden';
		this.skin.display = 'none';
		this.skin.left = '-500px';
		this.skin.top = '-500px';
		clearTimeout(timer);
	},
	move : function(e) {
		if (e == null) {
			e = window.event;
		}
		if (e.clientX || e.clientY) {
			x = e.clientX + document.body.scrollLeft;
			y = e.clientY + document.body.scrollTop;
			if (document.documentElement) {
				if (typeof(document.documentElement.scrollTop ) == 'number') {
					x += document.documentElement.scrollLeft;
					y += document.documentElement.scrollTop;
				}
			}
		} else {
			x = e.pageX;
			y = e.pageY;
		}
		toolTip.skin.left = x + toolTip.Xoffset + 'px';
		toolTip.skin.top = y + toolTip.Yoffset + 'px';
		toolTip.nudge(x);
	},
	nudge : function(x) {
		var extreme, overflow, temp;
		if (document.getElementById && document.all) {
			extreme = (document.body.clientWidth);
		} else {
			extreme = (window.innerWidth) - 15;
		}
		if (parseInt(this.skin.left) > extreme) {
			overflow = parseInt(this.skin.left) - extreme;
			temp = parseInt(this.skin.left);
			temp -= overflow;
			this.skin.left = temp + 'px';
		}
		if (parseInt(this.skin.left) < 1) {
			overflow = parseInt(this.skin.left) - 1;
			temp = parseInt(this.skin.left);
			temp -= overflow;
			this.skin.left = temp + 'px';
		}
	},
	create : function() {
		var div = document.createElement('div');
		div.id = 'ttip';
		div.style.position = 'absolute';
		document.getElementsByTagName('body')[0].appendChild(div);
	}
};

document.write('<div id="ttip" style="position:absolute;"></div>');

//toolTip.create();
