{% 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">

   {% filter breadcrumb %}
      {% format "/browse|Browse" %} ||
      {% format "/person|People" %} ||
      {% format "/person/%s|Person [%s]" object.handle object.gramps_id %} ||
      {% format "/person/%s/name/%s|Name #%s"  object.handle order order %}
   {% endfilter %}

<h3>{{nameform.model|make_name:user}} [{{person.gramps_id}}]</h3>
<div id="summaryarea">
<table class="infolist" style="width:90%;"> {% comment %} 4 cols {% endcomment %}
<tbody>

{% for error in nameform.errors %}
    <p id="error">{{error}}</a><br>
{% endfor %}

<form method="post">{% csrf_token %}
<tr>
 <td class="ColumnAttribute">{{surnameform.name_origin_type.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.name_origin_type user action %}</td>
 <td class="ColumnAttribute">{{nameform.name_type.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.name_type user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{surnameform.surname.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.surname user action "get_focus" %}</td>
 <td class="ColumnAttribute">{{surnameform.prefix.label}}:</td>
 <td class="ColumnValue" id="data">{% render surnameform.prefix user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{nameform.first_name.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.first_name user action %}</td>
 <td class="ColumnAttribute">{{nameform.nick.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.nick user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{nameform.title.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.title user action %}</td>
 <td class="ColumnAttribute">{{nameform.suffix.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.suffix user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute"></td>
 <td class="ColumnValue" id="data"></td>
 <td class="ColumnAttribute">{{nameform.call.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.call user action %}</td>
</tr>
<tr>
 <td class="ColumnAttribute">{{nameform.preferred.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.preferred user action %}</td>
 <td class="ColumnAttribute">{{nameform.private.label}}:</td>
 <td class="ColumnValue" id="data">{% render nameform.private user action %}</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-general" href="#tab-general">General</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-surnames" href="#tab-surnames">Surname</a></li>
    <li class="ui-corner-top ui-state-default"><a class="tab-names" href="#tab-names">Alternate Names</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-notes" href="#tab-notes">Note</a></li>
  </ul>

  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom"
  id="tab-general" style="background-color: #f4f0ec;"> 
    <div style="overflow: auto; height:150px;">
    <table border="1">
    <tr><td style="background-color: #FFF2C5;">{{nameform.group_as.label}}: </td>
        <td>{% render nameform.group_as user action %}</td>
    </tr>
    <tr><td style="background-color: #FFF2C5;">{{nameform.sort_as.label}}: </td>
        <td>{% render nameform.sort_as user action %}</td>
    </tr>
    <tr><td style="background-color: #FFF2C5;">{{nameform.display_as.label}}: </td>
         <td>{% render nameform.display_as user action %}</td>
    </tr>
    <tr><td style="background-color: #FFF2C5;">{{nameform.text.label}}: </td>
         <td>{% render nameform.text user action %}</td>
    </tr>
    </table>
    </div>
    &nbsp;
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-surnames" style="background-color: #f4f0ec;"> 
    {% surname_table person user action "/person/%s/name/%s/surname/add" person.handle nameform.model.order %}
  </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 nameform.model user action "/citation/add/person/%s/name/%s" person.handle nameform.model.order %}
  </div>
  <div class="ui-tabs-panel ui-widget-content ui-corner-bottom
	      ui-tabs-hide" id="tab-notes" style="background-color: #f4f0ec;"> 
    {% note_table nameform.model user action "/note/$act/person/%s/name/%s" person.handle nameform.model.order %}
  </div>
</div>

{% if user.is_superuser %}
  {% ifequal action "add" %}
    {% make_button "Cancel" "/person/%s" person.handle args "#tab-names" %}
    <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 %}
  {% ifequal action "edit" %}
    {% make_button "Cancel" "/person/" args "#tab-names" %}
    <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 %}
    <div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
    {% make_button "+Add Name" "/person/%s/name/add" person.handle args %}
    {% make_button "?Edit Name" "/person/%s/name/%s/edit" person.handle order args %}
    {% make_button "-Delete Name" "/person/%s/name/%s/delete" person.handle order args %}
    </div>
  {% endifequal %}
 {% endifequal %}
{% else %}
{% endif %}
</form>
{% endblock %}

