$(document).ready(function() {
    $('.container').jScrollPane({
         autoReinitialise: true
    });
});


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


$(document).ready(function(e) {
    if(document.location.hash == "#eng"){
        if($.cookie('lang') == "rus") {
            $.cookie('lang', "eng", {
                expires: 5,
                path: '/'
            });
            location.reload();
        }
    }else if(document.location.hash == "#rus"){
        if($.cookie('lang') == "eng") {
            $.cookie('lang', "rus", {
                expires: 5,
                path: '/'
            });
            location.reload();
        }
    }

    if($.cookie('lang') == "rus"){
        $('#lang_eng').removeClass('active');
        $('#lang_rus').addClass('active');
    }
    else if($.cookie('lang') == "eng"){
        $('#lang_rus').removeClass('active');
        $('#lang_eng').addClass('active');
    }
    $('body').on('click', '[lang]', function () {
        $.cookie('lang', $(this).attr('lang'), {
            expires: 5,
            path: '/'
        });
        location.reload();
    });
    $('.status .item').each(function(i, el) {
        $(el).find('.load-line').css('width',$(el).attr('data-online')/50+'%');
    });

    $('.news-block').each(function(i, el) {
        if(i <=1) {
            $(el).addClass('active');   
        }
        if(i >=2) {
            $('#btn_more_news').css('display','block');
        }
        

    });
    
});


// Анимация viewportChecker
//  jQuery(document).ready(function() {
// jQuery('.nav_wrapper').addClass("hidden").viewportChecker({
// classToAdd: 'visible animated fadeInDown',
// offset: 0
// });
// });

 // Анимация viewportChecker
 jQuery(document).ready(function() {
jQuery('.forum_wrapper').addClass("hidden").viewportChecker({
classToAdd: 'visible animated rotateInDownRight',
offset: 200
});
});

  // Анимация viewportChecker
 jQuery(document).ready(function() {
jQuery('.top_wrapper').addClass("hidden").viewportChecker({
classToAdd: 'visible animated rotateInDownRight',
offset: 200
});
});


 // Анимация viewportChecker
 jQuery(document).ready(function() {
jQuery('.lk_wrapper').addClass("hidden").viewportChecker({
classToAdd: 'visible animated rotateInDownRight',
offset: 200
});
});

  // Анимация viewportChecker
//  jQuery(document).ready(function() {
// jQuery('.news_wrapper').addClass("hidden").viewportChecker({
// classToAdd: 'visible animated zoomIn',
// offset: 0
// });
// });


// scrollTo
jQuery(document).ready(function(){
         jQuery.scrollTo('#target-reg',  {offset: -200});
});


