/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 */ 


// starting the script on page load
(function($) {
	
	this.imagePreview = function(){	
		/* CONFIG */

			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 */
		$("a.searchResultPreview").hover(function(e){
			// not using captions
			// this.t = this.title;
			// this.title = "";
			// var c = (this.t != "") ? "" + this.t : "";
			$("body").append("<div id='searchResultPreview'><img src='"+ this.rel +"' alt='Image preview' />"/* + "<p>"+ c +"</p>" */ + "</div>");
			$("#searchResultPreview")
				.delay(250)
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");
	    },
		function(){
			// not using captions
			// this.title = this.t;
			$("#searchResultPreview").remove();
	    });
		$("a.searchResultPreview").mousemove(function(e){
			$("#searchResultPreview")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});
	};
	
	//same as $(document).ready();
	$(function() {
		
		imagePreview();

		// remove the title element on product image links, store it in element's jQuery data()
		$("div.productImage a[title]").mouseout(function(){
	      	// not sure how to restore it, this doesn't seem to work
	        // $this.data('title');
		    }).mouseover(function(){
		      	$this = $(this);
		        $.data(this, 'title', $this.attr('title'));
		        $this.removeAttr('title');
		    });
		

	});


	$(window).bind("load", function() {
		
	
	});
	
})(jQuery);
