// JavaScript Document
	
		
this.tooltipPreview = function(){	
	
		
		xOffset = 15;
		yOffset = 35;
	
	/* Hide target elements
	$('.tooltip').each(function() {
		var href = $(this).attr('href'),
			$target = $(href);
			
			console.log($target);
		$target.hide();
	});*/
		
	$('.tooltip').live('mouseenter', function(e) {
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "",
			href = $(this).attr('href'),
			$tooltip = $('<p id="tooltip"></p>');
		
		if (this.rel) {
			// Show rel image as tooltip
			var $img = $('<img src="'+this.rel+'" />');
			$tooltip.append($img).appendTo($('body'));
			yOffset = $tooltip.height()+10;
			xOffset = -5;
		}
		else {
			// Show href target as tooltip
			$target = $('<div></div>').html($(href).html());
			$tooltip.append($target).appendTo('body');
		}
		
		// Set starting position of tooltip
		$("#tooltip")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");						
    })
	.live('mouseleave', function(){
		// Remove tooltip on mouseout
		this.title = this.t;	
		$("#tooltip").remove();
    })
	.live('mousemove', function(e){
		$("#tooltip")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	})
	.live('click', function() {
		return false;
	});
};

$(document).ready(function(){
	tooltipPreview();
});
