<div class="toolbar hh1">
  <div class="fn_g hp">

    <%= f.submit t("save"), name: "commit", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %>
    <% if not @personal_book.new_record? %>
      <%= submit_tag t("cancel"), :type => "button", "callback-method"=>"cancelbook", "ajax-remote" => "get", :href => panel_personal_book_desktop_personal_books_path, class: "fn_btn ini_input hp hh1 admbg2 admtxt" %>

    <% end %>
  </div>
  <div class="hh1 hp sdm">
    <div class="sdm_t hh1 ">Language</div>
    <div class="admbg sdm_o language_select">
      <ul>
        <% @site_in_use_locales.each_with_index do |locale, i| %>
          <li><a class="hp hh1 admtxt" href="" data-lang="<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
        <% end %>
      </ul>
    </div>
  </div>
  <div class="hh1 hp sdm">
    <div class="sdm_t hh1"><span class="icon-question-sign"></span></div>
  </div>
</div>
<div class="overview" content-layout="simple" base-width="420">
   <ul class="s_form" isotope="true">
        <li class="s_grid_row" >
            <% @site_in_use_locales.each_with_index do |locale, i| %>
              <% style = locale != I18n.locale.to_s ? 'style=display:none;' : "" %>
              <% data = "data-language=" + locale  %>
         
           <div class="form_fix" <%= style %> <%= data %>>
            <%= f.fields_for :paper_title_translations do |f| %>
              <%= f.text_area locale,
                class: "s_grid_12 s_grid s_grid_h_3",
                size: "20x4",
                placeholder: t("personal_book.paper_title")+ "("+I18nVariable.from_locale(locale)+")",
                value: (@personal_book.paper_title_translations[locale.to_s] rescue nil) %>
            <% end %>
         
               <%= f.fields_for :book_title_translations do |f| %>
                  <%= f.text_field locale,
                    size: "20",
                    placeholder: t("personal_book.book_title") + "("+I18nVariable.from_locale(locale)+")",
                    class: "s_grid_12 s_grid",
                    value: (@personal_book.book_title_translations[locale.to_s] rescue nil) %>
                <% end %>
             
               <%= f.fields_for :extracted_chapters_translations do |f| %>
                  <%= f.text_field locale,
                    size: "20",
                    placeholder: t("personal_book.extracted_chapters")+ "("+I18nVariable.from_locale(locale)+")",
                    class: "s_grid_12 s_grid",
                    value: (@personal_book.extracted_chapters_translations[locale.to_s] rescue nil) %>
                <% end %>
         
               <%= f.fields_for :publishers_translations do |f| %>
                  <%= f.text_field locale,
                    size: "20",
                    placeholder: t("personal_book.publishers")+ "("+I18nVariable.from_locale(locale)+")",
                    class: "s_grid_12 s_grid",
                    value: (@personal_book.publishers_translations[locale.to_s] rescue nil) %>
                <% end %>
              </div>
            <% end %>
          </li>
            <li class="s_grid_row">
              <%= label_tag("", t("personal_book.book_paper_type"), class: "s_grid_4 s_grid") %>
              <%= f.select :book_paper_type_id, BookPaperType.all.collect {|t| [ t.title, t.id ]}, {:class => "s_grid s_grid_8"} %>
            </li>
            <li class="s_grid_row">
               <%= label_tag("", t("personal_book.author_type"), class: "s_grid_4 s_grid") %>
              
              <div class="s_select_g s_grid s_grid_8 s_grid_h_1">
              
              <ul>
                <% @author_types.each_with_index do |author_type, i| %>
                  <li>
                  <%= check_box_tag "writing_book[book_author_type_ids][]",
                    author_type.id,
                    @personal_book.book_author_type_ids.include?(author_type.id),
                    id: "field-#{i}"
                    %><%= label_tag("field-#{i}", author_type.title) %>
                  </li>
                <% end %>
              </ul>
            </div>
            </li>
            
         <!--     <li class="s_grid_row">
            <%#= f.text_area :author_tokens,
              class: "s_grid_12 s_grid",
              size: "20x2",
              placeholder: t("personal_journal.authors"),
               "autocomplete" => "/panel/personal_journal/desktop/journal_pages/new.json",
               "autocomplete-format" => "--:[text,email]",
              "data-pre" => generate_authors_name(@personal_book.journal_co_author_ids) %>
            
            </li> -->
            <li class="s_grid_row">
                <%= label_tag("", t("personal_book.publication_date"), class: "s_grid_4 s_grid") %>
                <%= f.date_select :publish_date, {:use_month_numbers => true, :start_year => Time.now.year, :end_year => 1930, :order => [:year] }, {:class => 's_grid_4 s_grid'} %>
                <%= f.date_select :publish_date, {:use_month_numbers => true, :order => [:month, :day] }, {:class => 's_grid_2 s_grid'} %>
            </li>
             <li class="s_grid_row">
              <%= label_tag("", t("personal_book.url"), class: "s_grid_4 s_grid") %><%= f.text_field :url, size: "20", class: "s_grid_8 s_grid"%>
            </li>
            
        
            <li class="s_grid_row">
              <%= f.text_area :keywords, size: "20x3", placeholder: t("personal_book.keywords"), class: "s_grid_12 s_grid_h_2 s_grid"%>
            </li>
             <li class="s_grid_row">
              <%= label_tag("", t("personal_book.pages"), class: "s_grid_4 s_grid") %><%= f.text_field :pages, size: "20", class: "s_grid_8 s_grid"%>
            </li>
             <li class="s_grid_row">
                <%= f.label :language, t("personal_book.language"), :class => "s_grid s_grid_4" %>
                <%= f.select :language, WritingBook::LANGUAGE_TYPES,{} ,{:class => "s_grid s_grid_8"} %>
             </li>
               <li class="s_grid_row">
                 <%= label_tag("", t("personal_book.isbn"), class: "s_grid_4 s_grid") %><%= f.text_field :isbn, size: "20", class: "s_grid_8 s_grid"%>
             </li>
             <li class="s_grid_row">
                <%= f.text_area :note, size: "20x3", placeholder: t("personal_book.note"), class: "s_grid_12 s_grid s_grid_h_5 s_grid_h_full"%>
            </li>
        
          <li class="s_grid_row">
          <table class="s_table">
            <thead>
              <tr>
                <th class="s_grid_2"><%= t("personal_book.file")%></th>
                <th class="s_grid_4"><%= t("personal_book.file_name")%></th>
                <th class="s_grid_4"><%= t("personal_book.description") %></th>
                <th class="s_grid_2"></th>
              </tr>
            </thead>
            <tfoot>
              <tr>
                <td colspan="4">
                  <div id='add_plugin_file' class="info_input plugin_files_block s_action">
                    <%= hidden_field_tag 'plugin_file_field_count', @personal_book.writing_book_files.count %>
                    <a class="add setting_btn thmc1 thmtxt w1 hh1 hp" href="#"><i class="icon-plus icon-white"></i> add</a>
                  </div>
                </td>
              </tr>
            </tfoot>
            <tbody>
              <% @personal_book.writing_book_files.each_with_index do |writing_book_file, i| %>
                <%= f.fields_for :writing_book_files, writing_book_file do |f| %>
                  <%= render :partial => 'form_file', :object => writing_book_file, :locals => {:f => f, :i => i} %>
                <% end %>
              <% end %>
            </tbody>
          </table>
          </li>
        </ul>

</div>
<script>
  var get_html = function(old_id,new_id){
    return ("<%= escape_javascript(add_attribute 'form_file', f, :writing_book_files) %>").replace(old_id, new_id);
  }
</script>