/*
 * 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 = 93;
		yOffset = 0;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("div.product_thumb a").hover(function(e){
		$("#product_preview").empty();
		var html = $('div#'+this.title).html();
		this.t = this.title;
		var pos = $(this).position();
		var large_src = $('span#'+this.title+'_image > img').attr('src');
		this.title = "";
		var c = (html != "") ? "<br />" + html : "";
		$("#product_preview").html("<a href='"+this.href+"'><img src='"+ large_src +"' alt='Image preview' /></a>"+c);
		if (pos.left < 675) {
			$("#product_preview")
				.css("top", (pos.top+yOffset) + "px")
				.css("left", (pos.left+xOffset) + "px")
				.show();
		} else {
			$("#product_preview")
			.css("top", (pos.top+yOffset) + "px")
			.css("left", (pos.left-250) + "px")
			.show();
		}
    },
	function(){	
    	this.title = this.t;
		$("#product_preview").hide();
    });			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
