$(document).ready(function() {


  // Make the admin tabs disappear on mousing over the main content
  $("#site-body .tabs.primary").css('display', 'none')
  $("#site-body").hover(
    function() {
      $(".tabs.primary").slideDown('fast');
    },
    function() {
      $(".tabs.primary").slideUp('fast');
    }
  );

  // Initialise the scrolling guide box on the homepage
  $("div#homepage-guide-box").scrollable({size: 1}).navigator().autoscroll({autoplay: true, interval: 7000}).circular();

  // This sets up the news ticker under the main navigation, I'm guessing.
  var options = {
    newsList: '#news-ticker',
    startDelay: 10,
    tickerRate: 40,
    placeHolder1: '_',
    controls: false
  }
  $().newsTicker(options);

  $('#edit-name').placeholder({ message: 'Username' });

  // Initialize the stock ticker
  $(function(){
    $("ul#stock-ticker").liScroll({travelocity: 0.05});
  });

  // Set up cluetip
  $('.has-events .event-link').each(function (i) {
    $(this).cluetip({local:true, tracking: true});
  });
  $('#homepage-latestnews .story-link').each(function (i) {
    $(this).cluetip({local:true, tracking: true});
  });

  // Controls the hiding and display of the most read/most commented panels
  $("#tab-mostcommented").click(function () {
    $("#topstories-list, #forum-list").hide();
    $("#commented-list").fadeIn();
    $(this).addClass("active");
    $("#tab-mostread, #tab-forum").removeClass("active");
    return false;
  });

  $("#tab-mostread").click(function () {
    $("#commented-list, #forum-list").hide();
    $("#topstories-list").fadeIn();
    $(this).addClass("active");
    $("#tab-mostcommented, #tab-forum").removeClass("active");
    return false;
  });

  $("#tab-forum").click(function () {
    $("#topstories-list, #commented-list").hide();
    $("#forum-list").fadeIn();
    $(this).addClass("active");
    $("#tab-mostcommented, #tab-mostread").removeClass("active");
    return false;
  });

  // Controls the hiding and display of the tools panels
  $("#tools-tab-wfw").click(function () {
    $("#seatplans-block, #currency-block").hide();
    $("#flightsearch-block").fadeIn();
    $(this).addClass("active");
    $("#tools-tab-currency, #tools-tab-seats").removeClass("active");
    return false;
  });

  $("#tools-tab-currency").click(function () {
    $("#flightsearch-block, #seatplans-block").hide();
    $("#currency-block").fadeIn();
    $(this).addClass("active");
    $("#tools-tab-seats, #tools-tab-wfw").removeClass("active");
    return false;
  });

  $("#tools-tab-seats").click(function () {
    $("#currency-block, #flightsearch-block").hide();
    $("#seatplans-block").fadeIn();
    $(this).addClass("active");
    $("#tools-tab-currency, #tools-tab-wfw").removeClass("active");
    return false;
  });

  // Start up hovertips for glossary terms.
  $(".glossary-term").hovertip();
});










