var toolTipLib = {
	xCord : 0,
	yCord : 0,
	obj : null,
	attachToolTipBehavior: function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		var links = document.getElementsByTagName('a');
		var acronyms = document.getElementsByTagName('acronym');
		var abbrs = document.getElementsByTagName('abbr');
		var i;
		addEvent(document,'mousemove',toolTipLib.updateXY,false);
		if ( document.captureEvents ) {
				document.captureEvents(Event.MOUSEMOVE);
		}
		var emtDiv = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(emtDiv);
		emtDiv.style.position = 'absolute';
		for ( i=0;i<links.length;i++ ) {
			if (links[i].title != "") {
			  addEvent(links[i],'mouseover',toolTipLib.tipOver,false);
			  addEvent(links[i],'mouseout',toolTipLib.tipOut,false);
			  links[i].setAttribute('tip',links[i].title);
			  links[i].removeAttribute('title');
                        }
		}
		for ( i=0;i<acronyms.length;i++ ) {
			addEvent(acronyms[i],'mouseover',toolTipLib.tipOver,false);
			addEvent(acronyms[i],'mouseout',toolTipLib.tipOut,false);
			acronyms[i].setAttribute('tip',acronyms[i].title);
			acronyms[i].removeAttribute('title');
		}
		for ( i=0;i<abbrs.length;i++ ) {
			addEvent(abbrs[i],'mouseover',toolTipLib.tipOver,false);
			addEvent(abbrs[i],'mouseout',toolTipLib.tipOut,false);
			abbrs[i].setAttribute('tip',abbrs[i].title);
			abbrs[i].removeAttribute('title');
		}
	},
	updateXY : function(e) {
		if ( document.captureEvents ) {
			toolTipLib.xCord = e.pageX;
			toolTipLib.yCord = e.pageY;
		} else if ( window.event.clientX ) {
			toolTipLib.xCord = window.event.clientX+document.documentElement.scrollLeft;
			toolTipLib.yCord = window.event.clientY+document.documentElement.scrollTop;
		}
	},
	tipOut: function(e) {
		if ( window.tID ) {
			clearTimeout(tID);
		}
		if ( window.opacityID ) {
			clearTimeout(opacityID);
		}
		var l = getEventSrc(e);
		var div = document.getElementById('toolTip');
		if ( div ) {
			div.parentNode.removeChild(div);
		}
	},
	checkNode : function(obj) {
		var trueObj = obj;
		if ( trueObj.nodeName.toLowerCase() == 'a' || trueObj.nodeName.toLowerCase() == 'acronym' || trueObj.nodeName.toLowerCase() == 'abbr' ) {
			return trueObj;
		} else {
			return trueObj.parentNode;
		}
	},
	tipOver : function(e) {
		toolTipLib.obj = getEventSrc(e);
		tID = setTimeout("toolTipLib.tipShow()",500)
	},
	tipShow : function() {
		var newDiv = document.createElement('div');
		var scrX = Number(toolTipLib.xCord);
		var scrY = Number(toolTipLib.yCord);
		var tp = parseInt(scrY+15);
		var lt = parseInt(scrX+10);
		var anch = toolTipLib.checkNode(toolTipLib.obj);
		var addy = '';
		var access = '';
		if ( anch.nodeName.toLowerCase() == 'a' ) {
			addy = (anch.href.length > 25 ? anch.href.toString().substring(0,25)+"..." : anch.href);
			var access = ( anch.accessKey ? ' <span>['+anch.accessKey+']</span> ' : '' );
		} else {
			addy = anch.firstChild.nodeValue;
		}
		newDiv.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(newDiv);
		newDiv.innerHTML = "<p>"+anch.getAttribute('tip')+"<em>"+access+addy+"</em></p>";
		if ( document.documentElement.clientWidth < parseInt(newDiv.offsetWidth+lt) ) {
			newDiv.style.right = '20px';
		} else {
			newDiv.style.left = lt+'px';
		}
		if ( document.documentElement.clientHeight < parseInt(newDiv.offsetHeight+tp) ) {
			newDiv.style.top = parseInt(tp-(newDiv.offsetHeight+10))+'px';
		} else {
			newDiv.style.top = tp+'px';
		}
		newDiv.style.opacity = '.1';
		toolTipLib.tipFade('toolTip',10);
	},
	tipFade: function(div,opac) {
		var obj = document.getElementById(div);
		var passed = parseInt(opac);
		var newOpac = parseInt(passed+10);
		if ( newOpac < 80 ) {
			obj.style.opacity = '.'+newOpac;
			obj.style.filter = "alpha(opacity:"+newOpac+")";
			opacityID = setTimeout("toolTipLib.tipFade('toolTip','"+newOpac+"')",20);
		}
		else {
			obj.style.opacity = '.80';
			obj.style.filter = "alpha(opacity:80)";
		}
	}
};
addEvent(window,'load',toolTipLib.attachToolTipBehavior,false);
