<ul class="nav pull-right" role="navigation">

    <!-- search -->
    <li id="search" class="searchClear">
      <form id="search_form" method="get" action="/site_search">
        <%= text_field_tag 'q','', {:class => "search-query input-medium", :placeholder => "Search", 'x-webkit-speech' => ''} %>
      </form>
    </li>

    <!-- ntu sites -->
    <li id="orbit-tag" class="dropdown">
      <a class="dropdown-toggle orbit-bar-language" data-icons="&#xe02d;" href="#" data-toggle="dropdown"></a>
      <ul class="dropdown-menu language-menu">
        <% t('ntu.site_names').each do |site| %>
          <li><%= link_to site[1], get_link(site[0]) %></li>
        <% end %>
      </ul>
    </li>

    <!-- Language -->
    <li id="orbit-language" class="dropdown">
      <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown" title="<%= t('site.language')%>"><%= t(:_locale, :locale => I18n.locale) %></a>
      <ul class="dropdown-menu" role="menu" aria-labelledby="orbit-language">
        <% @site_in_use_locales.each do |locale| %>
          <%= content_tag :li, (link_to t(:_locale, :locale => locale), add_locale(remove_locale((@referer || request.fullpath)), locale)), :class => (I18n.locale.eql?(locale.to_sym) ? 'active' : nil), tabindex: "-1" %>
        <% end %>
      </ul>
    </li>

    <% if user_signed_in? %>
      <!-- user -->
      <li id="orbit-user" class="dropdown">
        <a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
          <%= image_tag 'menber-pic.png', class: "user-pic" %>
            <span><%= current_user.name %></span>
        </a>
        <ul class="dropdown-menu" role="menu" aria-labelledby="orbit-user">
          <li><%= link_to content_tag(:i, nil, class: 'icons-tools') + ' ' +  t("users.change_passwd"), admin_users_new_interface_setting_account_path(current_user), tabindex: '-1' %></li>
          <li><%= link_to content_tag(:i, nil, class: 'icons-vcard') + ' ' +  t("users.user_basic_data"), admin_users_new_interface_edit_user_data_path(current_user), tabindex: '-1' %></li>
          <% if @site.desktop_closed %>
          <li><%= link_to content_tag(:i, nil, class: 'icons-screen') + ' ' +  t(:desktop), desktop_path, tabindex: '-1' %></li>
          <% end %>
          <li><%= link_to content_tag(:i, nil, class: 'icons-logout') + ' ' +  t(:logout), user_logout_path, tabindex: '-1' %></li>
          <li class="divider"></li>
          <li><a tabindex="-1" href="#"><i class="icons-lifebuoy"></i> <%= t(:help) %></a></li>
        </ul>
      </li>
    <% else %>
      <!-- login -->
      <li id="orbit-login">
        <a href="#login" role="button" data-toggle="modal" title="<%= t('login')%>">
          <i class="icons-login"></i> <span class="hide"><%= t(:login) %></span>
        </a>
      </li>
      <!-- Log in Modal -->
        <div id="login" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="ModalLabel"><%= t(:login_orbit) %></h3>
          </div>
          <div class="modal-body">
            <%= form_for :user, url: user_session_path, html: {class: 'container'} do |f| %>

              <div class="other-sign-in">
                <% @request_hosts = request.host_with_port.split(".") %>
                <a class="btn btn-primary" type="submit" href="https://adfs.ntu.edu.tw/adfs/ls/?wa=wsignin1.0&wtrealm=https://galogin.ntu.edu.tw/saml_login&wctx=<%= @request_hosts[0] %>">使用計中帳號登入</a>
                <p>or</p>
              </div>
              <div class="input-prepend">
                <span class="add-on">
                  <i class="icon-user"></i>
                </span>
                <%= f.text_field :user_id, class: "input-xlarge" , placeholder: t("users.user_id") %>
              </div>
              <div class="input-prepend">
                <span class="add-on">
                  <i class="icon-lock"></i>
                </span>
                <%= f.password_field :password, class: "input-xlarge", placeholder: t(:password) %>
              </div>
              <div class="pull-left" style="width: 150px;">
                <label class="checkbox">
                  <input type="checkbox" name="user[remember_me]" value="1" checked="checked" />
                  <small>Remember me</small>
                </label>
                <%= content_tag :button, t(:login), :type => :submit, :class => 'btn btn-primary' %>
              </div>
              <div class="pull-right">
                <%= link_to content_tag(:small, t(:forgot_password)), new_user_password_path %>
              </div>
            <% end %>
          </div>
          <div class="modal-footer">
          </div>
        </div>
    <% end %>
</ul>