this.tooltip = function()
{	
	xOffset = -10;
	yOffset = 20;
	
	function updatePosition(e) {
		var x = (e.pageX + yOffset);
		if (x + $("#tooltip").width() > $('body').width())
			x = $('body').width() - $("#tooltip").width() - 10;

		var y = (e.pageY - xOffset);
		if (y + $("#tooltip").height() > $('body').height())
			y = $('body').height() - $("#tooltip").height() - 30;

		$("#tooltip").css( { 'top' : y + 'px', 'left' : x + 'px', 'display' : ''});
	}

	function hideTooltip(elt) {
		$("#tooltip").remove();
		var title = $(elt).attr("t");

		if(title != undefined)
			elt.title = title;
	}
	
	$("a[title]").hover(
	    function(e) //on hover
	    {
	        if (this.title != '')
	            $(this).attr("t", this.title);
		    
		    $("body").append('<div id="tooltip">'+ this.title +'</div>');
		    this.title = '';
		    
			updatePosition(e);
			$("#tooltip").css('display', '');
        },
	    function() { hideTooltip(this); } //on hover quit
    );
    
    $("a[title]").click( function() { hideTooltip(this); } );
	$("a[title]").mousemove(function(e){ updatePosition(e); } );
};

$(document).ready(function()
{
	tooltip();
	
    if ($.browser.msie && $.browser.version < 7)
    {
        $('img').each( function()
        {
            if ($(this).attr('src'))
            {
                if ($(this).attr('src').match(/.*\.png([?].*)?$/i))
                {
                    $(this).css({
			        filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+$(this).attr('src')+"')",
                    width:$(this).width(), height:$(this).height()
                    }).attr({src:'res/pixel.gif'});
		        }
	        }
        })
    }
});
