<% content_for :page_specific_css do %>
  <%= stylesheet_link_tag "lib/main-forms" %>
  <%= stylesheet_link_tag "lib/wrap-nav" %>
  <%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
  <%= javascript_include_tag "jquery-ui-custom.js" %>
  <%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
  <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
  <%= javascript_include_tag "lib/member/textarea-lang-btn.js" %>
  <%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
  <%= javascript_include_tag "survey.js" %>
<% end %>
<%= f.error_messages %>
<fieldset>
  <div class="input-area">
    <div class="attributes">
        <div class="attributes-header clearfix">
          <h4>Basic</h4>
        </div>
        <div class="attributes-body">
    </div>

    <!-- Tiltle -->
      <div class="control-group">
        <label class="control-label muted" for="">Title</label>
        <div class="controls">
          <div class="input-append">
            <div class="tab-content">
                <% @site_in_use_locales.each_with_index do |locale, i| %>
                   <div class="tab-pane fade in <%= ( i == 0 ) ? "active" : '' %>" id="title_<%= locale %>">
                    <%= f.fields_for :title_translations do |f| %>
                      <%= f.text_field locale, :class=>'span4', :value => (@survey.title_translations[locale] rescue nil), :placeholder => I18nVariable.from_locale(locale) %>
                    <% end %>
                   </div>
                <% end %>
            </div>
            <div class="btn-group" data-toggle="buttons-radio">
               <% @site_in_use_locales.each_with_index do |locale, i| %>
                  <a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#title_<%= locale %>" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a>
                <% end %>
            </div>
          </div>
        </div>
      </div>
        <!-- Description -->
        <div class="control-group">
          <label class="control-label muted">Description</label>
          <div class="controls">
            <div class="tab-content textarea-lang">
              <div class="btn-group" data-toggle="buttons-radio">
                <% @site_in_use_locales.each_with_index do |locale, i| %>
                  <a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#textarea_<%= locale %>_0" data-toggle="tab"><%= I18nVariable.from_locale(locale) %></a>
                <% end %>
              </div>
              <% @site_in_use_locales.each_with_index do |locale, i| %>
                 <div class="tab-pane fade in <%= ( i == 0 ) ? "active" : '' %>" id="textarea_<%= locale %>_0">
                  <%= f.fields_for :description_translations do |f| %>
                    <%= f.text_area locale, :class=>'resizable', :value => (@survey.description_translations[locale] rescue nil), :placeholder => I18nVariable.from_locale(locale), :rows=>"3" %>
                  <% end %>
                 </div>
              <% end %>
            </div>
          </div>
        </div>
        <!-- start date -->
        <div class="control-group">
          <label class="control-label muted" for="account">Start Date</label>
          <div class="controls">
           <%= f.datetime_picker :postdate, :no_label => true %>
          </div>
        </div>
        <!-- end date -->
         <div class="control-group">
          <label class="control-label muted" for="account">End Date</label>
          <div class="controls">
           <%= f.datetime_picker :deadline, :no_label => true %>
          </div>
        </div>

         <!-- redirect mode -->
          <div class="control-group">
            <label class="control-label muted" for="redirectMode">Redirect Mode</label>
            <div class="controls">
              <label class="checkbox">
               <!--  <input name="survey[redirect_mode]" type="hidden" value="0" />
                <input id="survey_redirect_mode" name="survey[redirect_mode]" type="checkbox" value="1" /> -->
                <%= f.check_box :redirect_mode %>
                The surveys is an external link
              </label>
            </div>
          </div>
          <!-- redirect url -->

          <div class="control-group redirect-url hide">
            <label class="control-label muted" for="survey_redirect_url">Redirect URL</label>
            <div class="controls">
               <%= f.text_field :redirect_url, :class=>"input-xlarge", :placeholder=>"Redirect URL" %>
            </div>
          </div>

        </div>
        <!-- questions -->
        <div class="questions">
            
        </div>

      </div>

      <div class="form-actions">
        <button type="button" class="btn btn-success add-question">Add Question</button>
        <%= f.submit t('save'), :class=>'btn btn-primary' %>
        <%= link_to t('cancel'), get_go_back, :class=>"btn" %> 
      </div>
</fieldset>

<%= render :partial => "questions" %>

<script type="text/javascript">
  editQuestion(<%= @sqs.to_json.html_safe %>);
</script>
