this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 12;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";
		/*IE fix
		$("body").before("<p id='tooltip'></p>");
		$("body").before("<p id='tooltipshadow'></p>");
		$("body").before("<p id='tooltiptext'>"+this.t+"</p>");*/
		if(e.pageX + 460 > GetWidth())
		{
			xOffset = -470;
			xarrOffset = -57;
			backgrImg = '/images/arrowright.png';
		}
		else
		{
			xOffset = 10;
			xarrOffset = 10;
			backgrImg = '/images/arrowleft.png';
		}
		
		var elem = $("#tooltiptext");
		elem[0].innerHTML = this.t;
		
		$("#tooltip")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xarrOffset) + "px")
			.css('backgroundImage','url(' + backgrImg +')')
			.fadeIn("fast");
		$("#tooltiptext")
			.css("top",(e.pageY - yOffset-23) + "px")
			.css("left",(e.pageX + xOffset+23) + "px")
			.fadeIn("fast");
		$("#tooltipshadow")
			.css("top",(e.pageY - yOffset-23) + "px")
			.css("left",(e.pageX + xOffset+23) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;		
		/*$("#tooltip").remove();
		$("#tooltiptext").remove();
		$("#tooltipshadow").remove();*/
		$("#tooltip").css("display","none");
		$("#tooltiptext").css("display","none");
		$("#tooltipshadow").css("display","none");
    });	
	$("a.tooltip").mousemove(function(e){
		if(e.pageX + 460 > GetWidth())
		{
			xOffset = -470;
			xarrOffset = -57;
			backgrImg = '/images/arrowright.png';
		}
		else
		{
			xOffset = 10;
			xarrOffset = 10;
			backgrImg = '/images/arrowleft.png';
		}
		$("#tooltip")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xarrOffset) + "px")
			.css('backgroundImage','url(' + backgrImg +')')
		$("#tooltiptext")
			.css("top",(e.pageY - yOffset-23) + "px")
			.css("left",(e.pageX + xOffset+23) + "px");
		$("#tooltipshadow")
			.css("top",(e.pageY - yOffset-23) + "px")
			.css("left",(e.pageX + xOffset+23) + "px")
			.fadeIn("fast");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
$('#dialog').jqm();
});


function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}