var actorTT;
if(!actorTT){
	actorTT=true;
	var toolTip;
	var relationCache=new Object();
	var ttvis=false;
	var tttarg=undefined;

	//page initialization
	function initTT(){
		toolTip=document.createElement('DIV');
		toolTip.id='tooltip';
		toolTip.innerHTML=' ';
		toolTip.className='hidden';
		document.body.appendChild(toolTip);

		attachToClass(document.getElementById('story'),'rel',setupTT);
	}

	//Show the tooltip. Bound to element.onmouseover
	function showTT(e){
		toolTip.className='';
		var pos=findPos(this);
		toolTip.style.left=(pos.x+this.offsetWidth)+'px';
		toolTip.style.top=pos.y+'px';

		ttvis=true;
		tttarg=parseInt(getAtt(this,'relid')); //getAtt found in utils.js

		if(relationCache['rel'+tttarg]){
			toolTip.innerHTML=relationCache['rel'+tttarg].payload;
		} else {
			toolTip.innerHTML='Please wait, retrieving relations...';
			sendRequest('/ajax?type=relQuery&relid='+tttarg,handleRequest); //sendRequest found in quirksAjax.js
		}
	}

	//Hide the tooltip. Bound to element.onmouseout
	function hideTT(){
		toolTip.className='hidden';
		ttvis=false;
	}

	//sets up all necessary properties and events to bind a tooltip to an anchor
	function setupTT(obj){
		obj.onmouseover=showTT;
		obj.onmouseout=hideTT;
	}

	//parses the JSON response and handles appropriately
	function handleRequest(req){
		var obj;
		eval(req.responseText);
		relationCache['rel'+obj.relid]=obj;
		if(ttvis && tttarg==obj.relid){
			toolTip.innerHTML=obj.payload;
		}
	}
	addLoadEvent(initTT);
}