// requires dimensions library | jquery.dimensions.js

jQuery.fn.poptip = function(baseRel,baseStyle) {
	$ = jQuery;
	//alert(baseRel);
	//create the empty tooltip
	$('<div id="'+ baseStyle + '"><div class="content" style="width:190px; position:absolute; left:50%; margin-left:-95px;" ></div></div>').hide().appendTo('body');
	
	//snatch up the graavy
	jQuery.extend(
		jQuery.expr[ ":" ],
		{
			poptips : ("jQuery(a).attr('rel') == '"+baseRel+"'")
		}
	);
	//track the mouse
	$("body").mousemove(function(e){
		mouseX = e.pageX - this.offsetLeft-110;
		mouseY = e.pageY - this.offsetTop-230;
	});
	//show and hide tooltips
	$("a:poptips").hover(function(){
		curX = this.offsetLeft;
		curY = this.offsetTop;
		curID = $(this).attr("id");
		curText = eval(curID+"text");
		$("#"+baseStyle).find(".content").html(curText);
		$("#"+baseStyle).show();
	},function(){
		$("#"+baseStyle).hide();
	});
	$("a:poptips").mousemove(function(){
		mainX = $(document).width();
		mainY = $(window).height();
		poptipW = $("#"+baseStyle).width();
			$("#"+baseStyle).css("top",mouseY);
			$("#"+baseStyle).css("left",mouseX);
	});
}