/* Minification failed. Returning unminified contents.
(2,13): run-time error CSS1031: Expected selector, found ';'
(2,13): run-time error CSS1025: Expected comma or open brace, found ';'
(14,1): run-time error CSS1019: Unexpected token, found '$'
(14,2): run-time error CSS1019: Unexpected token, found '('
(14,11): run-time error CSS1031: Expected selector, found ')'
(14,11): run-time error CSS1025: Expected comma or open brace, found ')'
(30,2): run-time error CSS1019: Unexpected token, found ')'
(32,10): run-time error CSS1031: Expected selector, found 'isDiscountValid('
(32,10): run-time error CSS1025: Expected comma or open brace, found 'isDiscountValid('
(47,1): run-time error CSS1019: Unexpected token, found '$'
(47,2): run-time error CSS1019: Unexpected token, found '('
(47,11): run-time error CSS1031: Expected selector, found ')'
(47,11): run-time error CSS1025: Expected comma or open brace, found ')'
(115,2): run-time error CSS1019: Unexpected token, found ')'
(118,10): run-time error CSS1031: Expected selector, found 'iFacRglCallback('
(118,10): run-time error CSS1025: Expected comma or open brace, found 'iFacRglCallback('
(131,10): run-time error CSS1031: Expected selector, found 'sShoppingBagCallback('
(131,10): run-time error CSS1025: Expected comma or open brace, found 'sShoppingBagCallback('
(140,21): run-time error CSS1031: Expected selector, found ';'
(140,21): run-time error CSS1025: Expected comma or open brace, found ';'
(141,1): run-time error CSS1019: Unexpected token, found 'jQuery('
(141,16): run-time error CSS1031: Expected selector, found ')'
(141,16): run-time error CSS1025: Expected comma or open brace, found ')'
(224,2): run-time error CSS1019: Unexpected token, found ')'
(226,10): run-time error CSS1031: Expected selector, found 'dFacRglCallback('
(226,10): run-time error CSS1025: Expected comma or open brace, found 'dFacRglCallback('
(246,10): run-time error CSS1031: Expected selector, found 'uFacRglCallback('
(246,10): run-time error CSS1025: Expected comma or open brace, found 'uFacRglCallback('
(259,10): run-time error CSS1031: Expected selector, found 'RefreshWinkelwagenCallback('
(259,10): run-time error CSS1025: Expected comma or open brace, found 'RefreshWinkelwagenCallback('
 */
var elem,
    newValue;

//$(document).load(function (e) {

//    if ($(".IfLarger").length) {
//        if ($(".display").height() > $(window).height()) {
//            $(".IfLarger").addClass("static");
//        }
//    }

//});

$(document).ready(function () {

    if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
        var a = 3;
        $(".txtQuantity").css("top", -a);
    }

    if (navigator.platform.indexOf('Mac') > -1) {
        var a = 0;
        $(".txtQuantity").css("top", -a);
    }


    var odata = {
    }
    AjaxRequest("POST", "/Winkelwagen.aspx/RefreshWinkelwagen", odata, "", "json", "RefreshWinkelwagenCallback");
});

function isDiscountValid() {
    var fv = $('.divGlobalForm').data('formValidation');
    var bOk = true;

    fv.revalidateField('ctl00$ContentPlaceHolder1$txtKortingscode');

    if (fv.isValidField('ctl00$ContentPlaceHolder1$txtKortingscode') === false) {
        bOk = false;
    }

    if (bOk) {
        __doPostBack('ctl00$ContentPlaceHolder1$btnKortingscode', '')
    }
}

$(document).ready(function () {

    $(".toggle").on("click touch", function (e) {

        var parent = $(this).parents(".drop")

        if (parent.hasClass("rel")) {
            var height = 0;
            parent.find(".item").each(function (e) {
                height = height + 200;
            });
        } else {
            var height = 200;
        }

        if (parent.hasClass("active")) {
            parent.removeClass("active");
            parent.find(".content").css("height", 0);
        } else {
            //$(".content").css("height", 0);
            //$(".drop").removeClass("active");
            parent.addClass("active")
            parent.find(".content").css("height", height);
        }

    });

    //$(window).on("click touch", function (evt) {
    //    if (evt.target.id == "toggle")
    //        return;

    //    if ($(evt.target).closest('.toggle').length)
    //        return;

    //    if (evt.target.id == "drop")
    //        return;

    //    if ($(evt.target).closest('.drop').length)
    //        return;

    //    $(".drop").removeClass("active");
    //    $(".content").css("height", 0);
    //});


    $('.aProductLink').click(function () {
        var odata = {
            iArtikelID: $(this).parent(".divItem").data("artikel-id"),
            iArtikelVariantID: $(this).parent(".divItem").data("variant-id"),
            iAantal: 1
        }
        AjaxRequest("POST", "/Data/shopping-cart.aspx/iFacRgl", odata, "", "json", "iFacRglCallback");
    });

    $('.aProductLinkFavo').click(function () {
        var Aantal = $(this).parent().find("#qtyInput2").val();
        if (parseInt(Aantal) == "NaN") {
            Aantal = 1
        } else if (Aantal < 1) {
            Aantal = 1
        }
        var odata = {
            iArtikelID: $(this).data("id"),
            iArtikelVariantID: $(this).data("variant-id"),
            iAantal: Aantal
        };
        AjaxRequest("POST", "/Data/shopping-cart.aspx/iFacRgl", odata, "", "json", "iFacRglCallback");
    });
});


function iFacRglCallback() {
    if (sMsg.d.code === 1) {
        //$('.spanCountProducts').html(sMsg.d.aantal);

        //AjaxRequest("POST", "/Data/shopping-cart.aspx", "", "", "html", "sShoppingBagCallback");
        location.reload();
        return true;
    } else {
        return false;
    }
}


function sShoppingBagCallback() {
    $('.divCartHolder').html($('.selector', $(sMsg)));
    $('#divWinkelmandTotal').html($('.selector-price', $(sMsg)).text());
    $('.lblDiscount').html($('.selector-discount', $(sMsg)).text());
    $('.lblTotalExcl').html($('.selector-subtotal', $(sMsg)).text());

    $('.liCart').addClass('show');
}

var newValue, target;
jQuery(document).ready(function () {

    $("#txtQuantity").keydown(function (e) {
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
            (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
            (e.keyCode >= 35 && e.keyCode <= 40)) {
            return;
        }
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    });

    $('#txtQuantity').keyup(function () {
        if ($(this).val() == '')
            $(this).val(0);
    });

    $('.aRemoveItem').click(function () {
        target = $(this).parent().parent();
        var odata = {
            iFacRglID: $(this).data('id')
        }
        AjaxRequest("POST", "/Winkelwagen.aspx/dFacRgl", odata, "", "json", "dFacRglCallback");
    });


    $('.txtQtyPlus').on("click touch", function (e) {
        e.preventDefault();

        target = $(this).parent(".Qty").find(".txtQuantity");

        var currentVal = parseInt(target.val());
        target.val(currentVal + 1);
        newValue = currentVal + 1;
        var odata = {
            iFacRglID: $(this).data('id'),
            iAantal: newValue
        }
        AjaxRequest("POST", "/Winkelwagen.aspx/uFacRgl", odata, "", "json", "uFacRglCallback");
    });

    $(".txtQtyMin").on("click touch", function (e) {
        e.preventDefault();
        target = $(this).parent(".Qty").find(".txtQuantity");
        var currentVal = parseInt(target.val());
        if (currentVal === 1) {
            return false;
        }
        if (currentVal === 0) {
            target.val(0);
        } else {
            target.val(currentVal - 1);
            newValue = currentVal - 1;
            var odata = {
                iFacRglID: $(this).data('id'),
                iAantal: newValue
            }
            AjaxRequest("POST", "/Winkelwagen.aspx/uFacRgl", odata, "", "json", "uFacRglCallback");
        }
    });
    $(".txtQuantity").on("blur", function (e) {
        e.preventDefault();
        target = $(this).parent(".Qty").find(".txtQuantity");
        var currentVal = parseInt(target.val());
        if (currentVal <= 0) {
            var odata = {
                iFacRglID: $(this).data('id')
            }
            AjaxRequest("POST", "/Winkelwagen.aspx/dFacRgl", odata, "", "json", "dFacRglCallback");
            return false;
        } else {
            target.val(currentVal);
            newValue = currentVal;
            
            var odata = {
                iFacRglID: $(this).data('id'),
                iAantal: newValue
            }
            console.log(odata);
            AjaxRequest("POST", "/Winkelwagen.aspx/uFacRgl", odata, "", "json", "uFacRglCallback");
        }
    });
});

function dFacRglCallback() {
    console.log(sMsg);
    $('.lblTotalExcl .right').html("&euro; " + sMsg.d.totaalExcl.replace(".",","));
    $('#divWinkelmandTotal .right').html("&euro; " + sMsg.d.totaalExcl.replace(".", ","));

    
    //$('.lblVat').html(msg.d.btw);
    $('.lblTotalIncl .right').html("&euro; " + sMsg.d.totaalIncl.replace(".", ","));
    $('.lblDiscount .right').html("&euro; " + sMsg.d.korting.replace(".", ","));
    $('.spanCountProducts').html(sMsg.d.aantal);
    $(target.parent().parent()).fadeOut('fast');
    if (sMsg.d.aantal === "0") {
        $(".spanInfo").show();
        $(".btnCheckout").hide();
        $("#divVerzendkosten1").hide();
        $("#divVerzendkosten2").hide();
        $("#divVerzendkosten3").hide();
    }
}

function uFacRglCallback() {
    $('.lblTotalExcl .right').html(sMsg.d.totaalExcl.replace(".", ","));
    //$('.lblVat').html(msg.d.btw);
    $('.lblTotalIncl .right').html(sMsg.d.totaalIncl.replace(".", ","));
    $('.lblDiscount .right').html(sMsg.d.korting.replace(".", ","));
    $('.spanCountProducts').html(sMsg.d.aantal);
    console.log(sMsg.d.bedragregel);
    console.log($(target).parent().parent().parent().find(".total"));
    //console.log($(target).parent().parent(".right").find(".total"));
    $(target).parent().parent().parent().find(".total").html(sMsg.d.bedragregel);
    $("#divWinkelmandTotal .right").html(sMsg.d.totaalIncl.replace(".", ","));
    //$(elem).parent().find(".spanQty").text(sMsg.d.aantal);
}
function RefreshWinkelwagenCallback() {
    $('.spanCountProducts').html(sMsg.d.aantal);
    $("#divWinkelmandTotal .right").html(sMsg.d.totaalIncl.replace(".", ","));
}

