window.Panel = '//sspanel.serversistemleri.com/';
var cookie = (typeof Cookie !== "undefined") ? new Cookie() : null;
if (localStorage.kvkk) {
    $(".footer-info").remove();
}
jQuery.fn.extend({
    alertBox: function (option) {
        if (typeof option === 'object') {
            var self = this;
            var modalContent = '';

            $(this).addClass('modal');
            $(this).addClass('fade');
            $(this).attr('tabindex', '-1');
            $(this).attr('role', 'dialog');
            $(this).attr('aria-labelledby', $(this).attr('id') + 'Label');

            modalContent += '<div class="modal-dialog modal-sm" role="document">';
            modalContent += '  <div class="modal-content">';
            if (!!option.title) {
                modalContent += '    <div class="modal-header">';
                modalContent += '      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
                modalContent += '      ' + (option.title);
                modalContent += '    </div>';
            }
            if (!!option.message) {
                modalContent += '    <div class="modal-body">';
                if (option.type === 'alert' || option.type === 'confirm') {
                    modalContent += '      ' + (option.message);
                } else if (option.type === 'prompt') {
                    var textId = $(this).attr('id') + 'PromptText';

                    modalContent += '      <div class="form-group">';
                    modalContent += '        <label>' + (option.message) + '</label>';
                    modalContent += '        <input type="text" id="' + textId + '" class="form-control">';
                    modalContent += '      </div>';
                }
                modalContent += '    </div>';
            }
            if (!!option.type) {
                modalContent += '    <div class="modal-footer">';
                if (option.type === 'alert') {
                    modalContent += '      <button id="okbuth" type="button" class="btn btn-primary" data-dismiss="modal">Tamam</button>';
                }
                if (option.type === 'confirm' || option.type === 'prompt') {
                    var buttonId = $(this).attr('id') + 'ActionButton';
                    var cancelId = $(this).attr('id') + 'CancelButton';

                    modalContent += '      <button type="button" id="' + buttonId + '" class="btn btn-primary" data-dismiss="modal">Evet</button>';
                    modalContent += '      <button type="button" id="' + cancelId + '" class="btn btn-default" data-dismiss="modal">Hayır</button>';
                }
                modalContent += '    </div>';
            }
            modalContent += '  </div>';
            modalContent += '</div>';

            $(this).html(modalContent);
            if (!!buttonId) {
                $('#' + buttonId).on('click', function () {
                    if (!!option.action) {
                        if (option.type === 'confirm') {
                            option.action();
                        } else if (option.type === 'prompt') {
                            if (!!textId) {
                                option.action($('#' + textId).val());
                                $('#' + textId).val('');
                            }
                        }
                    }
                });
            }

            if (option.type === 'confirm' || option.type === 'prompt') {
                if (!!cancelId) {
                    $('#' + cancelId).on('click', function () {
                        option.cancel();
                        if (option.type === 'prompt') {
                            if (!!textId) {
                                $('#' + textId).val('');
                            }
                        }
                    });
                }
            }
            return $(self);
        } else {
            throw 'Invalid parameter';
        }
    }
});
AOS.init({
    duration: 800,
    easing: 'slide'
});
var errors = {
    "Invalid Domain Name": "Domain adı hatalı. Lütfen kontrol ederek tekrar deneyiniz.",
    "unsupportedtld": "Uzantı türü hatalı. Lütfen kontrol ederek tekrar deneyiniz.",
    "none": "Bilinmeyen bir hata oluştu. Lütfen kontrol ederek tekrar deneyiniz.",
    "available": "Kayıtlı olmayan bir domain kullanamazsınız",
    "Operation can not completed successfully!": "İşlem tamamlanamadı. Alan adı hatalı olabilir!"
};
var firebaseConfig = {
    apiKey: "AIzaSyBT7LeNjNFc7QbZAX6PTum8jxGmfm89qpw",
    authDomain: "server-sistemleri.firebaseapp.com",
    databaseURL: "https://server-sistemleri.firebaseio.com",
    projectId: "server-sistemleri",
    storageBucket: "server-sistemleri.appspot.com",
    messagingSenderId: "938013051339",
    appId: "1:938013051339:web:cf7f23ca52ffac20778e4e",
    measurementId: "G-QWBDWDVVS4"
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
if (firebase.messaging.isSupported()) {
    var messaging = firebase.messaging()
    messaging.usePublicVapidKey('BIHmCaG1AUdKBLaK9tSt7vNY8XaNpSHsKjKDZ1tzq4hfA8Rne2GZad0X_W1cXor3dmZn8Je_fmYtBmky8P632l8')
}

function sendToken(token) {
    var rr = uuid();
    window.clbs[rr] = (data) => {}
    document.getElementById("pp").contentWindow.postMessage({
        code: `$.post('?addToken=${token}', {
            }).done(data => {
                window.parent.postMessage({type:"clb", id: a.data.callback, response: data}, '*');
            });`,
        callback: rr,
        Panel: window.Panel
    }, '*');
}
window.addEventListener("message", function (a) {
    switch (a.data.type) {
        case "imready":
            ppLoad();
            break;
        case "clb":
            window.clbs[a.data.id](a.data.response);
            break;
        case "reload":
            location.reload();
            break;
        case "cart":
            window.startWaitedOpt = true;
            data = JSON.parse(a.data.data);
            data.domains = (Array.isArray(data.domains) && data.domains.length) ? data.domains : null;
            data.products = (Array.isArray(data.products) && data.products.length) ? data.products : null;
            if ((Array.isArray(data.domains) || Array.isArray(data.products))) {
                window.Cart = data;
                var tt = ((data.domains) ? data.domains.length : 0) + ((data.products) ? data.products.length : 0);
                $("a.btndrop.basket span.badge").text(tt || "").removeAttr("count")
                if ($(".basket-details").length) {
                    var stc = setInterval(() => {
                        if (typeof loadBasket === "function") {
                            loadBasket();
                            clearInterval(stc);
                            stc = null;
                        }
                    }, 100);
                }
            } else {
                if ($(".basket-details").length) {
                    this.location.href = './';
                }
            }
            break;
    }
}, false);

function showNotif(notif) {
    var notification = new Notification(notif.title, {
        icon: notif.icon,
        body: notif.body,
        tag: 'renotify',
        renotify: true
    });
    notification.onclick = function () {
        parent.focus();
        window.focus();
        this.close();
        location.href = notif.click_action;
    };
}
window.ppLoad = function () {
    document.getElementById("pp").contentWindow.postMessage({
        type: "cart"
    }, '*');
    if (firebase.messaging.isSupported()) {
        messaging.getToken().then((token) => {
            sendToken(token);
        }).catch((err) => {});
        messaging.onTokenRefresh(function () {
            messaging.getToken().then(function (refreshedToken) {
                console.log('Token refreshed.');
                sendToken(refreshedToken);
            }).catch(function (err) {});
        });
        messaging.onMessage(function (payload) {
            showNotif(payload.notification);
            console.log('onMessage: ', payload);
        });
    }
    var yuyu = uuid();
    window.clbs[yuyu] = (data) => {
        if (typeof total === "function") {
            total(data);
        }
    }
    document.getElementById("pp").contentWindow.postMessage({
        code: `$.post('?cart=1&ajax=1&currency=${cookie[cookie.doviz.value].value}').done(data => {
          window.parent.postMessage({type:"clb", id: a.data.callback, response: data}, '*');
        });`,
        callback: yuyu,
        Panel: window.Panel
    }, '*');

}

function cSelect() {
    $('select:not(.select-check-hidden)').each(function () {
        var $this = $(this);
        $this.addClass('select-check-hidden');
        $this.wrap('<div class="select-check-item"></div>');
        $this.after('<div class="select-check-styled"></div>');
        var $styledSelect = $this.next('div.select-check-styled');
        var $list = $('<ul />', {
            'class': 'select-check-options'
        }).insertAfter($styledSelect);
        $styledSelect.text(this.firstElementChild.innerText);
        $this.children("option").each(function (a, e) {
            if (e.selected) {
                $styledSelect.text(e.innerText);
            }
            $('<li />', {
                text: e.innerText,
                rel: e.value
            }).appendTo($list);
        })
        var $listItems = $list.children('li');
        $styledSelect.click(function (e) {
            e.stopPropagation();
            $('div.select-check-styled.styledActive').not(this).each(function () {
                $(this).removeClass('styledActive').next('ul.select-check-options').hide();
            });
            $(this).toggleClass('styledActive').next('ul.select-check-options').toggle();
        });
        $listItems.click(function (e) {
            e.stopPropagation();
            $styledSelect.text($(this).text()).removeClass('styledActive');
            $this.val($(this).attr('rel'));
            $this.change();
            $list.hide();
            //console.log($this.val());
        });
        $(document).click(function () {
            $styledSelect.removeClass('styledActive');
            $list.hide();
        });
    });
}

function uuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
            v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}
window.clbs = {};

window.addEventListener("beforeunload", function () {
    $("#ss-loader").addClass("show");
    Tawk_API.hideWidget();
});

function addproductBasket(id, element, event) {
    element.innerHTML = '<span class="icon-spinner"></span> Bekleyiniz...';
    var uu = uuid();
    window.clbs[uu] = (data) => {
        if (!data) {
            element.href = './sepet';
            element.onclick = "";
            element.innerHTML = '<span class="icon-basket"></span> Ödeme Yap';
            document.getElementById("pp").contentWindow.postMessage({
                code: `location.reload()`
            }, '*');
            return;
        }
        var form = $(data).find("#frmConfigureProduct");
        var confproduct = uuid();
        window.clbs[confproduct] = (data) => {
            if (!data) {
                element.href = './sepet';
                element.onclick = "";
                element.innerHTML = '<span class="icon-basket"></span> Ödeme Yap';
                document.getElementById("pp").contentWindow.postMessage({
                    code: `location.reload()`
                }, '*');
            }
        }
        var options = {
            ajax: 1,
            a: "confproduct",
            currency: cookie[cookie.doviz.value].value,
            configure: true,
            billingcycle: element.getAttribute("data-billingcycle"),
        }
        for (const e of form[0].elements) {
            if (e.nodeName === "INPUT" || e.nodeName === "SELECT") {
                if (e.name !== "billingcycle") {
                    if (e.name === "hostname") {
                        options["hostname"] = "localhost";
                    } else if (e.name === "rootpw") {
                        options["rootpw"] = "password";
                    } else if (e.name === "ns1prefix") {
                        options["ns1prefix"] = "ns1";
                    } else if (e.name === "ns2prefix") {
                        options["ns2prefix"] = "ns2";
                    } else {
                        options[e.name] = e.value;
                    }
                }
            }
        };
        document.getElementById("pp").contentWindow.postMessage({
            code: `$.post('/cart.php', ${JSON.stringify(options)}).done(data => {
          window.parent.postMessage({type:"clb", id: a.data.callback, response: data}, '*');
          });`,
            callback: confproduct,
            Panel: window.Panel
        }, '*');
    }
    document.getElementById("pp").contentWindow.postMessage({
        code: `$.post('/cart.php', {
  ajax: 1,
  token: csrfToken,
  a: "add",
  billingcycle: "${element.getAttribute("data-billingcycle")}",
  currency: ${cookie[cookie.doviz.value].value},
  pid: ${id},
      }).done(data => {
      window.parent.postMessage({type:"clb", id: a.data.callback, response: data}, '*');
      });`,
        callback: uu,
        Panel: window.Panel
    }, '*');
    event.preventDefault();
    event.stopPropagation();
}


function domainTransfer(domain, element, epp) {
    element.value = 'Bekleyiniz...';
    var uu = uuid();
    window.clbs[uu] = (data) => {
        if (data.result === "added") {
            document.getElementById("pp").contentWindow.postMessage({
                code: `location.reload()`
            }, '*');
            location.href = './sepet';
        } else {
            var d = $('#alert').alertBox({
                title: 'Hata!',
                message: data.result.unavailable,
                type: 'alert'
            });
            d.modal("show")
            d.on('shown.bs.modal', function () {
                $('.btn-primary').focus();
            })
        }
    }
    document.getElementById("pp").contentWindow.postMessage({
        code: `
  $.post('/cart.php', {
    token: csrfToken,
    a: "addDomainTransfer",
    domain: "${domain}",
    epp:"${epp}",
  },'json').done(data => {
      window.parent.postMessage({type:"clb", id: a.data.callback, response: data}, '*');
  });`,
        callback: uu,
        Panel: window.Panel
    }, '*');
}

function domainAddCart(domain, element, premium, price) {
    element.innerHTML = '<span class="icon-spinner"></span> Bekleyiniz';
    var uu = uuid();
    window.clbs[uu] = () => {
        if (premium) {
            document.getElementById("pp").contentWindow.postMessage({
                code: `$.post('?cart=1&ajax=1&currency=${cookie[cookie.doviz.value].value}&premium=true&domain=${domain}&price=${price}');`,
                Panel: window.Panel
            }, '*');
        }
        element.href = './sepet';
        element.onclick = '';
        element.innerHTML = '<span class="icon-basket"></span> Ödeme Yap';
        document.getElementById("pp").contentWindow.postMessage({
            code: `location.reload()`
        }, '*');
    }
    document.getElementById("pp").contentWindow.postMessage({
        code: `
  $.post('/cart.php', {
    token: csrfToken,
    a: "addToCart",
    domain: "${domain}",
    whois:"1",
    sideorder:"0"
  },'json').done(data => {
    if (data.result === "added" || data.result === "registered" ) {
      window.parent.postMessage({type:"clb", id: a.data.callback}, '*');
    }
  });`,
        callback: uu,
        Panel: window.Panel
    }, '*');
}

$('[data-sp]').on("click", function () {
    var ids = $(this).data("sp").split(",");
    ids.forEach(e => {
        $("#SelectPlatform [data-type=" + e.split('-')[1] + "]").val(e.split('-')[0])
    });
    $("#SelectPlatform").on("submit", function (e) {
        hostingAddCart(this.radio.value, this[2]);
        e.preventDefault();
        e.stopPropagation();
    })
})

function hostingAddCart(pid, element) {
    cookie.set('cartProductPid', pid);
    element.innerHTML = '<span class="icon-spinner"></span> Bekleyiniz';
    location.href = './hosting-kurulum';
}
Date.calculate = function (d0, d1) {
    var diff = new Date(+d1).setHours(12) - new Date(+d0).setHours(12);
    return Math.round(diff / 8.64e7);
}

function loadmore(elem) {
    window.pagination = window.pagination + 5;
    window.paginationElem = elem;
    elem.innerText = 'Yükleniyor...';
    $("#queryDomain").submit();
}

var api = "api/?action=";
(function ($) {
    "use strict";

    $(".sscampaignbar a").click(function () {
        $(".sscampaignbar").remove();
    })
    var U = new URL(location.href);
    $("#BtnPrice2").change(function () {
        var scl = (this.checked) ? "USD" : "TRY";
        cookie.set("doviz", scl);
        document.querySelector("html").className = scl;
        if (document.querySelector(".basket-details")) {
            $('#ss-loader').addClass('show transparent');
            $("#cartCurChange option").removeAttr("selected");
            $("#cartCurChange option[value=" + scl + "]").attr('selected', 'selected')
            $("#cartCurChange").next(".select-check-styled").text((scl === "TRY") ? "TL" : "USD");
            document.getElementById("pp").src = "//sspanel.serversistemleri.com/feeds/req.php?currency=" + cookie[cookie.doviz.value].value;
        }
    })
    $(document).on("click", '[href="sepet"]', function (e) {
        var co = $(this).find("span.badge").text();
        if (co == "0" || !co) {
            var d = $('#confirm').alertBox({
                title: 'Sepetiniz Boş...',
                message: 'Sepetinizde hiç ürün bulunmamaktadır',
                type: 'alert'
            })
            d.modal("show")
            d.on('shown.bs.modal', function () {
                $('.btn-primary').focus();
            })
            e.preventDefault();
        } else {
            /* if (Cart.domains.length && (!Cart.products || !Cart.products.find(e => e.domain === "deneee.com"))) {
                console.log(Cart.domains);
            } */
        }
    })
    $("#emptybasket").click(function () {
        var d = $('#confirm').alertBox({
            title: 'Silmek istediğinizden emin misiniz?',
            message: 'Sepetiniz boşaltılacaktır. Onaylıyor musunuz?',
            type: 'confirm',
            action: function () {
                removeCartAll();
            },
            cancel: function () {}
        })
        d.modal("show")
        d.on('shown.bs.modal', function () {
            $('.btn-primary').focus();
        })
    })
    $(document).on("click", '#minicart .feature-btn-edit', function () {
        var data = $(this).data(),
            element = $("#basket [data-type='" + data.type + "'][data-item='" + data.item + "']");
        element.addClass("selected");
        $(document).scrollTop(element.offset().top - ($("#ss-navbar").height() + 90))
        setTimeout(() => {
            element.removeClass("selected");
        }, 2500);
    })
    $(document).on("click", '#minicart .feature-btn-delete', function () {
        var d = $('#confirm').alertBox({
            title: 'Silmek istediğinizden emin misiniz?',
            message: 'Ürününüz sepetinizden silinecektir. Onaylıyor musunuz?',
            type: 'confirm',
            action: () => {
                var data = $(this).data();
                $('#ss-loader').addClass('show transparent');
                removeCart((data.type === "domain"), data.item);
            },
            cancel: () => {}
        })
        d.modal("show")
        d.on('shown.bs.modal', function () {
            $('.btn-primary').focus();
        })
    })
    $("#transferDomain").submit(function (event) {
        if (this.domain.value && this.code.value) {
            domainTransfer(this.domain.value, this.elements[2], this.code.value);
        }
        event.preventDefault();
        event.stopPropagation();
    })
    $("#cartCurChange").change(function () {
        var val = $(this).val();
        $("#BtnPrice2")[0].checked = val === "USD";
        $("#BtnPrice2").change();
    })
    window.pagination = 0;
    $("#queryDomain").submit(function (event) {
        if (!event.isTrigger) {
            window.pagination = 0;
        }
        if (this.domain.value) {
            this[1].value = 'Bekleyiniz...';
            var domainName = this.domain.value.split(".")[0],
                ext = this.domain.value.split(".").splice(1).join(".");
            var results = $("#results"),
                html = '';
            if (window.pagination === 0) {
                $(".domain-whois").addClass("disnone");
                results.html('');
            }
            $.get(api + 'queryDomain&domain=' + domainName + '&ext=' + ext + '&skip=' + window.pagination, (data) => {
                if (data) {
                    $(".domain-whois").removeClass("disnone");
                    if (window.pagination === 0) {
                        $(document).scrollTop($("#results").offset().top - ($("#ss-navbar").height() + 420))
                    }
                    if (data.Code) {
                        html += `<div class="alert alert-danger">
            <span>Hata!</span>
            <p>${(errors[data.Message]) ? errors[data.Message] : errors["none"]}</p>
          </div>`;
                    } else {
                        data.sort(e => {
                            return e.TLD === ext ? -1 : 1
                        }).forEach(e => {
                            if (window.Cart && window.Cart.domains && window.Cart.domains.find(f => f.domain === `${e.DomainName}.${e.TLD}`)) {
                                var action = `href="sepet"`;
                                var text = `<a ${action} class="domain-to-cart register"><span class="icon-basket"></span> Ödeme Yap</a>`;
                            } else {
                                var action = (e.Status === "notavailable") ? `href="./domain-transferi?domain=${e.DomainName}.${e.TLD}"` : (e.Status === "unsupportedtld") ? `` : (e.Status === "premium") ? `href='javascript:void(0)' onclick="Tawk_API.maximize()"` : `onclick="javascript:domainAddCart('${e.DomainName}.${e.TLD}', this, ${e.Premium},${e.Price});"`;
                                var text = `<a ${action} class="domain-to-cart ${(e.Status === "notavailable") ? "transfer" : (e.Status === "premium") ? 'transfer' :'register'}"><span class="icon-${(e.Status === "notavailable") ? "rocket" : (e.Status === "premium") ? 'message' :'fs-plus'}"></span> ${(e.Status === "notavailable") ? "Transfer" : (e.Status === "premium") ? 'İletişim':'Kayıt'}</a>`;
                            }
                            html += `<div class="item">
            <div class="result ${(e.Status === "notavailable") ? "transfer" : (e.Status === "unsupportedtld") ? 'error' : (e.Status === "premium") ? 'transfer' :'register'}">
            <div class="row">
              <div class="col">
                <div class="domain-icon"></div>
                <div class="domain-name">${e.DomainName}.${e.TLD}${(e.Status === "premium") ? ' - Premium domainler için lütfen <a href="javascript:void()" onclick="Tawk_API.maximize()">iletişime geçin</a>' : ''}${(e.Status === "unsupportedtld") ? ' - Bu uzantı hatalıdır.' : ''}</div>
                <div class="domain-button whois-button">
                  <a target="_blank" href="whois-sorgulama?domain=${e.DomainName}.${e.TLD}" ${(e.Status === "notavailable") ? "class='whois'" : ''}> Kime Ait?</a>
                </div>
                <div class="domain-badges">
                  <div class="domain-status"></div>
                  <div class="free-transfer"></div>
                </div>
              </div>
              <div class="col-sm-1 mobile-prices col-md-3 col-lg-3 justify-content-end mobile-center">
              ${(e.oldPrice)?`<div class="domain-discount">%${Math.round(100 - (e.Price / e.oldPrice) * 100)} İndirim</div>
                <div class="domain-price-old">
                  <span class="prices">
                    <span class="price usd"><usd>$${e.oldPrice}/Yıl</usd><try>₺${new Number(e.oldPrice*document.getElementById("usdpr").innerText).toFixed(2)}/Yıl</try></span>
                  </span>
                </div>`:''}

                <div class="domain-price">
                  <span class="prices">
                    <span class="price usd"><usd>$${e.Price}/Yıl</usd><try>₺${new Number(e.Price.replace(",","")*document.getElementById("usdpr").innerText).toFixed(2)}/Yıl</try></span>
                  </span>
                </div>
              </div>
              <div class="col-sm-2 col-md-6 col-lg-2">
                <div class="domain-button">
                  ${text}
                </div>
              </div>
            </div>
          </div>
          </div>`;
                        });
                    }

                    if (window.pagination === 0) {
                        results.html(html);
                    } else {
                        results.append(html);
                    }
                }
            }).always(() => {
                this[1].value = "Sorgula";
                if (window.paginationElem) {
                    paginationElem.parentElement.parentElement.parentElement.parentElement.parentElement.remove();
                }
                results.append(`<div class="item">
        <div class="result register">
        <div class="row">
          <div class="col">
          <div class="domain-button" style="margin: 0 auto;">
          <a onclick="javascript:loadmore(this)" class="domain-to-cart register">Daha Fazla</a>
        </div>
          </div>
        </div>
      </div>
      </div>`);
            });
        }
        event.preventDefault();
        event.stopPropagation();
    })


    if (U.searchParams.get("domain") && $("#domain").length) {
        $("#domain").val(U.searchParams.get("domain"))
        var dsfdf = setInterval(() => {
            if (window.startWaitedOpt) {
                $("#queryDomain").submit();
                clearInterval(dsfdf);
            }
        }, 200);
    }
    $('.home-slider').owlCarousel({
        loop: true,
        autoplay: true,
        margin: 0,
        animateOut: 'fadeOut',
        animateIn: 'fadeIn',
        nav: true,
        autoplayHoverPause: true,
        items: 1,
        navText: ["<span class='icon-fs-left'></span>", "<span class='icon-fs-right'></span>"],
        responsive: {
            0: {
                items: 1,
                nav: false
            },
            600: {
                items: 1,
                nav: true
            },
            1000: {
                items: 1,
                nav: true
            }
        }
    });
    $('.carousel-testimony').owlCarousel({
        center: true,
        loop: true,
        autoplay: true,
        items: 1,
        margin: 30,
        stagePadding: 0,
        nav: true,
        navText: ['<span class="icon-fs-left">', '<span class="icon-fs-right">'],
        responsive: {
            0: {
                items: 1
            },
            600: {
                items: 3
            },
            1000: {
                items: 3
            }
        }
    });

    $('nav .dropdown').hover(function () {
        var $this = $(this);
        $this.addClass('show');
        $this.find('> a').attr('aria-expanded', true);
        $this.find('.dropdown-menu').addClass('show');
    }, function () {
        var $this = $(this);
        $this.removeClass('show');
        $this.find('> a').attr('aria-expanded', false);
        $this.find('.dropdown-menu').removeClass('show');
    });
    $('#dropdown04').on('show.bs.dropdown', function () {}); // scroll

    $('#section-counter').waypoint(function (direction) {
        if (direction === 'down' && !$(this.element).hasClass('ss-animated')) {
            var comma_separator_number_step = $.animateNumber.numberStepFactories.separator(',')
            var percent_number_step = $.animateNumber.numberStepFactories.append("+");
            $('.number').each(function () {
                var $this = $(this),
                    num = $this.data('number');
                $this.animateNumber({
                    number: num,
                    numberStep: comma_separator_number_step
                }, 7000);
            });
        }
    }, {
        offset: '95%'
    });
    $('.ss-animate').waypoint(function (direction) {
        if (direction === 'down' && !$(this.element).hasClass('ss-animated')) {
            $(this.element).addClass('item-animate');
            setTimeout(function () {
                $('body .ss-animate.item-animate').each(function (k) {
                    var el = $(this);
                    setTimeout(function () {
                        var effect = el.data('animate-effect');
                        if (effect === 'fadeIn') {
                            el.addClass('fadeIn ss-animated');
                        } else if (effect === 'fadeInLeft') {
                            el.addClass('fadeInLeft ss-animated');
                        } else if (effect === 'fadeInRight') {
                            el.addClass('fadeInRight ss-animated');
                        } else {
                            el.addClass('fadeInUp ss-animated');
                        }
                        el.removeClass('item-animate');
                    }, k * 50, 'easeInOutExpo');
                });
            }, 100);
        }
    }, {
        offset: '95%'
    });
    $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
        disableOn: 700,
        type: 'iframe',
        mainClass: 'mfp-fade',
        removalDelay: 160,
        preloader: false,
        fixedContentPos: false
    });

})(jQuery);