/*
 * 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(){
	var xOffset = 30;
	var yOffset = -300;
	
	$("a.preview").mouseover(function(e){
		this.t = this.title;
		var c = (this.t != "") ? "<br/>" + this.t : "";
		
		$("body").append("<p id='preview' style='border:2px solid #000;position:absolute;'><img id='imgprev' src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");
		
		// xOffset = -$("#preview").width() - 30;
		// 		yOffset = -$("#preview").height() - 30;

		
		$("#preview")
			.css("top",(yOffset + e.pageY) + "px")
			.css("left",(xOffset + e.pageX) + "px")
			.fadeIn("fast");
    });
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(yOffset + e.pageY) + "px")
			.css("left",(xOffset + e.pageX) + "px");
	});
	
	$("a.preview").mouseout(function() {
		$("#preview").remove();
	});
	
	$('a.preview').click(function(e) {
		return false;	
	});
};



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