function ctooltip() {
  this.img_dir = './_img/tooltip/';
  }
	
ctooltip.prototype = {

  // vykresleni tooltipoveho boxu
  drawTooltip : function() {
	
	sHTML = '<table id="tooltip" cellpadding="0" cellspacing="0" style="display: none; position: absolute; border: 0px;">';
	sHTML += '<tr>';
	sHTML += '<td><img src="' + this.img_dir + 'tooltip-top-left.gif" width="9" height="9"/></td>';
	sHTML += '<td><img class="tooltip-horizontal" src="' + this.img_dir + 'tooltip-top.gif" height="9"/></td>';
	sHTML += '<td><img src="' + this.img_dir + 'tooltip-top-right.gif" width="9" height="9"/></td>'
	sHTML += '</tr>';
	sHTML += '<tr>';
	sHTML += '<td style="background: url(\'' + this.img_dir + 'tooltip-left.gif\');"><img class="tooltip-vertical" src="' + this.img_dir + 'tooltip-left.gif" width="9"/></td>';
	sHTML += '<td><div class="content tooltip-horizontal" style="position: relative;"><b>Test</b><br/>Toto je muj tooltip<div></td>';
	sHTML += '<td style="background: url(\'' + this.img_dir + 'tooltip-right.gif\');"><img class="tooltip-vertical" src="' + this.img_dir + 'tooltip-right.gif" width="9"/></td>';
	sHTML += '</tr>';
	sHTML += '<tr>';
	sHTML += '<td><img src="' + this.img_dir + 'tooltip-bottom-left.gif" width="9" height="9"/></td>';
	sHTML += '<td><img class="tooltip-horizontal" src="' + this.img_dir + 'tooltip-bottom.gif" height="9"/></td>';
	sHTML += '<td><img src="' + this.img_dir + 'tooltip-bottom-right.gif" width="9" height="9"/></td>';
	sHTML += '</tr>';
	sHTML += '</table>';

	$('body').append(sHTML);
	
	},
  
  hide : function() {
  	$('#tooltip').hide();
  	},

  // inicializace tooltipu
  init : function() {
	// alert('init tooltip');

	this.drawTooltip();
	
	var self = this;
	
    $('[tooltip]').livequery('mouseover',
		function(event) {
			var iWidth = 0;
			$(this).css('cursor','help');
			if ($(this).attr('tooltip-width')) iWidth = parseFloat($(this).attr('tooltip-width')); else iWidth = parseFloat(150);
			// if (!(height = $(this).attr('tooltip-height'))) height = 50;
			$('#tooltip .tooltip-horizontal').width(iWidth);
			$('#tooltip .content').width(iWidth);
			$('#tooltip .content').html($(this).attr('tooltip'));
			// nastavcime okno dle aktualni pozice mysi
			$('#tooltip').css('top',event.pageY);
			$('#tooltip').css('left',event.pageX);
			$('#tooltip').show();
			
			// alert($('#tooltip .content').height()); // vysku muzeme nacist az po zobrazeni - show, pak by se tooltip mel zarovant dle pozice na strance
			iHeight = parseFloat($('#tooltip .content').height());
			// $('#tooltip .tooltip-vertical').height(iHeight);
			$('#tooltip').css('top',event.pageY - iHeight - 20);
			}
		);
  
    $('[tooltip]').livequery('mouseout',
		function(event) {
			$('#tooltip').hide();
			}
		);
  
  }
  
  }

// vytvoreni a inicializace tooltipu
tooltip = new ctooltip();
$(document).ready(function() {
   tooltip.init();
   });

