
/*
 * Trigger when the DOM is loaded
 */
$(document).ready(function() {
  
  /*
   * Datepicker activation for multiple datepickers (class instead of id)
   */
  $(".datepicker" ).datepicker({dateFormat: 'yy-mm-dd'});
  
	/* tabs
	---------------------------------------------------------- */
  fx_tabs.initTabs();
	/* end tabs
	---------------------------------------------------------- */
  
  /*****************************************************************************
   * guestbook / testimonials
   ****************************************************************************/
  $("#guestbook_add_form").hide();
  $("#show_guestbook_add_form a").click(function(event) {
    event.preventDefault();
    $("#guestbook_add_form").slideDown('slow');
    $("#show_guestbook_add_form").slideUp('slow');
  });
  /*****************************************************************************
   * end guestbook / testimonials
   ****************************************************************************/
});

/*
 * Trigger when all objects are loaded
 */
$(window).load(function() {
  // start slideshow
  $("#slideshow").slideShow({"title": "Perol Chico Ranch - Sacred Valley of the Incas - Cusco, Peru", "total": 6, "duration": 8000, "speed": 2000});
});

/*
 * tabs functions
 */
var fx_tabs = {
    "initTabs" : function() {
        var tabContainers = $('div.tabs > section');

        $(window).bind('hashchange', function () {
          var hash = window.location.hash || '#itinerary';
          //var hashtab = hash + '_tab';

          /*
          tabContainers.hide();
          tabContainers.filter(hash).fadeIn();
          */
          tabContainers.addClass('hidden');
          tabContainers.filter(hash).removeClass('hidden');
          $('.tabs .tab_navigation a').removeClass('selected');
          $('a[hash=' + hash + ']').addClass('selected');
        });

        $(window).trigger("hashchange");
    }
}


/* Google Analytics */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20712333-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);

(function() {
  var ga = document.createElement('script');ga.type = 'text/javascript';ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga, s);
})();
  
