var add_info = function () { 

  //
  var title = $(this).attr("title");
  
	if($("div.opened").attr("class") == "opened")
	  $("div.opened").hide("slow"); // zavre pripadne otevrene divy*/
	  
  var content = $("div#"+title).text();
  
  var write = '<table class="up"><tbody><tr><td id="topleft" class="corner"></td><td class="top"></td>'+
	'<td id="topright" class="corner"></td></tr><tr><td class="left"></td><td>'+
	content+
	'</td><td class="right"></td></tr><tr><td class="corner" id="bottomleft"></td><td class="bottom">'+
	'<img width="30" height="29" alt="popup tail" src="http://jqueryfordesigners.com/demo/images/coda/bubble-tail2.png"/></td>'+
	'<td id="bottomright" class="corner"></td></tr></tbody></table>';
        
        
	var write = "<div class='opened' style='display:block;'><div class='close'>X</div></div>";
	
	$(this).append(write).css("display", "none").show("fast");
  //$(this).append(write);
  
  
	
  return false; 
}; 

var close_info = function () { 
  $("div.opened").hide("slow");
};
$(function () {
jQuery("div.close").click(close_info);
});
$(function () {
jQuery("div.open").click(add_info);
});




//////////////////////////////////////////////
$(function () {
  $('.binfo').each(function () {
    // options
    var distance = 10;
    var time = 150;
    var hideDelay = 50;

    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('.o', this);
    var popup = $('.up', this).css('opacity', 0);

    // set the mouseover and mouseout on both element
    $([trigger.get(0), popup.get(0)]).mouseover(function () {
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);

      // don't trigger the animation again if we're being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;

        // reset position of popup box
        popup.css({
          top: -130,
          left: -100,
          display: 'block' // brings the popup back in to view
        })

        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          top: '-=' + distance + 'px',
          opacity: 1
        }, time, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      }
    }).mouseout(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });
  });
});

/////////////////////////////////////////////////////////////////\n

$(function () {
  $('.bclick').each(function () {
    // options
    var distance = 10;
    var time = 400; //jak dlouho se naimuje zavreni
    var time_open = 100; //jak dlouho se animuje otevreni
    var hideDelay = 30; // jak dlouho prodleva

    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('.o', this);
    var closer = $('.clo', this);
    var popup = $('.up', this).css('opacity', 0);

    // set the mouseover and mouseout on both element
    $([trigger.get(0)]).click(function () {
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);

      // don't trigger the animation again if we're being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;

        // reset position of popup box
        popup.css({
          top: -135,
          left: -100,
          display: 'block' // brings the popup back in to view
        })

        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          top: '-=' + distance + 'px',
          opacity: 1
        }, time_open, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      }
    });
		
		$([popup.get(0)]).click(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });

  });
});

/////////////////////////////////////////////


function get_obj(name) { // kompatibilata prace v jednotlivyc browserech - prejima id nazev polozdy, vraci objekt na nej
  if (document.getElementById) 
    return document.getElementById(name).style;
  else
    if (document.all) 
      return document.all[name].style;
    else
    if (document.layers) 
      return document.layers[name];
}

var last_id = false;

function opened(id_string) {
	id = get_obj(id_string);
	
  if (last_id !== false && last_id !== id_string) 
	  get_obj(last_id).display = 'none';

	last_id = id_string;
	
  return false;
  
}

function close_window(id) {

	id = get_obj(id);
	id.display = 'none';
  return false;
  
}






