
/* 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.tPreview = function(){	
	/* CONFIG */
		
		xOffset = 73;
		yOffset = 200;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.tPreview").hover(function(e){
		linkWidth = $(this).offset();
		$("body").append("<div id='tPreview'><img src='"+ this.rel +"' alt='preview' /><div class='tPreviewBubble'></div></div>");
		$("#tPreview")
			.css("top",(linkWidth.top - xOffset) + "px")
			.css("left", (linkWidth.left - yOffset) + "px")
			.show();						
    },
	function(){
		linkWidth = null;
		$("#tPreview").remove();
    });
	
	$("a.tPreview").click(function(e){
		linkWidth = null;
		$("#tPreview").remove();
	});
	
};


// starting the script on page load
$(document).ready(function(){
	tPreview();
});
