<div class="navHomepage">
  <div class="navHomepageLogo fl">
    <%=link_to image_tag("../images/nav_logo.png",width:"51px", height: "45px",class: "mt3"), signin_path%>
  </div>
  <div class="fl">
    <ul>
      <li class="navHomepageMenu fl mr40">
        <%= link_to "帮助中心", "https://#{Setting.host_name}/forums/1/memos/1168", :class =>"c_white f16 db p10" %>
      </li>
    </ul>
  </div>
  <script>
      function search(doc){
          //alert(1)
          // val = $('input:radio[name="search_type"]:checked').val();
          // alert(2)
          // $("#search_type").val(val);
          //  alert(3)
          $(doc).parent().submit();
      }
      <!--<%# type = type%>-->
//      $(function (){
//          if('<%#= type %>' != null && '<%#= type %>' == 'courses' ){
//              $('input:radio[value="courses"]').attr('checked','checked');
//          }
//          if('<%#= type %>' != null && '<%#= type %>' == 'projects' ){
//              $('input:radio[value="projects"]').attr('checked','checked');
//          }
//          if('<%#= type %>' != null && '<%#= type %>' == 'users' ){
//              $('input:radio[value="users"]').attr('checked','checked');
//          }
//      });

      function search_in_header(obj){
          var name = $.trim($('#navHomepageSearchInput').val());
          if (name != "" &&  name.length != 0) {
              //$('#type').val($('input[type=radio]:checked').val());
              obj.parent().submit();
          }
      }

          function search_in_header_I(e,obj){
              var name = $.trim($('#navHomepageSearchInput').val());
              if (e.keyCode == '13' && name != "" &&  name.length != 0) {
                  //$('#type').val($('input[type=radio]:checked').val());
                  obj.parent().submit();
              }
          }
  </script>
  <div class="fl" id="navHomepageSearch">
    <!--<form class="navHomepageSearchBox">-->
    <% name = name%>

    <%= 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="请输入关键词搜索公开的课程、项目、用户、资源以及帖子" onkeypress="search_in_header_I(event,$(this));"/>
        <input type="hidden" name="search_type" id="type" value="all"/>
        <input type="text" style="display: none;"/>
        <a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a>
    <% end %>
    <!--<div class="navSearchTypeBox" id="navHomepageSearchType">-->
      <!--<div class="fl mr15 mt8">-->
        <!--<input type="radio" value="courses" name="search_type"  checked/>-->
        <!--课程-->
      <!--</div>-->
      <!--<div class="fl mr15 mt8">-->
        <!--<input type="radio" value="projects" name="search_type" />-->
        <!--项目-->
      <!--</div>-->
      <!--<div class="fl mr15 mt8">-->
        <!--<input type="radio" value="users" name="search_type" />-->
        <!--用户-->
      <!--</div>-->
      <!--<div id="navSearchAlert" class="fr mr10">-->
        <!--<span class="c_red">请选择搜索类型</span>-->
      <!--</div>-->
    <!--</div>-->

  </div>
  <div id="loginInButton" class="fr ml20">
    <a href="<%= signin_url_without_domain %>" class="c_white db">登录</a>
  </div>
  <div id="loginSignButton" class="fr">
    <a href="<%= register_url_without_domain %>" class="c_white db">注册</a>
  </div>
</div>

<script type="text/javascript">
    //搜索相关
    $("#navHomepageSearch").mouseover(function(){
        $("#navHomepageSearchType").show();
    }).mouseout(function(){
        $("#navHomepageSearchType").hide();
    });

</script>
