﻿/// <reference path="jquery-1.3.2.js" />
/// <reference path="player/wmvplayer.js" />

// Constants
var PLAYER_TOOLBAR_HEIGHT = 20;
var PLAYER_XAML = '/Scripts/player/wmvplayer.xaml';

// Initialize
$(document).ready(function() {
    // Movie listing hover effect
    $(".movie").hover(
        function() { $(this).toggleClass("hover") },
        function() { $(this).toggleClass("hover") });

    // Smart grid hover effect
    $(".smartgrid tr:even").each(function() { $(this).addClass("row-1") });
    $(".smartgrid tr:odd").each(function() { $(this).addClass("row-2") });
    $(".smartgrid tr").hover(
        function() { $(this).toggleClass("hover") },
        function() { $(this).toggleClass("hover") });

    // Player
    $(".s-player").each(function() {
        // Increase height to accommodate player navigation
        $(this).height($(this).height() + PLAYER_TOOLBAR_HEIGHT);

        // Create player
        var jwp = new jeroenwijering.Player(this, PLAYER_XAML, {
            file: $(this).attr('href'),
            width: $(this).width(),
            height: $(this).height()
        });
    });
});

// Tab management
function SetTabByIndex(tabIndex) {
    $(document).ready(function() {
        $(".menu").addClass("tab" + tabIndex);
        $(".content").addClass("tab" + tabIndex);
        $(".footer").addClass("tab" + tabIndex);
    });
}

function SetTabByCode(movieCode) {
    if (movieCode.match("^X")) SetTabByIndex(2);
    if (movieCode.match("^LP")) SetTabByIndex(3);
    if (movieCode.match("^DIR")) SetTabByIndex(3);
    if (movieCode.match("^DRM")) SetTabByIndex(4);
    if (movieCode.match("^RGE")) SetTabByIndex(5);
}