/* Minification failed. Returning unminified contents.
(1,1): run-time error CSS1019: Unexpected token, found '$'
(1,2): run-time error CSS1019: Unexpected token, found '('
(1,12): run-time error CSS1031: Expected selector, found '('
(1,12): run-time error CSS1025: Expected comma or open brace, found '('
(69,2): run-time error CSS1019: Unexpected token, found ')'
(72,10): run-time error CSS1031: Expected selector, found 'GetLeftTotal('
(72,10): run-time error CSS1025: Expected comma or open brace, found 'GetLeftTotal('
(78,10): run-time error CSS1031: Expected selector, found 'GetBasketCount('
(78,10): run-time error CSS1025: Expected comma or open brace, found 'GetBasketCount('
(89,1): run-time error CSS1019: Unexpected token, found 'GetBasketCount('
(89,16): run-time error CSS1019: Unexpected token, found ')'
(93,10): run-time error CSS1031: Expected selector, found 'BJLoading('
(93,10): run-time error CSS1025: Expected comma or open brace, found 'BJLoading('
(144,10): run-time error CSS1031: Expected selector, found 'BJShowMsg('
(144,10): run-time error CSS1025: Expected comma or open brace, found 'BJShowMsg('
(173,10): run-time error CSS1031: Expected selector, found 'ChaneUrl('
(173,10): run-time error CSS1025: Expected comma or open brace, found 'ChaneUrl('
(190,1): run-time error CSS1019: Unexpected token, found '$'
(190,2): run-time error CSS1019: Unexpected token, found '('
(190,3): run-time error CSS1019: Unexpected token, found '"[data-showloding]"'
(190,22): run-time error CSS1019: Unexpected token, found ')'
(190,24): run-time error CSS1030: Expected identifier, found 'click('
(190,24): run-time error CSS1019: Unexpected token, found 'click('
(190,39): run-time error CSS1031: Expected selector, found '('
(190,39): run-time error CSS1025: Expected comma or open brace, found '('
(192,2): run-time error CSS1019: Unexpected token, found ')'
(194,10): run-time error CSS1031: Expected selector, found 'LoadingBar('
(194,10): run-time error CSS1025: Expected comma or open brace, found 'LoadingBar('
(206,1): run-time error CSS1019: Unexpected token, found '$'
(206,2): run-time error CSS1019: Unexpected token, found '('
(206,11): run-time error CSS1031: Expected selector, found ')'
(206,11): run-time error CSS1025: Expected comma or open brace, found ')'
(229,2): run-time error CSS1019: Unexpected token, found ')'
(231,1): run-time error CSS1019: Unexpected token, found '$'
(231,2): run-time error CSS1019: Unexpected token, found '('
(231,3): run-time error CSS1019: Unexpected token, found '".btn-search"'
(231,16): run-time error CSS1019: Unexpected token, found ')'
(231,18): run-time error CSS1030: Expected identifier, found 'click('
(231,18): run-time error CSS1019: Unexpected token, found 'click('
(231,33): run-time error CSS1031: Expected selector, found '('
(231,33): run-time error CSS1025: Expected comma or open brace, found '('
(236,2): run-time error CSS1019: Unexpected token, found ')'
(237,1): run-time error CSS1019: Unexpected token, found '$'
(237,2): run-time error CSS1019: Unexpected token, found '('
(237,3): run-time error CSS1019: Unexpected token, found ''.txt-search''
(237,16): run-time error CSS1019: Unexpected token, found ')'
(237,18): run-time error CSS1030: Expected identifier, found 'keyup('
(237,18): run-time error CSS1019: Unexpected token, found 'keyup('
(237,33): run-time error CSS1031: Expected selector, found '('
(237,33): run-time error CSS1025: Expected comma or open brace, found '('
(239,2): run-time error CSS1019: Unexpected token, found ')'
(242,10): run-time error CSS1031: Expected selector, found 'toggleURLParameter('
(242,10): run-time error CSS1025: Expected comma or open brace, found 'toggleURLParameter('
(251,10): run-time error CSS1031: Expected selector, found 'removeURLParameter('
(251,10): run-time error CSS1025: Expected comma or open brace, found 'removeURLParameter('
(273,10): run-time error CSS1031: Expected selector, found 'ChangeUrlParam('
(273,10): run-time error CSS1025: Expected comma or open brace, found 'ChangeUrlParam('
(288,10): run-time error CSS1031: Expected selector, found 'getUrlParameter('
(288,10): run-time error CSS1025: Expected comma or open brace, found 'getUrlParameter('
 */
$(function () {
    $(".tab-main-item").click(function () {
        $(".tab-main-item").removeClass("tab-main-active");
        $(".tab-panel-item").removeClass("tab-panel-active");
        $(this).addClass("tab-main-active");
        var idd = $(this).attr("id").split('-')[1];
        $("#tab-panel-" + idd).addClass("tab-panel-active");
    });

    $(".product-slider").each(function () {
        $("#" + $(this).attr("id")).SliderProduct();
    });

    $("[data-enter]").keypress(function (event) {
        if (event.keyCode === 13) {
            $("#" + $(this).data("enter")).click();
        }
    });
    
    $("[data-popup]").click(function (e) {        
        e.preventDefault();

        var MyModal = $("#myModal");
        var url = $(this).attr("href");
        var size = $(this).data("popup-size");
        var title = $(this).data("popup-title");
        var param = $(this).data("popup-param");

        if (size == "lg") {
            MyModal.addClass("bs-example-modal-lg");
            MyModal.find(".modal-dialog").addClass("modal-lg");
        }
        else if (size == "md") {
            MyModal.addClass("");
            MyModal.find(".modal-dialog").addClass("");
        }
        else if (size == "sm") {
            MyModal.addClass("bs-example-modal-sm");
            MyModal.find(".modal-dialog").addClass("modal-sm");
        }

        var MyModalTitle = MyModal.find('.modal-title');
        var MyModalBody = MyModal.find('.modal-body');
        var MyModalFooter = MyModal.find('.modal-footer');

        MyModalTitle.html(title);

        $.ajax({
            type: "get",
            url: url,
            data: param == "undefined" ? "" : param,
            success: function (response) {
                MyModalBody.html(response);
            }
        });

        MyModal.modal('show');
        MyModal.on('hidden.bs.modal', function (e) {
            MyModalBody.html("<div style=\"width:100%;text-align:center\"><img style=\"width:100px;\" src=\"https://sirius-image.s3.eu-central-1.amazonaws.com/tasarim/loadinicon.gif\" /></div>");
            MyModalTitle.html("");
            MyModalFooter.html("");
        });
    });

    $(".UpArrow").click(function () {
        var body = $("html, body");
        body.stop().animate({ scrollTop: 0 }, '500', 'swing');
    });
});


function GetLeftTotal(stepvalue) {
    $.post("/LeftTotalInfo", { stepv: stepvalue }, function (res) {
        $(".left-totle-info").html(res);
    });
}

function GetBasketCount() {
    $.post("/sepetadet", function (res) {
        if (res.result != 0) {
            $("#basketCount").text(res.result);
        }
        else {
            $("#basketCount").hide();
        }
    });
}

GetBasketCount();



function BJLoading(action, element, size, text) {
    var tool = $(element);  
    if (action) {
        tool.css("position", "relative");
        var bg = $("<div class='LoadingInBg'></div>");
        bg.css({
            'background-color': 'rgba(255, 255, 255, 0.60)',
            'top': '0',
            'left': '0',
            'position': element == 'body' ? 'fixed' : 'absolute',
            'width': '100%',
            'height': '100%',
            'z-index': '999999'
        });

        var gifImage = $("<img style=\"width:100%;\" src=\"https://sirius-image.s3.eu-central-1.amazonaws.com/tasarim/loadinicon.gif\" />");

        var gif = $("<div></div>");
        gif.css({
            'bottom': '0',
            'height': (size != null) ? size.split('x')[0] : 80,
            'width': (size != null) ? size.split('x')[1] : 80,
            'left': '0',
            'margin': 'auto',
            'position': 'absolute',
            'right': '0',
            'top': element == 'body' ? (bg.height() / 2) - gifImage.width() + 'px' : '0',
            'z-index': '2'
        });

        gif.append(gifImage);

        if (text != null) {
            var txt = $("<div></div>");
            txt.css({
                'width': '100%',
                'text-align': 'center',
                'text-shadow': '1px 1px 2px #fff, 1px -1px 2px #fff, -1px 1px 2px #fff, -1px -1px 2px #fff'
            });
            txt.html(text);
            gif.append(txt);
        }

        bg.append(gif)
        tool.append(bg);
    }
    else {        
        tool.find(".LoadingInBg").remove();
    }
}

function BJShowMsg(element, text, time) {
    var tool = $(element);
    tool.css("position", "relative");
    var bg = $("<div class='LoadingInBg'></div>");
    bg.css({
        'position': element == 'body' ? 'fixed' : 'absolute',
        'width': '100%',
        'color': '#11b532',
        'font-size': '20px',
        'text-align': 'center',
        'top': '0',
        'left': '0',
        'height': '100%',
        'background-color': 'rgba(255, 255, 255, 0.60)',
        'z-index': '11',        
        'text-shadow': '1px 1px 0 #000',
        'display': '-webkit-flex',
        'display': 'flex',
        'align-items': 'center',
        'justify-content': 'center'
    });
    bg.html(text)
    tool.append(bg);

    setTimeout(function () {
        tool.find(".LoadingInBg").remove();
    }, time);
}

function ChaneUrl(replaceindex, replacevalue) {
    var sPageURL = window.location.href.split('//');
    var sParameterName = sPageURL[1].split('/');
    var url = "";
    for (var i = 1; i < sParameterName.length; i++) {
        if (replaceindex == (i)) {
            url += replacevalue + "/";
        }
        else {
            url += sParameterName[i] + (i != (sParameterName.length - 1) ? "/" : "");
        }
    }
    return "/" + url;
}



$("[data-showloding]").click(function (e) {
    LoadingBar(true);
});

function LoadingBar(isShow) {
    if (isShow) {
        //$("body").append("<div style=\"background-color: #000;opacity: 0.40;filter:alpha(opacity=40);width:100%;height:100%;position:fixed;z-index:2000;top:0;left:0;\" class=\"divPopupBg\"></div>");
        //$("body").append("<div class=\"divLoading\"><img src=\"https://sirius-image.s3.eu-central-1.amazonaws.com/tasarim/loadinicon.gif\"></div>");
        $(".loading").removeClass("hide");
        $(".loading").attr("style", "opacity:0.7");
    }
    else {
        $(".loading").addClass("hide");
    }
}

$(document).on('click', '[data-loding-form]', function (e) {
    var $form = $(this).closest('form');
    if (!$form.length) return;

    // Unobtrusive validator henüz yoksa parse et
    if ($.validator && $.validator.unobtrusive && !$form.data('validator')) {
        $.validator.unobtrusive.parse($form);
    }

    var canValidate = typeof $form.valid === 'function';
    var isValid = !canValidate || $form.valid(); // validator yoksa geçerli say

    if (isValid) {
        LoadingBar(true);
        // (opsiyonel) Çifte tıklamayı önlemek için submit düğmesini devre dışı bırak
        setTimeout(function () {
            $form.find('button[type="submit"], input[type="submit"]').prop('disabled', true);
        }, 0);
        // e.preventDefault() YOK -> normal submit devam eder
    } else {
        // Geçersizse submit'i engelle
        e.preventDefault();
    }
});

$(".btn-search").click(function () {
    var text = $("input#txt-search").val();
    if (text != "") {
        location.href = "/arama?q=" + text + "&qt=1";
    }   
});
$('.txt-search').keyup(function () {
    $(".btn-search").attr("data-search", $(this).val());
});


function toggleURLParameter(key, value) {
    var url = removeURLParameter(window.location.href, key);
    if (value.length > 0) {
        var sep = (url.indexOf('?') > -1) ? '&' : '?';
        url = + url + sep + key + '=' + value;
    }
    window.location.href = url;
}

function removeURLParameter(url, parameter) {
    //prefer to use l.search if you have a location/link object
    var urlparts = url.split('?');
    if (urlparts.length >= 2) {
        var prefix = encodeURIComponent(parameter) + '=';
        var pars = urlparts[1].split(/[&;]/g);

        //reverse iteration as may be destructive
        for (var i = pars.length; i-- > 0;) {
            //idiom for string.startsWith
            if (pars[i].lastIndexOf(prefix, 0) !== -1) {
                pars.splice(i, 1);
            }
        }

        url = urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : "");
        return url;
    } else {
        return url;
    }
}

function ChangeUrlParam(paramName, value) {
    let searchParams = new URLSearchParams(window.location.search);
    var currentUrl = window.location.href;
    if (searchParams.has(paramName) == false) {
        if (window.location.href.indexOf("?") > -1) {
            currentUrl = window.location.href + "&" + paramName + "=" + value;
        } else {
            currentUrl = window.location.href + "?" + paramName + "=" + value;;
        }
    }
    var url = new URL(currentUrl);
    url.searchParams.set(paramName, value);
    return url.href;
}

function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) {
            return sParameterName[1];
        }
    }
}


