<% # encoding: utf-8 %>
<% if @title %>
	<h1 class="h1"><%= @title %></h1>
<% end %>

<% if !@widget_fields.blank? %>

<% if @widget_style == '1' %>

	<div class="news news1">
		<table class="newstb" border="0" cellpadding="0" cellspacing="0" >
		<thead>
			<tr>
				<% @widget_fields.each do |wf|  %>
				<th><span class="<%= wf[1] %>"><%= t("announcement.bulletin.#{wf[0]}") if !wf[0].blank? %></span></th>
				<% end %>
			</tr>
		</thead>
		<% @bulletins.each do |post| %>
			<% @widget_fields.each do |wf|  %>
			<tr class="<%= cycle('odd', '')%>">
				<td>
				<span class="<%= wf[1] %>">
				<% if wf[1] == 'title' %>
					<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
				<% elsif wf[1] == 'date' %>
					<%= display_date(post.send(wf[0])) %>
				<% elsif wf[1] == 'category' %>
					<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
				<% elsif wf[1] == 'img' %>
					<div class="img app-pic"><%= image_tag(post.send(wf[0]).url) %></div>
				<% elsif wf[1] == 'text' %>
					<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
					<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
				<% elsif wf[1] == 'status' %>
					<% if post.is_top? %>
						<span class="top"><%= t(:top) %></span>
					<% end %>
					<% if post.is_hot? %>
						<span class="hot"><%= t(:hot) %></span>
					<% end %>
				<% elsif wf[1] == 'link' %>
				<% elsif wf[1] == 'file' %>
				<% elsif wf[1] == 'tag' %>
				<% elsif wf[1] == 'viewcount' %>
					<%= dislpay_view_count(post) %>
				<% elsif wf[1] == 'poster' %>
					<%= User.from_id(post.update_user_id).name rescue ''%>
				<% end %>
				</span>
				</td>
			</tr>
			<% end %>
		<% end %>
		</table>
		
		<% if !@category_id.blank? %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
		<% else %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
		<% end %>
	</div>

<% elsif @widget_style == '2' %>

	<div class="news news2">	
		<ul class="newslist">
		<% @bulletins.each do |post| %>
			<li class="<%= cycle('odd', '')%>">
				<div class="img app-pic"><%= image_tag(post.image.url) %></div>
				
				<% @widget_fields.each do |wf|  %>
				<span class="<%= wf[1] %>">
				<% if wf[1] == 'title' %>
					<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
				<% elsif wf[1] == 'date' %>
					<%= display_date(post.send(wf[0])) %>
				<% elsif wf[1] == 'category' %>
					<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
				<% elsif wf[1] == 'text' %>
					<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
					<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
				<% elsif wf[1] == 'status' %>
					<% if post.is_top? %>
						<span class="top"><%= t(:top) %></span>
					<% end %>
					<% if post.is_hot? %>
						<span class="hot"><%= t(:hot) %></span>
					<% end %>
				<% elsif wf[1] == 'link' %>
				<% elsif wf[1] == 'file' %>
				<% elsif wf[1] == 'tag' %>
				<% elsif wf[1] == 'viewcount' %>
					<%= dislpay_view_count(post) %>
				<% elsif wf[1] == 'poster' %>
					<%= User.from_id(post.update_user_id).name rescue ''%>
				<% end %>
				</span>
				<% end %>
			</li>
		<% end %>
		</ul>
		
		<% if !@category_id.blank? %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
		<% else %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
		<% end %>
	</div>

<% elsif @widget_style == '3' %>

	<div class="news news3">	
		<ul class="newslist">
		
		<% @bulletins.each do |post| %>
			<li class="<%= cycle('odd', '')%>">
				<div class="img app-pic"><%= image_tag(post.image.url) %></div>
				<div class="wrap">
					<% @widget_fields.each do |wf|  %>
					<span class="<%= wf[1] %>">
					<% if wf[1] == 'title' %>
						<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
					<% elsif wf[1] == 'date' %>
						<%= display_date(post.send(wf[0])) %>
					<% elsif wf[1] == 'category' %>
						<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
					<% elsif wf[1] == 'text' %>
						<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
						<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
					<% elsif wf[1] == 'status' %>
						<% if post.is_top? %>
							<span class="top"><%= t(:top) %></span>
						<% end %>
						<% if post.is_hot? %>
							<span class="hot"><%= t(:hot) %></span>
						<% end %>
					<% elsif wf[1] == 'link' %>
					<% elsif wf[1] == 'file' %>
					<% elsif wf[1] == 'tag' %>
					<% elsif wf[1] == 'viewcount' %>
						<%= dislpay_view_count(post) %>
					<% elsif wf[1] == 'poster' %>
						<%= User.from_id(post.update_user_id).name rescue ''%>
					<% end %>
					</span>
					<% end %>
				</div>
			</li>
			<% end %>
		</ul>
			
		<% if !@category_id.blank? %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
		<% else %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
		<% end %>
		
	</div>

<% elsif @widget_style == '4' %>

	<div class="news news4">	
		<ul class="newslist">
		
		<% @bulletins.each do |post| %>
			<li class="<%= cycle('odd', '')%>">
				<div class="img app-pic"><%= image_tag(post.image.url) %></div>
				<div class="wrap">
					<% @widget_fields.each do |wf|  %>
					<span class="<%= wf[1] %>">
					<% if wf[1] == 'title' %>
						<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
					<% elsif wf[1] == 'date' %>
						<%= display_date(post.send(wf[0])) %>
					<% elsif wf[1] == 'category' %>
						<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
					<% elsif wf[1] == 'text' %>
						<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
						<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
					<% elsif wf[1] == 'status' %>
						<% if post.is_top? %>
							<span class="top"><%= t(:top) %></span>
						<% end %>
						<% if post.is_hot? %>
							<span class="hot"><%= t(:hot) %></span>
						<% end %>
					<% elsif wf[1] == 'link' %>
					<% elsif wf[1] == 'file' %>
					<% elsif wf[1] == 'tag' %>
					<% elsif wf[1] == 'viewcount' %>
						<%= dislpay_view_count(post) %>
					<% elsif wf[1] == 'poster' %>
						<%= User.from_id(post.update_user_id).name rescue ''%>
					<% end %>
					</span>
					<% end %>
				</div>
			</li>
			<% end %>
		</ul>
			
		<% if !@category_id.blank? %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
		<% else %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
		<% end %>
		
	</div>

<% elsif @widget_style == '5' %>

	<div class="news news5">
		<div class="img app-pic"><%= image_tag(@bulletins.first.image.url) %></div>
		<ul class="newslist">
			<% @bulletins.each do |post| %>
			<li class="<%= cycle('odd', '')%>">
				<% @widget_fields.each do |wf|  %>
				<span class="<%= wf[1] %>">
				<% if wf[1] == 'title' %>
					<%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %>
				<% elsif wf[1] == 'date' %>
					<%= display_date(post.send(wf[0])) %>
				<% elsif wf[1] == 'category' %>
					<%= post.send("#{post.class.to_s.underscore}_#{wf[0]}").i18n_variable[I18n.locale] rescue nil %>
				<% elsif wf[1] == 'text' %>
					<%#= post.send("#{wf[0]}[#{I18n.locale}]").html_safe %>
					<%= post.send("#{wf[0]}")[I18n.locale].html_safe %>
				<% elsif wf[1] == 'status' %>
					<% if post.is_top? %>
						<span class="top"><%= t(:top) %></span>
					<% end %>
					<% if post.is_hot? %>
						<span class="hot"><%= t(:hot) %></span>
					<% end %>
				<% elsif wf[1] == 'link' %>
				<% elsif wf[1] == 'file' %>
				<% elsif wf[1] == 'tag' %>
				<% elsif wf[1] == 'viewcount' %>
					<%= dislpay_view_count(post) %>
				<% elsif wf[1] == 'poster' %>
					<%= User.from_id(post.update_user_id).name rescue ''%>
				<% end %>
				</span>
				<% end %>
			</li>
			<% end %>
		</ul>
			
		<% if !@category_id.blank? %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
		<% else %>
		<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
		<% end %>
	</div>
		
<% end %>

<% end %>
