﻿$(document).ready(function()
{

    $(".dropdown dt a").click(function()
    {
        $(".dropdown dd ul").toggle();
        return false;
    });

    $(".dropdown dd ul li a").click(function()
    {
        var text = $(this).html();
        $(".dropdown dt a span").html(text);
        $(".dropdown dd ul").hide();
        UpdateVisibleToolbox();
        return false;
    });

    function DropDownGetSelectedValue(id)
    {
        return $("#" + id).find("dt a span.value").html();
    }

    $(document).bind('click', function(e)
    {
        var $clicked = $(e.target);
        if (!$clicked.parents().hasClass("dropdown"))
            $(".dropdown dd ul").hide();
    });

    function UpdateVisibleToolbox()
    {
        //var selectedValue = $("#ddToolboxSelect").val();
        var selectedValue = DropDownGetSelectedValue("ddToolboxSelect2");
        //alert("selected value: " + selectedValue);
        if (selectedValue == "Standard")
        {
            $("#toolsStandard").show();
            $("#toolsFourthOfJuly").hide();
            $("#toolsHalloween").hide();
            $("#toolsThanksgiving").hide();
            $("#toolsChristmas").hide();
        }
        else if (selectedValue == "FourthOfJuly")
        {
            $("#toolsStandard").hide();
            $("#toolsFourthOfJuly").show();
            $("#toolsHalloween").hide();
            $("#toolsThanksgiving").hide();
            $("#toolsChristmas").hide();
        }
        else if (selectedValue == "Halloween")
        {
            $("#toolsStandard").hide();
            $("#toolsFourthOfJuly").hide();
            $("#toolsHalloween").show();
            $("#toolsThanksgiving").hide();
            $("#toolsChristmas").hide();
        }
        else if (selectedValue == "Thanksgiving")
        {
            $("#toolsStandard").hide();
            $("#toolsFourthOfJuly").hide();
            $("#toolsHalloween").hide();
            $("#toolsThanksgiving").show();
            $("#toolsChristmas").hide();
        }
        else if (selectedValue == "Christmas")
        {
            $("#toolsStandard").hide();
            $("#toolsFourthOfJuly").hide();
            $("#toolsHalloween").hide();
            $("#toolsThanksgiving").hide();
            $("#toolsChristmas").show();
        }
    }

    //UpdateVisibleToolbox();

});

