﻿$(document).ready(function ()
{

    $(".fancybox").fancybox();
    LoadCalendar(0, 0);
    SetLeftHeight();
});

function SetLeftHeight()
{
    var total = 0;

    $(".intextsub").each(function ()
    {
        total += $(this).height();
    });

    total += 200;
    if (total > 600)
        $("#leftcontent").css("min-height", total + "px");
}

function TogglePlayerDetails(id)
{
    if ($("#player_" + id).css("display") == "none")
    {
        HideOpenPlayers();

        $("#player_" + id).show();
        
        SlideItDown("#player_" + id + " th div");
        
    }
    else
    {
        $("#player_" + id + " th div").slideUp(function () { HidePlayerRow(id) });
    }
}
function HidePlayerRow(id)
{
    $("#player_" + id).hide();
    
}

function HideOpenPlayers()
{
    $(".playerRow").each(function ()
    {
        if ($(this).css("display") != "none")
        {
            var theId = $(this).attr("playerId");

            $("#player_" + theId +" th div").slideUp(function () { HidePlayerRow(theId); });
        }
    });
}
function getIEVersionNumber()
{
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");

    if (MSIEOffset == -1)
    {
        return 0;
    } else
    {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}

function SlideItDown(selector)
{
    var ieVersion = getIEVersionNumber();


    if (ieVersion == 0 || ieVersion > 7)
    {

        $(selector).slideDown();
    }
    else
    {
        $(selector).show();
    }
}

function LoadCalendar(theMonth, theYear)
{
    var oParams = {};
    oParams["month"] = theMonth;
    oParams["year"] = theYear;

    $.post("Getters/Calendar/LoadCalendar.aspx", oParams, function (result)
    {
        $("#divCalendar").html(result);
    });

}
