      var speed=5000;
      var aktfotka=0;
      var pocetnovinek=$('#newsoverview>li').size();
      var aktnovinka=0;
      var povolslidenovinek=true;
      var speednews=5000;
      var timerID = false;

      function slideshow(){
        var pocetfotek=$('#headerimages img').size();
        if (pocetfotek>1){
          var nextfotka=(aktfotka+1)%pocetfotek;
          $('#headerimages img:eq('+aktfotka+')').fadeOut(2000);  
          $('#headerimages img:eq('+nextfotka+')').fadeIn(2000); 
          aktfotka=nextfotka;
          setTimeout('slideshow()',speed);
        }
      }
      
      function slidenews(){
        if (povolslidenovinek){
          $('#newsoverview>li').fadeOut('slow');
          x=$('#newslist>li:visible:not(:eq('+aktnovinka+'))').size();
          for (i=0;i<x;i++){
            $('#newslist>li:visible:not(:eq('+aktnovinka+')):eq('+i+')>a:first').css('background-image','url(images/news/'+$('#newslist>li:visible:not(:eq('+aktnovinka+')):eq('+i+')>a:first').attr('rel')+'n.png)');
          }
          $('#newslist>li:visible:eq('+aktnovinka+')>a:first').css('background-image','url(images/news/'+$('#newslist>li:visible:eq('+aktnovinka+')>a:first').attr('rel')+'a.png)');
          $('#newsoverview>li:eq('+aktnovinka+')').fadeIn('slow');
          aktnovinka=(aktnovinka+1)%pocetnovinek;
          if (pocetnovinek>1){
            timerID=setTimeout('slidenews()',speednews);
          }
        }
      }
      
      function setcontsize(){
        size1=$('#ikony').height()+341;
        size2=$('#maincontentcover').height();
        size3=$(window).height()-83-83;
        size4=$('#program').height()+341+200;
        max=Math.max(size1,size2,size3,size4);
        $('#maincontentcover').height(max);
        $('#footer').css('top',(max+83)+'px');      
      }
      
      $(window).resize(function(){
        setcontsize();
      });
      
      $(document).ready(function(){
        setcontsize();
        pocetnovinek=$('#newsoverview>li').size();
        $('#langs li a:first').css('border-left','none');
        $('#toplinks li a:last').css('border-left','none');
        $('#pocasicover').bind('mouseleave',function(){
          $('#pocasicover2').animate({height:'120px'},500);
        }).bind('mouseenter',function(){
          $('#pocasicover2').animate({height:"300px"},500);
        });
        $('#menu>li').bind('mouseleave',function(){
          $(this).children('ul').hide();
        }).bind('mouseenter',function(){
          $(this).children('ul').show();
        });
        $('#menu>li>a').css('background-image',function(e){
          return 'url(http://hosting.yconix.com/berta/imggenerator/button-berta.php?nadpis='+encodeURI($(this).text())+')';
        });
        $('#pobytcover h3:first').css('background-image',function(e){
          return 'url(http://hosting.yconix.com/berta/imggenerator/h3.php?nadpis='+encodeURI($(this).text())+')';
        }).css('line-height','300px');
        $('#prehledpobytu h3 a').css('background-image',function(e){
          return 'url(http://hosting.yconix.com/berta/imggenerator/h3-2.php?nadpis='+encodeURI($(this).text())+')';
        }).css('line-height','300px');
        
        $('#prehledpobytu h3 a').bind('mouseenter',function(){
          $(this).css('background-image',function(e){
            return 'url(http://hosting.yconix.com/berta/imggenerator/h3-2.php?hover=1&nadpis='+encodeURI($(this).text())+')';
          })}).bind('mouseleave',function(){
            $(this).css('background-image',function(e){
            return 'url(http://hosting.yconix.com/berta/imggenerator/h3-2.php?nadpis='+encodeURI($(this).text())+')';
          })});
        
        
        $('#menu>li>a').css('line-height','100px');
        $(document).ready(function(){
          $('#headerimages img:not(:first)').hide();
          slideshow();
        });
        
        if (!$('#newsoverview').size()){
          $('#newslist').hide();
        } else {
          for(i=pocetnovinek;i<10;i++){
            $('#newslist>li:eq('+i+')').hide();
          }
          for(i=0;i<pocetnovinek;i++){
            $('#newslist>li:eq('+i+')>a:first').bind('mouseenter',function(){
              z=parseInt($(this).attr('rel'))-1;
              $('#newsoverview>li:not(:eq('+z+'))').fadeOut('slow');
              $('#newsoverview>li:eq('+z+')').fadeIn('slow');
              x=$('#newslist>li:visible:not(:eq('+z+'))').size();
              for (i=0;i<x;i++){
                $('#newslist>li:visible:not(:eq('+z+')):eq('+i+')>a:first').css('background-image','url(http://hosting.yconix.com/berta/images/news/'+$('#newslist>li:visible:not(:eq('+z+')):eq('+i+')>a:first').attr('rel')+'n.png)');
              }
              $('#newslist>li:visible:eq('+z+')>a:first').css('background-image','url(http://hosting.yconix.com/berta/images/news/'+$('#newslist>li:visible:eq('+z+')>a:first').attr('rel')+'a.png)');
              povolslidenovinek=false;
              clearTimeout(timerID);
            }).bind('mouseleave',function(){
              aktnovinka=parseInt($(this).attr('rel'))%pocetnovinek;
              povolslidenovinek=true;
              timerID=setTimeout('slidenews()',speednews);
            });
          }
          $('#newsoverview>li').hide();
          slidenews();
        }
        pocet=$('.picturelist>li').size();
        for (i=3;i<pocet;i+=4){
          $('.picturelist>li:eq('+i+')').css('margin-right','0px');
        }
        pocet=$('.thumb img').size();
        for (i=0;i<pocet;i++){
          if ($('.thumb img:eq('+i+')').width()<101){
            $('.thumb img:eq('+i+')').width(101);
          }
        }
        $('.thickbox').lightbox();
        $('#prehledpobytu li:even').css('margin-right','14px');
      });
