/*
 * 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.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 0;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	jQuery("div.catalog a.preview img").hover(function(e){
		this.t = this.title;
		this.title = "";

		if(this.name) {
			jQuery("body").append("<div id='preview'><img src='"+ this.name +"' alt='Image preview' /></div>");	
		}
		else {
			jQuery("body").append("<div id='preview'><img src='"+ this.src +"' alt='Image preview' /></div>");	
		}
				
		jQuery("#preview")
		    .fadeIn("200")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.css("margin-top","-100px")
			.css("display","block");				
    },
	function(){
		this.title = this.t;	
		jQuery("#preview").remove();
    });	
	jQuery("div.catalog a.preview img").mousemove(function(e){
		jQuery("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
jQuery(document).ready(function(){
	imagePreview();
});