/*
 * 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 = (jQuery.browser.msie ? 323 : 323);
		yOffset = (jQuery.browser.msie ? 273 : 273);
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("#parent_wrapper div.category a").hover(function(e){
		$("#product_preview").empty();
		var html = $('div#'+this.title).html();
		this.t = this.title;
		var pos = jQuery(this).parent().position();
		var large_src = $('span#'+this.title+'_image').text();
		this.title = "";
		var c = (html != "") ? "<br />" + html : "";
		$("#product_preview").html("<a href='"+this.href+"' class='rollover_img'><img src='"+ large_src +"' alt='Image preview' /></a>"+c);
		if (pos.left < 750) {
			var height = $("#product_preview").height();
			$("#product_preview")
				.css("top", (((pos.top > 400) ? ((pos.top+4)-height) : pos.top+yOffset)) + "px")
				.css("left", (pos.left+xOffset) + "px")
				.show();
		} else {
			var height = $("#product_preview").height();
			$("#product_preview")
			.css("top", (((pos.top > 400) ? ((pos.top+4)-height) : pos.top+yOffset)) + "px")
			.css("left", (pos.left+33) + "px")
			.show();
		}
    },
	function(){	
    	this.title = this.t;
		$("#product_preview").hide();
    });			
};


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