<%= stylesheet_link_tag "gallery" %>
<div id="orbit_gallery" class="rg">
  <div class="rgbody">
    <div id="imgholder">
<ul class="breadcrumb">
	<li><span>Home</span><span class="divider">/</span></li>
	<li><span><%= t(:gallery) %></span><span class="divider">/</span></li>
	<li class="text-blue"><%= t('gallery.edit') %></li>
</ul>
<ul class="nav nav-tabs">
	<% @site_valid_locales.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>
<!-- <form id="edit_album" action="update_album" method="post"> -->
<%= form_for @album, :url => panel_gallery_back_end_album_path(@album), :html => {:class => 'clear'} do |f| %>
	<div class="tab_content">
			<div class="albumname_edit">
          <%= f.fields_for :name_translations do |name| %>
            <%= f.label t("gallery.album_name") %>
            <div class="inputui rginput rgih26 w380">
               <% @site_valid_locales.each_with_index do |locale, i| %>
                  <% if i == 0 %>
                    <div class="<%= locale %> fade tab-pane in active">
                  <% else %>
                    <div class="<%= locale %> fade tab-pane" >
                  <% end %>
              <%= name.text_field locale, :value => (@album_name[locale]), :class => "txtchange" %>
            </div>
              <% end %>
            </div>
          <% end %>
			</div>

			<div class='description_loader'>
				<% @images.each_with_index do |image,x| %>
					<div class="rgphoto_edit <%= locale %>" data-content="<%= image.id %>">
              <%= link_to panel_gallery_back_end_album_image_path(image) do %>
                <img src="<%= image.file.thumb.url %>" />
              <% end %>
						<div class="inputui rginput rgih98 w380">
							<%= f.fields_for :gallery_images, image do |j| %>
                <%= j.hidden_field :id, :value => (image.id) %>
                <%= j.hidden_field :_destroy, :value => false, :class => "del_field" %>
								<%= j.fields_for :description_translations do |desc|  %>
                <% @site_valid_locales.each_with_index do |locale, i| %>
                  <% if i == 0 %>
                    <div class="<%= locale %> fade tab-pane in active">
                  <% else %>
                    <div class="<%= locale %> fade tab-pane" >
                  <% end %>
									<%= desc.text_area locale, :value => (image.description_translations[locale] rescue nil), :class => "txtchange" %>
                </div>
                  <% end %>
								<% end %>
							<% end %>
						</div>
						<div class="edit_fn" no="<%= x %>">
							<% if image.id.to_s == @cover %>
								<a class="btn btn-primary rgbtsg bt-cover setcover active" onclick="return false;" title="<%= t("gallery.cover") %>" href="set_cover" for="<%= image.id %>"><span class="icon-star icon-white"></span></a>
							<% else %>
								<a class="btn rgbtsg bt-cover" onclick="return false;" title="<%= t("gallery.set_cover") %>" href="set_cover" for="<%= image.id %>"><span class="icon-star-empty"></span></a>
							<% end %>
							<a class="btn rgbtsg bt-tag" onclick="return false;" title="<%= t("gallery.photo_tag") %>" href="<%= image.id %>"><span class="icon-tags"></span></a>
							<a class="btn rgbtsg bt-dels" onclick="return false;" title="<%= t("gallery.delete") %>" href="<%= image.id %>"><span class="icon-trash"></span></a>
						</div>
					</div>
				<% end %>
			</div>	
		
      <input type="hidden" name="delete_cover" value="false" class="del_cover" />
	 <div class="form-actions form-fixed pagination-right rghead">
  		<div class="rgfn">
    	 	<a href="<%= panel_gallery_back_end_album_path(@album) %>" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a>
        <%= f.submit t('gallery.save'), :class=>'bt-save icon-ok btn btn-primary pull-right', :style=>"display:none;" %>
      </div>
    </div>
  </div>
<% end %>
</div>
  </div>
  <!-- tag part -->
  <div id="tag_panel" class="my_scroll">
    <div class="scrollbar">
      <div class="track">
        <div class="thumb">
          <div class="end"></div>
        </div>
      </div>
    </div>
     <% 
        @locales = Array.new
        @site_valid_locales.each do |locale|
          @locales << locale
        end
      %>
    <div class="viewport">
      <div class="overview">
        <ul class="tag_list" id="gallery_tag_list">
          <% @tags.each do |tag| %>
             <li data-content="<%= tag.id %>"><input id="tag_<%= tag.id %>" type="checkbox"><label for="tag_<%= tag.id %>"><%= tag[I18n.locale] %></label><span style="display:none;"><%= tag[@locales[1]] %> <%= tag[@locales[0]] %></span></li>
          <% end %>
        </ul>
      </div>
    </div>
     <div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"> <div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
  </div>
  
  <script type="text/javascript">
      var $tag_panel = $('#tag_panel');
          orbit_bar_height = $('#orbit-bar').outerHeight();
          action_panel_height = $('.form-actions').outerHeight();
          window_height = $(window).height();
      
      $tag_panel.height( window_height - orbit_bar_height - 90 );
      $tag_panel.tinyscrollbar();

      $(window).resize(function(){
        $tag_panel.tinyscrollbar_update('relative');
        $tag_panel.height( $(window).height() - orbit_bar_height - 90 );
      });

      
  </script>
  <!-- tag end -->
 

<% content_for :page_specific_javascript do %>
  <%= javascript_include_tag "galleryAPI" %>
<% end %>

<script type="text/javascript">
  galleryAPI.prototype.locale = "<%= I18n.locale %>";
  var gallery = new galleryAPI();
  gallery.initialize();
  gallery.editAlbum("<%= params[:id] %>");
</script>
