{% 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%;"> {% comment %} 5 cols {% endcomment %}
<tbody>
  {% if personform.errors or nameform.errors or surnameform.errors or logform.errors %}
    <hr>
    <p id="error">The following fields have errors. Please correct and try again.</p>
    <div id="error">
       {{personform.errors}}
       {{nameform.errors}}
       {{surnameform.errors}}
       {{logform.errors}}
    </div>
    <hr>
  {% endif %}
<form method="post">{% csrf_token %}
<tr>
 <td colspan="4" id="subtitle">{{nameform|render_name:user}}</td>
 <td class="ColumnAttribute">{{nameform.name_type.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.name_type user action %}</td>
</tr>
<tr><td id="rowspace"></td></tr>
<tr>
 <td class="ColumnAttribute">{{nameform.title.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.title user action "get_focus" %}</td>
 <td class="ColumnAttribute">{{nameform.nick.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.nick user action %}</td>
 <td class="ColumnAttribute">{{nameform.call.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.call user action %}</td>
</tr>
<tr><td id="rowspace"></td></tr>
<tr>
 <td class="ColumnAttribute">{{nameform.first_name.label}}:</td>
 <td class="ColumnValue" id="data" colspan="4">{% render nameform.first_name user action None "/person/?search=given%%3D%s" nameform.model.first_name %}</td>
 <td class="ColumnValue" id="data">{% render nameform.suffix user action %}</td>
</tr>
<tr><td id="rowspace"></td></tr>
<tr>
 <td class="ColumnAttribute">{{surnameform.surname.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.prefix user action %}
 <td class="ColumnValue" id="data" colspan="2">{% render surnameform.surname user action None "/person/?search=surname%%3D%s" surnameform.model.surname %}</td>
 <td class="ColumnAttribute">{{surnameform.name_origin_type.label}}:</td>
 <td class="ColumnValue" id="data" colspan="2">{% render surnameform.name_origin_type user action %}</td>
</tr>
<tr><td id="rowspace"></td></tr>
<tr>
 <td class="ColumnAttribute">{{personform.gender_type.label}}:</td>
 <td class="ColumnValue" id="data">{% render personform.gender_type user action None "/person/?search=gender%%3D%s" personform.model.gender_type %}</td>
 <td class="ColumnAttribute">{{personform.gramps_id.label}}:</td>
 <td class="ColumnValue" id="data">{% render personform.gramps_id user action %}</td>
 <td class="ColumnAttribute">{{personform.tags.label}}:</td>
 <td class="ColumnValue" id="data" rowspan="3">{% render personform.tags user action %}</td>
</tr>
<tr><td id="rowspace"></td></tr>
<tr>
 <td class="ColumnAttribute">{{personform.private.label}}:</td>
 <td class="ColumnValue" id="data">{% render personform.private user action %}</td>
 <td class="ColumnAttribute">{{personform.probably_alive.label}}:</td>
 <td class="ColumnValue" id="data">{% if person.probably_alive %}Yes{% else %}No{% endif %}</td>
</tr>
</tbody>
</table>

</div>
</div>
<!-- Tabs -->

<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs" style="border: none;">
  <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
    <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a class="tab-events" href="#tab-events">Event</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-references" href="#tab-references">Family</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-names" href="#tab-names">Name</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-citations" href="#tab-citations">Citation</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-addresses" href="#tab-addresses">Address</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-internet" href="#tab-internet">Internet</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-association" href="#tab-association">Association</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-lds" href="#tab-lds">LDS</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-history" href="#tab-history">History</a></li>
  </ul>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events" style="background-color: #f4f0ec;"> 
    <!-- Events -->
    {% event_table person user action "/event/$act/person/%s" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-names" style="background-color: #f4f0ec;"> 
    {% name_table person user action "/person/%s/name" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-citations" style="background-color: #f4f0ec;"> 
    {% citation_table person user action "/citation/$act/person/%s" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes" style="background-color: #f4f0ec;"> 
    {% attribute_table person user action "/attribute/$act/person/%s" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-addresses" style="background-color: #f4f0ec;"> 
    {% address_table person user action "/place/$act/person/%s" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom
	      ui-tabs-hide" id="tab-notes" style="background-color: #f4f0ec;"> 
    {% note_table person user action "/note/$act/person/%s" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-media" style="background-color: #f4f0ec;"> 
    {% media_table person user action "/media/$act/person/%s" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-internet" style="background-color: #f4f0ec;"> 
    {% internet_table person user action "/person/%s/$act/internet" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-association" style="background-color: #f4f0ec;"> 
    {% association_table person user action "/person/%s/$act/association" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-lds" style="background-color: #f4f0ec;"> 
    {% lds_table person user action "/person/%s/$act/lds" person.handle %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references" style="background-color: #f4f0ec;"> 
    {% person_reference_table person 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 person user action %}
  </div>
</div>

{% if logform %}
  <table>
    {{logform.as_table}}
  </table>
{% endif %}

{% if user.is_superuser %}
  {% if action == "edit" %}
    {% make_button "Cancel" "/person/%s" person.handle args %}
    <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" "/person/" args %}
      <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 Person" "/person/add" args %}
      {% make_button "?Edit Person" "/person/%s/edit" person.handle args %}
      {% make_button "-Delete Person" "/person/%s/delete" person.handle args %}
      </div>
    {% endifequal %}
  {% endif %}
{% else %}
{% endif %}
</form>
{% endblock %}