/*
 * 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() {	
	xOffset = 10;
	yOffset = 20;
	$(".tooltip").hover(function(e) {
		this.t = this.title;
		this.title = "";
		var parts = this.t.split(" :: ", 2);
		$('#tooltip').html(parts[1]);
		$('#tooltip').dialog({
			autoOpen: true, 
			draggable: false, 
			resizable: false, 
			position: [e.pageX + yOffset, e.pageY - xOffset],
			dialogClass: 'tooltip',
			minWidth: 100,
			minHeight: 70
		});
		$('.ui-dialog-titlebar-close').remove();
		$('#tooltip').dialog('option', 'title', parts[0]);
		$('#tooltip').dialog('open');
	},
	function() {
		this.title = this.t;
		$("#tooltip").dialog('close');
		//("#tooltip").remove();
	});
	$(".tooltip").mousemove(function(e){
		$("#tooltip").dialog('option', 'position', [e.pageX + yOffset, e.pageY - xOffset]);
	});
};

// starting the script on page load
$(document).ready(function(){
	tooltip();
	$("body").append('<div id="tooltip"></div>');
});