/*
 * 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(){

		xOffset = 10;
		yOffset = -200;

                imgdimension = 400;

	
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";
		var c = (this.t != "") ? "<br/>" + this.t : "";
                var src = $(this).find('img').attr('src');
                src = src.replace(/width=[0-9]*&/,'width='+imgdimension+'&height='+imgdimension+'&');          
		$("#content").append("<p id='preview'><img src='"+src+"' alt='Image preview' />"+ c +"</p>");
		$("#preview")                        
			.css("top",(topamount + yOffset) + "px")
			.css("left",(leftamount + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#preview").remove();
    });
	$("a.preview").mousemove(function(e){
            topamount = e.pageY;
            leftamount = e.pageX;
		$("#preview")
			.css("top",(($(window).height()/2) - (imgdimension/2)) + "px")
			.css("left",(leftamount + xOffset) + "px")
                               
	});
};


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

