J=jQuery.noConflict();

J(document).ready(function() {

	//Select all anchor tag with rel set to tooltip
	J('th.ttip').mouseover(function(e) {
		
    if(J(this).html() == "Rate" || J(this).html() == "Foreclosure Rate") {
      body = "Number of foreclosures/number of sales over the past 12 months";
    } else {
      body = "Number of foreclosures/number of properties in a given area/city/town";
    }
    
		//Remove the title attribute's to avoid the native tooltip from the browser
		J(this).attr('title','');
		
		//Append the tooltip template and its value
		J(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + body + '</div><div class="tipFooter"></div></div>');
		
		//Set the X and Y axis of the tooltip
		J('#tooltip').css('top', e.pageY + 10 );
		J('#tooltip').css('left', e.pageX + 20 );
		
		//Show the tooltip with faceIn effect
		//J('#tooltip').fadeIn('500');
		//J('#tooltip').fadeTo('10',0.8);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		J('#tooltip').css('top', e.pageY + 10 );
		J('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		J(this).attr('title',J('.tipBody').html());
	
		//Remove the appended tooltip template
		J(this).children('div#tooltip').remove();
		
	});

});
