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') == null) ? "" : a.getAttribute('title');
		
		//just to preload the favicons, same object will get overwritten
		//but the image will get cached
		image = new Image();
		image.src = a.href.match('(http|https):\/\/([^\/]+)\/')[0]+'favicon.ico';
		{//create all elements
			head = document.createElement('div');
				idN = 'tip-head-left';
			head.setAttribute('class', 'tip-head');
			head.id = idN;
				ficon = document.createElement('img');
				ficon.src = a.href.match('(http|https):\/\/([^\/]+)\/')[0]+'favicon.ico';
					//(not yet) ficon.src = '/wp-content/plugins/tooltippr/favicon.php?url=' + a.href;
				ficon.setAttribute('class','ficon');
				head.appendChild(ficon);
			head.appendChild(document.createTextNode(this.tip));
			body = document.createElement('div');
			body.setAttribute('class','tip-body');
			body.appendChild(document.createTextNode(a.href));
			container = document.createElement('div');
			container.id = 'tippr';
				container.appendChild(head);
				container.appendChild(body);
		}
		//assign styles relative to 'a'
		style = 'position:absolute;';
		style += 'left:'+a.offsetLeft+'px;';
		style += 'top:'+(a.offsetTop+a.offsetHeight)+'px;';
		style += 'display:none;margin-top:10px';
		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).show().css('opacity','0.0');
			$('#'+container.id).animate({
				marginTop:'0px',
				opacity: 0.9
			}, 300);
		}, 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).animate({
					marginTop:'10px',
					opacity: 0.0
			}, 300, 'linear', function(){
			$('#'+tipID).remove();
		});
	}
}//end of class

function addTips(bodies){
	timeout = new Array(); i =0;
	body = bodies.split(',');
	body_string = '';
	jQuery.each(body, function(){
		body_string += '.'+this+' a,';
	});
		
	$(body_string).hover(function(){
		epoch = new Date();
			epoch = epoch.getTime();
		eval('tt'+epoch+' = new Tooltipper($(this)[0])');
	}, function(){
		eval('tt'+epoch+'.removeTip()');
	});
	
	tips = new Array();
	tips[0] = new Image();
		tips[0].src = "http://adityamukherjee.com/geekaholic/wp-content/plugins/tooltippr/black-bg.png";
	tips[1] = new Image();
		tips[1].src = "http://adityamukherjee.com/geekaholic/wp-content/plugins/tooltippr/tippr-top.png";
}