{% extends "view_page_detail.html" %}
{% load my_tags %}

{% block content %} 

   <script type="text/javascript">
   $(function(){
     $('#tabs').tabs({
	'select': function(event, ui){
			document.location.hash = ui.panel.id;
		}
     });
   });
   </script>

<div class="content" id="IndividualDetail">

{% include "detail_breadcrumb.html" %}

<div id="summaryarea">
<table class="infolist" style="width:90%;"> 
<trbody>
  {% if eventform.errors %}
    <hr>
    <p id="error">The following fields have errors. Please correct and try again.</p>
    <div id="error">{{eventform.errors}}</div>
    <hr>
  {% endif %}
<form method="post" onsubmit="setReturnValues()">{% csrf_token %}
<tr>
<td class="ColumnAttribute">{{eventform.event_type.label}}:</td>
<td class="ColumnValue" id="data"> {% render eventform.event_type user action %}</td>
<td class="ColumnAttribute">{{eventform.text.label}}:</td>
<td class="ColumnValue" id="data">{% render eventform.text user action %}</td>
<td></td>
</tr>
<tr>
<td class="ColumnAttribute">Description:</td>
<td  class="ColumnValue" id="data" colspan="3">{% render eventform.description user action %}</td>
<td></td>
</tr>
<tr>
<td class="ColumnAttribute">ID:</td>
<td  class="ColumnValue" id="data" colspan="3">{% render eventform.gramps_id user action %}</td>
<td></td>
</tr>
<tr>
<td class="ColumnAttribute">Place:</td>
<td  class="ColumnValue" id="data" colspan="3">
{% if action != "view" %}
   <script type="text/javascript">  
        $(function() { 
            $('#place').flexbox('/json/?field=place', {
	        watermark: 'Place',
	        width: 600,
	        paging: {  
                  pageSize: 10  
	        },
	        initialValue: '{{event.place.get_selection_string}}',
  	        initialId: '{{event.place.handle}}'
	        });
        });  
    // </script>
    <div id="place"></div>  
{% else %}
    <a href="/place/?search={{event.place}}">{{event.place}}</a>
{% endif %}
</td>
<td>
<td  class="ColumnValue" id="data" colspan="3">{% render eventform.private user action %}
</td>
</tr>
</table>
</div>
</div>

{% if user.is_superuser %}
  {% if action == "edit" %}
    {% make_button "Cancel" "/event/%s" event.handle args %}
    <input type="hidden" id="place_return" name="place_return" value=""/>
    <input type="hidden" name="action" value="save"/>
    <input type="hidden" name="search" value="{{search}}"/>
    <input type="hidden" name="page" value="{{page}}"/>
    <input type="submit" value="Save"/>
  {% else %}
    {% ifequal action "add" %}
      {% make_button "Cancel" "/event/" args %}
      <input type="hidden" id="place_return" name="place_return" value=""/>
      <input type="hidden" name="action" value="create"/>
      <input type="hidden" name="search" value="{{search}}"/>
      <input type="hidden" name="page" value="{{page}}"/>
      <input type="submit" value="Create"/>
    {% else %}
      <div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
      {% make_button "+Add Event" "/event/add" args %}
      {% make_button "?Edit Event" "/event/%s/edit" event.handle args %}
      {% make_button "-Delete Event" "/event/%s/delete" event.handle args %}
      </div>
    {% endifequal %}
  {% endif %}
{% else %}
{% endif %}

<!-- Tabs -->

<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs" style="border: none;">
  <ul class="ui-tab-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
    <li class="ui-state-default ui-corner-top ui-tab-selected ui-state-active"><a class="tab-sources" href="#tab-sources">Citation</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-notes" href="#tab-notes">Note</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-media" href="#tab-media">Media</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-attributes" href="#tab-attributes">Attribute</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-references" href="#tab-references">Reference</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-history" href="#tab-history">History</a></li>
  </ul>
  <div class="ui-tab-panel ui-widget-content ui-corner-bottom" id="tab-sources" style="background-color: #f4f0ec;"> 
    {% citation_table event user action "/citation/$act/event/%s" event.handle %}
  </div>
  <div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-notes" style="background-color: #f4f0ec;"> 
    {% note_table event user action "/note/$act/event/%s" event.handle %}
  </div>
  <div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-media" style="background-color: #f4f0ec;"> 
    {% media_table event user action "/media/$act/event/%s" event.handle %}
  </div>
  <div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-attributes" style="background-color: #f4f0ec;"> 
    {% attribute_table event user action "/attribute/$act/event/%s" event.handle %}
  </div>
  <div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-references" style="background-color: #f4f0ec;"> 
    {% event_reference_table event user action %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history" style="background-color: #f4f0ec;"> 
    {% history_table event user action %}
  </div>
</div>

</form>
{% endblock %}