var xwMedia=new Array();$(document).ready(function(){$('#search-form-do').addClass('search_button').hover(function(){$(this).addClass('search_button_hover')},function(){$(this).removeClass('search_button_hover')});$("input[type='search'] + input[type='image']").hover(function(){$(this).attr('src','/images/search2.gif')},function(){$(this).attr('src','/images/search1.gif')});$('#header_all > .nav > ul > li').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});$('.questions-top-topic').hover(function(){$(this).find('> .questions-top-topic-title').addClass('hover')},function(){$(this).find('> .questions-top-topic-title').removeClass('hover')});$('.comment-one').not('.comment-inactive').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});$('.pagination li').hover(function(){$(this).addClass('mouse_over')},function(){$(this).removeClass('mouse_over')});$('.c-captcha-img > .refresh').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});$('#blogger-body').hide();$('#blogger-h2').toggle(function(){$('#blogger-body').slideDown()},function(){$('#blogger-body').slideUp()});$('#blogger-body textarea').click(function(){$(this).focus;$(this).select();});$('.index-page-module-body-right').find('li:first').css({'marginTop':'-3px','paddingTop':'0px'});$('.index-page-module-lenta > .index-page-module-body > .entry:first').css({'marginTop':'-1px'});$('.foreign_articles:last').css('marginBottom','0px');$('#inputLogin').focus();$('#doprint').click(function(){window.print()});$("input[type='search']").each(function(){if($(this).height()<17)
$(this).css({'height':'21px'});});$('.c-captcha input[name=turing]')
.attr('_placeholder','текст на картинке ...')
.css('font-size','1em')
.val('');$('#vFFF_name').add('#vFFF_email').add('#vFFF_city').add('#vFFF_text').add('#vFFF_question')
.add('#vFFF_title').add('.c-captcha input[name=turing]').add('#vFFF_occupation')
.each(function(){var el=$(this);var ph=el.attr('_placeholder');el.mouseover(function(){if(el.val()==ph){el.val('')}});el.mouseout(function(){setTimeout(function(){if(el.val()==''||!(/\S/.test(el.val()))){el.val(ph)}},500)});el.keydown(function(){if(el.val()==ph){el.val('')}});el.click(function(){if(el.val()==ph){el.val('')}});el.val(ph).attr('title',ph);});$('.tag-cloud').add('#secondary-subjects').add('#secondary-persons').each(function(){var collection=$(this).find('li').not('.clearboth');var cLen=collection.length-1;collection.each(function(i){if(i<cLen)
$(this).html($(this).html()+',');});});$('.index-page-module > .index-page-module-header > .topics > ul').each(function(){$(this).jcarousel({scroll:1,animation:1000,wrap:'last',buttonNextHTML:"<div class='scrollarr-next'>&rarr;</div>",buttonPrevHTML:"<div class='scrollarr-prev'>&larr;</div>"});});$('.jcarousel-next').empty().hover(function(){$(this).addClass('jcarousel-next-hover')},function(){$(this).removeClass('jcarousel-next-hover')});;$('.jcarousel-prev').empty().hover(function(){$(this).addClass('jcarousel-prev-hover')},function(){$(this).removeClass('jcarousel-prev-hover')});;$('#main-articles td.main-articles-main-image > div').each(function(index){if(index>0)$(this).hide();});var tds1=$('#main-articles td:not(".main-articles-main-image")');tds1.mouseover(function(){tds1.removeClass('hover');$(this).addClass('hover');var t=$('td.main-articles-main-image');t.find('> div[oid!='+$(this).attr('oid')+']').hide();t.find('> div[oid='+$(this).attr('oid')+']').show();});$('.f a').add('a.f').each(function(){var letters=$(this).html().split('');if(letters.length==0||letters[0]=='<'||letters[0]=='&')return;var i=0;if(/[^A-Za-zА-Яа-я0-9]/.test(letters[0]))i=1;letters[i]='<span class="z">'+letters[i]+'</span>';$(this).html(letters.join(''));});$('#search-header-form-i1').add('#search-form-input').add('#questions-topics-header-i1')
.autocomplete({source:"/search/tip.html",select:function(event,ui){$(this).val(ui.item.value);$(this).parents('form').trigger('submit');},minLength:2})
.keydown(function(event){if(event&&event.keyCode&&event.keyCode==13)
$(this).parents('form').trigger('submit');});$('.index-page-module-photo td:first').css('paddingLeft','0px');$('.index-page-module-photo td:last').css('paddingRight','0px');$('.index-page-module-cool td:first').css('paddingLeft','0px');$('.index-page-module-cool td:last').css('paddingRight','0px');$('.index-page-module-authors td:first').css('paddingLeft','0px');$('.index-page-module-authors td:last').css('paddingRight','0px');var trcA_timeout;var trc=$('#top-right-corner-3');var trcA=$('#top-right-corner-add');trcA.attr('showed',0).hide();trc.click(function(){if(trcA.attr('showed')==0){if(trcA.find('li').size()>0){trcA.attr('showed',1).fadeIn();}}else{trcA.attr('showed',0).fadeOut();}})
trcA.find('*').andSelf().add(trc.find('*').andSelf())
.mouseover(function(){window.clearTimeout(trcA_timeout)})
.mouseout(function(){window.clearTimeout(trcA_timeout);trcA_timeout=setTimeout(function(){trcA.attr('showed',0).fadeOut()},1000)});$('.index-page-module').each(function(){$('.ttdd-articles',$(this)).not('.ttdd-articles:first').hide();$('.index-page-module-header .topics li:first',$(this)).addClass('hover');});$('div.index-page-module-header > div.topics li')
.mouseover(function(){if(!$(this).hasClass('hover')){$(this).parent().find('> li').removeClass('hover');$(this).addClass('hover');var a=$('#ttdd-'+$(this).attr('oid')+'-articles');if(a.size()>0){$('.ttdd-articles',$(this).parents('.index-page-module')).hide();a.show();}}
return true;});$('div.bannerplace_fade').each(function(){var div=$(this);var ch=div.children();var chSize=ch.size();if(chSize>0){var max_height=ch.eq(0).height();ch.each(function(){if(max_height<$(this).height())max_height=$(this).height()});div.height(max_height);}
if(chSize<2)return;var j=0;ch.hide(0,function(){ch.eq(j).show()});setInterval(function(){var k=j+1;if(k>=chSize)k=0;ch.eq(j).fadeOut(900);ch.eq(k).fadeIn(1000);j=k;},7000);});for(var i=0,mLen=xwMedia.length;i<mLen;i++){var xwM=xwMedia[i];var o=$('#'+xwM['id']);if(o.size()>0){var oWidth=o.width()-2;var div=$(document.createElement('div')).addClass('media-embed-code').insertAfter(o).width(oWidth);var div1=$(document.createElement('div')).addClass('media-embed-code-code').appendTo(div);var inp=$(document.createElement('input')).appendTo(div1).click(function(){$(this).focus;$(this).select();}).width(oWidth-7);var div22Width=parseInt(oWidth/2);var div21Width=oWidth-div22Width-1;var div2=$(document.createElement('div')).addClass('media-embed-code-choose').appendTo(div);var div21=$(document.createElement('div')).text('Код плеера').appendTo(div2).width(div21Width).attr('p',0).css('borderRight','1px solid #bfbfbf');var div22=$(document.createElement('div')).text('для Livejournal').appendTo(div2).width(div22Width).attr('p',0);div21.hover(function(){$(this).addClass('hover')},function(){if($(this).attr('p')==0)$(this).removeClass('hover')})
.click(function(){inp.val(xwM['html']);div21.addClass('hover').attr('p',1);div22.removeClass('hover').attr('p',0);});div22.hover(function(){$(this).addClass('hover')},function(){if($(this).attr('p')==0)$(this).removeClass('hover')})
.click(function(){inp.val(xwM['lj']);div22.addClass('hover').attr('p',1);div21.removeClass('hover').attr('p',0);});div21.trigger('click');$(document.createElement('div')).addClass('clearboth').appendTo(div2);}}});var pageLoaded=0;function correctDivMainContentWidth(){var wrapper=$('#wrapper');var aller=$('#all-page');var wWidth=parseInt($('html,body').width());if(wWidth<1124)
aller.addClass('all-page-limit1');else if(wWidth>1300)
aller.addClass('all-page-limit2');else
aller.removeClass('all-page-limit1').removeClass('all-page-limit2');if(pageLoaded&&wWidth>1300)
return;else
pageLoaded=1;if(wrapper.size()>0){var w=wrapper.width()-(250+25)*($('> .sidebar',wrapper).length);$('#main-content').add('#foreign_sites').add('.main-content-header')
.width(w+'px');$('#questions-topics-header-i1').width((w-140-34)+'px');$('.index-page-module > .index-page-module-header').each(function(){var topics_div=$(this).find('.topics');var legend_div=$(this).find('.legend');if(topics_div.size()==0)return;var w2=w-legend_div.width()-55;var ul=topics_div.find('ul');if(ul.width()<w2)
$('.scrollarr-next',topics_div).add('.scrollarr-prev',topics_div).hide();else
$('.scrollarr-next',topics_div).add('.scrollarr-prev',topics_div).show();topics_div.width(w2+'px');});}
var div_nav=$('#header_all > .nav');var div_trc=$('#top-right-corner');var div_nav_ul=$('> ul',div_nav);var div_nav_ul_w=div_nav.width()-div_trc.width()-20;div_nav_ul.width(div_nav_ul_w+'px');var right_corner_ul=$('#top-right-corner-add > ul');right_corner_ul.empty();var right_corner_w=0;$('> li',div_nav_ul).each(function(){var li=$(this);var w1=parseInt(li.width());if(isNaN(w1))w1=0;var w2=parseInt(li.css('marginLeft'));if(isNaN(w2))w2=0;var w3=parseInt(li.css('marginRight'));if(isNaN(w3))w3=0;var w4=parseInt(li.css('paddingLeft'));if(isNaN(w4))w4=0;var w5=parseInt(li.css('paddingRight'));if(isNaN(w5))w5=0;right_corner_w+=w1+w2+w3+w4+w5;if(right_corner_w>div_nav_ul_w)
li.clone().appendTo(right_corner_ul);});var sI1=$('#search-header-form-i1');if(sI1.size()>0)
sI1.width((sI1.parent().width()-525-20-35)+'px');}
$(window).resize(correctDivMainContentWidth);$(window).load(correctDivMainContentWidth);function loadOtherImg(id){if(!id)return;var img=$('#'+id);var hidden_val=$('#'+id+'_tid');$.post('/rpc_main.html',{'img':parseInt(hidden_val.val()),'_proc':'getNewCaptcha'},function(data){var new_val=parseInt($(data).find('response').attr('captcha'));img.attr('src','/captcha/'+new_val+'.png');hidden_val.val(new_val);$('.c-captcha input[name=turing]').val('');},'xml');return false;}
function checkForm(f){if(!f)return false;f=$(f);var errors=new Array();var e1;f.find('input,select,textarea').each(function(){var e=$(this);var tagN=e.get(0).tagName;if(e.attr('_placeholder')||tagN=='SELECT'){if(e.val().length==0||e.val()==e.attr('_placeholder')){errors.push('Пожалуйста, заполните поле "'+(tagN=='SELECT'?e.find('option:first').text():e.attr('_placeholder'))+'"');if(!e1)e1=e;}else if((e.attr('name').indexOf('email')>-1||e.attr('name').indexOf('e_mail')>-1)&&!(e.val().match(/@\w+\.\w+$/))){errors.push('Пожалуйста, корректно заполните поле "'+e.attr('_placeholder')+'"');if(!e1)e1=e;}}});if(errors.length>0)
alert("Внимание!\n\n\n"+errors.join("\n\n"));if(e1)
e1.val('').focus();return errors.length>0?false:true;}
