/* v1.2 */ /* функция предзагрузки изображений https://github.com/farinspace/jquery.imgpreload */
if("undefined"!=typeof jQuery){(function(a){a.imgpreload=function(b,c){c=a.extend({},a.fn.imgpreload.defaults,c instanceof Function?{all:c}:c);if("string"==typeof b){b=[b]}var d=[];var e=b.length;for(var f=0;f<e;f++){var g=new Image;a(g).bind("load error",function(b){d.push(this);a.data(this,"loaded","error"==b.type?false:true);if(c.each instanceof Function){c.each.call(this)}if(d.length>=e&&c.all instanceof Function){c.all.call(d)}});g.src=b[f]}};a.fn.imgpreload=function(b){var c=[];this.each(function(){c.push(a(this).attr("src"))});a.imgpreload(c,b);return this};a.fn.imgpreload.defaults={each:null,all:null}})(jQuery)}
$(function() {
   $('.news h1, h3.widget-title').each(function() {$(this).after('<div class="clear"></div>')});
   $(".menu > ul > li:first").addClass('first-menu').children('a').addClass('current-if');$(".menu > ul > li:last-child").addClass('last-menu').children('a').addClass('current-if2');
   $('.icl-en a').text('Eng');
   //Загрузка социальных кнопок
    $('.rus #latest-twitter-follow-link').html('<a target="_blank" href="http://twitter.com/rl4you">Следите за новостями @rl4you в Твиттере</a>');
    $('.eng #latest-twitter-follow-link').html('<a target="_blank" href="http://twitter.com/rl4youcom">Follow to @rl4youcom</a>');
    $('#counter').load('/wp-content/themes/rl4you/ajax/counters.php');
    $('#partners').load('/wp-content/themes/rl4you/ajax/partners.html');
    $('#followus').load('/wp-content/themes/rl4you/ajax/followme.html');
    //$('#community').load('/wp-content/themes/rl4you/ajax/community.php');
    $.post('/wp-content/themes/rl4you/ajax/community.php','',onajaxdone);
    function onajaxdone (data) {
      $('#community').html(data);
    }
    $('.social').load('/wp-content/themes/rl4you/ajax/social.php');
    $('div.likes').each(function() {
      var $urles = $(this).attr('title');
      var $title = $(this).children('span').attr('title');
      this.innerHTML = VK.Share.button({ url : $urles, title: $title}, {type: 'button', text: "Поделиться"});
      $(this).html('<ul><li class="facebook"><div class="fb-like" data-href="'+ $urles +'" data-send="false" data-layout="button_count" data-width="130" data-show-faces="true" data-font="tahoma"></div></li><li class="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-url="'+ $urles +'" data-text="'+ $title +'" data-lang="ru">Твитнуть</a></li><li class="vkontakte">' + $(this).html() + '</li></ul>');
    });
      twttr.widgets.load();
});
$(window).load(function(){
   //Меню
   $("#menu ul li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('display', 'block');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('display', 'none');
    });
    $("#menu ul li ul li:has(ul)").find("a:first").append("<span class='arrow'></span>");
    $("#menu ul li ul").find("li:first").css('border-top', 'none'); 
    
    //Слайдер
    $('#slider').hover(function() {$(this).addClass('hover')},function() {$(this).removeClass('hover')});
    
    //Поиск
    $('.search .f-text').focus(function() {if($(this).val() == 'Поиск по сайту'){$(this).val('')}});
    $('.search .f-text').blur(function() {if($(this).val() == ''){$(this).val('Поиск по сайту')}});
    
     
    //Предзагрузка картинок спонсоров
    $('.partners img').imgpreload(function(){});
    //Одинаковая высота четырех блоков
    if($('#cw1').height() > $('#cw2').height()) {
      $('#cw2').height($('#cw1').height());
    } else {
      $('#cw2').height($('#cw1').height());
    }
    if($('#cw3').height() > $('#cw4').height()) {
      $('#cw4').height($('#cw3').height());
    } else {
      $('#cw3').height($('#cw4').height());
    }
    //Копирование формы подписки на сайдбар
    $('.emailsign').clone().appendTo('.subscribe-widget');
    //Переключение коментов
    $('.tabs a').click(function() {
      $('.comment-area').each(function() {$(this).fadeOut();});
      $('.tabs a').each(function() {$(this).removeClass('active');});
      $(this).addClass('active');
      $($(this).attr('href')).fadeIn();
      return false;
    });
    //открытие/закрытие ползунка
    $('.staticmenu-hold a').click(function() {
      $('.staticmenu').toggle(); 
      return false;
    });
    $('.ngg-album').click(function() {
      window.location = $(this).children('.ngg-albumtitle').children().attr('href');
    })
    $('body.category-11 iframe').each(function() {
      var url = $(this).attr("src");
      $(this).attr("src",url+"?wmode=transparent");
      });
     FB.XFBML.parse(document.getElementById('content'));
});
