jQuery(function($){
	thumbnailPreview = function(){	
		/* ===== Offsets ===== */
		xOffset = 10;
		yOffset = 10;
		$("a.tTip").each(function(){
			var $this = $(this);
			$("<img>").attr("src", this.rel).bind('load',
				function(){}
			).bind('error',
				function(){($this).addClass('error')}
			)
			$(this).hover(function(e){
				this.t = this.title || '';
				this.title = "";
				this.offset = $this.offset();
				this.tLeft = this.offset.left;
				this.tTop = this.offset.top;
				this.tWidth = $this.width();
				this.tHeight = $this.height();
				
				$("body").append("<div id='thumbnail' class='tip'><div class='tipMid'><span><img src='"+ this.rel +"' alt='' /></span></div><div class='tipBtm'></div></div>");
				if(!$this.hasClass('error')){ // don't show any hover image where an error occurred loading the thumbnail image
					$("#thumbnail")
						.css("top",(this.tTop - $("#thumbnail").height() - yOffset) + "px")
						.css("left",(this.tLeft + (this.tWidth - $("#thumbnail").width())/2) + "px")
						.fadeIn("fast");
				};
			},
			function(){
				this.title = this.t;
				$("#thumbnail").remove();
			});
		});
	};
	thumbnailPreview();
});
