﻿
    $(document).ready(function () {

        $(".hideVideoThumbnail").live("click", function (e) {
            $(".videoThumbnailOverlay").hide(0);
            $(".videoStreamer").show(0);
        });

        $(".hideCaption").live("click", function (e) {
            $(".caption").hide(0);
        });

        $(".tabContent").live("click", function (f) {
            $(".homeTabs li").removeClass("current");
            $(this).parent().addClass("current");
            $(".mediaContent").hide();
            $(".caption").hide();
            $(".videoStreamer").hide();
            $(".videoThumbnailOverlay").show();
            $(this).siblings(".mediaContent").show();
            $(this).siblings(".mediaContent").children(".caption").show()

            try {
                //Note the first call to stop the video fails (hence the try/catch) becuase it hasn't loaded yet
                var players = $(".videoPlayer");
                $.each(players, function (v, x) {
                    var flash = document.getElementById(x.id);
                    flash.sendToActionscript();
                });
            } catch (e) {
                //writeDebugObject(e);
            }
        });

        //Setup everything as though we had clicked Tab 0
        $(".tabContent.0").click();
//        //Then make it look unselected
//        $(".homeTabs li").removeClass("current");

        window.setInterval(function() {
         selectNextWelcomeTab();
        }, 5000);

    });

    // Tab cycling.
    var currentTab = 0;
    function selectNextWelcomeTab(){
      currentTab++;
      if (currentTab > 2)
        currentTab = 0;
      $(".tabContent." + currentTab).click();
    }

