$(document).ready(function() {
    HandleWineCard();
});

function HandleWineCard()
{
    if ($("div.container_winecatalog").length)
    {
        // Test if we have to hide the elements
        if($.cookie('kogs_wine_hide') == null || $.cookie('kogs_wine_hide') == "true")
        {
            HideElements();
            $("input#chkwinecatalog").attr('checked', false);
        }
        else
        {
            ShowElements();
            $("input#chkwinecatalog").attr('checked', true);
        }


        $("input#chkwinecatalog").click(
            function () {
                if ($(this).is(":checked"))
                {
                    $.cookie('kogs_wine_hide', "false");
                    ShowElements();
                }
                else
                {
                    $.cookie('kogs_wine_hide', "true");
                    HideElements();
                }
            }
        );
    }
}

function HideElements()
{
    /* WineCatalog fields */
    $("table#FavoriteList .fav_col_glass_price").hide();
    $("table#FavoriteList .fav_col_half_bottle_price").hide();
    $("table#FavoriteList .fav_col_full_bottle_price").hide();

    /* Favorit fields */
    $("table#FavoriteList .fav_col_unitsperparcel").show();
    $("table#FavoriteList .fav_col_quantity").show();                
    $("table#FavoriteList .fav_col_delete").show();

    /* Favorit btn fields */
    $("div#btn_action_container").show();

    /* wine catalog panel */
    $("div#divWineCatalog").hide(); 
    $("div.container_winecatalog input.BtnC").hide();   
}
function ShowElements()
{
    /* WineCatalog fields */
    $("table#FavoriteList .fav_col_glass_price").show();
    $("table#FavoriteList .fav_col_half_bottle_price").show();
    $("table#FavoriteList .fav_col_full_bottle_price").show();
    
    /* Favorit fields */
    $("table#FavoriteList .fav_col_unitsperparcel").hide();
    $("table#FavoriteList .fav_col_quantity").hide();
    $("table#FavoriteList .fav_col_delete").hide();
    
    /* Favorit btn fields */
    $("div#btn_action_container").hide();
    
    /* wine catalog panel */
    $("div#divWineCatalog").show();
    $("div.container_winecatalog input.BtnC").show();
}

