<% current_user = @user == User.current %>
<% str = current_user ? '我' : 'TA' %>

<% show_package = @user.project_packages.count.nonzero? || @user.bidding_project_packages.count.nonzero? %>

<script>
    function showedit_headphoto() {
        var html = "<%= escape_javascript(render :partial => "users/upload_avatar") %>";
        pop_box_new(html, 550, 510);
        $("#imageHead img").attr({"src": $("#user_avatar_show").attr("src")});
        $("#wrapper_image_show img").attr({"src": $("#user_avatar_show").attr("src")});
    }
</script>
<div class="user-main-half">
  <div class="user-headImg"></div>
  <div class="user-headCon">
    <div class="pr" style="min-height: 465px;">
      <div class="educontent pt80 clearfix edu-txt-center">
        <div class="inline">
          <div class="fl headtab">
            <span><%= current_user ? "" : "TA的" %>经验值</span>
            <%= link_to @user.experience, user_experience_user_path(@user) %>
          </div>
          <em class="v-h-line fl"></em>
          <div class="fl headtab">
            <span><%= current_user ? "" : "TA的" %>金币</span>
            <%= link_to @user.grade, user_grade_user_path(@user), :id => "user_code" %>
          </div>
          <div class="headphoto mt14">
            <%= image_tag(url_to_avatar(@user), :alt => "头像", :nhname => "avatar_image", :id => "user_avatar_show") %>
            <% if current_user || User.current.admin? %>
              <p class="headphoto-black" onclick="showedit_headphoto();">修改头像</p>
            <% end %>
          </div>
          <div class="fl headtab">
            <span><%= current_user ? "" : "TA的" %>粉丝</span>
            <%= link_to @user_fanlist_count, user_fanslist_user_path(@user), :id => "user_h_fan_count" %>
          </div>
          <em class="v-h-line fl"></em>
          <div class="fl headtab">
            <span><%= current_user ? "" : "TA的" %>关注</span>
            <%= link_to @user_watchlist_count, user_watchlist_user_path(@user) %>
          </div>
          <span class="clearfix"></span>
          <span class="myName"><%= current_user ? @user.show_real_name : @user.show_name %></span>

        </div>
      </div>
      <div class="educontent mt10 clearfix edu-txt-center">
        <div class="inline">
          <span class="mypost fl mr10"><%= current_user ? @user.identity : (@user.identity == "学生" ? "" : @user.identity) %></span>
          <%# if current_user %>
<!--            <a href="<%#= authentication_account_path %>" target="_blank" class="ringauto fl">-->
              <%# if @user.authentication %>
<!--                <img src="/images/educoder/icon/auto-identityed.svg" class="mt2" data-tip-down="已实名认证">-->
              <%# else %>
                <%# apply_auth = ApplyUserAuthentication.where(:user_id => @user.id, :auth_type => 1).last %>
<!--                <img src="/images/educoder/icon/auto-identity.svg" class="mt2" data-tip-down="<%#= apply_auth && apply_auth.status == 0 ? '实名认证中' : '未实名认证' %>">-->
              <%# end %>
<!--            </a>-->
<!--            <a href="<%#= professional_certification_account_path %>" target="_blank" class="ringauto fl">-->
              <%# if @user.professional_certification %>
<!--                <img src="/images/educoder/icon/auto-posted.svg" class="mt2" data-tip-down="已职业认证">-->
              <%# else %>
                <%# apply_auth = ApplyUserAuthentication.where(:user_id => @user.id, :auth_type => 2).last %>
<!--                <img src="/images/educoder/icon/auto-post.svg" class="mt2" data-tip-down="<%#= apply_auth && apply_auth.status == 0 ? '职业认证中' : '未职业认证' %>">-->
              <%# end %>
<!--            </a>-->
            <%# if @user.try(:phone).blank? %>
<!--              <a href="<%#= change_or_bind_path(:type => 'phone') %>" target="_blank" class="ringauto fl"><img src="/images/educoder/icon/auto-phone.svg" class="mt2" data-tip-down="未绑定手机"></a>-->
            <%# else %>
<!--              <a href="<%#= my_account_path %>" target="_blank" class="ringauto fl"><img src="/images/educoder/icon/auto-phoneed.svg" class="mt2" data-tip-down="已绑定手机"></a>-->
            <%# end %>
            <%# if @user.try(:mail).blank? %>
<!--              <a href="<%#= change_or_bind_path(:type => 'mail') %>" target="_blank" class="ringauto fl"><img src="/images/educoder/icon/auto-email.svg" class="mt2" data-tip-down="未绑定邮箱"></a>-->
            <%# else %>
<!--              <a href="<%#= my_account_path %>" target="_blank" class="ringauto fl"><img src="/images/educoder/icon/auto-emailed.svg" class="mt2" data-tip-down="已绑定邮箱"></a><-->
            <%# end %>
            <%# if @user.department_members.count > 0 %>
<!--              <a href="<%#= statistics_college_path(@user.department_members.first.try(:department)) %>" target="_blank" class="ringauto fl"><i class="iconfont icon-chengyuanguanli font-12 color-blue" data-tip-down="学院管理员"></i></a>-->
            <%# end %>
          <%# else %>
            <span class="ringauto fl">
              <% if @user.authentication %>
                <img src="/images/educoder/icon/auto-identityed.svg" class="mt2" data-tip-down="已实名认证"><!--实名认证-->
              <% else %>
                <% apply_auth = ApplyUserAuthentication.where(:user_id => @user.id, :auth_type => 1).last %>
                <img src="/images/educoder/icon/auto-identity.svg" class="mt2" data-tip-down="<%= apply_auth && apply_auth.status == 0 ? '实名认证中' : '未实名认证' %>">
              <% end %>
            </span>
            <span class="ringauto fl">
              <% if @user.professional_certification %>
                <img src="/images/educoder/icon/auto-posted.svg" class="mt2" data-tip-down="已职业认证">
              <% else %>
                <% apply_auth = ApplyUserAuthentication.where(:user_id => @user.id, :auth_type => 2).last %>
                <img src="/images/educoder/icon/auto-post.svg" class="mt2" data-tip-down="<%= apply_auth && apply_auth.status == 0 ? '职业认证中' : '未职业认证' %>">
              <% end %>
            </span>
            <% if @user.try(:phone).blank? %>
              <span class="ringauto fl"><img src="/images/educoder/icon/auto-phone.svg" class="mt2" data-tip-down="未绑定手机"></span><!--手机认证-->
            <% else %>
              <span class="ringauto fl"><img src="/images/educoder/icon/auto-phoneed.svg" class="mt2" data-tip-down="已绑定手机"></span><!--手机认证-->
            <% end %>
            <% if @user.try(:mail).blank? %>
              <span class="ringauto fl"><img src="/images/educoder/icon/auto-email.svg" class="mt2" data-tip-down="未绑定邮箱"></span><!--邮箱认证-->
            <% else %>
              <span class="ringauto fl"><img src="/images/educoder/icon/auto-emailed.svg" class="mt2" data-tip-down="已绑定邮箱"></span><!--邮箱认证-->
            <% end %>
            <% if @user.department_members.count > 0 && current_user %> <!--访问他人主页无连接 -->
            <a href="<%= statistics_college_path(@user.department_members.first.try(:department)) %>" target="_blank" class="ringauto fl"><i class="iconfont icon-chengyuanguanli font-12 color-blue" data-tip-down="学院管理员"></i></a>
            <% elsif @user.department_members.count > 0 %>
              <a href="javascript:void(0)" class="ringauto fl"><i class="iconfont icon-chengyuanguanli font-12 color-blue" data-tip-down="学院管理员"></i></a><!--学院管理员身份-->
            <% end %>
          <%# end %>
        </div>
      </div>
      <div class="mt15 educontent clearfix edu-txt-center">
        <p class="mb30" style="height: 28px">
          <% if current_user %>
            <input id="current_user_id" value="<%= @user.id %>" type="hidden">
            <span class="mysign-span" onclick="editmysign(this);">
              <%= @user.user_extensions.brief_introduction.blank? ? "这家伙很懒,什么都没留下~" : @user.user_extensions.brief_introduction %>
            </span>
            <input type="text" class="mysign-input none" placeholder="请输入您的个性签名" value="这家伙很懒,什么都没留下~" onblur="savemysign(this)"/>
          <% else %>
            <span class="mysign-span" style="cursor: default">
              <%= @user.user_extensions.brief_introduction.blank? ? "这家伙很懒,什么都没留下~" : @user.user_extensions.brief_introduction %>
            </span>
          <% end %>
        </p>
        <div class="inline">
          <% if current_user %>
            <% if @can_attendance %>
              <a herf="javascript:void(0);" onclick="user_attendance('<%= @user.login %>');" id="attendance" class="user_default_btn user_orange_btn fl">签到</a>
              <span id="attendance_span" style="display: none;" class="fl user_default_btn user_grey_btn mb5">已签到</span>
              <%# if @apply_trial %>
<!--                <a herf="javascript:void(0);" onclick="user_apply_trail();" id="authentication_apply" class="user_default_btn user_private_btn fl ml15">试用申请</a>-->
              <%# end %>
              <div class="clearfix"></div>
              <span id="attendance_notice" class="none font-12 color-grey-6">明日签到&nbsp;<font class="color-orange">+<%= @next_attachment_score < 100 ? (@next_attachment_score + 10) : 100 %></font>&nbsp;金币</span>
            <% else %>
              <span class="user_default_btn user_grey_btn mb5 fl">已签到</span>
              <% if @apply_trial %>
                <a herf="javascript:void(0);" onclick="user_apply_trail();" id="authentication_apply" class="user_default_btn user_private_btn fl ml15">试用申请</a>
              <% end %>
              <div class="clearfix"></div>
              <span class="font-12 color-grey-6">明日签到&nbsp;<font class="color-orange">+<%= @next_attachment_score %></font>&nbsp;金币</span>
            <% end %>
          <% else %>
            <% if (@user.watched_by?(User.current)) %>
              <%= link_to "取消关注",
                          unwatch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id, :className => "user_default_btn user_watch_btn user_private_btn fl mr20"),
                          :class => "user_default_btn user_watch_btn user_private_btn fl mr20",
                          :id => "cancel_watch",
                          :method => "post",
                          :remote => "true" %>
            <% else %>
              <%= link_to "关注",
                          watch_path(:object_type => 'user', :object_id => @user.id, :target_id => @user.id, :className => "user_default_btn user_watch_btn user_private_btn fl mr20"),
                          :class => "user_default_btn user_watch_btn user_private_btn fl mr20",
                          :method => "post",
                          :remote => "true" %>
            <% end %>
            <%= link_to "私信", message_detail_user_path(User.current, :user_id => @user.id), :class => "user_default_btn user_private_btn fl" %>
          <% end %>
        </div>
      </div>
      <div class="edu-txt-center navPositon">
        <div class="inline user-nav-item">
          <li class="<%= @type == 'a_course' || @type == 'p_course' || @type == 'l_course' ? 'active' : '' %>" id="user_course"><%= link_to "课堂", user_path(@user, :type => "a_course"), :remote => true %></li>
          <li class="<%= (@type == 'a_shixun' || @type == 'l_shixun' || @type == 'p_shixun') ? 'active' : '' %>" id="user_shixun"><%= link_to "实训", user_path(@user, :type => "a_shixun"), :remote => true %></li>
          <li class="<%= (@type == 'a_path' || @type == 'l_path' || @type == 'p_path') ? 'active' : '' %>" id="user_path"><%= link_to "实训课程", user_path(@user, :type => "a_path"), :remote => true %></li>
          <li class="<%= (@type == 'a_project' || @type == 'l_project' || @type == 'p_project') ? 'active' : '' %>" id="user_project"><%= link_to "项目", user_path(@user, :type => "a_project"), :remote => true %></li>
          <% if @user.user_extensions.try(:identity) == 0 && current_user %>
            <li class="<%= @type == 'm_bank' ? 'active' : '' %>" id="user_bank"><%= link_to "题库", user_path(@user, :type => "m_bank"), :remote => true %></li>
          <% end %>
          <% if show_package %>
            <li class="<%= %w(a_package p_package l_package).include?(@type) ? 'active' : '' %>" id="user_package"><%= link_to "众包", user_path(@user, :type => "a_package"), :remote => true %></li>
          <% end %>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="educontent">
  <!-- 教师身份的课堂 “我管理的”在前,其他身份“我学习的”在前 -->
  <% if @user.user_extensions.try(:identity) == 0 %>
    <!--课堂-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_course' ? '' : 'none' %>">
      <li class="active" id="a_course"><%= link_to "全部", user_path(@user, :type => "a_course"), :remote => true %></li>
      <li id="p_course"><%= link_to str + "管理的", user_path(@user, :type => "p_course"), :remote => true %></li>
      <li id="l_course"><%= link_to str + "学习的", user_path(@user, :type => "l_course"), :remote => true %></li>
    </div>

    <!--实训-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_shixun' ? '' : 'none' %>">
      <li class="active" id="a_shixun"><%= link_to "全部", user_path(@user, :type => "a_shixun"), :remote => true %></li>
      <li id="p_shixun"><%= link_to str + "管理的", user_path(@user, :type => "p_shixun"), :remote => true %></li>
      <li id="l_shixun"><%= link_to str + "学习的", user_path(@user, :type => "l_shixun"), :remote => true %></li>
    </div>

    <!--实训路径-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_path' ? '' : 'none' %>">
      <li class="active" id="a_path"><%= link_to "全部", user_path(@user, :type => "a_path"), :remote => true %></li>
      <li id="p_path"><%= link_to str + "管理的", user_path(@user, :type => "p_path"), :remote => true %></li>
      <li id="l_path"><%= link_to str + "学习的", user_path(@user, :type => "l_path"), :remote => true %></li>
    </div>
  <% else %>
    <!--课堂-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_course' ? '' : 'none' %>">
      <li class="active" id="a_course"><%= link_to "全部", user_path(@user, :type => "a_course"), :remote => true %></li>
      <li id="l_course"><%= link_to str + "学习的", user_path(@user, :type => "l_course"), :remote => true %></li>
      <li id="p_course"><%= link_to str + "管理的", user_path(@user, :type => "p_course"), :remote => true %></li>
    </div>

    <!--实训-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_shixun' ? '' : 'none' %>">
      <li class="active" id="a_shixun"><%= link_to "全部", user_path(@user, :type => "a_shixun"), :remote => true %></li>
      <li id="l_shixun"><%= link_to str + "学习的", user_path(@user, :type => "l_shixun"), :remote => true %></li>
      <li id="p_shixun"><%= link_to str + "管理的", user_path(@user, :type => "p_shixun"), :remote => true %></li>
    </div>

    <!--实训路径-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_path' ? '' : 'none' %>">
      <li class="active" id="a_path"><%= link_to "全部", user_path(@user, :type => "a_path"), :remote => true %></li>
      <li id="l_path"><%= link_to str + "学习的", user_path(@user, :type => "l_path"), :remote => true %></li>
      <li id="p_path"><%= link_to str + "管理的", user_path(@user, :type => "p_path"), :remote => true %></li>
    </div>
  <% end %>

  <!--项目-->
  <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'a_project' ? '' : 'none' %>">
    <li class="active" id="a_project"><%= link_to "全部", user_path(@user, :type => "a_project"), :remote => true %></li>
    <li id="p_project"><%= link_to str + "管理的", user_path(@user, :type => "p_project"), :remote => true %></li>
    <li id="l_project"><%= link_to str + "参与的", user_path(@user, :type => "l_project"), :remote => true %></li>
  </div>

  <% if @user.user_extensions.try(:identity) == 0 && current_user %>
    <!--题库-->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= @type == 'm_bank' || @type == "p_bank" ? '' : 'none' %>">
      <li class="<%= @type == 'm_bank' ? 'active' : '' %>" id="m_bank"><%= link_to "私有题库", user_path(@user, :type => "m_bank"), :remote => true %></li>
      <li class="<%= @type == 'p_bank' ? 'active' : '' %>" id="p_bank"><%= link_to "公共题库", user_path(@user, :type => "p_bank"), :remote => true %></li>
    </div>
  <% end %>

  <% if show_package %>
    <!-- 众包 -->
    <div class="white-panel edu-back-white pt25 pb25 clearfix <%= %w(a_package p_package l_package).include?(@type) ? '' : 'none' %>">
      <li class="active" id="a_package"><%= link_to "全部", user_path(@user, :type => "a_package"), :remote => true %></li>
      <li id="p_package"><%= link_to str + "管理的", user_path(@user, :type => "p_package"), :remote => true %></li>
      <li id="l_package"><%= link_to str + "参与的", user_path(@user, :type => "l_package"), :remote => true %></li>
    </div>
  <% end %>
</div>

<div id="user_object_list">
  <% if @type == "m_bank" || @type == "p_bank" %>
    <%= render :partial => "users/m_bank" %>
  <% elsif @type == 'a_project' || @type == 'l_project' || @type == 'p_project' %>
    <%= render :partial => "users/l_project" %>
  <% elsif @type == 'a_course' || @type == 'l_course' || @type == 'p_course' %>
    <%= render :partial => "users/l_course" %>
  <% elsif @type == 'a_shixun' || @type == 'l_shixun' || @type == "p_shixun" %>
    <%= render :partial => "users/l_shixun" %>
  <% elsif @type == 'a_path' || @type == 'l_path' || @type == "p_path" %>
    <%= render :partial => "users/p_path" %>
  <% elsif %w(a_package p_package l_package).include?(@type) %>
    <%= render :partial => "users/project_package" %>
  <% end %>
</div>

<script>
    $(function () {
        <% if @noticed && @noticed_update.nil? %>
          var html = "<%= escape_javascript(render :partial => 'account/certification_one_day') %>";
          pop_box_new(html, 480, 200,true);
        <% end %>
    });
    function user_apply_trail(){
        var html = "<%= escape_javascript(render :partial => 'welcome/two_btn_mask_pop') %>";
        pop_box_new(html, 500, 338,true);
        $("input[name='from_user']").val(1);
    }
</script>