$(document).ready(function(){
	$("a[rel]").live("mouseover",function(){
		$("body").append("<div class='tip'></div>");
		var ePos = $(this).offset();
		var windowWidth = $(window).width();
		var windowHeight = $(document).height();
		var yPos = ePos.top + $(this).height();
		var x = "window height: " + windowHeight + " yPos: " + yPos;
		var xPos = ePos.left + $(this).width(); 
		if((xPos + $(".tip").width()) > windowWidth){
			xPos = windowWidth-($(".tip").width()+20);
		}
		if((yPos + $(".tip").height()) > windowHeight){
			yPos = windowHeight - $(".tip").height();
		}
		var tooltip = $(".tip");
		tooltip.css('left', xPos + 'px');
		tooltip.css('top', yPos + 'px');
		tooltip.html($(this).attr("rel"));
		tooltip.show();
	});
	$("a[rel]").live("mouseout",function(){	  		
		$(".tip").remove();
	});	
}); 
