<% content_for :header do %>
  <%= javascript_include_tag 'lightwindow' %>
  <%= stylesheet_link_tag 'lightwindow' %>
<% end -%>

<h1><%= @page.new_record? ? 'New' : 'Editing a' %> Page</h1>

<% form_for([:admin, @page], :html => { :id => 'has-assets-form' }) do |f| %>
  <%= f.error_messages %>

  <%= f.hidden_field :parent_id %>
  
<% if @page.lock_level < Page::LOCK_LEVEL_TITLE %>
  <p>
    <%= f.label :title, 'Title*' %><br/>
    <%= f.text_field :title, :class => 'title' %>
  </p>
<% else %>
  <p>
    <%= f.label :title %><br/>
    <%= @page.title %> (locked)
  </p>
<% end %>

<% if @page.lock_level < Page::LOCK_LEVEL_PERMALINK %>
  <p>
    <%= f.label :permalink, "URL" %><br/>
    <%= root_url %><%= f.text_field :permalink %>
    <p>URLs are most efficient if they closely reflect the title or main subject of this content. Changing the permalink will make search engines think it is a different page resulting in a loss of page rank, only change if very necessary. Leave blank to use the title.</p>
  </p>
<% else %>
  <p>
    <%= f.label :permalink, "URL" %><br/>
    <%= root_url %><%= @page.permalink %> (locked)
  </p>
<% end %>

  <p>
    <%= f.label :description, "Description for search engines*" %><br/>
    <%= f.text_area :description, "rows" => 4 %>
  </p>

  <p>
    <%= f.label :tag_list, "Keywords (used by search engines) & Tags - comma separated*" %><br/>
    <%= f.text_field :tag_list, :class => 'long' %>
  </p>
  
  <% if @page.lock_level < Page::LOCK_LEVEL_TEMPLATE %>
  <p>
    <%= f.label :template %>
    <%= f.select :template, get_template_names.collect{|t| [ t.titleize, t ] } %>
  </p>
  <% else %>
  <p>
    <%= f.label :template %> <%= @page.template.titleize %>
    (locked)
  </p>
  <% end %>

  <p>
    <%= f.label :body, 'Body*' %><br/>
    <%= f.text_area 'body', :class => 'editor'  %>
  </p>

  <%= publish_select(f) %>

  <p class="submission">
    <%= preview_link(@page) %>
    <%= f.submit 'Publish', :name => 'page[publish]' %>
    <%= f.submit 'Save as draft', :name => 'page[hide]' %>
    or <%= link_to 'Cancel', admin_pages_path %>
  </p>

<% end %>

<% content_for :sub_content do %>

<%= asset_list(@page) %>

<h2>File Library</h2>
<%= asset_browser(true) %>

<h2>File Upload</h2>
<%= asset_upload_form %>

<%= flickr_select %>
<% end %>