<% # encoding: utf-8 %>

  <%= f.error_messages %>

	<!--Widget start-->
	
	<div id="sub-wiget">
		  
		<div id="widget-status" class="widget-box widget-size-300">
			<div class="widget-action clear">
				<a class="action"><i title="Setting the announcement state" class="icon-exclamation-sign icon-white tip"></i></a>
			</div>
			<h3 class="widget-title"><i class="icons-star-thin icons-white"></i>Status</h3>
			<div class="widget-content clear">
				<div class="controls">
					<%= f.check_box :is_top %><%= t('top') %>
					<%= f.check_box :is_hot %><%= t('hot') %>
					<%= f.check_box :is_hidden %><%= t('hide') %>
				</div>
			</div>
		</div>

		<div id="widget-tags" class="widget-box widget-size-300">
			<div class="widget-action clear">
				<a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
			</div>
			<h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3>
			<div class="widget-content clear form-horizontal">
				<% @tags.each do |tag| %>
				<%= check_box_tag 'archive_file[tag_ids][]', tag.id, @archive_file.tag_ids.include?(tag.id)%>
				<%= tag[I18n.locale] %>
				<% end %>
			</div>
		</div>  
  
	</div>
  
  
<!--Wiget End-->
<!--Post Start-->

	<div id="post-body">
		<div id="post-body-content" class="clear">
		
			<%= f.label :category %>
			<%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.title, t.id ]} %>
			
			<ul class="nav nav-tabs">
				<% @site_valid_locales.each_with_index do |locale, i| %>
				<%# site_valid_locales_default_head.each_with_index do |locale, i| %>
			    <li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
				<% end %>
			</ul>
			
			<div class="tab-content">
			
				<% @site_valid_locales.each_with_index do |locale, i| %>
				
				<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
					<div class="title">
						<%= f.label :title %>
						<%= f.fields_for :title_translations do |f| %>
							<%= I18nVariable.from_locale(locale) %>
							<%= f.text_field locale, :class=>'post-title', :value => (@archive_file.title_translations[locale] rescue nil) %>
						<% end %>		
					</div>
					
				</div>

				<% end %>
				
			</div>
			
			
			<div>
						
				<div class="archive_file_multiples_block">
					
				<table class="table table-condensed">
					<thead>
						<tr>
							<th>File</th>
							<th>File Name</th>
							<th class="span2"><%= t('呈現語系')%></th>
							<th class="span1"></th>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td style="text-align:center" colspan="4">
								<div id='add_archive_file_multiple' class="info_input archive_file_multiples_block">
									<%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
									<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i> ADD/新增</span></a>
								</div>
							</td>
						</tr>
					
					</tfoot>
					<tbody>
						
						<% @archive_file.archive_file_multiples.each_with_index do |archive_file_multiple, i| %>
							<%= f.fields_for :archive_file_multiples, archive_file_multiple do |f| %>
								<%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %>
							<% end %>
						<% end %>	
					</tbody>
				</table>
				
				</div>
				
			</div>
			
			
		</div>
	
<!--Post End-->
  
  
	  <div class="form-actions">
		<%= f.submit t('submit'), :class=>'btn btn-primary' %>
		<%= link_to t('cancel'), get_go_back, :class=>"btn" %> 
	  </div>
	
	</div>
	
	

<% content_for :page_specific_javascript do %>
	<%= javascript_include_tag "archive_form" %>
	<script>
		$('#add_archive_file_multiple a.add').live('click', function(){
			var new_id = $(this).prev().attr('value');
			var old_id = new RegExp("new_archive_file_multiples", "g");
			$(this).prev().attr('value', parseInt(new_id) + 1);
			$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>").replace(old_id, new_id));
		});
		
		$('.archive_file_multiples_block a.delete').live('click', function(){
		  $(this).parents('.list_item').remove();
		});

		$('.action a.remove_existing_record').live('click', function(){
		  $(this).next('.should_destroy').attr('value', 1);
		  $("tr#archive_file_" + $(this).prev().attr('value')).hide();
		});

	</script>
<% end %>
 