var slideshowPlay = true;
$(function() {
  // homepage slideshow
  var slideshow = $("#slideshow-tabs");
  if (slideshow.length) {
    slideshow.tabs("#slideshow > img", {
      effect: "fade",
      fadeOutSpeed: "slow",
      rotate: "true"
    }).slideshow({clickable: false});
    slideshow.tabs().play();
  }

  $("#slideshow-wrapper button.pause").click(function() {
    $(this).addClass("inactive");
    $("#slideshow-wrapper button.play").removeClass("inactive");
    $("#slideshow-tabs").tabs().stop();
  });

  $("#slideshow > img").click(function() {
    var api = $("#slideshow-tabs").tabs();
    if (slideshowPlay) api.stop();
    else               api.play();
    slideshowPlay = !slideshowPlay;
  });

  if ($("#flowplayer").length) {
    var player = $f("flowplayer", "/static/flowplayer/flowplayer.swf");
  }
  $("#welcome-video-button").overlay({
    top: "center",
    expose: {
      color: "#333",
      loadSpeed: 200,
      opacity: 0.9,
      onLoad: function() {
        player.load();
      },
      onClose: function() {
        player.close();
      }
    }
  });
});

