jQuery(document).ready(function() {
	var hideDelay = 100;  
	var currentID;
	var hideTimer = null;
	var hideDelayM = 2000;  
	var hideTimerM = null;

  // One instance that's reused to show info for the current person
  var container = $('<div id="personPopupContainer">'
      + '<table width="" border="0" cellspacing="0" cellpadding="0" align="center" class="personPopupPopup">'
      + '<tr>'
      + '   <td class="corner topLeft"></td>'
      + '   <td class="top"></td>'
      + '   <td class="corner topRight"></td>'
      + '</tr>'
      + '<tr>'
      + '   <td class="left">&nbsp;</td>'
      + '   <td class="center"><div id="personPopupContent">'
    +  '<div id="izpis_kat" class="treeview zzapri"></div></div></td>'
      + '   <td class="right">&nbsp;</td>'
      + '</tr>'
      + '<tr>'
      + '   <td class="corner bottomLeft">&nbsp;</td>'
      + '   <td class="bottom">&nbsp;</td>'
      + '   <td class="corner bottomRight"></td>'
      + '</tr>'
      + '</table>'
      + '</div>');

  $('body').append(container);

  $('.katTrigger').live('mouseover', function()
  {
  	//$("body").addClass("mis_cakaj");

      /* var settings = $(this).attr('rel').split(',');
      var pageID = settings[0];
      currentID = settings[1];
      if (currentID == '')
          return;
*/
      if (hideTimer)
          clearTimeout(hideTimer);

      var pos = $(this).offset();
      var width = $(this).width();
      container.css({
          left: (pos.left + width) - 25 + 'px',
          top: pos.top + 20 + 'px'
      });

      $('#izpis_kat').html('&nbsp;');

		var link_prev = $(this).next();
		var link_prev_ = link_prev.next();
		//link = link_prev.attr("href");
		var arr_link = link_prev_.attr("href").split('/');
		arr_link = arr_link.reverse();

		if(arr_link[0]!=''){ 
			super_link = "treeview-" + arr_link[0] + ".php";
		}else{
		// to je podarim
			super_link = 'treeview-podarim0.php'
		}
//$('#izpis_kat').load("cache/treeview-" + arr_link[0] + ".php");
	$.get("cache/"+super_link, {},function(data){
		$('#izpis_kat').html(data);
		$("#navigation").show();
	});



/*      $.ajax({
          type: 'GET',
          url: 'personajax.aspx',
          data: 'page=' + pageID + '&guid=' + currentID,
          success: function(data)
          {
              // Verify that we're pointed to a page that returned the expected results.
              if (data.indexOf('personPopupResult') < 0)
              {
                  $('#personPopupContent').html('<span >Page ' + pageID + ' did not return a valid result for person ' + currentID + '. Please have your administrator check the error log.</span>');
              }

              // Verify requested person is this person since we could have multiple ajax
              // requests out if the server is taking a while.
              if (data.indexOf(currentID) > 0)
              {                  
                  var text = $(data).find('.personPopupResult').html();
                  $('#personPopupContent').html(text);
              }
          }
      });
*/
      container.css('display', 'block');
      
//      $("body").removeClass("mis_cakaj");
  });

  $('.katTrigger').live('mouseout', function()
  {
      if (hideTimer)
          clearTimeout(hideTimer);
      hideTimer = setTimeout(function()
      {
          container.css('display', 'none');
      }, hideDelay);
  });
  $('#personPopupContainer').mouseover(function()
  {
      if (hideTimer)
          clearTimeout(hideTimer);
  });
  $('#personPopupContainer').mouseout(function()
  {
      if (hideTimer)
          clearTimeout(hideTimer);
      hideTimer = setTimeout(function()
      {
          container.css('display', 'none');
      }, hideDelay);
  });
   


});    