$(document).ready(function(){
  var TOpointer;
  $("#kafelki a img").mouseenter(function(e){
    var parent=$(this).parent();
    parent.css('z-index','6');
    var next=parent.next();
    next.show();
    $('div .box[name]').hide();
    $("div .box[name='"+parent.find('.tab_on').text()+"']").show();
    $("#kafelki .kafel").css('z-index','4');
  });
  
  $("#kafelki a img").mouseleave(function(e){
    $(this).parent().parent().find(".k_pole").hide();
  });
  
  $("a.important").click(function(e){
    if(!confirm("Ta akcja wymaga potwierdzenia. Jeżeli chcesz kontynuować kliknij OK.")){
      e.preventDefault();
    }
  });
  
  var widoczny=0;
  var pTop=parseInt($("#belka").css('top'))*(-1);
  
  $(".logowanie").mouseenter(function(){
    clearTimeout(TOpointer);
	if(!widoczny){
      widoczny=1;
      $("#belka").animate({
        top: '+='+pTop
      },500);
    }
  });
  
  $("#belka").mouseenter(function(){
    clearTimeout(TOpointer);
  });
  
  $("#belka").mouseleave(function(){
    if(widoczny){
		TOpointer=setTimeout(function(){
			widoczny=0;
			$("#belka").animate({
				top: '-='+pTop
			},500);
		},2000);
    }
  });
  
});
