<% # encoding: utf-8 %>

  <%= f.error_messages %>
  <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>

  <div class="field">
    <%= f.label :image, t('announcement.image') %><br />
    <%= f.file_field :image %>
	<% if @bulletin.image.file %>
	  <%= check_box_tag 'bulletin[image_del]' %>
	  <%= t('announcement.刪除已上傳檔案') %>
	<% end %>
  </div>

	<div class="field">
    <%= f.label :title %>
		<%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %>
		  <% @site_valid_locales.each do |locale| %>
		    <td>
					<%= I18nVariable.from_locale(locale) %>
					<%= f.text_field locale %>
				</td>
		  <% end %>
		<% end %>
	</div>
  
	<div class="field">
		<%= f.label :subtitle %>
		<%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %>
			<% @site_valid_locales.each do |locale| %>
				<td>
					<%= I18nVariable.from_locale(locale) %>
					<%= f.text_area locale, :rows => 10, :cols => 40 %>
				</td>
			<% end %>
		<% end %>
	</div>

	<div class="field">
		<%= f.label :text %>
		<%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %>
			<% @site_valid_locales.each do |locale| %>
				<td>
					<%= I18nVariable.from_locale(locale) %>
					<%= f.text_area locale, :rows => 10, :cols => 40 %>
				</td>
			<% end %>
		<% end %>
	</div>
  
  <div class="field">
    <%= f.label :postdate %><br />
    <%= f.date_select :postdate, :order => [:year, :month, :day], :use_month_numbers => true %>
    <%#= date_select("bulletin", "postdate", :use_month_numbers => true) %>
  </div>
  
  <div class="field">
    <%= f.label :deadline %><br />
    <%= f.date_select :deadline, :use_month_numbers => true, :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year'}  %>
    <%#= f.date_select :deadline, :order => [:year, :month, :day],:default => 1.years.from_now, :use_month_numbers => true  %>
  </div>
  
  <div class="field">
    <%#= f.label :url %><br />
    <%#= f.text_field :url, :size => 60 %>
  </div>
  
  
  <div id='bulletin_links' class="bulletin_links_block <%= @class %>">
	
	<div id='add_bulletin_link' class="info_input bulletin_links_block">
		<h2>Bulletin links</h2>
		<%= hidden_field_tag 'bulletin_link_field_count', @bulletin.bulletin_links.count %>
		<a href="#" class="add"><%= t(:add) %></a>
	</div>
	
	<%#= render :partial => 'link', :locals => { :bulletin_links => @bulletin.bulletin_links , :f => f} %>
	
	
	<% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %>
		<%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %>
		<%= f.fields_for :bulletin_links, bulletin_link do |f| %>
			<%= render :partial => 'bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %>
		<% end %>
	<% end %>	
	
  </div>
  
  
  <div id='bulletin_files' class="bulletin_files_block <%= @class %>">
	
	<div id='add_bulletin_file' class="info_input bulletin_files_block">
		<h2>Bulletin files</h2>
		<%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %>
		<a href="#" class="add"><%= t(:add) %></a>
	</div>
	
	<%#= render :partial => 'file', :locals => { :bulletin_files => @bulletin.bulletin_files , :f => f} %>
	
	
	<% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %>
		<%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %>
		<%= f.fields_for :bulletin_files, bulletin_file do |f| %>
			<%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %>
		<% end %>
	<% end %>	
	
  </div>
  
  <br />
  <br />
  
  
  <div class="actions">
    <%= f.submit %>
  </div>
  
  

<% content_for :page_specific_javascript do %>
	<%= javascript_include_tag "bulletin_form" %>
	<script>
		$('#add_bulletin_link a.add').live('click', function(){
			var new_id = $(this).prev().attr('value');
			var old_id = new RegExp("new_bulletin_links", "g");
			$(this).prev().attr('value', parseInt(new_id) + 1);
		  $('#bulletin_links').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id));
		});
		$('#add_bulletin_file a.add').live('click', function(){
			var new_id = $(this).prev().attr('value');
			var old_id = new RegExp("new_bulletin_files", "g");
			$(this).prev().attr('value', parseInt(new_id) + 1);
		  $('#bulletin_files').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id));
		});
	</script>
	<script type="text/javascript">
	  $(function() {
	    $('textarea').tinymce({
	      theme: 'advanced'
	    });
	  });
	</script>
<% end %>

<!--Widget start-->
<!-- <div id="sub-wiget">
    <div id="widget-date" class="widget-box">
        <div class="widget-action clear">
            <a href="#" class="action"><i title="Set the announcement to start and end dates" class="icon-exclamation-sign icon-white tip"></i></a>
        </div>
        <h3 class="widget-title"><i class="icons-calendar icons-white"></i> Date</h3>
            <div class="widget-content clear">
            <div class="control-group">
                <label class="control-label">Start</label>
                <div class="controls">
                    <select id="start-day" class="input-small">
                        <option>Day</option>
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                        <option>5</option>
                        <option>6</option>
                        <option>7</option>
                        <option>8</option>
                        <option>9</option>
                        <option>10</option>
                        <option>11</option>
                        <option>12</option>
                        <option>13</option>
                        <option>14</option>
                        <option>15</option>
                        <option>16</option>
                        <option>17</option>
                        <option>18</option>
                        <option>19</option>
                        <option>20</option>
                        <option>21</option>
                        <option>22</option>
                        <option>23</option>
                        <option>24</option>
                        <option>25</option>
                        <option>26</option>
                        <option>27</option>
                        <option>28</option>
                        <option>29</option>
                        <option>30</option>
                        <option>31</option>
                    </select>
                    <select id="start-month" class="input-small">
                        <option>Month</option>
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                        <option>5</option>
                        <option>6</option>
                        <option>7</option>
                        <option>8</option>
                        <option>9</option>
                        <option>10</option>
                        <option>11</option>
                        <option>12</option>
                    </select>
                    <select id="start-year" class="input-small">
                        <option>Year</option>
                        <option>2012</option>
                        <option>2011</option>
                        <option>2010</option>
                        <option>2009</option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">End</label>
                <div class="controls">
                    <select id="start-day" class="input-small">
                        <option>Day</option>
                        <option>1</option>
                        <option>2</option>
												<option>3</option>
												<option>4</option>
												<option>5</option>
												<option>6</option>
												<option>7</option>
												<option>8</option>
												<option>9</option>
                        <option>10</option>
                        <option>11</option>
                        <option>12</option>
                        <option>13</option>
                        <option>14</option>
                        <option>15</option>
                        <option>16</option>
                        <option>17</option>
                        <option>18</option>
                        <option>19</option>
                        <option>20</option>
                        <option>21</option>
                        <option>22</option>
                        <option>23</option>
                        <option>24</option>
                        <option>25</option>
                        <option>26</option>
                        <option>27</option>
                        <option>28</option>
                        <option>29</option>
                        <option>30</option>
                        <option>31</option>
                    </select>
                    <select id="start-month" class="input-small">
                        <option>Month</option>
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                        <option>5</option>
                        <option>6</option>
                        <option>7</option>
                        <option>8</option>
                        <option>9</option>
                        <option>10</option>
                        <option>11</option>
                        <option>12</option>
                    </select>
                    <select id="start-year" class="input-small">
                        <option>Year</option>
                        <option>2012</option>
                        <option>2011</option>
                        <option>2010</option>
                        <option>2009</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div id="widget-status" class="widget-box">
        <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">
                <label class="checkbox inline"><input type="checkbox" value="hot">Hot</label>
                <label class="checkbox inline"><input type="checkbox" value="top">Top</label>
                <label class="checkbox inline"><input type="checkbox" value="hide">Hide</label>
            </div>
        </div>
    </div>
    <div id="widget-role" class="widget-box">
        <div class="widget-action clear">
            <a class="action"><i title="Set the read role" class="icon-exclamation-sign icon-white tip"></i></a>
            <a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
        </div>
        <h3 class="widget-title"><i class="icons-lock icons-white"></i>Permissions</h3>
        <div class="widget-content clear">
            <div class="controls">
                <label class="radio inline"><input class="privacy" type="radio" value="public" name="privacy">Public</label>
                <label class="radio inline"><input class="privacy" type="radio" value="private" name="privacy">Private</label>
                <div class="well select-role">
                    <label class="checkbox inline"><input type="checkbox" value="hot">Student</label>
                    <label class="checkbox inline"><input type="checkbox" value="top">Teacher</label>
                    <label class="checkbox inline"><input type="checkbox" value="hide">Staff</label>
                </div>
            </div>
        </div>
    </div>
    <div id="widget-picture" class="widget-box">
        <div class="widget-action clear">
            <a class="action"><i title="Upload pictures" class="icon-exclamation-sign icon-white tip"></i></a>
        </div>
        <h3 class="widget-title"><i class="icons-picture icons-white"></i>Picture</h3>
        <div class="widget-content clear">
            <div class="control-group">
                <img class="pull-left upload-picture" src="images/default-img.png" />
                <div class="controls file-upload">
                <label class="control-label btn" for="input-upload">
                    Browse/選擇檔案
                    <input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fu').innerHTML = this.form.fu.value = this.value;">
                </label>
                <span id='fu' class="file-name"></span>
                <br>
                <input name='fu' class="input-medium" type="text">
                </div>
            </div>
        </div>
    </div>
    
    <div id="widget-tags" class="widget-box">
        <div class="widget-action clear">
            <a class="action"><i title="Enter post tags, Chinese and English required" class="icon-exclamation-sign icon-white tip"></i></a>
            <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">
                <div class="control-group error">
                    <label class="control-label" for="tags-zh-tw">
                        Chinese
                    </label>
                    <div class="controls">
                        <input id='tags-zh-tw' class="input-prepend" type="text">
                        <span class="help-inline">Please correct the error</span>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="tags-en">
                        English
                    </label>
                    <div class="controls">
                        <input id='tags-en' class="input-prepend" type="text">
                        <span class="help-inline">Please correct the error</span>
                    </div>
                </div>
                <div class="clear">
                    <a class="pull-right btn btn-primary" href="#">Add/新增</a>
                </div>
                <hr>
                <span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
                <span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
                <span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
                <span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
            </div>
    </div>
</div> -->
<!--Wiget End-->
<!--Post Start-->
<!-- <div id="post-body">
  <div id="post-body-content" class="clear">
    <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>      <div class="btn-group pull-right">
      <a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
                English
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
                <li><a href="#">English</a></li>
                <li><a href="#">Chinese</a></li>
                <li><a href="#">Japanese</a></li>
                <li><a href="#">French</a></li>
                <li><a href="#">German</a></li>
                <!--<li class="divider"></li>
             <li><a href="#">Separated link</a></li>-->
            </ul>
        </div>


        <div class="title">
            <input class="post-title" type="text" placeholder="Enter title here">
        </div>


        <div class="editor">
        	<%= text_area_tag 'locale', nil, :style=>"width:100%" %>
        </div>
        <div class="main-wiget">
            <div id="widget-link" class="widget-box">
                <div class="widget-action clear">
                    <a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
                </div>
                <h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
                <div class="widget-content">
                    <table class="table table-condensed">
                        <thead>
                            <tr>
                                <th>Chinese</th>
                                <th>English</th>
                                <th class="span1"></th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td style="text-align:center" colspan="3">
                                    <a class="btn btn-primary btn-small" href="#modal-link" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
                                </td>
                            </tr>
                        </tfoot>
                        <tbody>
                            <tr>
                                <td>…</td>
                                <td>…</td>
                                <td><a href="#modal-link" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="modal-link" class="modal hide fade">
                    <div class="modal-header">
                        <a class="close" data-dismiss="modal">×</a>
                        <h3>Add Link / Edit Link</h3>
                    </div>
                    <div class="modal-body form-horizontal">
                        <div class="control-group">
                            <label for="http" class="control-label">http://</label>
                            <div class="controls">
                            <input type="text" value="" id="http" class="input-xlarge">
                            <span class="help-inline">Please correct the error</span>
                            </div>
                        </div>
                        <div class="control-group error">
                            <label for="link-zh-tw" class="control-label">Chinese</label>
                            <div class="controls">
                            <input type="text" value="" id="link-zh-tw" class="input-xlarge">
                            <span class="help-inline">Please correct the error</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label for="link-en" class="control-label">English</label>
                            <div class="controls">
                            <input type="text" value="" id="link-en" class="input-xlarge">
                            <span class="help-inline">Please correct the error</span>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <a class="btn btn-primary" href="#">Submit/確定</a>
                        <a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
                    </div>
                </div>
            </div>
            <div id="widget-file" class="widget-box">
                <div class="widget-action clear">
                    <a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
                </div>
                <h3 class="widget-title"><i class="icons-paperclip icons-white"></i>File</h3>
                <div class="widget-content">
                    <table class="table table-condensed">
                        <thead>
                            <tr>
                                <th>Chinese</th>
                                <th>English</th>
                                <th class="span1"></th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <td style="text-align:center" colspan="3">
                                    <a class="btn btn-primary btn-small" href="#modal-file" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
                                </td>
                            </tr>
                        </tfoot>
                        <tbody>
                            <tr>
                                <td>…</td>
                                <td>…</td>
                                <td><a href="#modal-file" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="modal-file" class="modal hide fade">
                    <div class="modal-header">
                        <a class="close" data-dismiss="modal">×</a>
                        <h3>Add File / Edit File</h3>
                    </div>
                    <div class="modal-body form-horizontal">
                        <div class="controls file-upload">
                        <label class="control-label btn" for="input-upload">
                            Browse
                            <input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fn').innerHTML = this.value;">
                        </label>
                        <span id='fn' class="file-name"></span>
                        </div>
                        <div class="control-group">
                            <label for="file-zh-tw" class="control-label">Chinese</label>
                            <div class="controls">
                            <input type="text" value="" id="file-zh-tw" class="input-xlarge">
                            <span class="help-inline">Please correct the error</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label for="file-en" class="control-label">English</label>
                            <div class="controls">
                            <input type="text" value="" id="file-en" class="input-xlarge">
                            <span class="help-inline">Please correct the error</span>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <a class="btn btn-primary" href="#">Submit/確定</a>
                        <a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div> -->
<!--Post End-->
<!-- <div class="form-actions"> -->
  <button class="btn btn-success" type="submit">Preview/預覽</button>
    <button class="btn btn-primary" type="submit">Submit/送出</button>
    <button class="btn" type="reset">Cancel/取消</button>
<!-- </div> -->
