<% @nav_dispaly_forum_label = 1 %>
<%= stylesheet_link_tag 'welcome' %>
<%= javascript_include_tag 'welcome' %>
<script type="text/javascript" language="javascript">
	$(function() {
		$("#main").find("a").attr("target", "_blank");
		setCss();
	});
	//设置div居中
	function setCss() {
		var mainBar = $('#main-content-bar')[0];
		var topHeight = mainBar.offsetHeight;
		var welcomeLeft = $('#welcome_left')[0];
		var leftHeight = welcomeLeft.offsetHeight;
		var searchbar = $('#search-bar')[0];
		var searchHeight = searchbar.offsetHeight;
		welcomeLeft.style.marginTop = (topHeight - leftHeight) / 2 + "px";
		searchbar.style.marginTop = (topHeight - searchHeight) / 2 + "px";
		//alert((topHeight - leftHeight)/2 );
	}

	// 给主页用户弹新页面
	$(document).ready(function($) {
		$("#loggedas").find("a").attr("target", "_blank");
		//$("#content .tabs_new~ .pagination").find("a").removeAttr("target");
	});
</script>

<div class='top_bar'>
	<%#= render partial: 'wei_xin' %>
	<div class="main-content-bar" id="main-content-bar">
		<div style="float: left;padding-left:15px ">
			<!-- <#%= image_tag(get_project_avatar(@first_page), size: "75x75") %>  -->
			<% if @organization.nil? %>
				<% if get_avatar?(@first_page) %>
					<%= image_tag(url_to_avatar(@first_page), width:@first_page.image_width,height: @first_page.image_height) %>
				<% else %>
					<%= image_tag '/images/transparent.png', width:@first_page.image_width,height: @first_page.image_height %>
				<% end %>
			<% else %>
              <%= image_tag(url_to_avatar(@organization), width:@first_page.image_width,height: @first_page.image_height) %>
			<% end %>
		</div>
		<div class="welcome_left" id="welcome_left">
			<% if @organization.nil? %>
				<% unless @first_page.nil? %>
					<!-- 改为国际化后无法通过后台配置
						 <%#= @first_page.description.html_safe %>
						 -->
					<!--<span class="font_welcome_trustie"><%#= @first_page.title.html_safe %></span>,&nbsp;-->
				    <span class="font_welcome_tdescription"><span class="font_welcome_tdescription"><%= @first_page.description.html_safe %></span></span>
				<% end %>
			<% else %>
                <span class="font_welcome_school" style="color: #E8770D">
                  <%=  @organization.name %>
                </span>
            <br/>
            <span class="font_welcome_trustie">
              <%= @enterprise_page.title %>
            </span>
			<% end %>
		</div>
		<div class="search-bar" id="search-bar">
			<%= render :partial => "search_project", :locals => {:project_type => 0}%>
		</div>
		<div style="clear: both;"></div>
	</div>
</div>

<div style="clear:both"></div>
<div id="J_Slide" class="d-p-index-box d-p-index-hot">
	<h3 style="margin-left: 5px; color: #e8770d;"><strong> <%= l(:lable_hot_projects)%> </strong></h3>
	<span style="margin-top: -20px;float: right; display: block;"> <% if User.current.logged? %>
		<%= link_to(l(:label_project_new), {:controller => 'projects',
		:action => 'new',
		:course => 0,
		:project_type =>( @project_type||=0)},
		:class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
		&nbsp;&nbsp;&nbsp;&nbsp;
		<%= link_to l(:label_join_project), join_project_projects_path ,:remote => true, :class => 'icon icon-add' %>
		&nbsp;&nbsp;&nbsp;&nbsp;
		<% end %> </span>
	<div class="d-p-projectlist-box">
		<ul class="d-p-projectlist">
			<!-- 如果企业版参数正确,这进入企业版页面 -->
			<% if @organization.nil? %>
				<% @projects.map do |project| %>
					<%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
				<% end; reset_cycle  %>
			<!-- 企业版项目 -->
			<% else %>
              <% if @part_projects.empty? %>
                  <% @projects.map do |project| %>
                      <%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
                  <% end %>
              <% else %>
                  <% @organization_projects.map do |project| %>
                      <%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
                  <% end %>
                  <li>
                    <h1></h1>
                    <div id="errorExplanation">
                      <%= l(:label_part_enterprise_tips) %>
                    </div>
                    <h1></h1>
                  </li>
                  <% @part_projects.map do |project| %>
                      <%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
                  <% end %>
              <% end %>
			<% end %>
		</ul>
	</div>
</div>
<div class="right" style="float: right; width: 48%; padding-top: 8px;">
	<ul class="welcome-message-list">
		<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
			<h3 style="color: rgb(21, 188, 207);"><strong> <%= l(:lable_bar_active)%> </strong> <%= link_to l(:label_my_question) , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
			<%= link_to l(:label_my_feedback) , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> </h3>
			<span style="margin-top: -30px;float: right; display: block;"> <%= link_to l(:button_more), forums_path %> </span>
		</div>
		<div class="welcome-box-list-new memo_activity">
			<% topics = find_new_forum_topics(12) %>
		    <% topics.includes(:forum, :last_reply, :author).each do |topic|%>
                <li class="message-brief-intro" style="line-height:1.4em;">
                    <div class='memo_title text_nowrap'>
                      <%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %>
                      <%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
                    </div>
                    <div class='memo_attr'>
                        <span class='memo_timestamp'>
                            <%#= "#{l(:field_updated_on, value: format_time(topic_last_time topic))}" %>
                          <%= l(:field_updated_on) %>
                          <%= format_time topic_last_time topic %>
                        </span>
                        <span class="memo_author">
                          <%= l(:label_question_sponsor)%>
                          <%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %>
                        </span>
                        <span class="memo_last_person">
                          <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %>
                              <%= l(:label_final_reply)%>
                              <%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%>
                          <% end %>
                        </span>
                        <span class="memo_reply">
                          <%= l(:label_reply)%>
                          (<%= link_to topic.try(:replies_count), topic.event_url %>)
                        </span>
                    </div>
                </li>
              <% end %>
		</div>
	</ul>
</div>

<div class="clearfix"></div>
<%= render partial: 'link_to_another' %>