Tooltipper = function(a){
			this.anch = a;
			this.tip = '';
			this.tipID = '';
			this.timeoutkey = 0;

			this.tooltippr();
			
}//constructor
Tooltipper.prototype = {
	tooltippr: function(){
		//get left or right
		a = this.anch;
		if(!this.tip)
			this.tip = a.getAttribute('title');

		left = (a.offsetLeft>(0.5*$('body')[0].offsetWidth)) ? 1 : 0;
		{//create all elements
			head = document.createElement('div');
				idN = (left) ? 'tip-head-left' : 'tip-head-right' ;
			head.setAttribute('class', 'tip-head');
			head.id = idN;
			head.innerHTML = this.tip;
			body = document.createElement('div');
			body.setAttribute('class','tip-body');
			body.innerHTML = a.href;
			container = document.createElement('div');
			container.id = (left) ? 'tippr-left' : 'tippr-right';
				container.appendChild(head);
				container.appendChild(body);
		}
		//assign styles relative to 'a'
		style = 'position:absolute;';
		style += (left) ? 'left:'+(a.offsetLeft-320)+'px;' : 'left:'+(a.offsetLeft+a.offsetWidth+10)+'px;';
		style += 'top:'+(a.offsetTop-(a.offsetHeight*0.2))+'px;';
		style += 'display:none;';
		container.setAttribute('style', style);
		container.setAttribute('class','tippr');
		$('body')[0].appendChild(container);
		
		//rewrite class globals
		this.tipID = container.id;
		
		this.timeoutkey = window.setTimeout(function(){
			$('#'+container.id).fadeIn();
		}, 300);
		this.anch.setAttribute('title', '');
	},

	removeTip: function(){
		if(!this.timeoutkey)
			return;
		else
			window.clearTimeout(this.timeoutkey);
			
		tip = this.tip;
		tipID = this.tipID;
		this.anch.setAttribute('title', tip);
		$('#'+this.tipID).fadeOut(300, function(){
			$('#'+tipID).remove();
		});
	}
}//end of class

function addTips(bodies){
	body = bodies.split(',');
	body_string = '';
	for(i in body)
		body_string += '.'+body[i]+' a,';
	
	for(i=0;i<$(body_string).length;i++){
		var timeout = new Array();
		$(body_string).eq(i).hover(function(){
			elem = this;
			timeout[i] = new Tooltipper(elem);
		},
		function(){
			timeout[i].removeTip();
		});
	}
}