/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 50;
		yOffset = 120;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */
	
	var onMouseOver = function(e){
		this.t = this.title;
		this.title = "";	
		if($('div#tooltip').length<1){
			$('<div id="tooltip" />')
				.appendTo('body');
		}
		$('div#tooltip')
				.html('<img src="'+ this.href +'" alt="'+this.t+'" border="0" />')
				.css('padding','5px')
				.show();
				//.fadeIn("fast")
	}
	
	var onMouseMove = function(e){
		if($('#tooltip').length>0){
			var objX = e.pageX - $('#tooltip').width() *0.5;
			var objY = e.pageY - $("#tooltip").height() - 50;
			$("#tooltip")
				.css("top",objY+ "px")
				.css('left',objX+ "px");
		}
	}
	
	
	var onMouseOut = function(e){
		
		this.title = this.t;
		//$("#tooltip").remove();
		$('#tooltip').hide();
	}
	
	$("a.tooltip").each(function(){
		this.direction ='left';
		$(this).hover(onMouseOver,onMouseOut);	
		$(this).mousemove(onMouseMove);	
	});
	$("a.tooltip-left").each(function(){
		this.direction ='right';
		$(this).hover(onMouseOver,onMouseOut);	
		$(this).mousemove(onMouseMove);	
	});
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});