function initMenu() {
  $('#menu ul').hide();
  if (!what_ | what_=="editpoem" | what_=="editcat") $('.m_poem').show();
  else if (what_=="msg_pvoutbox" | what_=="msg_pvinbox") $('.m_msg_pv').show();
  else if (what_=="favorpoems" | what_=="favorusers") $('.m_favor').show();
  else if (what_=="editsett" | what_=="usrblackedit") $('.m_sett').show();
  else if (what_=="entry") $('.m_entry').show();
  else if (what_=="photo" | what_=="album") $('.m_photo').show();
  else if (what_=="statreaders" | what_=="statpoints" | what_=="statufavor") $('.m_stat').show();
  else if (what_=="searchusers" | what_=="searchpoems") $('.m_search').show();
  else if (what_=="commentstomypoems" | what_=="commentsmy_to_poems" | what_=="commentsmonitoring") $('.m_comments').show();
  else if (what_=="friendsedit" | what_=="friendsquery") $('.m_friends').show();

  
  $('#menu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#menu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
$(document).ready(function() {
  initMenu();
  //Внешние ссылки
   $('a[href^="http"]').live("click",function(){
      host_allow=new Array('poem4you.ru','poem.com.ua','staratel.com','stiholub.ru','youtube.ru','yandex.ru','google.com','facebook.com','odnoklassniki.ru','vk.com');
      a_domain=this.hostname;
      link_f=false;
      $.each(host_allow,function(){  
          if (this==a_domain || ("www."+this)==a_domain) {
            link_f=true;return false;
          }
      });
      if (!link_f && !confirm("Вы действительно хотите перейти по внешней ссылке?\n"+$(this).attr("href")+"\n\nБудьте осторожны, если не доверяете сайту, на который собираетесь перейти.")) return false;
   });
  
});

