
this.imagePreview = function(){	
	/* CONFIG */
		xOffset = -90;
		yOffset = -30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("img.imgpreview").hover(function(e){


		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='imgpreview'><img src='"+ this.getAttribute('src') +"' alt='Image preview'>" +"</img>" + c +"</p>");								 
								 
		$("#imgpreview")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("slow");						
    },
	function(){
		this.title = this.t;	
		$("#imgpreview").remove();
    });	
	$("img.imgpreview").mousemove(function(e){
		$("#imgpreview")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

