/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * Based on the script 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(){	

	xOffset = -20;
	yOffset = 10;

	$("a.preview").hover(
		function(e){
			this.t = (this.title != "") ? this.title : "";
			this.title = "";
			
			var c = (this.t != "") ? "<span>" + this.t + "</span>" : "";
			$("body").append("<div id='biopreview'><img src='"+ this.href +"' />"+ c +"</div>");
			
			$("#biopreview")
				.fadeIn("fast");
			
			var w = $('#biopreview').children('img').attr('width');
			$("#biopreview")
				.css("top", (e.pageY + yOffset ) + "px")
				.css("left", (e.pageX + xOffset - w) + "px");

		},
		function(){
			this.title = (this.t != "") ? this.t : "";
			$("#biopreview").remove();
		}
	);
	
	$("a.preview").mousemove(
		function(e){
			var w = $('#biopreview').children('img').attr('width');
			$("#biopreview")
				.css("top",(e.pageY + yOffset) + "px")
				.css("left",(e.pageX + xOffset - w) + "px");
		}
	);
	
	$("a.preview").click(
		function (){
			return false;
		}
	);
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
