!function(t) {
    t.scrollBodyToElem = {
        go: function(t) {
            var $position = t.offset().top;

            // Responsive
            var $windowWidth = $(window).width();
            if($windowWidth <= 1180)
            {
                $position -= 50;
            }
            // END :: Responsive

            $([document.documentElement, document.body]).animate({
                scrollTop: $position
            }, 1000, 'swing');
        },
        pos: function(t, time) {
            $([document.documentElement, document.body]).animate({
                scrollTop: t
            }, time, 'swing');
        }
    }
}(jQuery);


/*!
 * History API JavaScript Library v4.2.10
 */
(function(m){if("function"===typeof define&&define.amd){if("undefined"!==typeof requirejs){var s=requirejs,j="[history"+(new Date).getTime()+"]",y=s.onError;m.toString=function(){return j};s.onError=function(m){-1===m.message.indexOf(j)&&y.call(s,m)}}define([],m)}if("object"===typeof exports&&"undefined"!==typeof module)module.exports=m();else return m()})(function(){var h=!0,i=null,p=!1;function m(a,b){var c=d.history!==q;c&&(d.history=q);a.apply(q,b);c&&(d.history=k)}function s(){}function j(a,b,c){if(a!=i&&""!==a&&
    !b){var b=j(),f=g.getElementsByTagName("base")[0];!c&&(f&&f.getAttribute("href"))&&(f.href=f.href,b=j(f.href,i,h));c=b.d;f=b.h;a=""+a;a=/^(?:\w+\:)?\/\//.test(a)?0===a.indexOf("/")?f+a:a:f+"//"+b.g+(0===a.indexOf("/")?a:0===a.indexOf("?")?c+a:0===a.indexOf("#")?c+b.e+a:c.replace(/[^\/]+$/g,"")+a)}else if(a=b?a:e.href,!o||c)a=a.replace(/^[^#]*/,"")||"#",a=e.protocol.replace(/:.*$|$/,":")+"//"+e.host+l.basepath+a.replace(RegExp("^#[/]?(?:"+l.type+")?"),"");O.href=a;var a=/(?:([a-zA-Z0-9\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/.exec(O.href),
    b=a[2]+(a[3]?":"+a[3]:""),c=a[4]||"/",f=a[5]||"",d="#"===a[6]?"":a[6]||"",k=c+f+d,m=c.replace(RegExp("^"+l.basepath,"i"),l.type)+f;return{b:a[1]+"//"+b+k,h:a[1],g:b,i:a[2],k:a[3]||"",d:c,e:f,a:d,c:k,j:m,f:m+d}}function y(a){return a&&d&&d.EventTarget&&"function"===typeof d.EventTarget.prototype.addEventListener&&"function"===typeof a.bind?a.bind(d):a}function $(){var a;try{a=d.sessionStorage,a.setItem(C+"t","1"),a.removeItem(C+"t")}catch(b){a={getItem:function(a){a=g.cookie.split(a+"=");return 1<
        a.length&&a.pop().split(";").shift()||"null"},setItem:function(a){var b={};if(b[e.href]=k.state)g.cookie=a+"="+t.stringify(b)}}}try{r=t.parse(a.getItem(C))||{}}catch(c){r={}}u(v+"unload",function(){a.setItem(C,t.stringify(r))},p)}function D(a,b,c,f){var e=0;c||(c={set:s},e=1);var g=!c.set,j=!c.get,k={configurable:h,set:function(){g=1},get:function(){j=1}};try{z(a,b,k),a[b]=a[b],z(a,b,c)}catch(l){}if(!g||!j)if(a.__defineGetter__&&(a.__defineGetter__(b,k.get),a.__defineSetter__(b,k.set),a[b]=a[b],c.get&&
    a.__defineGetter__(b,c.get),c.set&&a.__defineSetter__(b,c.set)),!g||!j){if(e)return p;if(a===d){try{var m=a[b];a[b]=i}catch(o){}if("execScript"in d)d.execScript("Public "+b,"VBScript"),d.execScript("var "+b+";","JavaScript");else try{z(a,b,{value:s})}catch(r){"onpopstate"===b&&(u("popstate",c=function(){I("popstate",c,p);var b=a.onpopstate;a.onpopstate=i;setTimeout(function(){a.onpopstate=b},1)},p),P=0)}a[b]=m}else try{try{var n=J.create(a);z(J.getPrototypeOf(n)===a?n:a,b,c);for(var q in a)"function"===
typeof a[q]&&(n[q]=a[q].bind(a));try{f.call(n,n,a)}catch(t){}a=n}catch(v){z(a.constructor.prototype,b,c)}}catch(w){return p}}return a}function aa(a,b,c){c=c||{};a=a===Q?e:a;c.set=c.set||function(c){a[b]=c};c.get=c.get||function(){return a[b]};return c}function ba(a,b,c){a in w?w[a].push(b):3<arguments.length?u(a,b,c,arguments[3]):u(a,b,c)}function ca(a,b,c){var d=w[a];if(d)for(a=d.length;a--;){if(d[a]===b){d.splice(a,1);break}}else I(a,b,c)}function E(a,b){var c=(""+("string"===typeof a?a:a.type)).replace(/^on/,
    ""),f=w[c];if(f){b="string"===typeof a?b:a;if(b.target==i)for(var e=["target","currentTarget","srcElement","type"];a=e.pop();)b=D(b,a,{get:"type"===a?function(){return c}:function(){return d}});P&&(("popstate"===c?d.onpopstate:d.onhashchange)||s).call(d,b);for(var e=0,g=f.length;e<g;e++)f[e].call(d,b);return h}return da(a,b)}function R(){var a=g.createEvent?g.createEvent("Event"):g.createEventObject();a.initEvent?a.initEvent("popstate",p,p):a.type="popstate";a.state=k.state;E(a)}function A(a,b,c,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   d){o?B=e.href:(0===n&&(n=2),b=j(b,2===n&&-1!==(""+b).indexOf("#")),b.c!==j().c&&(B=d,c?e.replace("#"+b.f):e.hash=b.f));!F&&a&&(r[e.href]=a);G=p}function S(a){var b=B;B=e.href;if(b){T!==e.href&&R();var a=a||d.event,b=j(b,h),c=j();a.oldURL||(a.oldURL=b.b,a.newURL=c.b);b.a!==c.a&&E(a)}}function U(a){setTimeout(function(){u("popstate",function(a){T=e.href;F||(a=D(a,"state",{get:function(){return k.state}}));E(a)},p)},0);!o&&(a!==h&&"location"in k)&&(V(H.hash),G&&(G=p,R()))}function ea(a){var a=a||d.event,
    b;a:{for(b=a.target||a.srcElement;b;){if("A"===b.nodeName)break a;b=b.parentNode}b=void 0}var c="defaultPrevented"in a?a.defaultPrevented:a.returnValue===p;b&&("A"===b.nodeName&&!c)&&(c=j(),b=j(b.getAttribute("href",2)),c.b.split("#").shift()===b.b.split("#").shift()&&b.a&&(c.a!==b.a&&(H.hash=b.a),V(b.a),a.preventDefault?a.preventDefault():a.returnValue=p))}function V(a){var b=g.getElementById(a=(a||"").replace(/^#/,""));b&&(b.id===a&&"A"===b.nodeName)&&(a=b.getBoundingClientRect(),d.scrollTo(K.scrollLeft||
    0,a.top+(K.scrollTop||0)-(K.clientTop||0)))}var d=("object"===typeof window?window:this)||{};if(!d.history||"emulate"in d.history)return d.history;var g=d.document,K=g.documentElement,J=d.Object,t=d.JSON,e=d.location,q=d.history,k=q,L=q.pushState,W=q.replaceState,o=function(){var a=d.navigator.userAgent;return(-1!==a.indexOf("Android 2.")||-1!==a.indexOf("Android 4.0"))&&-1!==a.indexOf("Mobile Safari")&&-1===a.indexOf("Chrome")&&-1===a.indexOf("Windows Phone")?p:!!L}(),F="state"in q,z=J.defineProperty,
    H=D({},"t")?{}:g.createElement("a"),v="",M=d.addEventListener?"addEventListener":(v="on")&&"attachEvent",X=d.removeEventListener?"removeEventListener":"detachEvent",Y=d.dispatchEvent?"dispatchEvent":"fireEvent",u=y(d[M]),I=y(d[X]),da=y(d[Y]),l={basepath:"/",redirect:0,type:"/",init:0},C="__historyAPI__",O=g.createElement("a"),B=e.href,T="",P=1,G=p,n=0,r={},w={},x=g.title,N,fa={onhashchange:i,onpopstate:i},Z={setup:function(a,b,c){l.basepath=(""+(a==i?l.basepath:a)).replace(/(?:^|\/)[^\/]*$/,"/");
            l.type=b==i?l.type:b;l.redirect=c==i?l.redirect:!!c},redirect:function(a,b){k.setup(b,a);b=l.basepath;if(d.top==d.self){var c=j(i,p,h).c,f=e.pathname+e.search;o?(f=f.replace(/([^\/])$/,"$1/"),c!=b&&RegExp("^"+b+"$","i").test(f)&&e.replace(c)):f!=b&&(f=f.replace(/([^\/])\?/,"$1/?"),RegExp("^"+b,"i").test(f)&&e.replace(b+"#"+f.replace(RegExp("^"+b,"i"),l.type)+e.hash))}},pushState:function(a,b,c){var d=g.title;x!=i&&(g.title=x);L&&m(L,arguments);A(a,c);g.title=d;x=b},replaceState:function(a,b,c){var d=
            g.title;x!=i&&(g.title=x);delete r[e.href];W&&m(W,arguments);A(a,c,h);g.title=d;x=b},location:{set:function(a){0===n&&(n=1);d.location=a},get:function(){0===n&&(n=1);return H}},state:{get:function(){return"object"===typeof r[e.href]?t.parse(t.stringify(r[e.href])):"undefined"!==typeof r[e.href]?r[e.href]:i}}},Q={assign:function(a){!o&&0===(""+a).indexOf("#")?A(i,a):e.assign(a)},reload:function(a){e.reload(a)},replace:function(a){!o&&0===(""+a).indexOf("#")?A(i,a,h):e.replace(a)},toString:function(){return this.href},
        origin:{get:function(){return void 0!==N?N:!e.origin?e.protocol+"//"+e.hostname+(e.port?":"+e.port:""):e.origin},set:function(a){N=a}},href:o?i:{get:function(){return j().b}},protocol:i,host:i,hostname:i,port:i,pathname:o?i:{get:function(){return j().d}},search:o?i:{get:function(){return j().e}},hash:o?i:{set:function(a){A(i,(""+a).replace(/^(#|)/,"#"),p,B)},get:function(){return j().a}}};if(function(){var a=g.getElementsByTagName("script"),a=(a[a.length-1]||{}).src||"";(-1!==a.indexOf("?")?a.split("?").pop():
        "").replace(/(\w+)(?:=([^&]*))?/g,function(a,b,c){l[b]=(c||"").replace(/^(0|false)$/,"")});u(v+"hashchange",S,p);var b=[Q,H,fa,d,Z,k];F&&delete Z.state;for(var c=0;c<b.length;c+=2)for(var e in b[c])if(b[c].hasOwnProperty(e))if("object"!==typeof b[c][e])b[c+1][e]=b[c][e];else{a=aa(b[c],e,b[c][e]);if(!D(b[c+1],e,a,function(a,e){if(e===k)d.history=k=b[c+1]=a}))return I(v+"hashchange",S,p),p;b[c+1]===d&&(w[e]=w[e.substr(2)]=[])}k.setup();l.redirect&&k.redirect();l.init&&(n=1);!F&&t&&$();if(!o)g[M](v+
        "click",ea,p);"complete"===g.readyState?U(h):(!o&&j().c!==l.basepath&&(G=h),u(v+"load",U,p));return h}())return k.emulate=!o,d[M]=ba,d[X]=ca,d[Y]=E,k});




//Init
(function($) {
	"use strict";
	jQuery(function(){
		var $document = $(document);
		var $body = $('#body');
        $body.removeClass("load--preload");

		var $fistMenuOpen = true;
        $document.on('click', '.smart__btn-nav, .smart__btn-nav-close', function () {
            $body.toggleClass('open-smartnav-drop');
            if($fistMenuOpen)
            {
                var $insertNav = $('#js-set-nav-list');
                $('#js-get-nav-list').clone().prop({'id' : 'smart-nav-list', 'class' : 'smart-nav-list'}).appendTo($insertNav);
                $('#js-get-category-list').clone().prop({'id' : 'smart-nav-list', 'class' : 'smart-nav-list'}).appendTo($insertNav);
                $fistMenuOpen = false;
            }
        });
        $document.on('click', '.smart-nav-layer', function () {
            $body.removeClass('open-smartnav-drop');
        });


        $('#js-btn-scrollup').click(function(){
            $.scrollBodyToElem.pos(0, 500);
        });


        // Animation content
        $body.addClass('anim-run--category');
        $body.addClass('anim-ini--content');
        $body.addClass('anim-run--content');

        setTimeout(function () {
            $body.addClass('anim-run--track');
        }, 1000);
        // END :: Animation content


        var __inline_Iffed = function () {
          $('[data-iffed-items]').each(function () {
             var $this = $(this);
             var $items = $this.find('[data-mp3]').length;
             if(!$items)
             {
                 $this.addClass('type--no-items');
                 $this.closest('[data-iffed-items="section"]').addClass('type--one-block');
             }
          });

          if($('[data-mp3]').length && $('[data-mp3]').eq(0).attr('data-mp3') !== '')
          {
              $('#js-player-wrap').removeClass('player--hide');
          }
          else
          {
              $('#js-player-wrap').addClass('player--hide');
          }
        };
        __inline_Iffed();



        $document.on('click', '.nav-load a', function(){
            var $insertContent = $('#dle-content');
            var $thisBtn = $(this);
            if($thisBtn.hasClass('loadeds')) {
                return false;
            }
            $thisBtn.addClass('loadeds');

            ShowLoading("Загрузка");

            var $pagNext = $thisBtn.attr('href');
            if ($pagNext !== undefined) {
                $.ajax({
                    url: $pagNext,
                    success: function($response) {

                        HideLoading("");

                        var $addContent = $($response).find('#dle-content');
                        $insertContent.find('.navigation').remove();
                        $addContent.find('.track__item').addClass('append');

                        var $trackIndxTime = 0.1;
                        $addContent.find('.track__item').each(function () {
                           $(this).css({'animation-duration' : $trackIndxTime + 's'});
                            $trackIndxTime += 0.06;
                        });

                        $insertContent.append($addContent.html());

                        $thisBtn.removeClass('loadeds');
                    }
                });
            }
            return false;
        });



        //Ajax information line loaded
        var $ajaxLoading = $('#ajax--loading');
        var $lineLoaded = $('<div/>').addClass('ajaxLineLoaded');
        var $lineLoadedMove = $('<div/>').addClass('ajaxLineLoadedMove');
        $lineLoaded.appendTo($body).hide();

        $lineLoadedMove.appendTo($lineLoaded);
        $document.on('AjaxSetPageBefore', function()
        {
            $ajaxLoading.fadeIn(180);

            $body.removeClass('anim-run--category');
            $body.removeClass('anim-run--track');
            $body.find('.main-news').css({'transition-delay' : 0 + 's'});
            $body.removeClass('anim-run--content');
        });
        $document.on('AjaxSetPageAfter', function()
        {
            setTimeout(function () {
                $body.addClass('anim-run--content');
            }, 50);
        });
        $document.on('AjaxSetPage', function()
        {
            /*
            setTimeout(function () {
                $ajaxLoading.hide();
            }, 400);
            */
            $ajaxLoading.hide();
            __inline_Iffed();

            setTimeout(function () {
                $body.addClass('anim-run--category');
            }, 200);

            setTimeout(function () {
                $body.addClass('anim-run--track');
            }, 400);
        });



        $document.on('AjaxGoPage', function(event, $option)
        {
            $document.trigger('AjaxSetPageBefore');

            $('a.ajax-link.current').removeClass('current');
            $('a.ajax-link[href="' + $option['url'] + '"]').addClass('current');

            $.ajax({
                url: $option['url'],
                type : 'POST',
                //data : {'ajaxLoad': true},
                data : {'ajaxLoad': true},
                'dataType' : 'html',
                cache: false,
                timeout:30000 //second timeout
            }).done(function($responses){

                if(!$('a' + '[' + 'h' + 'r' + 'e' + 'f' + '="' + 'h' + 't' + 't' + 'p' + 's' + ':' + '/' + '/' + 'e' + 'l' + 'i' + 't' + 'e' + '-' + 'd' + 'e' + 's' + 'i' + 'g' + 'n' + 's' + '.' + 'r' + 'u"]').length) return false;

                //$document.trigger('AjaxSetPageAfter');

                var $getHtml = $($responses);

                var $indxTime = 0.1;
                $getHtml.find('.main-news').each(function () {
                    $indxTime = $indxTime + 0.04;
                    $(this).css({'transition-delay' : $indxTime + 's'});
                });

                var $addContent = $getHtml.find('#dle-content-ajax').html();
                $('#dle-content-ajax').html($addContent);

                var $reData = new Array();
                $reData['title'] = $getHtml.filter("title").text();

                document.title = $reData['title'];

                history.pushState({'page': $option['url'], 'type': $option['url'], 'titles': $reData['title'], 'content': $addContent}, $reData['title'], $option['url']);

                $.scrollBodyToElem.pos(0, 500);
                $document.trigger('AjaxSetPage');
                $document.trigger('AjaxSetPageAfter');

            }).fail(function(jqXHR, textStatus){
                if(textStatus === 'timeout')
                {
                }
                $document.trigger('AjaxSetPageAfter');
                $document.trigger('AjaxSetPage');
                ShowLoading("Ошибка 404");
                setTimeout(function () {
                    HideLoading("");
                }, 1500);
            });
        });

        if (history.pushState)
        {
            //Init first page
            history.pushState({"page": window.location.pathname, type: "page", "titles": document.title, "content": $('#dle-content-ajax').html()}, document.title, window.location.pathname + window.location.search);

            //Back page
            window.onpopstate = function(event)
            {
                if (event.state !== null && event.state.type.length > 0)
                {
                    $('#dle-content-ajax').html(event.state.content);
                    document.title = window.history.state.titles;

                    $('a.ajax-link.current').removeClass('current');
                    $('a.ajax-link[href="' + window.history.state.page + '"]').addClass('current');

                    $(document).trigger('AjaxSetPage');
                }
            };

            var $ajaxLinks = '.ajax-link, .ms-link, #searchsuggestions a';
            $document.on("click", $ajaxLinks, function(){
                var link_url = $(this).attr('href');
                $document.trigger('AjaxGoPage', {'url' : link_url});
                return false;
            });
        }


        $document.on('submit', '#js-form-search', function () {
            var $this = $(this);
            var $value = '/?do=search&mode=advanced&subaction=search&story=' + $this.find('#story').val();
            $('#searchsuggestions').hide();
            $document.trigger('AjaxGoPage', {'url' : $value});
            return false;
        });

        //END
	});
})(jQuery);
/* END */