<div class="navHomepage">
  <div class="navHomepageLogo fl">
    <a href ="javascript:void(0);" disabled="true" class="mt3"><%= image_tag("../images/nav_logo.png",width:"51px", height: "45px",class: "mt3")%></a>
  </div>
  <div class="fl">
    <ul>
      <li class="navHomepageMenu fl">
        <a href ="javascript:void(0);" disabled="true" class="c_white f16 db p10">首页</a>
      </li>
      <li class="navHomepageMenu fl">
        <a href ="javascript:void(0);" disabled="true" class="c_white f16 db p10">资源库</a>
      </li>
      <% if hidden_unproject_infos %>
          <li class="navHomepageMenu fl">
            <a href ="javascript:void(0);" disabled="true" class="c_white f16 db p10">题库</a>
          </li>
          <li class="navHomepageMenu fl mr30">
            <a href ="javascript:void(0);" disabled="true" class="c_white f16 db p10">帮助中心</a>
          </li>
      <% end %>
    </ul>
  </div>
  <div class="fl" id="navHomepageSearch">
    <!--<form class="navHomepageSearchBox">-->
    <% name = name%>
    <a href ="javascript:void(0);" disabled="true"><%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do  %>
        <input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的班级、项目、用户、资源以及帖子"/>
        <input type="hidden" name="search_type" id="type" value="all"/>
        <input type="text" style="display: none;"/>
        <a href="javascript:void(0);" class="homepageSearchIcon" disabled="true"></a>
    <% end %></a>
  </div>

  <div class="navHomepageProfile" id="navHomepageProfile">
    <ul>
      <li class="homepageProfileMenuIcon" id="homepageProfileMenuIcon">
        <div  class="mt5 mb8" id="user_avatar"></div>
        <a href ="javascript:void(0);" disabled="true"><%= image_tag(url_to_avatar(User.current),:width =>"40",:height => "40",:alt=>"头像", :id => "nh_user_logo", :class => "portraitRadius") %></a>
        <ul class="topnav_login_list none" id="topnav_login_list">
          <li>
            <%= link_to "修改资料", my_account_path(:tip => 1), :class => "menuGrey"%>
          </li>
          <li>
            <a href ="javascript:void(0);" class="menuGrey" disabled="true">我的组织</a>
          </li>
          <li>
            <a href ="javascript:void(0);" class="menuGrey" disabled="true">新建组织</a>
          </li>
          <!--<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>-->
          <li>
            <%= link_to "退出", logout_url_without_domain, :class => "menuGrey", :method => "post"%>
          </li>
        </ul>
      </li>
    </ul>
  </div>

  <div class="navHomepageNews" id="user_messages">
    <a href ="javascript:void(0);" class="homepageNewsIcon" disabled="true" title = "您的所有消息" ></a>
    <%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>
  </div>
</div>
<script type="text/javascript">
    var onUserMessages = false;
    var onNotice = false;
    //搜索相关
    $("#navHomepageSearch").mouseover(function(){
        $("#navHomepageSearchType").show();
    }).mouseout(function(){
        $("#navHomepageSearchType").hide();
    });

    $("#user_messages").mouseenter(function(){
        onNotice = true;
        $("#user_messages_list").show();
        if($("#message_list_detail").length == 0){
            $.get('<%=user_messages_unviewed_users_path %>');
            $("#ajax-indicator").hide();
        }
        var obj = $("#user_messages_list");
        clearTimeout(obj.timer);
    }).mouseleave(function(){
        onNotice = false;
        var obj = $("#user_messages_list");
        setTimeout(function(){
            if(!onNotice && !onUserMessages) {
                obj.hide();
                obj.html("<%=escape_javascript(render :partial => 'layouts/message_loading') %>");
            } }, 500);
    });
    $("#message_list_detail").mouseenter(function(event){
        event.stopPropagation();
        onUserMessages = true;
    }).mouseleave(function(){
        onUserMessages = false;
    });

    $("#navHomepageProfile").mouseenter(function(){
        $("#homepageProfileMenuIcon").addClass("homepageProfileMenuIconhover");
        $("#topnav_login_list").show();
    });
    $("#navHomepageProfile").mouseleave(function(){
        $("#homepageProfileMenuIcon").removeClass("homepageProfileMenuIconhover");
        $("#topnav_login_list").hide();
    });

    function signout(){
        $.post(
                '<%= signout_path%>',
                {}
        );
    }
</script>
