
  var menuwidth=0;
  var footerwidth=0;
	var slidespeed=5000;
	var maxfoto=0;
	var maxhp=0;

	function slideimages(selector){
		pocet=$(selector).size();
		actimg=$(selector).index($(selector+':visible:first'));
		actimg=(actimg+1)%pocet;
		if (pocet>1){
			$(selector).fadeOut('slow');
			$(selector+':eq('+actimg+')').fadeIn('slow');
			$('#topbannerlink').attr('href', $(selector+':eq('+actimg+')').parent().attr('href'));
			setTimeout("slideimages('"+selector+"')",slidespeed);
		}
	}

  $(document).ready(function(){
    var map_reloaded = 0;
	$('.tab-content iframe').load(function(){
      //$(this).attr('src',$(this).attr('src'));
	  //$(this).unbind('load');
    });  
	$('#topbannerlink').attr('href', $('#headerimg img:visible:first').parent().attr('href'));
  
    $('img').closest('a[href$=jpg]').lightbox();
    $("#menu>li").map(function(){
      menuwidth+=$(this).width();
    });
    $('#menu').css('padding-left',Math.round((861-menuwidth)/2)+'px');
    $('#footer ul>li').map(function(){
      footerwidth+=$(this).width();
    });
    $('#footer ul').css('margin-left','-'+(footerwidth/2)+'px');
    $('#headerimg img').map(function(){
      maxfoto=Math.max(maxfoto,$(this).height());
    });
    $('#headerimg').height(maxfoto);
    
    $('#tabs').hide();
    maxheight=Math.max($('#leftcol').height(),$('#rightcol').height());
    $('#tabs').show();
    $('#tabs>div').map(function(){
      $('#tabs>div').hide();
      $(this).show();
      maxheight=Math.max(maxheight,$('#rightcol').height()+20);
    });
	
    if (!$('#homepage').size()){
        $('#content').height(Math.max(maxheight+maxfoto+36+10,$(window).height()-211));
    } else {
        $('#content').height(Math.max($('#col1').height(),$('#col2').height(),$('#col3').height())+maxfoto+36);
    }
      $('#headerimg img:not(:first)').hide();
      setTimeout("slideimages('#headerimg img')",slidespeed);
    $('#tablist a').each(function() {
		$(this).attr('href', document.location.pathname+'#'+$(this).html());
	});
	
    $('#tablist a').click(function(){
      $('#tablist li').attr('class','noactive');
      $(this).closest('li').attr('class','active');
      $('#tabs>div').hide();
      $('#tabs>div:eq('+$('#tablist a').index(this)+')').show();
    });
    $('#tabs>div:not(:first)').hide();
    $('#tabs>div:first').show();
    $('#tablist li:first').attr('class','active');
    $('#col1,#col2,#col3').map(function(){
      maxhp=Math.max(maxhp,$(this).height());								
    });
    $('#col1,#col2,#col3').height(maxhp);

	$('#tablist li a').each(function() {
		if('#' + $(this).html() == document.location.hash) {
			$('#tablist li').attr('class','noactive');
			$(this).parent().attr('class','active');
			$('#tabs>div').hide();
			$('#tabs>div:eq('+$('#tablist a').index(this)+')').show();			
		}
	});
	
	$('.leftbox form.reserv select').change(function() {
		$('.leftbox form.reserv').attr('action', resorts_url[$(this).val()]+'#Enquiries');
	});
});
