var toolTipLib = { 
	xCord : 0,
	yCord : 0,
	attachToolTipBehavior: function() {
		var links = document.getElementsByTagName('a');
		var i;
		for ( i=0;i<links.length;i++ )
			toolTipLib.attachToolTipBehaviorSingle(links[i]);
		links = document.getElementsByTagName('img');
		for ( i=0;i<links.length;i++ )
			toolTipLib.attachToolTipBehaviorSingle(links[i]);
	},
	attachToolTipBehaviorSingle: function(obj) {
		if(obj.title.length > 0)
		{
			addEvent(obj,'mouseover',toolTipLib.tipOver,false);
			addEvent(obj,'mouseout',toolTipLib.tipOut,false);
			obj.setAttribute('tip',obj.title);
			obj.removeAttribute('title');
		}
	},
	tipOver: function(e) {
		if ( window.tID )
		clearTimeout(tID);
		if ( window.opacityID )
		clearTimeout(opacityID);
		tID = setTimeout("toolTipLib.tipOutImmediate()", 50);

		obj = getEventSrc(e);
		toolTipLib.xCord = findPosX(obj);
		toolTipLib.yCord = findPosY(obj);
		tID = setTimeout("toolTipLib.tipShow(obj,'"+toolTipLib.xCord+"','"+toolTipLib.yCord+"')", 250)
	},
	tipOver2: function(e) {
		if ( window.tID )
		clearTimeout(tID);
		if ( window.opacityID )
		clearTimeout(opacityID);
		
		var obj = document.getElementById('toolTip');
		obj.style.opacity = '.90';
		obj.style.filter = "alpha(opacity:90)";
	},
	tipOut: function(e) {
		if ( window.tID )
		clearTimeout(tID);
		if ( window.opacityID )
		clearTimeout(opacityID);
		tID = setTimeout("toolTipLib.tipOutImmediate()", 500);
	},
	tipOutImmediate: function() {
		var div = document.getElementById('toolTip');
		if ( div )
			div.parentNode.removeChild(div);
	},
	checkNode : function(obj) {
		var trueLink = obj;
		if ( trueLink.nodeName.toLowerCase() == 'a' ) {
		return trueLink;
		}
		while ( trueLink.nodeName.toLowerCase() != 'a' && trueLink.nodeName.toLowerCase() != 'body' )
		trueLink = trueLink.parentNode;
	return trueLink;
	},
	tipShow: function(obj,x,y) {
		var newDiv = document.createElement('div');
		var scrX = Number(x);
		var scrY = Number(y);
		var tp = parseInt(scrY + 15);
		var lt = parseInt(scrX - 30);
		if(lt + 250 > document.body.clientWidth)
		{
			lt = document.body.clientWidth - 250;
			newDiv.style.width = 235+'px';
		}
		if(lt < 5)
			lt = 5;
		var anch = toolTipLib.checkNode(obj);
		tp += obj.offsetHeight - 17;
		//var addy = (anch.href.length > 25 ? anch.href.toString().substring(0,25)+"..." : anch.href);
		newDiv.id = 'toolTip';
		newDiv.style.top = tp+'px'; newDiv.style.left = lt+'px';
		document.body.appendChild(newDiv);
		newDiv.innerHTML = "<p>"+anch.getAttribute('tip') + "</p>";//+"<em>"+addy+"</em></p>";
		newDiv.style.opacity = '.1';
		
		addEvent(newDiv,'mouseover',toolTipLib.tipOver2,false);
		addEvent(newDiv,'mouseout',toolTipLib.tipOut,false);
		
		toolTipLib.tipFade('toolTip', 10);
	},
	tipFade: function(div,opac) {
		var obj = document.getElementById(div);
		var passed = parseInt(opac);
		var newOpac = parseInt(passed + 10);
		if ( newOpac < 90 ) {
		obj.style.opacity = '.'+newOpac;
		obj.style.filter = "alpha(opacity:"+newOpac+")";
		opacityID = setTimeout("toolTipLib.tipFade('toolTip','"+newOpac+"')", 15);
		}
		else { 
		obj.style.opacity = '.90';
		obj.style.filter = "alpha(opacity:90)";
		}
	}
};
addEvent(window,'load',toolTipLib.attachToolTipBehavior,false);