/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imgPreview = function(){

    xOffset = 100;
    yOffset = -525;

	$("img.imgPreview").hover(function(e){
		this.t = this.alt;
		this.title = "";
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='imgPreview'><img src='"+ this.getAttribute("rel") +"' alt='Image preview' />"+ c +"</p>");
		$("#imgPreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#imgPreview").remove();
    });
	$("img.imgPreview").mousemove(function(e){
		$("#imgPreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
};


// starting the script on page load
$(document).ready(function(){
	imgPreview();
});
