/**
 * jQuery image preview plugin
 */
 
jQuery.fn.imagePreview = function() {

	return this.each(function() {
		
		$(this).hover(function(e) {
		
			this.t = this.title;
				
			this.title = ""; // remove title
			
			// work out the url of the full size image
			var url = this.src.replace("renderGallery", "renderDefault");
			url = url.replace("renderThumbnail", "renderDefault");
					
			var caption = (this.t != "") ? "<br/>" + this.t : "";
				
			$("body")
				.append("<p id='preview_large'><img src='"+ url +"' alt='Image preview' />"+ caption +"</p>");
												 
			$("#preview_large")
				.css("top",(e.pageY - 200) + "px")
				.css("left",(e.pageX + 10) + "px")
				.fadeIn(500);
											
		    },
			function(){
			
				this.title = this.t; // replace title
				$("#preview_large").remove();
				
		    });	
		    
			$(this).mousemove(function(e){
			
				$("#preview_large")
					.css("top",(e.pageY - 200) + "px")
					.css("left",(e.pageX + 10) + "px");
					
			});			
		
	});

};
