<% content_for :page_specific_javascript do %>
	<%= javascript_include_tag "inc/modal-preview" %>
	<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
	<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
<% end %>


<div id="poststuff">
	<form class="clear">
		<!--Widget start-->
		<div id="sub-wiget">
          <div id="widget-date" class="widget-box">
              <div class="widget-action clear tip" title="<%= t('ad.set_dates') %>">
                  <a href="#" class="action"><i class="icon-exclamation-sign icon-white"></i></a>
              </div>
              <h3 class="widget-title"><i class="icons-calendar"></i><%= t(:date_) %></h3>
              <div class="widget-content clear">
                <%= f.datetime_picker :post_date, :picker_type => 'date', :label => t(:start_date) %>
                <%= f.datetime_picker :unpost_date, :picker_type => 'date', :label => t(:end_date) %>
              </div>
          </div>
		
			<div id="widget-picture" class="widget-box">
        <div class="widget-action clear tip" title="<%= t('ad.upload_pictures') %>" >
            <a class="action"><iclass="icon-exclamation-sign icon-white"></i></a>
        </div>
        <h3 class="widget-title"><i class="icons-pictures"></i><%= t(:picture) %></h3>
        <div class="widget-content clear">         
          <div class="control-group">
            <div  class="upload-picture">
              <!--請程式務必將圖片尺寸加入到行內裡-->
              <%= image_tag @ad_image.file rescue ''%>
            </div>
            <% if !@ad_image.ad_banner.best_size.empty?%>
              <span class="alert widgetInfo"><%= t("ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) %>
              </span>
              <% end -%>
            <div class="controls file-upload input-prepend">
              <label class="control-label add-on btn" for="input-upload">
								<%= t(:browse) %>
								<%= f.file_field :file,:id=>"input-upload",:class => "upload", :onchange=> "document.getElementById('fu1').innerHTML = this.form.fu1.value = this.value;" %>
							</label>
							<span id="fu1" class="file-name"></span>
							<br>
							<input name="fu1" class="input-medium" type="text">
						</div>
					</div>
				</div>
			</div>
				
			<div id="widget-type" class="widget-box">
					<div class="widget-action clear tip" title="<%= t('ad.select_fx') %>">
						<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
					</div>
					<h3 class="widget-title"><i class="icons-target"></i><%= t(:type) %></h3>
					<div class="widget-content clear">
						<%= f.select :link_open ,AdImage::LINK_OPEN_TYPES%>
					</div>
				</div>
			
			<div id="widget-time" class="widget-box widget-size-300">
					<div class="widget-action clear tip" title="<%= t('ad.set_range') %>">
						<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
					</div>
					<h3 class="widget-title"><i class="icons-time"></i><%= t(:frequency) %></h3>
					<div class="widget-content clear">
						 <%= f.text_field :weight ,:class=> 'span3',:placeholder=> t('ad.chinese_1') %>
					</div>
				</div>
				
			<div id="widget-link" class="widget-box widget-size-300">
					<div class="widget-action clear tip" title="<%= t('ad.add_link') %>">
						<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
					</div>
					<h3 class="widget-title"><i class="icons-link"></i><%= t(:link) %></h3>
					<div class="widget-content clear">
						<%= f.text_field :out_link ,:class=> 'span3',:placeholder => t('ad.chinese_2') %>
					</div>
				</div>

		</div>
			<!--Wiget End-->
			<!--Post Start-->
			<div id="post-body">
				<div id="post-body-content" class="clear">
					<ul class="nav nav-tabs">
						<% @site_valid_locales.each do |locale|%>
							<%= content_tag :li,link_to(I18nVariable.from_locale(locale),"##{locale}",:data=>{:toggle => "tab"}),:class=> (active_when_current_locale_eq locale)  %>
						<% end %>
					</ul>
					<div class="tab-content">
						<%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title",params[:ad_banner_id]) , :class=>"input-medium" %>
						<% @site_valid_locales.each do |locale|%>
							<%= content_tag :div,:class	=> "tab-pane #{active_when_current_locale_eq locale}",:id=>"#{locale}" do%>
								<div class="title">
									<%= f.fields_for :title_translations do |f| %>
										<%= f.text_field locale, :class=>"ad_image-title post-title", :placeholder => t('ad.chinese_3'), :value => (@ad_image.title_translations[locale] rescue nil) %>
									<% end %>
								</div>
								<br/>
								<div class="context editor">
									<%= f.fields_for :context_translations, @ad_image.context do |f| %>
									<%= f.text_area locale, :style => "width:100%", :class => "tinymce_textarea post-title", :value => (@ad_image.context_translations[locale] rescue nil) %>
									<% end %>
								</div>

							<% end %>
						<% end %>
						</div>
						
					</div>
				</div>
				<div class="form-actions">
					<%#= link_to t(:preview), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%>
					<%= f.submit t("submit"),:class=>"btn btn-primary" %>
					<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %>
				</div>
			</div>
			<!--Post End-->
		</form>
	</div>