/*
 * 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
 *
 */

var w4xPreviewHover=true, w4xPreviewApplied=false;
this.imagePreview = function(){	
	/* CONFIG */
		
		if (w4xPreviewApplied==true) return;
		w4xPreviewApplied=false;
		
		xOffset = 10;
		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.w4xpreview").hover(function(e){
		if (w4xPreviewHover==false) return;
		
		this.t = this.title;
		this.title = "";
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='w4xpreview'><img src='"+ this.src +"' alt='Image preview' />"+ c +"</p>");
		
		// alert("<p id='preview'><img src='"+ this.src +"' alt='Image preview' />"+ c +"</p>")
									 
		$("#w4xpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");				
    },
	function(){
		if (w4xPreviewHover==false) return;
		
		this.title = this.t;	
		$("#w4xpreview").remove();
    });	
	$("img.w4xpreview").mousemove(function(e){
		if (w4xPreviewHover==false) return;
		
		$("#w4xpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	// imagePreview();
});
