ght);var scrollTop=(window.pageYOffset!==undefined)?window.pageYOffset:document.body.scrollTop;var footer=$('nav-wrapper')?$('nav-wrapper').getSize():null;var height_footer=footer?footer.y:282;var fixsize=elfix.getSize();var height_fix=fixsize.y;var bottom_height=565;if(position_fix-20>scrollTop)
{elfix.removeClass('fixed-on');elfix.style.top='';}
else if(position_fix-20<=scrollTop&&scrollTop<height_all-height_fix-height_footer-bottom_height)
{elfix.addClass('fixed-on');elfix.style.top='';}
else if(scrollTop>=height_all-height_fix-height_footer-bottom_height)
{if(elfix.hasClass('fixed-on'))
{var top=height_all-position_fix-height_fix-height_footer-bottom_height;elfix.removeClass('fixed-on');elfix.style.top=(top)+'px';}}});function bind_captcha()
{new Request({method:'post',url:'/service/bindcaptcha',onComplete:function(json)
{json=strToJson(json);if(json.is_captcha)
{$('form-register-data').innerHTML+='<div style="margin-top: 10px;"><input type="text" name="register[captcha]" placeholder="Текст с картинки" tabindex="3" style="margin-right: 10px;width: 216px;"><img src="/service/captcha" style="vertical-align: -9px; margin-right: -2px;"></div>'}}}).send();}
function set_ip_status(ip,status_element)
{var status_id=$(status_element).value;new Request({method:'post',url:'/admin/setipstatus',onComplete:function(json)
{json=strToJson(json);if(json.error)
{alert('Ошибка!');return false;}
else
{$('tinyalert').innerHTML+='<div class="green"><a href="javascript:void(0)" title="Закрыть" class="action a-close" onclick="this.getParent().hide();"><span class="i-clear"></span></a>Статус ip изменен</div>';}}}).send("ip="+ip+"&status_id="+status_id);}
function nf17_update_ll_id(nf17_book_id)
{var ll_edition_id=$('ll-id-input-'+nf17_book_id).value;if(ll_edition_id=='')
{alert('Необходимо указать идентификатор книги на ЛайвЛиб');return false;}
var params="edition_id="+ll_edition_id+"&nf17_book_id="+nf17_book_id;new Request({url:'/nonfiction/updatellid',method:'post',onComplete:function(json)
{json=strToJson(json);prepare(json);if(json.error)
{alert(json.error);}
else
{alert(json.okay);}},onRequest:initAd,onSuccess:closeAd,onFailure:failure}).send(params);}
function nf17_update_ll_publisher_id(nf17_participant_id)
{var ll_publisher_link=$('ll-publisher-link-input-'+nf17_participant_id).value;if(ll_publisher_link=='')
{alert('Необходимо указать ссылку издательства на ЛайвЛиб');return false;}
var params="publisher_link="+ll_publisher_link+"&nf17_participant_id="+nf17_participant_id;new Request({url:'/nonfiction/updatellpublisher',method:'post',onComplete:function(json)
{json=strToJson(json);prepare(json);if(json.error)
{alert(json.error);}
else
{alert(json.okay);}},onRequest:initAd,onSuccess:closeAd,onFailure:failure}).send(params);}
function menu_content_change()
{var container=$('menu-content');var elements=$$('#menu-content li');if(elements.length<=0)return false;var more=$('ul-context-more');var elementsmore=$$('#ul-context-more li');var size=$('menu-inner').getSize();var width=0;var margin_li=0;var margin_container=$('a-context-more').hasClass('button')?0:215;var more_count=$('a-context-more').hasClass('button')?0:1;for(var i=0;i<elements.length;i++)
{var elsize=elements[i].getSize();width+=(i>0?margin_li:0)+elsize.x;if(width>size.x)
{if($('more-li'))$('more-li').style.display='';$('a-context-more').style.display=$('a-context-more').hasClass('button')?'inline-block':'inline';for(var j=elements.length-1;j>=i;j--)
{var current_menus=$$('#ul-context-more li');if(current_menus.length>0)
{more.insertBefore(elements[j],current_menus[0]);}
else
{more.appendChild(elements[j]);}}
return false;}}
elementsmore=$$('#ul-context-more li');if(elementsmore.length<=0)
{$('a-context-more').hide();more.style.visibility='hidden';if($('more-li'))$('more-li').hide();return false;}
for(i=0;i<elementsmore.length;i++)
{var elsize=elementsmore[i].getSize();width+=(i>0?margin_li:0)+elsize.x;if(width<=size.x-margin_container)
{container.insertBefore(elementsmore[i],$('more-li'));if(i==elementsmore.length-1)
{$('a-context-more').hide();more.style.visibility='hidden';}}
else
{return false;}}
return false;}
if($('menu-content'))
{menu_content_change();}
function nf17_map_clear()
{var svgdoc=$('moozoom').contentDocument;var paper=Snap(svgdoc.getElementById('map'));var elements=paper.selectAll('.svg-hover');if(elements.length>0)
{for(var i=0;i<elements.length;i++)
{elements[i].removeClass('svg-hover');elements[i].attr('opacity','0.3');}}
var elements=paper.selectAll('.tooltip');if(elements.length>0)
{for(var i=0;i<elements.length;i++)
{elements[i].remove();}}
nf17_tooltip_clear();}
function nf17_tooltip_clear()
{var elements=$$('.nf17-tooltip-text');if(elements.length>0)
{for(var i=0;i<elements.length;i++)
{elements[i].dispose();}}}
function nf17_map_tooltip(element,text,stand,clear,without_text)
{if(clear&&clear!='undefined')nf17_map_clear();text=text||'';stand=stand||'';if(text==stand)stand='';without_text=without_text||false;var elements=element.split(',');var svgdoc=$('moozoom').contentDocument;var paper=Snap(svgdoc.getElementById('map'));if(elements.length>0)
{var tooltips=paper.selectAll('.tooltip');var with_tooltip=true;if(tooltips.length/2+elements.length>6)
{nf17_tooltip_clear();with_tooltip=false;}
for(var i=0;i<elements.length;i++)
{if(!elements[i])continue;var el=paper.select('#'+elements[i]);if(!el)continue;var size=el.getBBox();el.attr({'opacity':'1','class':'svg-hover'});var x=size.cx;var y=size.y;var tooltip=paper.path('M'+x+','+y+' C'+x+','+y+' '+(x+60)+','+(y-67)+' '+(x+60)+','+(y-102)+' C'+(x+60)+','+(y-137)+' '+(x+33)+','+(y-165)+' '+(x)+','+(y-165)+' C'+(x-33)+','+(y-165)+' '+(x-60)+','+(y-137)+' '+(x-60)+','+(y-102)+' C'+(x-60)+','+(y-67)+' '+(x)+','+(y)+' '+(x)+','+(y)+' Z');tooltip.attr({'fill':'#39424C',class:'tooltip'});if(with_tooltip&&text&&!without_text)
{var number=(tooltips.length/2+1);var tooltip_center=paper.text(x-21.75,(y-78),number);tooltip_center.attr({'style':'font-size:72px;fill:#ffffff;font-weight:bold;font-family:Arial;',class:'tooltip'});var t='<table class="nf17-tooltip-text"><tr><td title="'+text+'"><b>'+number+'.</b>&nbsp;'+text+'</td><td style="white-space:nowrap;padding-left:10px;text-align:right;"><b>'+stand+'</b></td></tr></table>';$('nf17-tooltip-'+(number>3?'right':'left')).innerHTML+=t;}
else
{var tooltip_center=paper.path('M'+x+','+(y-78)+' C'+(x+12)+','+(y-78)+' '+(x+22)+','+(y-88)+' '+(x+22)+','+(y-100)+' C'+(x+22)+','+(y-112)+' '+(x+12)+','+(y-122)+' '+(x)+','+(y-122)+' C'+(x-12)+','+(y-122)+' '+(x-22)+','+(y-112)+' '+(x-22)+','+(y-100)+' C'+(x-22)+','+(y-88)+' '+(x-12)+','+(y-78)+' '+(x)+','+(y-78)+' Z');tooltip_center.attr({'fill':'#FFFFFF',class:'tooltip'});}
tooltips=paper.selectAll('.tooltip');}}}
function profile_bg_image()
{if(!$('profile-bg-name')||!$('profile-bg-file'))return false;var file=$('profile-bg-file').value;if(!file)
{file='загрузить обложку';if($('profile-bg-action'))$('profile-bg-action').value='current';}
else
{file=file.replace(/(.+)[\/|\\]([^\/\\]+)/g,"$2");if(file.length>20)file=file.substring(0,20)+'...';if($('profile-bg-action'))$('profile-bg-action').value='file';}
$('profile-bg-name').innerHTML=file;}
function profile_bg_url()
{if(!$('profile-bg-url'))return false;if($('profile-bg-url').value!='')
{if($('profile-bg-name'))$('profile-bg-name').innerHTML='загрузить обложку';if($('profile-bg-file'))$('profile-bg-file').value='';if($('profile-bg-action'))$('profile-bg-action').value='url';}
else
{if($('profile-bg-action'))$('profile-bg-action').value='current';}}
function profile_bg_delete()
{if(!confirm('Вы действительно хотите удалить файл?'))return false;if($('profile-bg-action'))$('profile-bg-action').value='current';new Request({method:'post',data:{picture_action:'no'},url:'/user/profilebg',onComplete:function(json)
{json=strToJson(json);prepare(json);if(json.message)
{alert(json.message);return false;}
else
{if($('profile-bg-wrapper'))$('profile-bg-wrapper').setAttribute('style','');if(json.old_date&&$('profile-bg-return'))
{$('profile-bg-return').show('inline');$('profile-bg-remove').hide();$('profile-bg-return').setAttribute('onclick','profile_bg_return(\''+json.old_date+'\')');}
if($('profile-bg-btn'))$('profile-bg-btn').innerHTML='Добавить обложку';}}}).send();if($('profile-bg-name'))$('profile-bg-name').innerHTML='загрузить обложку';if($('profile-bg-url'))$('profile-bg-url').value='';}
function profile_bg_return(pic_date)
{if($('profile-bg-action'))$('profile-bg-action').value='current';new Request({method:'post',data:{picture_action:'return',pic_date:pic_date},url:'/user/profilebg',onComplete:function(json)
{json=strToJson(json);prepare(json);if(json.message)
{alert(json.message);return false;}
else
{if(json.picture_url&&$('profile-bg-wrapper'))
{$('profile-bg-wrapper').setAttribute('style','margin-top:20px;background:#fff url('+json.picture_url+') center center no-repeat;');if($('profile-bg-btn'))$('profile-bg-btn').innerHTML='Изменить обложку';}
else if(json.picture_action&&json.picture_action=='no')
{$('profile-bg-wrapper').setAttribute('style','');}
$('profile-bg-return').hide();$('profile-bg-remove').show('inline');$('profile-bg-return').setAttribute('onclick','');}}}).send();if($('profile-bg-name'))$('profile-bg-name').innerHTML='загрузить обложку';if($('profile-bg-url'))$('profile-bg-url').value='';}
function profile_bg_save()
{var is_new_design=$('is-new-design')?$('is-new-design').value:'';var file=$('profile-bg-file')&&$('profile-bg-file').files&&$('profile-bg-file').files[0]?$('profile-bg-file').files[0]:null;var picture_action=$('profile-bg-action')?$('profile-bg-action').value:'current';var url=$('profile-bg-url')?$('profile-bg-url').value:'';var xhr=new XMLHttpRequest();upload=xhr.upload;formData=new FormData();formData.append('file',file);formData.append('url',url);formData.append('picture_action',picture_action);xhr.onreadystatechange=function(){if(xhr.readyState==4)
if((xhr.status>=200&&xhr.status<300)||xhr.status==304){this.response=this.response||this.responseText;var json=strToJson(this.response);prepare(json);if(json.message)
{alert(json.message);return false;}
if(json.picture_url&&$('profile-bg-wrapper'))
{$('profile-bg-wrapper').setAttribute('style','margin-top:20px;background:#fff url('+json.picture_url+') center center no-repeat;');if($('profile-bg-remove'))$('profile-bg-remove').show('inline');if($('profile-bg-return'))$('profile-bg-return').hide();if($('profile-bg-btn'))$('profile-bg-btn').innerHTML='Изменить обложку';}
else if(json.picture_action&&json.picture_action=='no')
{$('profile-bg-wrapper').setAttribute('style','');}
if($('profile-bg'))$('profile-bg').hide();}else onerror.call(xhr);};xhr.open('POST','/user/profilebg',false);xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');xhr.send(formData);}