/*
 * Url 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.showBubble = function()
	{	
	/* CONFIG */
	
	
		xOffset2 = (0 + $("#popup_bubble").height());
		yOffset2 = 5;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.popup_bubble").hover(function(e)
		{
		this.t = this.title;
		this.title = "";
		var rel = this.rel;
		if($("#popup_bubble")) {
		   $("#popup_bubble").remove(); // delete old bubble
		}
		
		$("body").append("<div id='popup_bubble'></div>");
		$("#popup_bubble").fadeIn(125);
		$("#popup_bubble").append($("#" + rel).clone(true));
		$("#popup_bubble")
			
			.css("left",(e.pageX - ($("#popup_bubble").width()/2) - xOffset2 ) + "px")
			.css("top",(e.pageY - $("#popup_bubble").height() - yOffset2 - 10) + "px");
			
    	},
		
	function()
		{
		this.title = this.t;
		$("#popup_bubble").fadeOut(75);
		});
	  
	  $("a.popup_bubble").mousemove(function(e)
		  {
		  var kompenzace = 0;		  
		  if((e.pageX + ($("#popup_bubble").width()/2) + xOffset2) >= $("body").width()) {
		     kompenzace = $("body").width() - (e.pageX + ($("#popup_bubble").width()/2) + xOffset2);
		  }
		  
		  $("#popup_bubble")
		
		  	.css("left",(e.pageX - ($("#popup_bubble").width()/2) - xOffset2 + kompenzace) + "px")
		  	.css("top",(e.pageY - $("#popup_bubble").height() - yOffset2 - 10) + "px");
			
		  });
	};


// starting the script on page load
$(document).ready(function(){
	showBubble();
});