﻿var fHeight = 150;

$(document).ready(function ()
{
    /*
    if ($(pFilter).height() == fHeight)
    {
    $("#pFilterBottom").show();
    $(pFilter).loader({ action: "show" });
    MrCode.Epos.Web.Store.StoreWS.ActivateFilter(CategoryId, Lang, succCategory, errCategory);
    }*/

});

var animatePending = 0;
function activateFilter()
{
    $(deactFilter).show();
    $(actFilter).hide();
    $("#pFilterBottom").show();
    MrCode.Epos.Web.Store.StoreWS.ActivateFilter(CategoryId, Lang, succCategory, errCategory);
    animatePending = 1;
    $(pFilter).animate({ height: 30 }, "slow", function ()
    {
        if (animatePending == 1) $(pFilter).loader({ action: "show" });
    });
}


function deactivateFilter()
{
    $(actFilter).show();
    $(deactFilter).hide();
    $("#pFilterBottom").hide();
    MrCode.Epos.Web.Store.StoreWS.DeactivateFilter();
    //$(pFilter).animate({ height: 0 }, "slow");
    window.location.reload();
}

function filterSend()
{
    var data = "m:" + $(".filtM").val() + "|p1:" + $(".filtP1").val() + "|p2:" + $(".filtP2").val() + "|mName:" + $(".filtM :selected").html();
    MrCode.Epos.Web.Store.StoreWS.SaveFilter(data, succFilter, errCategory);
}

function succFilter(res)
{
    if (res == "")
    {
        window.location.reload();
    }
}

function succCategory(res)
{
    animatePending = 0;
    $(pFilter).loader({ action: "hide" });
    $("#pFilterContent").html(res);
    if ($("#pFilterContent").height() < fHeight)
    {
        $(pFilter).animate({ height: $("#pFilterContent").height() + 10 }, "slow");
    }
}

function errCategory(error)
{
    alert(error.get_message());
}

function filterChanged()
{
    /*
    var data = "m:" + $(".filtM").val();



    $("#filterHf").val(data);
    */
}

