/* Minification failed. Returning unminified contents.
(1,10): run-time error CSS1031: Expected selector, found 'LoadingBar('
(1,10): run-time error CSS1025: Expected comma or open brace, found 'LoadingBar('
(12,10): run-time error CSS1031: Expected selector, found 'device_detec('
(12,10): run-time error CSS1025: Expected comma or open brace, found 'device_detec('
(79,1): run-time error CSS1019: Unexpected token, found 'device_detec('
(79,14): run-time error CSS1019: Unexpected token, found ')'
(82,1): run-time error CSS1019: Unexpected token, found '$'
(82,2): run-time error CSS1019: Unexpected token, found '('
(82,3): run-time error CSS1019: Unexpected token, found '".home-overlay"'
(82,18): run-time error CSS1019: Unexpected token, found ')'
(82,20): run-time error CSS1030: Expected identifier, found 'click('
(82,20): run-time error CSS1019: Unexpected token, found 'click('
(82,35): run-time error CSS1031: Expected selector, found '('
(82,35): run-time error CSS1025: Expected comma or open brace, found '('
(91,2): run-time error CSS1019: Unexpected token, found ')'
(93,1): run-time error CSS1019: Unexpected token, found '$'
(93,2): run-time error CSS1019: Unexpected token, found '('
(93,3): run-time error CSS1019: Unexpected token, found '".a-mobil-category"'
(93,22): run-time error CSS1019: Unexpected token, found ')'
(93,24): run-time error CSS1030: Expected identifier, found 'click('
(93,24): run-time error CSS1019: Unexpected token, found 'click('
(93,39): run-time error CSS1031: Expected selector, found '('
(93,39): run-time error CSS1025: Expected comma or open brace, found '('
(113,2): run-time error CSS1019: Unexpected token, found ')'
(115,1): run-time error CSS1019: Unexpected token, found '$'
(115,2): run-time error CSS1019: Unexpected token, found '('
(115,3): run-time error CSS1019: Unexpected token, found '".top-userin-mobil"'
(115,22): run-time error CSS1019: Unexpected token, found ')'
(115,24): run-time error CSS1030: Expected identifier, found 'click('
(115,24): run-time error CSS1019: Unexpected token, found 'click('
(115,39): run-time error CSS1031: Expected selector, found '('
(115,39): run-time error CSS1025: Expected comma or open brace, found '('
(128,2): run-time error CSS1019: Unexpected token, found ')'
(131,1): run-time error CSS1019: Unexpected token, found '$'
(131,2): run-time error CSS1019: Unexpected token, found '('
(131,3): run-time error CSS1019: Unexpected token, found '".nav-link-slider"'
(131,21): run-time error CSS1019: Unexpected token, found ')'
(131,23): run-time error CSS1030: Expected identifier, found 'click('
(131,23): run-time error CSS1019: Unexpected token, found 'click('
(131,38): run-time error CSS1031: Expected selector, found '('
(131,38): run-time error CSS1025: Expected comma or open brace, found '('
(135,2): run-time error CSS1019: Unexpected token, found ')'
(137,10): run-time error CSS1031: Expected selector, found 'isValidEmailAddress('
(137,10): run-time error CSS1025: Expected comma or open brace, found 'isValidEmailAddress('
(142,1): run-time error CSS1019: Unexpected token, found '$'
(142,2): run-time error CSS1019: Unexpected token, found '('
(142,3): run-time error CSS1019: Unexpected token, found '"#btn-ebulten"'
(142,17): run-time error CSS1019: Unexpected token, found ')'
(142,19): run-time error CSS1030: Expected identifier, found 'click('
(142,19): run-time error CSS1019: Unexpected token, found 'click('
(142,34): run-time error CSS1031: Expected selector, found '('
(142,34): run-time error CSS1025: Expected comma or open brace, found '('
(167,2): run-time error CSS1019: Unexpected token, found ')'
(169,1): run-time error CSS1019: Unexpected token, found '$'
(169,2): run-time error CSS1019: Unexpected token, found '('
(169,3): run-time error CSS1019: Unexpected token, found '".btn-search"'
(169,16): run-time error CSS1019: Unexpected token, found ')'
(169,18): run-time error CSS1030: Expected identifier, found 'click('
(169,18): run-time error CSS1019: Unexpected token, found 'click('
(169,33): run-time error CSS1031: Expected selector, found '('
(169,33): run-time error CSS1025: Expected comma or open brace, found '('
(179,2): run-time error CSS1019: Unexpected token, found ')'
(180,1): run-time error CSS1019: Unexpected token, found '$'
(180,2): run-time error CSS1019: Unexpected token, found '('
(180,3): run-time error CSS1019: Unexpected token, found ''.txt-search''
(180,16): run-time error CSS1019: Unexpected token, found ')'
(180,18): run-time error CSS1030: Expected identifier, found 'keyup('
(180,18): run-time error CSS1019: Unexpected token, found 'keyup('
(180,33): run-time error CSS1031: Expected selector, found '('
(180,33): run-time error CSS1025: Expected comma or open brace, found '('
(182,2): run-time error CSS1019: Unexpected token, found ')'
(183,1): run-time error CSS1019: Unexpected token, found '$'
(183,2): run-time error CSS1019: Unexpected token, found '('
(183,12): run-time error CSS1031: Expected selector, found '('
(183,12): run-time error CSS1025: Expected comma or open brace, found '('
(251,2): run-time error CSS1019: Unexpected token, found ')'
(253,10): run-time error CSS1031: Expected selector, found 'GetBasketCount('
(253,10): run-time error CSS1025: Expected comma or open brace, found 'GetBasketCount('
(268,1): run-time error CSS1019: Unexpected token, found 'GetBasketCount('
(268,16): run-time error CSS1019: Unexpected token, found ')'
(270,10): run-time error CSS1031: Expected selector, found 'BJLoading('
(270,10): run-time error CSS1025: Expected comma or open brace, found 'BJLoading('
(321,10): run-time error CSS1031: Expected selector, found 'BJShowMsg('
(321,10): run-time error CSS1025: Expected comma or open brace, found 'BJShowMsg('
(350,10): run-time error CSS1031: Expected selector, found 'ChaneUrl('
(350,10): run-time error CSS1025: Expected comma or open brace, found 'ChaneUrl('
(367,1): run-time error CSS1019: Unexpected token, found '$'
(367,2): run-time error CSS1019: Unexpected token, found '('
(367,3): run-time error CSS1019: Unexpected token, found '"[data-showloding]"'
(367,22): run-time error CSS1019: Unexpected token, found ')'
(367,24): run-time error CSS1030: Expected identifier, found 'click('
(367,24): run-time error CSS1019: Unexpected token, found 'click('
(367,39): run-time error CSS1031: Expected selector, found '('
(367,39): run-time error CSS1025: Expected comma or open brace, found '('
(369,2): run-time error CSS1019: Unexpected token, found ')'
(371,10): run-time error CSS1031: Expected selector, found 'LoadingBar('
(371,10): run-time error CSS1025: Expected comma or open brace, found 'LoadingBar('
(383,10): run-time error CSS1031: Expected selector, found 'toggleURLParameter('
(383,10): run-time error CSS1025: Expected comma or open brace, found 'toggleURLParameter('
(392,10): run-time error CSS1031: Expected selector, found 'removeURLParameter('
(392,10): run-time error CSS1025: Expected comma or open brace, found 'removeURLParameter('
(414,10): run-time error CSS1031: Expected selector, found 'ChangeUrlParam('
(414,10): run-time error CSS1025: Expected comma or open brace, found 'ChangeUrlParam('
(429,10): run-time error CSS1031: Expected selector, found 'getUrlParameter('
(429,10): run-time error CSS1025: Expected comma or open brace, found 'getUrlParameter('
(441,1): run-time error CSS1019: Unexpected token, found '$'
(441,2): run-time error CSS1019: Unexpected token, found '('
(441,3): run-time error CSS1019: Unexpected token, found '"[data-ajax-form]"'
(441,21): run-time error CSS1019: Unexpected token, found ')'
(441,23): run-time error CSS1030: Expected identifier, found 'click('
(441,23): run-time error CSS1019: Unexpected token, found 'click('
(441,38): run-time error CSS1031: Expected selector, found '('
(441,38): run-time error CSS1025: Expected comma or open brace, found '('
(469,2): run-time error CSS1019: Unexpected token, found ')'
 */
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>");
    }
    else {
        $(".divLoading").remove();
        $(".divPopupBg").remove();
    }
}

function device_detec() {
    if (window.innerWidth >= 1200) {//LG 

        $(".top-category-item").mouseover(function () {
            $(this).find(".top-subcategory").show();
        }).mouseout(function () {
            $(this).find(".top-subcategory").hide();
        });


        $(".top-subcategory").mouseover(function () {
            $(this).parent(".top-category-item").find("a")
                .css("background-color", "#fbfbfb")
                .css("color", "#038acd")

        }).mouseout(function () {
            $(this).parent(".top-category-item").find("a").removeAttr("style");
        });

        $(".top-userin").removeClass("top-userin-mobil");
    }
    else if (window.innerWidth < 1200 && window.innerWidth >= 992) {//MD

        $(".top-category-item").mouseover(function () {
            $(this).find(".top-subcategory").show();
        }).mouseout(function () {
            $(this).find(".top-subcategory").hide();
        });

        $(".top-subcategory").mouseover(function () {
            $(this).parent(".top-category-item").find("a")
                .css("background-color", "#fbfbfb")
                .css("color", "#038acd");
        }).mouseout(function () {
            $(this).parent(".top-category-item").find("a").removeAttr("style");
            });

        $(".top-userin").removeClass("top-userin-mobil");

    }
    else if (window.innerWidth < 992 && window.innerWidth >= 768) {//SM
        $(".register-conditions").attr("data-popup", "").attr("data-popup-size", "md").attr("href", "/Uyelik-kosulari/" + $("body").attr("data-languageid")).attr("data-popup-title", ".");

        $(".top-category-item").click(function () {
            $(this).find(".top-subcategory").toggle();
        });

        $(".top-userin").removeAttr("href");

        $(".a-topcategory-item").removeAttr("href");
    }
    else if (window.innerWidth < 768) {//XS      
        $(".register-conditions").attr("data-popup", "").attr("data-popup-size", "md").attr("href", "/Uyelik-kosulari/" + $("body").attr("data-languageid")).attr("data-popup-title", ".");

        $(".top-category-item").click(function () {
            $(this).find(".top-subcategory").toggle();
        });

        $(".top-userin").removeAttr("href");

        $(".a-topcategory-item").removeAttr("href");

        $(".footer-link-list > h4").click(function () {
            $(this).parent().find("ul").slideToggle();
        });
    }
}
device_detec();


$(".home-overlay").click(function () {
    $(".top-user-menu").removeClass("us-active");
    $(".top-category-con").removeClass("hm-active");

    $(".home-overlay").hide();
    $("body").removeClass("no-scroll");

    $(".category-product-filter").find(".fa-check").hide().parent().css("padding-top", "6px");
    $(".category-product-filter").find(".fa-filter, span").show();
});

$(".a-mobil-category").click(function () {    
    $(".top-user-menu").removeClass("us-active");
    $(".top-category-con").toggleClass("hm-active", function () {
        
        if ($(this).is(".hm-active")) {
            
            $(".home-overlay").show();
            $("body").addClass("no-scroll");

            //$(".category-product-filter").find(".fa-check").show().parent().css("padding-top", "16px");
            //$(".category-product-filter").find(".fa-filter, span").hide();
        } else {
          
            $(".home-overlay").hide();
            $("body").removeClass("no-scroll");

            //$(".category-product-filter").find(".fa-check").hide().parent().css("padding-top", "6px");
            //$(".category-product-filter").find(".fa-filter, span").show();
        }
    });
});

$(".top-userin-mobil").click(function () {
    $(".top-category-con").removeClass("hm-active");
    $(".top-user-menu").toggleClass("us-active", function () {
        if ($(this).is(".us-active")) {

            $(".home-overlay").show();
            $("body").addClass("no-scroll");
        } else {

            $(".home-overlay").hide();
            $("body").removeClass("no-scroll");
        }
    });
});


$(".nav-link-slider").click(function () {
    $(".tab-contaner").removeClass("activ")
    var idd = $(this).attr("href").replace("#", "");
    $("#" + idd).addClass("activ");
});

function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

$("#btn-ebulten").click(function (e) {

    var email = $("#txt-ebulten").val();

    if (isValidEmailAddress(email)) {
        $.ajax({
            url: "/ebultenkayit",
            type: 'POST',
            data: { eemail: email },
            success: function (data) {
                swal({
                    title: 'Kayıt',
                    text: "E-Bülten kayıdınız başarılı bir şekilde yapıldı teşekkür ederiz",
                    type: 'success',
                });
            }
        });
    }
    else {
        swal({
            title: 'Uyarı!',
            text: "Email hatalı, geçerli bir mail girin!",
            type: 'error',
        });
    }  
});

$(".btn-search").click(function () {
    var text = $("input#txt-search").val();    
    if (text == "") {
        location.href = "/arama?q=" + $(".btn-search").data("search") + "&qt=1";
    }
    else {
        if (text != "") {
            location.href = "/arama?q=" + text + "&qt=1";
        }
    }
});
$('.txt-search').keyup(function () {
    $(".btn-search").attr("data-search", $(this).val());
});
$(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 GetBasketCount() {
    $.ajax({
        url: "/sepetadet",
        type: 'POST',
        success: function (data) {
            if (data.result != "0") {
                $(".top-basket").html("<span class=\"top-basket-count\">" + data.result + "</span>Sepetim");
            }
            else {
                $(".top-basket").html("Sepetim");
            }
        }
    });
}

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) {
    BJLoading(true, "body", null, null)
});

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>");
    }
    else {
        $(".divLoading").remove();
        $(".divPopupBg").remove();
    }
}


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];
        }
    }
}


$("[data-ajax-form]").click(function () {    
    var ths = $(this);
    var form = ths.parents("form");
    var GetForgeryId = form.find("#forgeryToken").val();
   
    if (form.valid()) {
        $.ajax({
            url: form.attr('action'),
            type: 'POST',
            data: form.serialize(),
            traditional: true,
            headers: {
                'VerificationToken': GetForgeryId
            },
            success: function (data) {                
                if (data.result) {
                    if (ths.attr("data-ajax-msg") != null) {
                        $(".modal-body").html("<div style=\"font-size:20px;text-align: center;width: 100%;padding:20px 0;\">" + ths.attr("data-ajax-msg") + "</span>");
                    }  
                    if (ths.attr("data-ajax-close") != null) {
                        setTimeout(function () {
                            $('#myModal').modal('hide');
                        }, parseInt(ths.attr("data-ajax-close")));
                    }
                }
            }
        });
    }
});
