﻿var the_open_menu=false;var just_clicked_account_menu=false;var just_clicked_explore_menu=false;var just_clicked_search_menu=false;var search_text_for_current_page='My Posts';var active_page_menu=false;var notes_slide_effect;var members_slide_effect;var filter_slide_effect;var ajax_like_request;var key_commands_are_suspended=false;var is_ie=(navigator.appName&&navigator.appName=="Microsoft Internet Explorer")?true:false;image1=new Image();image1.src='/images/content_tab_left_active.png';image2=new Image();image2.src='/images/like.png';image3=new Image();image3.src='/images/like_active.png';if(top!=self)top.location.href=self.location.href;function track_link_click(link){link.original_href=link.href;link.href='/route?url='+encodeURIComponent(link.href);setTimeout(function(){link.href=link.original_href},0)}function select_field(element){el=$(element);if(el.createTextRange){var oRange=el.createTextRange();oRange.moveStart("character",0);oRange.moveEnd("character",el.value.length);oRange.select()}else if(el.setSelectionRange){el.setSelectionRange(0,el.value.length)}}function hideToolbar(){setTimeout(function(){window.scrollTo(0,1)},100)}function suspend_key_commands(){key_commands_are_suspended=true}function resume_key_commands(){key_commands_are_suspended=false}function click_filter_button(){if(filter_slide_effect&&filter_slide_effect.state=='running')return false;if(Element.visible('filter_pane')){$('filter_menu_arrow').setOpacity(1);if(is_ie){Element.hide('filter_pane')}else{filter_slide_effect=new Effect.SlideUp('filter_pane',{duration:0.5})}}else{if($('members')&&Element.visible('members')){members_slide_effect=new Effect.SlideUp('members')}$('filter_menu_arrow').setOpacity(0.5);if(is_ie){Element.show('filter_pane')}else{filter_slide_effect=new Effect.SlideDown('filter_pane',{duration:0.5})}}return false}function click_members_button(){if(members_slide_effect)members_slide_effect.cancel();if(Element.visible('members')){members_slide_effect=new Effect.BlindUp('members')}else{if(Element.visible('filter_pane')){filter_slide_effect=new Effect.BlindUp('filter_pane',{duration:0.5})}members_slide_effect=new Effect.BlindDown('members')}return false}function launch_sound_box(){window.open('/sound_box','sound_box','toolbar=0,scrollbars=0,location=0,statusbar=0,'+'menubar=0,resizable=0,width=400,height=275')}function click_content_tab(){if(!Element.visible('content_tab_menu')){$('content_tab').style.backgroundColor='#848e91';$('content_tab').style.borderRight='solid 2px #848e91';$('content_tab_left').src='/images/content_tab_left_active.png';Element.show('content_tab_menu');just_opened_menu=true}return false}function sclick(){if(just_clicked_account_menu){if($('explore_menu'))Element.hide('explore_menu');if($('account_menu'))Element.toggle('account_menu');if($('search_controls'))Element.hide('search_controls');just_clicked_account_menu=false}else if(just_clicked_explore_menu){if($('account_menu'))Element.hide('account_menu');if($('explore_menu'))Element.toggle('explore_menu');if($('search_controls'))Element.hide('search_controls');just_clicked_explore_menu=false}else if(just_clicked_search_menu){if($('account_menu'))Element.hide('account_menu');if($('explore_menu'))Element.hide('explore_menu');if($('search_controls'))Element.toggle('search_controls');just_clicked_search_menu=false}else{if($('explore_menu'))Element.hide('explore_menu');if($('account_menu'))Element.hide('account_menu');if($('search_controls'))Element.hide('search_controls')}if($('account_menu')){if(Element.visible('account_menu')||window.location.toString().match('settings')||window.location.toString().match('addons')){$('account_nav_item').style.backgroundColor='#a1adaf'}else{$('account_nav_item').style.background='transparent'}}if($('explore_menu')){if(Element.visible('explore_menu')||window.location.toString().match('photos')||window.location.toString().match('likes')||window.location.toString().match('mozaika')||window.location.toString().match('mosaic')||window.location.toString().match('popular')||(window.location.toString().match('music')||window.location.toString().match('videos')||window.location.toString().match('quotes')||window.location.toString().match('latest')||window.location.toString().match(/\/themes\/$/)||window.location.toString().match(/\/themes\/recent$/)||window.location.toString().match(/\/themes\/popular$/))||(window.location.toString().match('search')&&!window.location.toString().match('dashboard/')&&!window.location.toString().match('shog/'))||window.location.toString().match('srory')||window.location.toString().match('browse')){$('explore_nav_item').style.backgroundColor='#a1adaf'}else{$('explore_nav_item').style.background='transparent'}}}function refresh_search_controls(){$$('#search_controls .check').invoke('hide');if(['Поиск','Поиск','Моя','Мои посты0',''].include($('search_query').value)){if($('search_query').value=='Поиск')default_search_text='Поиск';default_search_text=search_text_for_current_page;}}function display_post_notes(id){if(notes_slide_effect&&notes_slide_effect.state=='running')return;if(Element.visible('notes_outer_container_'+id)){if(Element.visible('notes_loader_'+id))return false;if(is_ie){Element.hide('notes_outer_container_'+id)}else{notes_slide_effect=Effect.SlideUp('notes_outer_container_'+id)}return false}if(Element.visible('notes_hide_link_'+id)){if(is_ie){Element.show('notes_outer_container_'+id)}else{notes_slide_effect=Effect.SlideDown('notes_outer_container_'+id)}return false}new Ajax.Updater('notes_container_'+id,'/notes/'+id,{onComplete:function(){$('notes_control_'+id).style.height='auto';Element.hide('notes_loader_'+id);Element.show('notes_hide_link_'+id);if(is_ie){Element.show('notes_container_'+id)}else{notes_slide_effect=Effect.SlideDown('notes_container_'+id,{duration:0.5})}}});if(is_ie){Element.show('notes_outer_container_'+id)}else{notes_slide_effect=Effect.SlideDown('notes_outer_container_'+id,{duration:0.5,afterFinish:function(){$('notes_outer_container_'+id).style.height='auto'}})}}function submit_answer(post_id){new Ajax.Request('/answer',{asynchronous:true,parameters:$('answer_form_'+post_id).serialize()});
if(is_ie){$('answer_container_'+post_id).innerHTML='<div class="answer_container">Вы ответили: <span style="font-weight:normal;">'+$('answer_text_'+post_id).value.replace('<','&lt;')+'</span></div>'}else{$('answer_status_'+post_id).innerHTML='Спасибо!';
var current_answer_count=parseInt($('answer_count_'+post_id).innerHTML);if(!current_answer_count)current_answer_count=0;$('answer_count_'+post_id).innerHTML=(current_answer_count+1)+' ответов';$('answer_text_'+post_id).disable();
Effect.SlideUp('answer_container_'+post_id,{afterFinish:function(){$('answer_container_'+post_id).innerHTML='<div class="answer_container">Вы ответили: <span style="font-weight:normal;">'+$('answer_text_'+post_id).value.replace('<','&lt;')+'</span></div>';
Effect.SlideDown('answer_container_'+post_id)}})}}function submit_like(post_id,unlike){if(unlike){Element.hide('unlike_form_'+post_id);Element.show('like_form_'+post_id)}else{Element.hide('like_form_'+post_id);Element.show('unlike_form_'+post_id)}new Ajax.Request($((unlike?'unlike_form_':'like_form_')+post_id).action,{asynchronous:true,parameters:Form.serialize($(unlike?('unlike_form_'+post_id):('like_form_'+post_id))),onFailure:function(){alert('Извините, кажется возникла какая-то проблема. Попробуйте позже.')}})}function set_cookie(name,value,expire_days){var ex_date=new Date();ex_date.setDate(ex_date.getDate()+expire_days);document.cookie=name+"="+escape(value)+((expire_days==null)?"":"; expires="+ex_date.toGMTString())+'; path=/'}function toggle_advanced_options_pane(){$('advanced_options').toggle();if($('advanced_options').visible()){Element.show('bubble_uncollapsed_arrow');Element.hide('bubble_collapsed_arrow');set_cookie('show_advanced_options',1,365)}else{Element.hide('bubble_uncollapsed_arrow');Element.show('bubble_collapsed_arrow');set_cookie('show_advanced_options',0,365)}}function pad_seconds(value){return(!isNaN(value)&&value.toString().length==1)?'0'+value:value}function time_format(time){var days=Math.floor(time/(3600*24));var seconds_remaining=time%(3600*24);var hours=Math.floor(seconds_remaining/3600);var seconds_remaining=seconds_remaining%3600;var minutes=Math.floor(seconds_remaining/60);var seconds=seconds_remaining%60;var output='';if(days)output+=days+' '+((days==1)?'day':'days')+' and ';if(hours)output+=hours+':';if(minutes)output+=minutes+':';output+=pad_seconds((seconds?seconds:0));return output}function block(tumblelog,el,context,form_key){var tumblelog_label=(tumblelog.substring(0,3)=='ip:'?'this person':tumblelog);if(confirm('Are you sure you want to block '+tumblelog_label+" from appearing on your Dashboard and blog?")){if(context=='note'){new Effect.Fade(el.up(),{duration:0.5})}else if(context=='notification'){new Effect.Fade(el.up(),{duration:0.5,to:0.5});el.innerHTML=''}new Ajax.Request('/block/add',{method:'post',asynchronous:true,parameters:{tumblelog:tumblelog,form_key:form_key},onFailure:function(){alert('Извините, кажется возникла какая-то проблема. Попробуйте позже.')}})}}