/*
 * 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.wait_ = function(){	
		 $('#wait').hide();		 
//		 $('#main').show();
		 $('#main').fadeIn('slow');
	 }
 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 100;
		yOffset = 50;
				
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){								  							  								  
		$("body").append("<div id='preview'><div>" + this.rev + "</div><div id='wait' class='loading' /><div><img id='main' src='"+ this.name +"' width=350 onload='wait_()' style='display:none'/></div><div>" + this.rel + "</div></div>");
		
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
//		$("#proType").hide();
    },
	function(){
		//this.title = this.t;	
		$("#preview").remove();
//		$("#proType").show();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});		
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});