!function(t,e){"use strict";function r(r,a,i,u,l){function f(){L=t.devicePixelRatio>1,i=c(i),a.delay>=0&&setTimeout(function(){s(!0)},a.delay),(a.delay<0||a.combined)&&(u.e=v(a.throttle,function(t){"resize"===t.type&&(w=B=-1),s(t.all)}),u.a=function(t){t=c(t),i.push.apply(i,t)},u.g=function(){return i=n(i).filter(function(){return!n(this).data(a.loadedName)})},u.f=function(t){for(var e=0;e<t.length;e++){var r=i.filter(function(){return this===t[e]});r.length&&s(!1,r)}},s(),n(a.appendScroll).on("scroll."+l+" resize."+l,u.e))}function c(t){var i=a.defaultImage,o=a.placeholder,u=a.imageBase,l=a.srcsetAttribute,f=a.loaderAttribute,c=a._f||{};t=n(t).filter(function(){var t=n(this),r=m(this);return!t.data(a.handledName)&&(t.attr(a.attribute)||t.attr(l)||t.attr(f)||c[r]!==e)}).data("plugin_"+a.name,r);for(var s=0,d=t.length;s<d;s++){var A=n(t[s]),g=m(t[s]),h=A.attr(a.imageBaseAttribute)||u;g===N&&h&&A.attr(l)&&A.attr(l,b(A.attr(l),h)),c[g]===e||A.attr(f)||A.attr(f,c[g]),g===N&&i&&!A.attr(E)?A.attr(E,i):g===N||!o||A.css(O)&&"none"!==A.css(O)||A.css(O,"url('"+o+"')")}return t}function s(t,e){if(!i.length)return void(a.autoDestroy&&r.destroy());for(var o=e||i,u=!1,l=a.imageBase||"",f=a.srcsetAttribute,c=a.handledName,s=0;s<o.length;s++)if(t||e||A(o[s])){var g=n(o[s]),h=m(o[s]),b=g.attr(a.attribute),v=g.attr(a.imageBaseAttribute)||l,p=g.attr(a.loaderAttribute);g.data(c)||a.visibleOnly&&!g.is(":visible")||!((b||g.attr(f))&&(h===N&&(v+b!==g.attr(E)||g.attr(f)!==g.attr(F))||h!==N&&v+b!==g.css(O))||p)||(u=!0,g.data(c,!0),d(g,h,v,p))}u&&(i=n(i).filter(function(){return!n(this).data(c)}))}function d(t,e,r,i){++z;var o=function(){y("onError",t),p(),o=n.noop};y("beforeLoad",t);var u=a.attribute,l=a.srcsetAttribute,f=a.sizesAttribute,c=a.retinaAttribute,s=a.removeAttribute,d=a.loadedName,A=t.attr(c);if(i){var g=function(){s&&t.removeAttr(a.loaderAttribute),t.data(d,!0),y(T,t),setTimeout(p,1),g=n.noop};t.off(I).one(I,o).one(D,g),y(i,t,function(e){e?(t.off(D),g()):(t.off(I),o())})||t.trigger(I)}else{var h=n(new Image);h.one(I,o).one(D,function(){t.hide(),e===N?t.attr(C,h.attr(C)).attr(F,h.attr(F)).attr(E,h.attr(E)):t.css(O,"url('"+h.attr(E)+"')"),t[a.effect](a.effectTime),s&&(t.removeAttr(u+" "+l+" "+c+" "+a.imageBaseAttribute),f!==C&&t.removeAttr(f)),t.data(d,!0),y(T,t),h.remove(),p()});var m=(L&&A?A:t.attr(u))||"";h.attr(C,t.attr(f)).attr(F,t.attr(l)).attr(E,m?r+m:null),h.complete&&h.trigger(D)}}function A(t){var e=t.getBoundingClientRect(),r=a.scrollDirection,n=a.threshold,i=h()+n>e.top&&-n<e.bottom,o=g()+n>e.left&&-n<e.right;return"vertical"===r?i:"horizontal"===r?o:i&&o}function g(){return w>=0?w:w=n(t).width()}function h(){return B>=0?B:B=n(t).height()}function m(t){return t.tagName.toLowerCase()}function b(t,e){if(e){var r=t.split(",");t="";for(var a=0,n=r.length;a<n;a++)t+=e+r[a].trim()+(a!==n-1?",":"")}return t}function v(t,e){var n,i=0;return function(o,u){function l(){i=+new Date,e.call(r,o)}var f=+new Date-i;n&&clearTimeout(n),f>t||!a.enableThrottle||u?l():n=setTimeout(l,t-f)}}function p(){--z,i.length||z||y("onFinishedAll")}function y(t,e,n){return!!(t=a[t])&&(t.apply(r,[].slice.call(arguments,1)),!0)}var z=0,w=-1,B=-1,L=!1,T="afterLoad",D="load",I="error",N="img",E="src",F="srcset",C="sizes",O="background-image";"event"===a.bind||o?f():n(t).on(D+"."+l,f)}function a(a,o){var u=this,l=n.extend({},u.config,o),f={},c=l.name+"-"+ ++i;return u.config=function(t,r){return r===e?l[t]:(l[t]=r,u)},u.addItems=function(t){return f.a&&f.a("string"===n.type(t)?n(t):t),u},u.getItems=function(){return f.g?f.g():{}},u.update=function(t){return f.e&&f.e({},!t),u},u.force=function(t){return f.f&&f.f("string"===n.type(t)?n(t):t),u},u.loadAll=function(){return f.e&&f.e({all:!0},!0),u},u.destroy=function(){return n(l.appendScroll).off("."+c,f.e),n(t).off("."+c),f={},e},r(u,l,a,f,c),l.chainable?a:u}var n=t.jQuery||t.Zepto,i=0,o=!1;n.fn.Lazy=n.fn.lazy=function(t){return new a(this,t)},n.Lazy=n.lazy=function(t,r,i){if(n.isFunction(r)&&(i=r,r=[]),n.isFunction(i)){t=n.isArray(t)?t:[t],r=n.isArray(r)?r:[r];for(var o=a.prototype.config,u=o._f||(o._f={}),l=0,f=t.length;l<f;l++)(o[t[l]]===e||n.isFunction(o[t[l]]))&&(o[t[l]]=i);for(var c=0,s=r.length;c<s;c++)u[r[c]]=t[0]}},a.prototype.config={name:"lazy",chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:t,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",srcsetAttribute:"data-srcset",sizesAttribute:"data-sizes",retinaAttribute:"data-retina",loaderAttribute:"data-loader",imageBaseAttribute:"data-imagebase",removeAttribute:!0,handledName:"handled",loadedName:"loaded",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:e,afterLoad:e,onError:e,onFinishedAll:e},n(t).on("load",function(){o=!0})}(window);

$ = jQuery; $contentblock = "#primary";
$ = jQuery;
var $window           = $(window),  win_height_padded = $window.height() * 1.1;
var lcx_events,lcx_frontend;



function cld_setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}

function cld_getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
};


(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD
        define(['jquery'], factory);
    } else if (typeof exports === 'object') {
        // CommonJS
        factory(require('jquery'));
    } else {
        // Browser globals
        factory(jQuery);
    }
}(function ($) {
    var pluses = /\+/g;
    function encode(s) {
        return config.raw ? s : encodeURIComponent(s);
    }
    function decode(s) {
        return config.raw ? s : decodeURIComponent(s);
    }
    function stringifyCookieValue(value) {
        return encode(config.json ? JSON.stringify(value) : String(value));
    }
    function parseCookieValue(s) {
        if (s.indexOf('"') === 0) {
            s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
        }
        try {
            s = decodeURIComponent(s.replace(pluses, ' '));
            return config.json ? JSON.parse(s) : s;
        } catch(e) {}
    }
    function read(s, converter) {
        var value = config.raw ? s : parseCookieValue(s);
        return $.isFunction(converter) ? converter(value) : value;
    }
    var config = $.cookie = function (key, value, options) {
        // Write
        if (arguments.length > 1 && !$.isFunction(value)) {
            options = $.extend({}, config.defaults, options);
            if (typeof options.expires === 'number') {
                var days = options.expires, t = options.expires = new Date();
                t.setTime(+t + days * 864e+5);
            }
            return (document.cookie = [
                encode(key), '=', stringifyCookieValue(value),
                options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
                options.path    ? '; path=' + options.path : '',
                options.domain  ? '; domain=' + options.domain : '',
                options.secure  ? '; secure' : ''
            ].join(''));
        }
        var result = key ? undefined : {};
        var cookies = document.cookie ? document.cookie.split('; ') : [];
        for (var i = 0, l = cookies.length; i < l; i++) {
            var parts = cookies[i].split('=');
            var name = decode(parts.shift());
            var cookie = parts.join('=');
            if (key && key === name) {
                // If second argument (value) is a function it's a converter...
                result = read(cookie, value);
                break;
            }
            if (!key && (cookie = read(cookie)) !== undefined) {
                result[name] = cookie;
            }
        }
        return result;
    };
    config.defaults = {};
    $.removeCookie = function (key, options) {
        if ($.cookie(key) === undefined) {
            return false;
        }
        $.cookie(key, '', $.extend({}, options, { expires: -1 }));
        return !$.cookie(key);
    };
}));


(function ($) {
    $.Lazy('loadTemplatePart', function (element, response) {
        if (element.hasClass("encjs")) {
            element.addClass("loaded");
            part = element.data("part");
            var options = {
                'template-parts': part
            }
            $.each(element[0].attributes, function() {
                if (this.name != 'data-loader' && this.name != 'data-part'){
                    options[this.name] = this.value;
                }
            });
            mo.m.call('template-parts-loader', '', options, function (data) {
                if (typeof options['data-no-container'] != 'undefined'){
                    element.replaceWith(data);
                } else {
                    element.html(data);
                }
                element.find(".lazy").each(function (){ $(this).lazy();});
            });
        }
        response(true);
    });
    $.Lazy('loadScriptsSC', function (element, response) {
        if (element.hasClass("encjs")){
            element.addClass("loaded");
            var dtype = element.data("ajaxtype");
            mo.root.call('script_sc_print',{ jstxt: element.html(), ajaxtype:dtype},function(data){
                element.html(data);
            });
        }
        response(true);
    });
    $.Lazy('loadComparisonSC', function (element, response) {
        mo.root.call('get_compare_shortcode',{atts:element.data("scatts")},function(data){
            element.html(data);
            element.find(".lazy").each(function(){ $(this).lazy();});
        });
        response(true);
    });
})(window.jQuery || window.Zepto);


$.fn.popup = function(){
    this.each(function(){
        $(this).show().css({"opacity":"0"});
        $(this).find(".overlay").css({"opacity":"0"});
        if (window.innerWidth > '767') {
            var margintop = (window.innerHeight - $(this).find(".inner").outerHeight()) / 2.1;
            var marginleft = (window.innerWidth - $(this).find(".inner").outerWidth()) / 2;
        } else {
            var margintop = 0;
            var marginleft = 0;
        }
        $(this).find(".inner").css({"margin-top":margintop+"px"});
        $(this).find(".inner").css({"margin-left":marginleft+"px"});
        $(this).find(".overlay").animate({"opacity":"1"},10);
        $(this).animate({"opacity":"1"},300);
        var _thisb = $(this);
        var _thism = $(this).find(".inner");
        window.addEventListener('resize', function(event){
            if (window.innerWidth > '767') {
                var margintop = (window.innerHeight - _thism.outerHeight()) / 2.1;
                var marginleft = (window.innerWidth - _thism.outerWidth()) / 2;
            } else {
                var margintop = 0;
                var marginleft = 0;
            }
            _thism.animate({"margin-top":margintop+"px","margin-left":marginleft+"px"},200);
        });
        if (window.innerWidth < 767){
            var innercontheight = _thisb.find(".innside").height();
            if (innercontheight+60 < window.innerHeight){
                var diffjb = (window.innerHeight-(innercontheight+60))/2;
                _thisb.find(".innside").css({"margin-top":diffjb+"px"});
            }
        }
        $(this).find(".overlay").on("click",function(e){
            e.preventDefault();
            var thisholder = $(this).parent();
            thisholder.fadeOut(100);
            if (window.innerWidth < 960) {
                $(document).find("body").css({"height": "inherit"});
                $("#primary.site-content").show();
            }
            setTimeout(function (){
                thisholder.remove();
            },100);
        });
        $(this).find(".popupClose").on("click",function(e){
            e.preventDefault();
            var thisholder = $(this).parent().parent();
            thisholder.fadeOut(100);
            if (window.innerWidth < 960) {
                $(document).find("body").css({"height": "inherit"});
                $("#primary.site-content").show();
            }
            setTimeout(function (){
                thisholder.remove();
            },100);
        });
    });
};class MoUser{

    constructor() {

        this.user_details  = [];

        this.logged = 0;

        this.user_menu = 0;

        this.subscribtions_loaded = 0;

        this.check_logged();

        $("body").append('<div class="mo-holder"></div>');

        this.ui_holder = $(".mo-holder");

        var _this = this;



        $("body").delegate(".user-login-button","click",function(e){
            e.preventDefault();
            if ( $.cookie('mouser') == '' || typeof $.cookie('mouser') == 'undefined') {
                _this.show_login();
            } else {
                if (_this.user_menu == 0){
                    if (_this.ui_holder.find(".userpanel").length < 1) {
                        mo.m.call("users","user_panel","",function(data){
                            _this.ui_holder.append(data);
                            _this.hide_all_other_popups("mo-user-panel");
                        });
                    } else {
                        _this.hide_all_other_popups("mo-user-panel");
                    }}
            }
        });

        $(document).on("click",".user-show-register",function(e){e.preventDefault();
            if (_this.ui_holder.find(".registerbox").length < 1){
                mo.m.call("users","register_box","",function(data){
                    _this.ui_holder.append(data);
                    _this.hide_all_other_popups("registerbox");
                });
            } else {
                _this.hide_all_other_popups("registerbox");
                $(".registerbox").popup();
            }
        });
        $(document).on("click",".user-show-forgot",function(e){e.preventDefault();
            if (_this.ui_holder.find(".mo_forgot_box").length < 1){
                mo.m.call("users","forgot_box","",function(data){
                    _this.ui_holder.append(data);
                    _this.hide_all_other_popups("mo_forgot_box");
                    $(".mo_forgot_box").popup();
                });
            } else {
                _this.hide_all_other_popups("mo_forgot_box");
                $(".mo_forgot_box").popup();
            }
        });
        $("body").on("click",".googlelogin",function(){
            mo.ui.preloader();
        });
        $("body").delegate(".mo_logout","click",function(e) {
            e.preventDefault();
            _this.logout();
        });

        $("body").delegate(".comment-reply-link","click",function(e){
            e.preventDefault();
            var commcontainer = $(this).parent();
            if (commcontainer.find(".reply-form").length < 1){
                commcontainer.append('<div class="reply-form"></div>');
            }
            var parcontainer = commcontainer.find(".reply-form");
            var commentid = $(this).data("commentid");
            mo.m.call("users","load_comment_form",
                {form:'reply',lang:$lang,postID:$postID,parent:commentid}
                ,function(data){
                    parcontainer.html(data);
                });
        });


        $(document).on("click", ".pubc", function (e) {
            e.preventDefault();
            $(this).hide();
        });

    }



    check_logged(){
        var fpcookies = [];
        var cookies = document.cookie ? document.cookie.split('; ') : [];
        for (var i = 0, l = cookies.length; i < l; i++) {
            var parts = cookies[i].split('=');
            var name = parts.shift();
            fpcookies.push(name);
        }
        if ( $.cookie('mouser') != '' && typeof $.cookie('mouser') != 'undefined') {
            setInterval(function(){
                mo.m.call("users","check_user_cred",{"nopreloader":1},function(data){
                    if (data == 'false'){
                        location.reload();
                    }
                });
            },15000);
            if ( typeof $.cookie('mo_user_checked') == 'undefined') {
                mo.m.call("users", "inudets", {"nopreloader":1}, function (data) {
                    $.cookie('mo_user_checked', '1', {expires: 0.3, path: '/'});
                });
            }
        }
        if (typeof $.cookie('mouser') == 'undefined' || $.cookie('mouser') == '' ){
            this.logged = 0;
        } else {
            if (this.user_details == ''){
                this.user_details = JSON.parse($.cookie('mouser_details'));
            }
            this.logged = 1;
        }
        this.subscribtions();

    }


    subscribtions(){
        if (this.subscribtions_loaded == 0) {
            //subscribtions buttons
            var _thiss = this;
            if ($(document).find(".user-subscribe-button").length > 0) {
                $(".user-subscribe-button").each(function () {
                    var thisuid = $(this).data("uid");
                    if (thisuid == _thiss.user_details['ID']) {
                        $(this).hide();
                    } else {
                        if (typeof _thiss.user_details['subscribtions'] != 'undefined') {
                            if (_thiss.user_details['subscribtions'].includes(thisuid)) {
                                $(this).addClass("subscribed");
                                $(this).find("span").text($(this).data("subscribed-text"));
                                if ($(this).find("i").length > 0) {
                                    $(this).find("i").attr("class", "icon-check");
                                }
                            }
                        }
                    }
                });
                $(document).delegate(".user-subscribe-button", "click", function (e) {
                    e.preventDefault();
                    var UID = $(this).data("uid");
                    var _this = $(this);
                    if (_thiss.logged == 1) {
                        mo.m.call("users", "subscribe", {uid: UID}
                            , function (data) {
                                if (data == 'subscribed') {
                                    _this.addClass("subscribed");
                                    _this.find("span").text(_this.data("subscribed-text"));
                                } else {
                                    _this.removeClass("subscribed");
                                    _this.find("span").text(_this.data("subscribe-text"));
                                }
                            }
                        );
                    } else {
                        _thiss.show_login();
                    }
                });
            }
        }
    }

    facebook_login(callback){
        FB.login(function(response) {
            if (response.authResponse) {
                FB.api('/me?fields=name,email,picture.width(400).height(400)', function(response) {
                    mo.m.call('users',"facebook_callback",response,function(data){
                        mo.user.check_logged();
                        mo.root.theme['login']();
                        if (callback == 1){
                            mo_callback_mofunk(data);
                        }
                    });
                });
            } else {
                alert('User cancelled login or did not fully authorize.');
            }
        },{scope: 'email,public_profile'});
    }


    logout(){
        this.delete_user_cache();
    }


    delete_user_cache(){
        mo.m.call("users","logout","",function(data){
            location.reload();
        });
    }


    show_login() {
        var _this = this;
        if (this.ui_holder.find(".mo_login_box").length < 1) {
            mo.m.call("users","login_box","",function(data){
                _this.ui_holder.append(data);
                _this.hide_all_other_popups("mo_login_box");
            });
        } else {
            _this.hide_all_other_popups("mo_login_box");
            $(".mo_login_box").popup();
        }
    }

    comment_form(form_type,postID,button,reviewtext){
        if ($(".mo_comment_form_holder").length > 0){
            mo.m.call("users","load_comment_form",
                {
                    form:form_type,lang:$lang, postID:postID,button:button,reviewtext:reviewtext
                }
                ,function(data){
                    $(".mo_comment_form_holder").html(data);
                });
        }
    }

    scroll_to_comment_form(){
        $('html, body').animate({ scrollTop: $(".mo_comment_form_holder").offset().top-50}, 1500);
    }


    hide_all_other_popups(dclases){
        $(document).find("#mopopup").each(function(){
            if (!$(this).hasClass(dclases)){
                $(this).hide();
            }
        })
    }

    validate_email(email) {
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
        {
            return true
        } else {
            return false;
        }
    }

    moments(time){
        var timedef = time;
        if (mo.root.device_sys != 'ios') {
            time = time + ':00 UTC';
        }
        switch (typeof time) {
            case 'number':
                break;
            case 'string':
                if (mo.root.device_sys == 'ios'){
                    time = time.toString();
                    // time = time.toISOString();
                }
                time = new Date(time);
                time = new Date(time);
                break;
            case 'object':
                if (time.constructor === Date) time = time.getTime();
                break;
            default:
                time = +new Date();
        }

        if (isNaN(time)){
            return time;
        } else {
            var diff = Math.floor((new Date() - new Date(time)) / 1000);
            if (diff < 0){
                diff = 0;
            }
            if(typeof jstiming == 'string'){
                jstiming = JSON.parse(jstiming);
            }
            var time_formats = [
                [0, jstiming['time-ago/just-now']],
                [60, jstiming['time-ago/minutes/one']],
                [120, jstiming['time-ago/minutes/many']],
                [3600, jstiming['time-ago/hours/one']],
                [7200, jstiming['time-ago/hours/many']],
                [86400, jstiming['time-ago/yesterday']],
                [172800, jstiming['time-ago/days/many']],
                [5184000, jstiming['time-ago/months/many']],

            ];

            var current_format = '';
            var i = 0,
                format;
            while (format = time_formats[i++]) {
                if (diff > format[0]){
                    current_format = format[1];
                }
            }
            if (diff == 0){
                current_format = jstiming['time-ago/just-now'];
            }
            if (current_format.includes("[date]")){
                return new Date(time);
            } else if (current_format.includes("[month]")){
                return current_format.replace("[month]",Math.floor(diff/2592000));
            } else if (current_format.includes("[days]")){
                return current_format.replace("[days]",Math.floor(diff/86400));
            } else if (current_format.includes("[hours]")){
                return current_format.replace("[hours]",Math.floor(diff/3600));
            } else if (current_format.includes("[minutes]")){
                return current_format.replace("[minutes]",Math.floor(diff/60));
            }
            return current_format;
        }


    }
}





class UIMessages {
    constructor() {}
    hideme(){
        this.base.css({"opacity":0});
        this.base.hide();
    }
    show(message,time,fnstart,fnend) {
        var _this = this;
        $(".usermessages .contt").hide();
        if ($(".usermessages").length < 1){
            $("body").append('<div class="usermessages"><div class="ovr"></div><div class="contt"><div class="icon-x"></div><div class="hln"></div></div></div>');
            this.base = $(".usermessages");
        }
        this.base.show();
        this.base.find(".hln").html(message);
        var mhd = this.base.find(".contt").height();
        var mwd = this.base.find(".contt").width();
        this.base.find(".contt").css({
            "top":($(window).height()-mhd) /2,
            "left":($(window).width()-mwd) /2,
        });
        if (fnstart != ''){ eval(fnstart);  }
        setTimeout(function(){ $(".usermessages .contt").show(); $(".usermessages").animate({"opacity":1},2); },100);
        setTimeout(function(){
            $(".usermessages").fadeOut(100);
            setTimeout(function(){
                $(".usermessages .contt").hide();
                $(".usermessages .hln").html('');
            },120);
            if (fnend != ''){ eval(fnend);}
        },time);
        this.base.find(".ovr").on("click",function(){ if (fnend != ''){ eval(fnend);} _this.hideme(); });
        this.base.find(".icon-x").on("click",function(){  if (fnend != ''){ eval(fnend);} _this.hideme();});
    }
}
let uimessages = new UIMessages();


class StarChooser {
    fillstars(_this,d){
        var i = 0;
        _this.find(".activ").each(function (){
            $(this).removeClass("activ");
        });
        _this.find(".icon-star").each(function(){
            i++;
            if (i < d){
                $(this).addClass("activ");
            } else if (i == d) {
                $(this).addClass("activ current");
            } else {
                $(this).removeClass("activ");
            }
        });
        _this.find("b").text(d);
    }
    constructor() {
        $("body").delegate(".mo_rating","mouseout",function(){
            var star_rating_value = $(this).attr("data-default-rating");
            if (star_rating_value != $(this).find("b").text()){
                starChooser.fillstars($(this),star_rating_value);
            }
        });
        $("body").delegate(".mo_rating .icon-star","mouseover",function(){
            starChooser.fillstars($(this).parent(),$(this).data("sti"));
        });
        $("body").delegate(".mo_rating .icon-star","click",function(){
            $(this).parent().attr("data-default-rating",$(this).data("sti"));
            starChooser.fillstars($(this).parent(),$(this).data("sti"));
        });
    }
}

let starChooser = new StarChooser();


const Reactions = {
    $root: null,
    selectors: new Object(),
    after_emo_hook: null,
    currentItem : null,
    $document: null,
    animationEnd: null,
    click_outside: [],
    start(ops) {
        this.bundle = ops['bundle'];
        this.item_selector = ops['selector_items'];
        this.area_selector = ops['selector_area'];
        this.selectors = {
            root    : this.area_selector,
            trigger : this.item_selector,
            popover : '[data-reactions-popover]',
            btnEmo  : '[data-trigger-emo]'
        };
        if (typeof ops['after_emo_hook'] != 'undefined'){
            this.after_emo_hook = ops['after_emo_hook'];
        };
        this.$root        = $(this.selectors.root);
        this.$document    = $(document);
        this.animationEnd = this.checkAnimationEnd();
        this.bind();
    },
    checkAnimationEnd() {
        const div = document.createElement('div')
        const animations = {
            animation      : 'animationend',
            OAnimation     : 'oAnimationEnd',
            MozAnimation   : 'mozAnimationEnd',
            WebkitAnimation: 'webkitAnimationEnd',
        }
        for (let t in animations) {
            if (div.style[t] !== undefined) {
                return animations[t];
            }
        }
    },
    bind() {
        this.$root.on('click', "*",  $.proxy(this.onClickOutside, this));
        $(document).delegate(this.selectors.trigger, 'click',  $.proxy(this.onTriggerClick, this));
        $(document).delegate(this.selectors.btnEmo, 'click',  $.proxy(this.onEmoClick,    this));
        this.$document.on('keydown', $.proxy(this.onEscPress, this));
    },
    onClickOutside(event){
        var t = $(event.target);
        for(var el in this.click_outside){
            if (typeof this.click_outside[el][0] == 'function'){
                if (t.closest(this.click_outside[el][1]).length == 0) {
                    this.click_outside[el][0](this.click_outside[el][1]);
                }
            }
        }
    },
    onTriggerClick(event) {
        event.preventDefault();
        const $target   = $(event.target);
        const $root     = $target.closest(this.selectors.root);
        const $popover  = $root.find(this.selectors.popover);
        const isVisible = false === $popover.hasClass('reacts-only');
        if (isVisible) {
            var currentTargetRect = event.currentTarget.getBoundingClientRect();
            $(this.selectors.popover).removeClass('reacts-only');
            var leftps = currentTargetRect.left;
            if ((leftps+$(this.selectors.popover).width()) > window.outerWidth ){
                leftps = leftps-((leftps+$(this.selectors.popover).width()) - window.outerWidth);
            }
            $(this.selectors.popover).css({"top":currentTargetRect.top-$(this.selectors.popover).height() - 10,"left":leftps});
            $(this.selectors.popover).show();
            $(this.selectors.popover).attr("data-to-id",$(event.currentTarget).data("id"));
            $(this.selectors.popover).attr("data-to-bundle",this.bundle);
            this.currentItem = $(event.currentTarget);
            var itemm = this.selectors.popover;
            this.set_outside_listener('test',itemm,  function (itemm) {
                $(document).find(itemm).hide();
            });
        } else {
            $(this.selectors.popover).addClass('reacts-only');
        }
    },
    set_outside_listener(name,element,after){
        this.click_outside[name] = '';
        var _this = this;
        setTimeout(function () {
            _this.click_outside[name] = [
                after,
                element
            ];
        }, 50)
    },
    onEmoClick(event) {
        event.preventDefault();
        this.doReaction($(event.target).data("trigger-emo"))
    },
    doReaction(type) {
        this.closePopovers();
        var toid = $(document).find(this.selectors.popover).attr("data-to-id");
        var array = {
            action: 'mo_ajax',
            module: 'reactions',
            do: 'do_reactions',
            lang: mosettings['lang'],
            core: 1,
            type:type,
            bundle:this.bundle,
            for_id:  toid
        };
        $.ajax({
            type: 'POST', url: window.location.protocol+'//'+window.location.hostname + '/core/bridge/load.php?mod=users',
            data: array
        }).done($.proxy(this.onSaveSuccess, this))
            .fail($.proxy(this.onSaveFail, this));

    },
    findItemResults(){
        if (this.currentItem.find(".moreact-reactions__results").length > 0){
            return this.currentItem.find(".moreact-reactions__results");
        } else {
            return this.currentItem.parent().find(".moreact-reactions__results");
        }
    },
    onSaveSuccess(response) {
        response = JSON.parse(response);
        var thisitemclicked = this.findItemResults();
        if (thisitemclicked != '') {
            thisitemclicked.replaceWith(response['html']);
            thisitemclicked = this.findItemResults();
            thisitemclicked.addClass("react-changde");
            var _this = this;
            $(this.selectors.root).find(".react-changde").each(function () {
                var _this = $(this);
                setTimeout(function () {
                    _this.removeClass("react-changde");
                }, 100000);
            });
            if (this.after_emo_hook != '') {
                var hookdd = this.after_emo_hook;
                if (typeof window[hookdd] !== "undefined") {
                    window[hookdd](response);
                }
            }
        }
        this.currentItem = null;
    },
    onSaveFail(xhr, status, error) {
        if (typeof mo.user != 'undefined'){
            if (mo.user.logged == 1) {
                uimessages.show("Please login!",545458000,"",'');
            }
        }
    },
    onEscPress(event) {
        if (event.keyCode && event.keyCode === 27) {
            this.closePopovers()
        }
    },
    closePopovers() {
        $(this.selectors.popover).hide().addClass('reacts-only');
    },
};class gdpr {
    constructor(types,hooks) {
        if ($.cookie('gdpr') == '1') {
        } else {
            if (typeof types != 'undefined') {
                if (typeof hooks != 'undefined') {
                    this.hooks = hooks;
                    this.cookie_types = types;
                    this.delegates();

                }
            }
        }
    };

    render_types(){
        if (this.rendered == 0) {
            $("#cookie-policy__configure").prepend('<ul id="cpol_nav"></ul>');
            for (var v in this.cookie_types['types']) {
                $(".cpol_form").append('<div class="cookies-policy__section" id="cpol_' + v + '"><span class="tttld">' + this.cookie_types['types'][v]['title'] + '</span>' + this.cookie_types['types'][v]['description'] + '<label><input type="checkbox"> ' + this.cookie_types['types'][v]['title'] + '</label></div>');
                $("#cpol_nav").append('<li rel="cpol_' + v + '">' + this.cookie_types['types'][v]['title'] + '</li>');
            }
            $(".cpol_form .cookies-policy__section").first().addClass("active");
            $(".cpol_form .cookies-policy__section").first().find("input").attr("checked", "checked");
            $("#cpol_nav li").first().addClass("active");
            this.rendered = 1;
        }
    }

    delegates(){
        var _this = this;
        this.rendered = 0;
        $(".cookie-policy").show();
        $(".cpol_desc").html(this.cookie_types['title']);
        $("#cookie-policy__config").on("click",function (){
            _this.render_types();
            $(".cpol_configure").slideDown(200);
        }) ;
        $(".cookie-policy").delegate("#cpol_nav li","click",function (){
            var thisrel = $(this).attr('rel');
            $(".cookies-policy__section").each(function (){
                $(this).removeClass("active");
                if ($(this).attr("id") == thisrel){
                    $(this).addClass("active");
                }
            });
            $("#cpol_nav li").each(function (){
                $(this).removeClass("active");
            });
            $(this).addClass("active");
        });
        $("#cookie-policy__accept").on("click",function (){
            $.cookie('gdpr', '1', {expires: 120, path: '/'});
            $(".cookie-policy").slideUp(200);
            _this.run_cookies(Object.keys(_this.cookie_types['types']));
        })
        $("#cookie-policy__done").on("click",function (){
            var dd = [];
            $(".cookies-policy__section").each(function (){
                if ($(this).find("input").prop("checked") == true){
                    dd.push($(this).attr("id").replace("cpol_",""));
                }
            });
            _this.run_cookies(dd);
        });
    }
    run_cookies(types){
        for(var tyy in this.cookie_types['types']){
            if (this.cookie_types['types'][tyy]['cookies'].length > 0) {
                for (var coo in this.cookie_types['types'][tyy]['cookies']) {
                    if (typeof this.hooks[this.cookie_types['types'][tyy]['cookies'][coo]] != 'undefined') {
                        this.hooks[this.cookie_types['types'][tyy]['cookies'][coo]]();
                    }
                }
            }
        }
    }
}class MoTables {

    constructor() {
        if (typeof mo_table_id !== 'undefined') {
            this.table_id = mo_table_id;
            this.row_class = mo_row_class;
            this.row_cell = mo_row_cell;
            this.cell_count = 0;
            this.no_reorder_js = mo_table_no_reorder_js;
            this.init();
        }
    };
    init(){
        if ($(this.table_id).length > 0) {
            this.labels = $(this.table_id).find(this.row_class + ".labels");
            //get cell counts
            var thiscellcount = 0;
            $(this.row_class).first().find(this.row_cell).each(function () {
                thiscellcount++;
            });
            this.cell_count = thiscellcount;
            //resolution fixes
            this.resolution_fixes();
            this.delegates();
        }
    }

    delegates(){
        $(this.table_id).delegate("."+mo_show_more_class,"click",function(){
            $(this).parent().parent().find(mo_row_class+".dontshow").each(function(){
                $(this).removeClass("dontshow");
            });
            $(this).remove();
        });
    }

    resolution_fixes(){
        if (mo.root.win_width > 767 && this.cell_count > 4){
            var cellarrangement = new Object();
            $(this.table_id).find(this.row_class).first().find(this.row_cell).each(function (){
                cellarrangement[$(this).data("cell")] = $(this).width();
            });
            $(this.table_id).find(this.row_cell).each(function (){
                $(this).css({"width":cellarrangement[$(this).data("cell")]});
            });
        }
    }


    reorder(){
        if (this.no_reorder_js != 1) {
            var topops = [];

            function reOrderTable_changefield(field, opslug, obj) {
                if (obj.length > 0) {
                    if (field in mo.root.user_params['countryPrefDetails'][opslug]) {
                        obj.text(mo.root.user_params['countryPrefDetails'][opslug][field]);
                    }
                }
            }
            if (typeof mo.root.user_params['countyHide'] != 'undefined') {
                $(mo.tables.table_id).find(mo.tables.row_class).each(function () {
                    if (mo.root.user_params['countyHide'].includes($(this).data("operator"))) {
                        $(this).remove();
                    }
                });
            }
            var out = '';
            for (var i in mo.root.user_params['countryPreferred']) {
                if (topops.hasOwnProperty(mo.root.user_params['countryPreferred'][i])) {
                    out += topops[mo.root.user_params['countryPreferred'][i]];
                }
            }

            if ($(mo.tables.labels).length > 0) {
                $(mo.tables.labels).after(out);
            } else {
                if ($(mo.tables.table_id).find(".rows").length > 0){
                    $(mo.tables.table_id).find(".rows").prepend(out);
                } else {
                    $(mo.tables.table_id).find("table").prepend(out);
                }
            }
        }
        $(mo.tables.table_id).find(mo.tables.row_class).each(function () {
            if ($(this).hasClass("highlight")){
                $(this).removeClass("dontshow");
            }
            if ($(this).html() == ''){
                $(this).remove();
            }
        });
        $(mo.tables.table_id).find("img[data-src]").lazy();
        $(mo.tables.table_id).find(".logo.lazy").lazy();
        $(mo.tables.table_id).find(".paymnt.lazy").lazy();
    }
}
const mo = [];

class Mo {

    constructor() {
        this.win_width          = $(window).width();
        this.win_height         = $(window).height();
        this.doc_height         = $(document).height();
        this.doc_width          = $(document).width();
        this.click_outside      = [];
        this.hooks              = [];
        this.loc_hooks          = [];
        this.theme              = [];
        this.user_params        = [];
        this.nav_closed         = 1;
        this.device_sys         = '';
        this.device             = '';
        this.check_device();
        this.ui_listeners();

    };


    init(){
        this.listeners();
        this.languages();
    }

    load(){
        this.init();
        mo.m = new MoModules();
        mo.ui = new MOUI();
        mo.user = new MoUser();
        mo.tables = new MoTables();
        this.filters();
        this.load_theme();
    }



    listeners(){
        //on click out listener
        document.body.onclick = function(event){
            var t = $(event.target);
            for(var el in mo.root.click_outside){
                if (typeof mo.root.click_outside[el][0] == 'function'){
                    if (t.closest(mo.root.click_outside[el][1]).length == 0) {
                        mo.root.click_outside[el][0](mo.root.click_outside[el][1]);
                    }
                }
            }
        };
    }

    set_outside_listener(name,element,after){
        mo.root.click_outside[name] = '';
        setTimeout(function () {
            mo.root.click_outside[name] = [
                after,
                element
            ];
        }, 200)
    }

    filters(){
        for(var hook in this.hooks){
            this.hooks[hook]();
        }
    }

    user_location_init(){
        if (mo.tables) {mo.tables.reorder();}
        for(var hook in this.loc_hooks){
            this.loc_hooks[hook]();
        }
    }

    set_cookie(name,value,period){
        $.cookie(name, value, {expires: period, path: '/'});
    }


    load_theme(){
        for(var hook in this.theme){
            this.theme[hook]();
        }
    }


    call(dod,options,callback){
        var array = {
            action: 'ajaxmo', type: dod, lang:mosettings['lang']
        };
        $.extend( array, options );
        $.ajax({
            type: 'POST',  url: mosettings['host']+'/ajax.php',
            data: array,
            success: function (data) {
                if(typeof callback == "function") {
                    callback(data);
                }
            }
        });
        return true;
    }


    sharer(){
        if (this.device_sys == 'android' && typeof navigator.share == 'function') {
            $('.android-share').addClass("shown");
            $(".agent-share").hide();
            const android_btn = document.querySelector('.android-share');
            android_btn.addEventListener('click', async () => {
                try {
                    const shareData = {
                        title: $('.android-share').data("title"),
                        text: $('.android-share').data(""),
                        url: $('.android-share').data("link"),
                    }
                    await navigator.share(shareData)
                } catch (err) {}
            });
        }
    }


    languages(){
        if (this.device == 'desktop'){
            $("#languages").hover(function(){
                $(this).addClass("active");
            },function(){
                $(this).removeClass("active");
            });
        } else {
            $("#languages .current").on("click",function(){
                var _langs = $(this).parent();
                _langs.addClass("active");
                if ($("body").hasClass("is_mobile")) {
                    if ($(this).parent().find(".icon-x").length == 0) {
                        $(this).parent().find("ul").prepend("<i class='icon-x'></i>");
                    }
                }
                mo.root.click_outside['language_hide'] = [
                    function(){
                        $("#languages").removeClass("active");
                    },
                    "#languages"
                ];
            });
            $("#languages").on("click", ".icon-x", function () {
                $(this).parent().parent().removeClass("active");
            });
        }
    }



    check_device(){
        this.device_sys = this.operatingSystem();
        this.device = this.deviceType();
    }


    deviceType(){
        var touch = 0;
        if(window.matchMedia("(pointer: coarse)").matches) {
            touch = 1;
        }
        var type = 'phone';

        if (this.win_width > 767){
            type = 'tablet';
        }
        if (this.win_width > 767 && touch == 0){
            type = 'desktop';
        }
        return type;
    }



    operatingSystem() {
        var operatingSystemName = NaN;
        var userAgent = window.navigator.userAgent;
        var osNamesTokens = [{
            osName: "Windows 2000",
            osToken: /(Windows NT 5.0|Windows 2000)/,
        }, {
            osName: "Windows XP",
            osToken: /(Windows NT 5.1|Windows XP)/,
        }, {
            osName: "Windows Server 2003",
            osToken: /Windows NT 5.2/,
        }, {
            osName: "Windows Vista",
            osToken: /Windows NT 6.0/,
        }, {
            osName: "Windows 7",
            osToken: /(Windows 7|Windows NT 6.1)/,
        }, {
            osName: "Windows 8.1",
            osToken: /(Windows 8.1|Windows NT 6.3)/,
        }, {
            osName: "Windows 8",
            osToken: /(Windows 8|Windows NT 6.2)/,
        }, {
            osName: "Windows Phone",
            osToken: /Windows Phone/,
        }, {
            osName: "Windows 10",
            osToken: /(Windows 10|Windows NT 10.0)/,
        }, {
            osName: "Windows ME",
            osToken: /Windows ME/,
        }, {
            osName: "Windows NT 4.0",
            osToken: /(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/,
        }, {
            osName: "Android",
            osToken: /Android/,
        }, {
            osName: "Open BSD",
            osToken: /OpenBSD/,
        }, {
            osName: "Sun OS",
            osToken: /SunOS/,
        }, {
            osName: "Linux",
            osToken: /(Linux|X11)/,
        }, {
            osName: "iOS",
            osToken: /(iPhone|iPad|iPod)/,
        }, {
            osName: "Mac OS X",
            osToken: /Mac OS X/,
        }, {
            osName: "Mac OS",
            osToken: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/,
        }, {
            osName: "QNX",
            osToken: /QNX/,
        }, {
            osName: "UNIX",
            osToken: /UNIX/,
        }, {
            osName: "BeOS",
            osToken: /BeOS/,
        }, {
            osName: "OS/2",
            osToken: /OS\/2/,
        }, {
            osName: "Search Bot",
            osToken: /(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/,
        },];

        for (var index in osNamesTokens) {
            var osKeyValuePair = osNamesTokens[index];
            if (osKeyValuePair.osToken.test(userAgent)) {
                operatingSystemName = osKeyValuePair.osName;
                break;
            }
        }

        if(operatingSystemName && operatingSystemName.indexOf("Windows") !== -1 && operatingSystemName.indexOf("Phone") === -1){
            let lastSpace = operatingSystemName.lastIndexOf(" ");
            if(lastSpace !== -1)
            {
                operatingSystemName = operatingSystemName.substring(0, lastSpace);
            }
        }
        return operatingSystemName.toLowerCase();
    }




    ui_listeners(){

        var _this = this;
        //sharer
        $(function (){
            _this.sharer();
        });

        //tooltip
        $(document).delegate("[data-tooltip]","mouseover",function(){  mo.ui.tooltip($(this)); });
        $(document).delegate("[data-tooltip]","mouseout",function(){   $(".toolTip").hide();  });


        if ($(".dropdown").length > 0){
            $(".dropdown").each(function (){
                var thisid = $(this).attr("id");
                _this.make_dropdown("#"+thisid);
            })
        }

        $("body").delegate(".base_tabs .nav li","click",function () {
            var thisc = $(this).data("slug");
            $(this).parent().find("li").each(function(){
                $(this).removeClass("active");
            });
            $(this).addClass("active");
            $(this).parent().parent().find(".tab").each(function(){
                $(this).removeClass("active");
                if ($(this).data("slug") == thisc){
                    $(this).addClass("active");
                }
            });
        });

        $("body").delegate(".acc-box .achead","click",function(){
            $(this).parent().find(".accont").fadeToggle(300);
            if ($(this).parent().hasClass("opened")){
                $(this).parent().removeClass("opened");
            } else {
                $(this).parent().addClass("opened");
            }
            if (typeof $(this).parent().find(".accont img").attr("src") == 'undefined'){
                var dmd = $(this).parent().find(".accont img").attr("data-src");
                $(this).parent().find(".accont img").attr("src",dmd);
            }
        });

        $("body").delegate(".accbox .head","click",function(){
            $(this).parent().find(".cont").slideToggle(300);
            if ($(this).parent().hasClass("opened")){
                $(this).parent().removeClass("opened");
            } else {
                $(this).parent().addClass("opened");
            }
            if (typeof $(this).parent().find(".cont img").attr("src") == 'undefined'){
                var dmd = $(this).parent().find(".cont img").attr("data-src");
                $(this).parent().find(".cont img").attr("src",dmd);
            }
        });

        $("body").delegate("[data-molink]","click",function(){
            if ($(this).data("molink") != ''){
                if ($(this).data("molink-target") != '' && typeof $(this).data("molink-target") != 'undefined'){
                    if ($(this).data("molink-target") == '_blank'){
                        window.open($(this).data("molink"),'_blank');
                    }
                } else {
                    window.location.href = $(this).data("molink");
                }
            }
        });
    }

    make_dropdown(item,label){
        if (typeof item !== 'object'){
            var item = $(item);
        }
        if (!item.hasClass("dropdown")){
            item.addClass("dropdown");
        }
        if (!item.hasClass("downrc")) {
            var title = item.attr("data-dropdown-title");
            if (typeof label != 'undefined'){
                title = label;
            }

            var selected_label = item.attr("data-selected-label");
            if (typeof selected_label == 'undefined') {
                selected_label = title;
            }
            var label = '<span class="label"><span>' + selected_label+'</span>';
            if (item.data("counts")){
                label += '<b class="count">'+item.data("counts")+'</b>';
            }
            label += '</span>';

            item.prepend(label);
            item.find(".uidrop").attr("id", "dropdown" + (Math.floor(Math.random() * Math.floor(999999))));
            item.find(".label").on("click", function () {
                var id = "#" + $(this).parent().find(".uidrop").attr("id");
                if ($(id+"_shownd").length > 0){
                    if ($(id+"_shownd").hasClass("shown")){
                        $(id+"_shownd").fadeOut(200);
                        setTimeout(function () {
                            $(id + "_shownd").remove()
                        });
                    } else {
                        $(id+"_shownd").fadeIn(200);
                    }
                } else {
                    $(id).show();
                    item.find(".imglazy").each(function () {
                        $(this).lazy();
                        $(this).css({"background-image": "url(" + $(this).data("src") + ")"});
                    });
                    item.find(".lazy").each(function () {
                        $(this).lazy();
                        $(this).css({"background-image": "url(" + $(this).data("src") + ")"});
                    });

                    if (item.data("element-callback")){
                        mo.root.show_dropdown(id, $(this),item.data("element-callback"));
                    } else {
                        mo.root.show_dropdown(id, $(this));
                    }

                }
            });
            item.addClass("downrc");
        }

    }


    show_dropdown(item,clicked,callback) {
        var windowwith = $(window).width();
        //create copy
        var htmldd = $(item).html();
        var root_elem = clicked.parent();
        if (typeof root_elem != 'undefined'){
            var fullwidth = root_elem.attr("fullwidth");
        }
        var attr_id = $(item).attr("id");
        var attr_class = $(item).attr('class');
        var selected = clicked.parent().attr('data-select');

        var olditem = "#"+attr_id;
        item = "#"+attr_id+"_shownd";
        if ($("body").find("#"+attr_id+"_shownd").length == 0){
            var htmltoins = "<div id='"+attr_id+"_shownd' class='"+attr_class+"'>";
            if (root_elem.data("search") == '1'){
                htmltoins += '<input type="text" class="search_cur_dropbox" placeholder="'+root_elem.data("search-label")+'"/>';
            }
            htmltoins += '<div class="inner">'+htmldd+'</div></div>';
            $("body").append(htmltoins);
        }


        //calibrating position
        if (clicked == ''){
            $(item).css({left: (windowwith - $(olditem).outerWidth())/2});
        } else {
            var thisoffset = clicked.offset();
            var thiswidth = clicked.width();
            var dropdownwidth = $(olditem).outerWidth();

            thisoffset.top += clicked.height()+10;
            $(item).css({"top":thisoffset.top,"left":thisoffset.left});
            if (windowwith > 430 || dropdownwidth < (windowwith*0.6)) {
                if (($(item).width() + thisoffset.left) > $(window).width()) {
                    $(item).css({
                        top: thisoffset.top,
                        left: (thisoffset.left + thiswidth) - $(item).width() -10
                    });
                    $(item).addClass("alnright");
                } else {
                    $(item).css({top: thisoffset.top, left: thisoffset.left});
                }
            } else {
                $(item).css({top: thisoffset.top, left: (windowwith - $(olditem).outerWidth())/2});
            }
            if (fullwidth == 1){
                $(item).css({"max-width":root_elem.outerWidth(),  left: thisoffset.left});
            }
            $(item).slideDown(150);
        }

        if (selected != ''){
            $("#"+attr_id+"_shownd").find("[data-ty='"+selected+"']").addClass('active');
        }


        //setting the search
        if (root_elem.data("search") == '1') {
            $("#"+attr_id+"_shownd .search_cur_dropbox").on("keyup",function (){
                var s = $(this).val().toLowerCase();
                if (s != '') {
                    $("#" + attr_id + "_shownd .inner").children().each(function () {
                        var thistext = $(this).text().toLowerCase();
                        if (thistext.includes(s)){
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    });
                } else {
                    $("#" + attr_id + "_shownd .inner").children().each(function () {
                        $(this).show();
                    });
                }
            });
        }

        $(item).show();
        $(olditem).hide();

        if (clicked != '' && typeof mo.root.max_width_container != 'undefined') {
            if (windowwith > mo.root.max_width_container) {
                var itemoffset = $(clicked).offset();
                var itemwidth = $(item).outerWidth();
                if ((itemoffset.left + itemwidth) > ((windowwith - mo.root.max_width_container) / 2 + mo.root.max_width_container)) {
                    $(item).css({"left": "inherit"});
                    $(item).css({"right": (windowwith - mo.root.max_width_container) / 2});
                }
            }
        }

        //click on ghost element li
        $(item).delegate("li", "click", function () {
            $(this).parent().hide();
            var selected = $(this).attr("data-ty");
            if (typeof $(this).attr('data-ty-label') != 'undefined') {
                var text = $(this).attr('data-ty-label');
            } else {
                var text = $(this).text();
            }

            // element_callback
            if(typeof window[callback] == "function") {
                window[callback](selected);
            }

            $(olditem).parent().find(".active").each(function (){$(this).removeClass("active");});
            $(this).addClass("active");
            $(olditem).parent().find(".uidrop > li[data-ty='"+selected+"']").trigger("click");
            $(olditem).parent().attr("data-select", selected);
            if (selected == '') {
                $(olditem).parent().find(".label").html($(olditem).parent().data("dropdown-title"));
            } else {
                $(olditem).parent().find(".label").html(text);
            }
        });

        mo.root.set_outside_listener('hide_'+item,item,  function (item) {
            $(document).find(item).remove();
        });
    };
}



class MoModules {
    constructor() {};
    call(module,doo,options,callback){
        if (typeof options['nopreloader'] === "undefined"){
            mo.ui.preloader();
        }
        var array = {
            action: 'mo_ajax', module: module, do:doo, lang:mosettings['lang']
        };
        $.extend( array, options );
        $.ajax({
            type: 'POST',  url: mosettings['host']+'/ajax.php?mod='+module,
            data: array,
            success: function (data) {
                mo.ui.hide_preloader();
                if(typeof callback == "function") {
                    callback(data);
                }
            }
        });
        return true;
    }
    call_core(module,doo,options,callback){
        mo.ui.preloader();
        var array = {
            action: 'mo_ajax', module: module, do:doo, lang:mosettings['lang'] , core:1
        };
        $.extend( array, options );
        $.ajax({
            type: 'POST',  url: mosettings['host']+'/core/bridge/load.php?mod='+module,
            data: array,
            success: function (data) {
                mo.ui.hide_preloader();
                if(typeof callback == "function") {
                    callback(data);
                }
            }
        });
        return true;
    }
}



class MOUI {

    constructor() {
        var _this = this;

        if ($(".section").length > 0) {
            $(".section").each(function(){
                if ($(this).hasClass("is_fullwidth")){
                    $(this).css({"width":mo.root.win_width});
                    var rect = $(this).offset();
                    rect = -rect.left;
                    $(this).css({"margin-left":rect});
                };
            })
        }
        if(!$('body').hasClass('no_fullwidth')){
            //fullwidths
            if ($(".box.fullwidth").length > 0) {
                $(".box.fullwidth").each(function () {
                    _this.box_fullwidth($(this));
                });
            }
        }

    }

    preloader(){
        if ($("body").find(".sitePreloader").length < 1){
            $("body").append('<div class="sitePreloader"></div>');
        }
        $(".sitePreloader").show();
    }
    hide_preloader(){
        $(".sitePreloader").hide();
    }

    tooltip(el){
        var html = el.data("tooltip");
        if ($(".toolTip").length == 0){
            $("body").append('<div class="toolTip"><div class="in"></div></div>');
        }
        $(".toolTip").removeClass("alignleft");
        var offset = el.offset();
        var arrow_position = 'center';
        if (el.width() < 100){
            arrow_position = 'left';
        }
        $(".toolTip .in").html(html);
        var toolheight = $(".toolTip").height() + 20;
        if ($window.width() < ($(".toolTip").width()+offset.left)){
            $(".toolTip").addClass("alignleft");
            $(".toolTip").css({"top":offset.top-toolheight,"left":(offset.left-$(".toolTip").width())});
        } else {
            $(".toolTip").css({"top":offset.top-toolheight,"left":offset.left});
        }
        $(".toolTip").attr("data-arrow-position",arrow_position);
        $(".toolTip").show();
    }

    box_fullwidth(_this){
        var pos = _this.offset();
        _this.css({
            "width":$(window).width(),
            "margin-left":-pos.left
        });
        _this.find(".inside").css({
            "width": $($contentblock).width(),
            "margin-left": pos.left
        });
        _this.find("img").each(function(){
            $(this).lazy();
        });
        _this.find(".lazy").each(function(){
            $(this).lazy({visibleOnly: true});
        });
    }
}
mo.root = new Mo();


mo.root.theme['lazy'] = function () {
    $('.lazy').lazy({visibleOnly: true});
}



mo.root.theme['timing'] = function(){
    $("time,.time").each(function(){
        $(this).html(mo.user.moments($(this).attr("datetime")));
    });
}


mo.root.theme['scroll'] = function () {
    var body = $("body");
    var rscrtop = $(".totop");
    $(window).scroll(function () {
        var scroll = $(window).scrollTop();
        if (scroll >= 140) {
                rscrtop.fadeIn();
        } else {
                rscrtop.fadeOut();
        }
        if (scroll > mo.root.win_height/2){
            body.addClass("attachedHeader");
        } else {
            body.removeClass("attachedHeader");
        }
    });
}



mo.root.theme['objectLikes'] = function () {
    var ajax_flag = 0;
    user_likes = new Object();
    if (localStorage.getItem("objectLikes")){
        var user_likes = JSON.parse(localStorage.getItem("objectLikes"));
        for (p in user_likes) {
            if (document.querySelector(".objectLikes[data-id='"+user_likes[p]['i']+"'][data-type='"+user_likes[p]['t']+"']")){
                document.querySelector(".objectLikes[data-id='"+user_likes[p]['i']+"'][data-type='"+user_likes[p]['t']+"'] > ."+user_likes[p]['a']+"").setAttribute("data-active","1");
            }
        }
    }
    $(document).delegate(".objectLikes > div","click",function (){
        if (ajax_flag == 0) {
            clearTimeout(timeoutclikked);
            var options = {i:$(this).parent().data("id"),t:$(this).parent().data("type"),a:$(this).attr("class")};
            var ol_sel = $(this);
            var ol_hash = options['i']+options['t'];
            var decrease = 0;
            var votedalready = 0;
            if (user_likes[ol_hash]){
                if (user_likes[ol_hash]['a'] == options['a']){
                    decrease = 1;
                }  else {
                    votedalready = 1;
                }
            }
            var newnum = parseInt(ol_sel.find(".num").text()) + 1;

            if (decrease == 1){
                var newnum = parseInt(ol_sel.find(".num").text()) - 1;
                options['decrease'] = 1;
                delete user_likes[ol_hash];
                ol_sel.parent().find("> div[data-active='1']").removeAttr('data-active');
            } else {
                user_likes[ol_hash] = options;
                ol_sel.parent().find("> div[data-active='1']").removeAttr('data-active');
                ol_sel.attr("data-active",'1');
                if (votedalready == 1){
                    ol_sel.parent().find("> div").each(function (){
                        if ($(this).attr("data-active") != '1') {
                            var mdn = parseInt($(this).find(".num").text()) - 1;
                            if (mdn < 0) {
                                mdn = 0;
                            }
                            $(this).find(".num").text(mdn);
                        }
                    });
                }
            }
            if (newnum < 0) { newnum = 0; }
            ol_sel.find(".num").text(newnum);
            localStorage.setItem('objectLikes', JSON.stringify(user_likes));
            if (votedalready == 1){  options['already_voted'] = 1; }
            ajax_flag = 1;
            var timeoutclikked = setTimeout(function (){
                mo.m.call("reactions", "objectLike", options, function (data) {
                    ajax_flag = 0;
                });
            },500);
        }
    });
}


mo.root.theme['start'] = function () {

    $(".casino-header .showmore").on("click",function (){
        $(this).remove();
            $(".casino-details li").each(function (){
                $(this).removeClass("hidden");
            })
    });
    $(document).find(".makefavorite").each(function (){
        var localFavs = JSON.parse(localStorage.getItem('gameFavs'));
        if (typeof localFavs == 'object' && localFavs != null) {
            if (localFavs.includes($(this).data("gameid"))) {
                $(this).addClass("is_fav");
            }
        }
    });

    $(".scrollToTop").click(function (e) {
        e.preventDefault();
        $("html, body").animate({scrollTop: 0}, "slow");
    });

    $(".starRate").on("click",".stars i",function(){
        var _thisID = $(this).parent().parent().data("id");
        var _this = $(this);
        var options = new Object();
        options['id'] = _thisID;
        options['rating'] = _this.attr("rel");
        options['type'] = $(this).parent().parent().data("type");
        _this.parent().animate({"opacity":0.5},400);
        if ($.cookie('starrating_'+_thisID+'') != 1) {
            console.log(mo);
            mo.root.call('stars_rating',{data: options},function(data){
                $.cookie('starrating_' + _thisID + '', '1', { expires: 1 });
                _this.parent().animate({"opacity":1},400);
                uimessages.show(data,10000,"","window.location.reload()");
            });
        }
    });


    $(document).delegate(".makefavorite","click",function (){
        var localFavs = JSON.parse(localStorage.getItem('gameFavs'));
        var gameid = $(this).data("gameid");
        if (typeof localFavs == 'undefined' || localFavs == null){
            localFavs = [];
        }
        if ($(this).hasClass("is_fav")) {
            $(this).removeClass("is_fav");
            if (localFavs.length > 0) {
                localFavs = localFavs.filter(data => data != gameid);
            }
            uimessages.show("Removed from favorites!",1500,"");
        } else {
            $(this).addClass("is_fav");
            uimessages.show("Added in favorites!",1500,"");
            localFavs.push(gameid);
        }
        localStorage.setItem('gameFavs', JSON.stringify(localFavs));
    });

    $(".game-details .info").on("click",function (){
        $(this).find(".tipBox").addClass("activee");
        $(".tipBox").each(function (){
            if (!$(this).hasClass("activee")){
                $(this).hide();
            }
        })
        $(this).find(".tipBox").fadeToggle(200);
        $(this).find(".tipBox").removeClass("activee");
    });

    $(".totop").click(function (e) {
        e.preventDefault();
        $("html, body").animate({scrollTop: 0}, "slow");
    });

            $(".dropdown-toggle").on("click",function(e){
                e.preventDefault();
                $('ul#'+jQuery(this).data('toggle')).slideToggle(300);
                var _thiss = $(this);
                _thiss.find(".icon-arrow-down").toggleClass("icon-arrow-up");
                setTimeout(function (){
                    _thiss.toggleClass("open");
                },250);
            });
            $(".toggled .title").on("click",function(){
                $(this).parent().find(".content").slideToggle(300);
                var _thiss = $(this);
                _thiss.find(".icon-arrow-down").toggleClass("icon-arrow-up");
                setTimeout(function (){
                    _thiss.parent().toggleClass("open");
                },250);
            });

            $(".smwall .clicksmwall").on("click",function(){
                $(this).parent().removeClass("smwall");
                $(this).remove();
            });
            $(document).on("click", ".bonus_code_button", function (e) {
                var $m = $(this).data("loadurl");
                setTimeout(function () {
                    window.location.href = $m;
                }, 1500);
            });

            var ajax_flag = 0;

            $(".share-menu .icon-plus").on("click",function(){
                $(this).parent().toggleClass("showother");
            });

            $(".header-right-icons .icon-search").on("click",function(){
                $("#topHeadSearch").fadeIn(200);
                $("#topHeadSearch input").focus();
            });
            $("#topHeadSearch .close").on("click",function(){
                $("#topHeadSearch").fadeOut(200);
            });



    $activepaymentsthumbs = [];
    $("#payment-thumbs div").on("click",function (){
        var thism = 'method-'+$(this).data("method");
        if ($(this).hasClass("active")){
            $(this).removeClass("active");
            if ($activepaymentsthumbs.includes(thism)){
                var index = $activepaymentsthumbs.indexOf(thism);
                $activepaymentsthumbs.splice(index, 1);
            }
        } else {
            $(this).addClass("active");
            if (!$activepaymentsthumbs.includes(thism)){
                $activepaymentsthumbs.push(thism);
            }
        }

        if ($activepaymentsthumbs.length > 0) {
            console.log($activepaymentsthumbs);
            $("#payment-thumbs").next().find("tr").each(function () {
                var thisccass = $(this).attr("class");
                if (typeof thisccass != 'undefined') {
                    thisccassd = thisccass.replace(' hidden', '');
                    thisccass = thisccassd;
                    if ($activepaymentsthumbs.includes(thisccass)) {
                        $(this).removeClass("hidden");
                    } else {
                        $(this).addClass("hidden");
                    }
                }
            });
        } else {
            $("#payment-thumbs").next().find("tr").each(function () {
                $(this).removeClass("hidden");
            });
        }
    });

    $(".showmore-table").on("click",function (){
       $(this).parent().find(".showmore").show();
       $(this).remove();
    });

};


mo.root.menu_mobile_show = function(){
            $('body').toggleClass("overlay");
            $('body').toggleClass("menuEnabled");
            $("nav#site-menu > ul").removeClass('opened');
            $("nav#site-menu li").removeClass('shown');
            $('.head-right').removeClass("opened");
            if ($("nav#site-menu > ul").find(".suggestionsMb").length == 0){
                $("nav#site-menu > ul").append('<li class="suggestionsMb" style="display: none"></li>');
                mo.root.call('load_mobile_menu_suggestions', {args: ""}, function (data) {
                    $(".suggestionsMb").html(data);
                    $(".suggestionsMb").fadeIn(200);
                });
            }
}

mo.root.theme['login'] = function(){
    if (mo.user.logged == 1){
        $(".mo_login_button .logged").show();
        $(".mo_login_button .login").hide();
        $(".mo_login_button .logged").find('i').html( mo.user.user_details['first_name']);
        if (mo.user.user_details['photo'] != ''){
            $(".mo_login_button").find(".logged b").css({"background-image":"url(https://nodepositslots.org/static/uploads-users/"+mo.user.user_details['photo']+")"});
        }
    } else {
        $(".mo_login_button .login").show();
        $(".mo_login_button .logged").remove();
    }
}


mo.root.theme['menu'] = function () {
    $("#content").on("click",function (){
        $('body').removeClass("overlay");
        $('body').removeClass("menuEnabled");
    });
            if ($("body").hasClass("is_mobile")){
                $("nav#site-menu li.has_submenu").each(function(){
                    $(this).append('<i class="icon-arrow-right"></i>');
                });
                $("nav#site-menu").delegate("i.icon-arrow-right","click",function(e){
                    e.preventDefault();
                    // $("nav#site-menu li").removeClass("shown");
                    if ($(this).parent().hasClass("shown")){
                        $(this).parent().removeClass("shown");
                    } else {
                        $(this).parent().addClass("shown");
                    }
                    $('nav#site-menu > ul').addClass("opened");
                });
                $("nav#site-menu").delegate("i.icon-arrow-left","click",function(){
                    $('nav#site-menu > ul').removeClass('opened');
                    setTimeout(function(){
                        $("nav#site-menu li").removeClass('shown');
                        $('.head-right').removeClass("opened");
                    },350);
                });
            } else {
                $(document).delegate("#site-menu > ul > li","mouseover",function(){
                    if ($(this).find(".submenu").length > 0) {
                        $(this).addClass("shown");
                    }
                });
            }

}

$(function(){mo.root.load()});