var $=jQuery,canRate=true,chatUnreadInterval=null;function insertBBcode(){var textarea=document.getElementById('comment');if(!textarea)return;var bbcode=this.className.replace(' tt','').toLowerCase(),scrollPos=textarea.scrollTop,selectStart=0,selectEnd=0,isIE=document.selection?true:false;if(isIE){textarea.focus();var range=document.selection.createRange();stored_range=range.duplicate();stored_range.moveToElementText(textarea);stored_range.setEndPoint('EndToEnd',range);selectStart=stored_range.text.length-range.text.length;selectEnd=selectStart+range.text.length}else{selectStart=textarea.selectionStart;selectEnd=textarea.selectionEnd}var text='',front=(textarea.value).substring(0,selectStart);back=(textarea.value).substring(selectEnd,textarea.value.length);if(selectStart==selectEnd){text='['+bbcode+']'+'[/'+bbcode+']'}else{text='['+bbcode+']'+textarea.value.substring(selectStart,selectEnd)+'[/'+bbcode+']'}textarea.value=front+text+back;textarea.focus();if(isIE){var range=textarea.createTextRange();range.collapse(true);range.moveStart('character',selectStart);range.moveEnd('character',0);range.select()}else{textarea.setSelectionRange(selectStart,selectStart+text.length)}textarea.scrollTop=scrollPos}function getUnreadChatMsgs(){$.ajax({type:'GET',url:'http://lolkot.ru/features/chat/unread.php',data:'t='+(new Date()).getTime(),dataType:'json',success:function(data){if(data.unread==0){$('#chatLink').html('Чат')}else{$('#chatLink').html('Чат ('+data.unread+')')}},error:function(XMLHttpRequest,textStatus,errorThrown){clearInterval(chatUnreadInterval);chatUnreadInterval=null}})}function positionLoginForm(){$('#overlay').css('height',$(document).height()+'px').css('width',$(document).width()+'px');$('#boxcontainer').css('top',($(window).height()/2+$(document).scrollTop()-100)+'px').css('left',($(window).width()/2+$(window).scrollLeft()-175)+'px')}function showLoginForm(){if($('#boxcontainer').length){positionLoginForm();$('#overlay').css('display','block');$('#boxcontainer').css('display','block');$('select').css('visibility','hidden');$(window).resize(positionLoginForm).scroll(positionLoginForm)}else{$.ajax({type:'GET',url:'http://lolkot.ru/features/login/form.php',success:function(data){$(document.body).append(data);$('#closeLink').click(function(){$('#overlay').css('display','none');$('#boxcontainer').css('display','none');$('select').css('visibility','visible');$(window).unbind('resize').unbind('scroll')});$('#return_to').val(location.href);showLoginForm()}})}}function positionPostAwardList(){$('#awardbox').css('top',($(window).height()/2+$(document).scrollTop()-105)+'px').css('left',($(window).width()/2+$(window).scrollLeft()-205)+'px')}function showAvailablePostAwards(o,postid){postid=postid?postid:$(this).parent().attr('class').replace('rating ','');var overlay=$('#overlay');if(overlay.length==0){$(document.body).append('<div id="overlay"></div>')}$('#overlay').height($(document.body).outerHeight(true)).css('display','block');var ab=$('#awardbox');if(ab.length==0){$(document.body).append('<div id="awardbox"><a class="closeLink" title="Закрыть">[x]</a><div id="award-content"></div>');$('#awardbox a.closeLink').click(function(){$('#awardbox').css('display','none');$('#overlay').css('display','none');$('select').css('visibility','visible');$(window).unbind('resize').unbind('scroll')})}$.ajax({type:'GET',url:'http://lolkot.ru/features/awards/post/user_awards.php',data:'postid='+postid+'&t='+(new Date()).getTime(),success:function(data){if(data=='mustlogin'){showLoginForm();return}ab.css('display','block');$('#award-content').html(data);positionPostAwardList();$('select').css('visibility','hidden');$(window).resize(positionPostAwardList).scroll(positionPostAwardList)}})}function buyPostAward(giftID,postID,confirmed){$('#award-content').load('http://lolkot.ru/features/awards/post/buy_post_award.php?postid='+postID+'&giftid='+giftID+'&confirmed='+confirmed+'&t='+(new Date()).getTime())}$(function(){$('.bbcode img').click(insertBBcode);$('.tt').poshytip({className:'tip-yellowsimple',alignTo:'target',alignX:'center',showTimeout:100,offsetY:5,slide:false,fade:false});$('.commentlink').poshytip({className:'tip-yellowsimple',alignTo:'target',alignX:'center',showTimeout:100,offsetY:5,slide:false,fade:false,bgImageFrameSize:11,alignY:'bottom',content:function(updateCallback){var post_id=this.className.replace('commentlink l','');$.ajax({type:'GET',url:'http://lolkot.ru/features/comments/tooltip_preview.php',data:'id='+post_id,success:function(msg){updateCallback(msg)}});return'Загрузка комментариев...'}});$('a.external').click(function(){window.open($(this).attr('href'));return false});$('#subscribe-email').click(function(){if(this.value.toLowerCase()=='email'){this.value=''}});$('#subscribe-action').click(function(){var email=$('#subscribe-email').val();if(!/^([\w\-]+(?:\.[\w\-]+)*)@((?:[\w\-]+\.)*\w[\w\-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(email)){alert("Неверный формат email адреса!");return}$.ajax({type:'GET',url:'http://lolkot.ru/daily/subscribe.php',data:'email='+encodeURIComponent(email),success:function(data){alert(data)}})});$('span.copycodelink').click(function(){var id=$(this).attr('id').replace('copycodelink','');$(this).toggleClass('copycodelink_active');if($('#copycode'+id).hasClass('loaded')){$('#copycode'+id).toggleClass('displayblock')}else{$.ajax({type:'GET',url:'http://lolkot.ru/wp-content/themes/lolkot/paste-code.php',data:'id='+id,success:function(data){$('#copycode'+id).html(data).toggleClass('displayblock').addClass('loaded')}})}});function bgOver(){if($(this).hasClass('added')){return}$(this).addClass('bgOver')}function bgOut(){if($(this).hasClass('added')){return}$(this).removeClass('bgOver')}function rate(o,rateUp){if(!canRate){return}canRate=false;var p=$(o).parent(),id=p.attr('class').replace('rating ','');$.ajax({url:'http://lolkot.ru/features/rating/rate.php',data:'id='+id+'&rate='+(rateUp?'up':'down'),dataType:'json',success:function(data){canRate=true;var node=p.children('.ratetext');if(data.error==''){node.text((data.rating>0?'+':'')+data.rating).effect('pulsate')}else if(data.error=='mustlogin'){showLoginForm()}else if(data.error=='alreadyvoted'){node.effect('pulsate')}}})}function favourite(){var me=$(this),p=me.parent(),id=p.attr('class').replace('rating ','');$.ajax({type:'POST',url:'http://lolkot.ru/features/favourite/do.php',data:'act=add&postid='+id,success:function(data){if(data=='added'){me.removeClass('bgOver').addClass('added')}else if(data=='removed'){me.removeClass('bgOver').removeClass('added')}else{showLoginForm()}}})}$('.rateup').mouseover(bgOver).mouseout(bgOut).click(function(){rate(this,true)});$('.ratedown').mouseover(bgOver).mouseout(bgOut).click(function(){rate(this,false)});$('.favourite').mouseover(bgOver).mouseout(bgOut).click(favourite);$('.award').mouseover(bgOver).mouseout(bgOut).click(showAvailablePostAwards);function insertSmilie(){var text=this.src;text=text.substring(text.lastIndexOf('/')+1,text.lastIndexOf('_'));text=' :'+text+': ';var txtarea=$('#comment').get(0);var scrollPos=txtarea.scrollTop;var strPos=0;var br=((txtarea.selectionStart||txtarea.selectionStart=='0')?"ff":(document.selection?"ie":false));var range;if(br=="ie"){txtarea.focus();range=document.selection.createRange();range.moveStart('character',-txtarea.value.length);strPos=range.text.length}else if(br=="ff"){strPos=txtarea.selectionStart}var front=(txtarea.value).substring(0,strPos);var back=(txtarea.value).substring(strPos,txtarea.value.length);txtarea.value=front+text+back;strPos=strPos+text.length;if(br=="ie"){txtarea.focus();range=document.selection.createRange();range.moveStart('character',-txtarea.value.length);range.moveStart('character',strPos);range.moveEnd('character',0);range.select()}else if(br=="ff"){txtarea.selectionStart=strPos;txtarea.selectionEnd=strPos;txtarea.focus()}txtarea.scrollTop=scrollPos}$('#smilies img').click(insertSmilie);function linkHover(){$(this).toggleClass('hover')}$('.link').mouseover(linkHover).mouseout(linkHover);function go2lolmixer(){location.href='http://lolkot.ru/lolmixer/#'+$(this).attr('id').replace('lolmixerLink','')}$('span.lolmixerLink').click(go2lolmixer);function go2lolmixer2(){location.href='http://lolkot.ru/lolmixer/#'+$(this).attr('id').replace('redolink','')}$('span.redolink').click(go2lolmixer2);function rndGlrImgHvr(){$(this).toggleClass('hover')}$('span.lolmixerLink').mouseover(rndGlrImgHvr).mouseout(rndGlrImgHvr);if(location.href.indexOf('http://lolkot.ru/chat/')==-1){if($('#chatLink').length>0){chatUnreadInterval=setInterval(getUnreadChatMsgs,10000)}}var top100img=new Image();top100img.src="http://counter.rambler.ru/top100.scn?1481132&rn="+Math.random()+"&rf="+escape(document.referrer);/*$.ajax({url:'http://lolkot.ru/features/ads/adlabs.php',dateType:'html',success:function(text){$('#sidebar-right span:last').before(text)}});*/$('#liCounter').html("<a href='http://www.liveinternet.ru/click' target='_blank'><img src='http://counter.yadro.ru/hit?t26.16;r"+escape(document.referrer)+((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+";"+Math.random()+"' alt='' title='LiveInternet: количество посетителей сегодня' border='0' width='88' height='15'><\/a>");$.getScript('http://static.lolkot.ru/js/ga.js',function(){pageTracker=_gat._getTracker("UA-2745309-3");pageTracker._trackPageview()})});