/* OVLADANI SLIDERU */
function mycarousel_initCallback(carousel) {
  jQuery('.slider .controls .circle a').bind('click', function() {
    carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
    return false;
  });
  jQuery('.slider-next a').bind('click', function() {
    carousel.next();
    return false;
  });
  jQuery('.slider-prev a').bind('click', function() {
    carousel.prev();
    return false;
  });
};

/* SUPERBOX */
jQuery(function() {
  jQuery.superbox.settings = {
    closeTxt: "Close",
    loadTxt: "Loading...",
    nextTxt: "Next",
    prevTxt: "Previous"
  };
  jQuery.superbox();
});


jQuery(document).ready(function() {
  // ROZBALOVACI
	jQuery(".toggle-container").hide();
	jQuery(".trigger").click(function() {
	});

  // INICIALIZACE SLIDERU
  jQuery(".slider .content").jcarousel({
    scroll: 1,
    auto: 4,
    wrap: 'last',
    animation: 1500,
    initCallback: mycarousel_initCallback,
    buttonNextHTML: null,
    buttonPrevHTML: null,
    start: 1
  });

  // FANCYBOX
  jQuery("a.fancy").fancybox({
    'opacity'		: true,
    'overlayShow'	: false,
    'transitionIn'	: 'opacity',
    'transitionOut'	: 'opacity'
  });
  jQuery("a[rel=fancy-gallery]").fancybox({
    'transitionIn'		: 'opacity',
    'transitionOut'		: 'opacity',
    'titlePosition' 	: 'over',
    'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
      return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    }
  });

  // TABY
  jQuery(".tab-content").hide();
  jQuery(".nav li:first").addClass("ac").show();
  jQuery(".tab-content:first").show();
  jQuery(".nav li").click(function() {
    jQuery(".nav li").removeClass("ac");
    jQuery(this).addClass("ac");
    jQuery(".tab-content").hide();
    var activeTab = jQuery(this).find("a").attr("href");
    jQuery(activeTab).fadeIn();
    return false;
  });

  // TABY - DOMY
  jQuery(".tab-middle").hide();
  if (document.location.toString().match('#')) jQuery( '#' + document.location.toString().split('#')[1] ).parent().show();
  else {
    jQuery(".hs li:first").addClass("ac").show();
    jQuery(".tab-middle:first").show();
  }

  jQuery(".hs li").click(function() {
    jQuery(".hs li").removeClass("ac");
    jQuery(this).addClass("ac");
    jQuery(".tab-middle").hide();
    var activeTab = jQuery(this).find("a").attr("href");

    jQuery(activeTab + " .nav2 li").removeClass("ac");
    jQuery(activeTab + " .sec-tab-content").hide();
    jQuery(activeTab + ' .nav2 li:first').addClass("ac").show();
    jQuery(activeTab + " .sec-tab-content:first").show();

    jQuery(activeTab).fadeIn();
    return false;
  });

  // TABY - PODLAZI
  jQuery(".sec-tab-content").hide();
  jQuery(".nav2 li:first").addClass("ac").show();
  jQuery(".sec-tab-content:first").show();
  jQuery(".nav2 li").click(function() {
    jQuery(".nav2 li").removeClass("ac");
    jQuery(this).addClass("ac");
    jQuery(".sec-tab-content").hide();
    var activeTab = jQuery(this).find("a").attr("href");
    jQuery(activeTab).fadeIn();
    return false;
  });









  /*
  jQuery('#tabs1').tabs({ fxFade:true, remote:false });
  jQuery('#tabs1 .nav').find('li.tabs-selected').addClass('ac');
  jQuery('#tabs1 .nav li a').click(function() {
    jQuery('#tabs1 .nav li').removeClass('ac');
    jQuery(this).parent().addClass('ac');
  });

  jQuery('#tabs-second').tabs({ fxFade:true, remote:false });
  jQuery('#tabs-second .nav2').find('li.tabs-selected').addClass('ac');
  jQuery('#tabs-second .nav2 li a').click(function() {
    jQuery('#tabs-second .nav2 li').removeClass('ac');
    jQuery(this).parent().addClass('ac');
  });
  */
  


  jQuery('a[href*=#]').click(function(e) {
    var activeTab = this.hash;
    jQuery('.nav li').each(function() {
      if (
        activeTab==jQuery(this).children('a').attr('href') && (
        location.pathname=='/bydleni' ||
        location.pathname=='/ubytovani-a-sluzby' ||
        location.pathname=='/www.farskeluky.cz/bydleni' ||
        location.pathname=='/www.farskeluky.cz/ubytovani-a-sluzby'
      )) jQuery(this).click();
    })
    if (
      location.pathname==this.pathname
      && !jQuery(this).parent().parent().hasClass('apar')
      && !jQuery(this).parent().parent().parent().parent().parent().parent().hasClass('apar')
    ) {
      e.preventDefault();
      window.location.hash = this.hash;
    }
  });
  if (document.location.toString().match('#')) {
    var anchor = '#' + document.location.toString().split('#')[1];
    if (
      anchor=='#pronajem-apartmanu-informace' ||
      anchor=='#pronajem-apartmanu-nabidka' ||
      anchor=='#pronajem-apartmanu-cenik' ||
      anchor=='#pronajem-apartmanu-rezervace' ||
      anchor=='#pronajem-apartmanu-stravovani'
    ) {
      jQuery('a[href="#pronajem-apartmanu"]').click();
      jQuery('a[href="' + anchor + '"]').click();

    } else if (
      anchor=='#jidelni-listek-predkrmy' ||
      anchor=='#jidelni-listek-polevky' ||
      anchor=='#jidelni-listek-salaty' ||
      anchor=='#jidelni-listek-testoviny-rizota' ||
      anchor=='#jidelni-listek-pizza' ||
      anchor=='#jidelni-listek-masa-ryby' ||
      anchor=='#jidelni-listek-gril' ||
      anchor=='#jidelni-listek-prilohy' ||
      anchor=='#jidelni-listek-dezerty'
    ) {
      jQuery('a[href="#jidelni-listek"]').click();
      jQuery('a[href="' + anchor + '"]').click();
    } else jQuery('a[href="' + anchor + '"]').click();
  }

});
