  regex=new RegExp("([0-9]{2}\.[0-9]{2}\.[0-9]{2})$");
  
  var galpocet=0;
  var panopocet=0;
  var aktgal=0;
  var aktpano=0;
  var timer=false;
  var galspeed=8000;
  var aktpos=0;
  var aktpospano=0;
  
  function galanim(){
    $('#gal>a>img').fadeOut('slow');
    aktgal=(aktgal+1)%galpocet;
    $('#gal>a>img:eq('+aktgal+')').fadeIn('slow');
    $('#gal td a').attr('class','nonactive');
    $('#gal td a:eq('+aktgal+')').attr('class','active');
    timer=setTimeout('galanim()',galspeed);
  } 

  function panoanim(){
    $('#pano>a>img').fadeOut('slow');
    aktpano=(aktpano+1)%panopocet;
    $('#pano>a>img:eq('+aktpano+')').fadeIn('slow');
    $('#pano td a').attr('class','nonactive');
    $('#pano td a:eq('+aktpano+')').attr('class','active');
    timer2=setTimeout('panoanim()',galspeed);
  } 

  $(document).ready(function(){
  
    $('#overview li:first').css('border-top','none');
    $('.news li:first').css('border-top','none');
  
    $('.leftcover').find('.NewsSummary:last').css('border-bottom','none');
  
    $('.leftcover>ul>li:last').css('border-bottom','none');
    
    $('#pano td:last').css('background-image','none');
    $('#gal td:last').css('background-image','none');
    
    if ($('#video').size()){
      url='http://www.youtube.com/watch?v=cThhbFI91IA';
      var tube = new SWFObject('player/player.swf','ply','413','234','9','#ffffff');
      tube.addParam('allowfullscreen','true');
      tube.addParam('allowscriptaccess','always');
      tube.addParam('wmode','opaque');
      tube.addVariable('autostart',true);
      tube.addVariable('file',url);
      tube.write('videoframe');
    }
    
    $('.rightarrow').attr('href','javascript:;').click(function(){
      if (($('#gal div div:first').width()+aktpos+1)<$('#gal div div table').width()){
        aktpos+=127;
        $('#gal table').animate({left: -aktpos+'px'},'slow');
      }
    });
    $('.leftarrow').attr('href','javascript:;').click(function(){
      if (aktpos>0){
        aktpos-=127;
        $('#gal table').animate({left: -aktpos+'px'},'slow');
      }
    });
  
    $('.rightarrowpano').attr('href','javascript:;').click(function(){
      if (($('#pano div div:first').width()+aktpospano+1)<$('#pano div div table').width()){
        aktpospano+=127;
        $('#pano table').animate({left: -aktpospano+'px'},'slow');
      }
    });
    $('.leftarrowpano').attr('href','javascript:;').click(function(){
      if (aktpospano>0){
        aktpospano-=127;
        $('#pano table').animate({left: -aktpospano+'px'},'slow');
      }
    });
  
    if ($('#gal img').size()>1){
      $('#gal>a>img:not(:first)').hide();
      galpocet=$('#gal>a>img').size();
      $('#gal td a:eq('+aktgal+')').attr('class','active');
      timer=setTimeout('galanim()',galspeed);
    }
    if ($('#pano img').size()>1){
      $('#pano>a>img:not(:first)').hide();
      panopocet=$('#pano>a>img').size();
      $('#pano td a:eq('+aktpano+')').attr('class','active');
      timer2=setTimeout('panoanim()',galspeed);
    }

    $('#gal td a').attr('href','javascript:;').click(function(){
      idx=$('#gal td').index($(this).closest('td'));
      if (timer){
        clearTimeout(timer);
      }
      $('#gal>a>img:not(:eq('+idx+'))').fadeOut('slow');
      $('#gal>a>img:eq('+idx+')').fadeIn('slow');
      $('#gal td a').attr('class','nonactive');
      $('#gal td a:eq('+idx+')').attr('class','active');
    });
  
    $('#pano td a').attr('href','javascript:;').click(function(){
      idx=$('#pano td').index($(this).closest('td'));
      if (timer2){
        clearTimeout(timer2);
      }
      $('#pano>a>img:not(:eq('+idx+'))').fadeOut('slow');
      $('#pano>a>img:eq('+idx+')').fadeIn('slow');
      $('#pano td a').attr('class','nonactive');
      $('#pano td a:eq('+idx+')').attr('class','active');
    });
  

    if($('#gal div div:first').width()+1<$('#gal div div table').width()){
      $('.leftarrow,.rightarrow').show();
    } else {
      $('.leftarrow,.rightarrow').hide();
    }
    if($('#pano div div:first').width()+1<$('#pano div div table').width()){
      $('.leftarrowpano,.rightarrowpano').show();
    } else {
      $('.leftarrowpano,.rightarrowpano').hide();
    }

    $('#mapbutton').click(function(){
      $('#mapcover').fadeIn('slow');
    });
    $('#mapclose').click(function(){
      $('#mapcover').fadeOut('slow');
    });
    $('#onlinebuchen').click(function(){
      $('#onlinebuchenform').show();
      //$('#onlinebuchenform').slideToggle('slow');
      if ($('#onlinebuchenform').width()==0){
        $('#onlinebuchenform').animate({width: 200,paddingLeft: 15},'slow');
      } else {
        $('#onlinebuchenform').animate({width: 0,paddingLeft: 0},'slow',function(){$('#onlinebuchenform').hide();});
      }
    });
    $('#onlinebuchenform').width(0);
    $('#introtext').css("margin-left",$("h2").width()+20);
    $('#rightcol table').find('tr:first').attr('class','topline');
    $('#rightcol table tr:not(:first)').find('td:last').css('paddingRight','10px');
    $('#rightcol table tr').find('td:first').map(function(){
      txt=$(this).text();
      if (txt.search(regex)>=0){
        arr=txt.match(regex)[1].split('.');
        datum='20'+arr[2]+'-'+arr[1]+'-'+arr[0];
        d=new Date();
        datum2=d.getFullYear()+'-'+('0'+(d.getMonth()+1)).substr(-2)+'-'+('0'+d.getDate()).substr(-2);
        if (datum2>datum){
          $(this).closest('tr').hide();
        }
      }
    });
    $('input[rel=date]').datepicker({ dateFormat: 'dd.mm.y' });
    
    $('.galdiv').map(function(){
      //$(this).find('a.img:not(:first)').hide();
      $(this).find('a.img').hide().attr('rel','gallery');
      $(this).find('a.img:first').show();
      $(this).find('a.left').click(function(){
          pocet=$(this).closest('.galdiv').find('a.img').size();
          idx=$(this).closest('.galdiv').find('a.img').index($(this).closest('.galdiv').find('a.img:visible'));
          newnum=(idx+pocet-1)%pocet;
          $(this).closest('.galdiv').find('a.img').hide();
          $(this).closest('.galdiv').find('a.img:eq('+newnum+')').show();
      });
      $(this).find('a.right').click(function(){
          pocet=$(this).closest('.galdiv').find('a.img').size();
          idx=$(this).closest('.galdiv').find('a.img').index($(this).closest('.galdiv').find('a.img:visible'));
          newnum=(idx+1)%pocet;
          $(this).closest('.galdiv').find('a.img').hide();
          $(this).closest('.galdiv').find('a.img:eq('+newnum+')').show();
      });
    });
    $('a.img').lightbox();
    $('a[href$=jpg],a[href$=JPG],a[href$=gif],a[href$=GIF]').lightbox();

    $('.nadpis td,.nadpis th').css('background-position','center center');
    $('.nadpis').find('th:first').css('background-position','left center');
    $('.nadpis').find('td:first').css('background-position','left center');
    $('.nadpis').find('th:last').css('background-position','right center');
    $('.nadpis').find('td:last').css('background-position','right center');
  
    $('.topline td,.topline th').css('background-position','center center');
    $('.topline').find('th:first').css('background-position','left center');
    $('.topline').find('td:first').css('background-position','left center');
    $('.topline').find('th:last').css('background-position','right center');
    $('.topline').find('td:last').css('background-position','right center');

  });
