$(document).ready(function(){
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 10;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$('a[href*="get_item.php"][rel!=no_tool], a[href*="system/assign_item.php"][rel!=no_tool]').hover(function(e){
	    var raw  = $(this).attr('href');
	    var href = new String(raw);
	    var ide  = new String(href.match(/id=\d+/));
	        ide  = ide.substring(3);
        $("#tooltip").remove();
        $("body").append("<div id='tooltip' style='top:"+(e.pageY - xOffset)+"px;left:"+(e.pageX + yOffset)+"px;'>Loading ...</div>");	
        $.getJSON("http://www.grophland.com/system/js/callbacks/item_tooltip.php", { id: ide, x: e.pageX, y: e.pageY },
          function(data){
            $("#tooltip")
              .html(data.description)
              .css("top",(data.y - xOffset) + "px")
              .css("left",(parseInt(data.x) + yOffset) + "px")
              .fadeIn("fast");	
        });
    },
	function(e){
		$("#tooltip").remove();
    });	
	$('a[href*="get_item.php"]').mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});		
});
