<!--deal_involved_qtip
	<div class="qtip_panel">
		<dl>
			<dt>Value</dt><dd>[%=format_currency(deal.amount)%]</dd>
			<dt>Probability</dt><dd>[%=deal.probability%]%</dd>
		</dl>
	</div>
	  
-->

<!--contact_note_holder
	<dl class="note-list notes-left-today hide">
		<dt class="note-group">Left Today</dt>
	</dl>
	
	<dl class="note-list notes-left-yesterday hide">
		<dt class="note-group">Left Yesterday</dt>
	</dl>
	
	<dl class="note-list notes-left-recently hide">
		<dt class="note-group">Left Recently</dt>
	</dl>
	
-->

<!--contact_task_holder
	<dl class="task-list tasks-overdue hide">
		<dt class="task-group">
			Overdue
		</dt>
	</dl>
	<dl class="task-list tasks-due-today hide">
		<dt class="task-group">
			Today
		</dt>
	</dl>
	<dl class="task-list tasks-due-tomorrow hide">
		<dt class="task-group">
			Tomorrow
		</dt>
	</dl>
	<dl class="task-list tasks-due-this-year hide">
		<dt class="task-group">
			Future
		</dt>
	</dl>
	<dl class="task-list complete-tasks hide">
		<dt class="task-group">
			Complete
		</dt>
	</dl>
	<div class="Actions" style="display: none;">
		<ul>
			<li>
				<a href="#" id="show_me_more_notes" name="show_me_more_notes">Show me 10 more</a>
			</li>
		</ul>
	</div>
	
-->


<!--contact_task
	[%
        var usr=get_user(task.assignedTo);
    %]
    <dd class="task" rel="[%=task.id%]">
        <dl>
            <dd class="check-mark"><input type="checkbox" class="task-checkbox" [%=(task.complete=='true')?'checked=\'checked\'':''%] value="16"/></dd>
            <dd class="left-item-panel"><strong class="assignee">[%=user_fullname(usr)%]</strong>&nbsp;-&nbsp;[%=task.title%]</dd>
            <dd class="right-item-panel"><strong class="type">[%=lookup_task_type(task_types,task.type).name%]</strong>&nbsp;-&nbsp;<strong class="due-date"><abbr class="timeago" title="[%=task.dueOn%]"></abbr></strong></dd>
        </dl>
    </dd>
-->




<!--task_list_group
	<dl class="task-list [%=group.css%]">
    	<dt class="task-group">[%=group.title%]</dt>
    </dl>

-->
<!--group_list_empty_feedback
	<div class="feedback notification">[%=resource_string('feedback.contacts.index.chooseacontact')%]</div>
-->
<!--contact_note
	<dd rel="[%=note.id%]">
<dl>
    [%
    var user = get_user(note.createdBy);
    %]
    <dd class="note-meta">
        <span class="">
            <a href="/profile/[%=user.id%]">[%=user_fullname(user)%]</a>
        </span>
        <em>
            <abbr class="published updated timeago" title="[%=note.createdAt%]">[%=note.createdAt%]</abbr>
        </em>
    </dd>
    <dd class="note-actions ">
        <ul>
        <li id="edit-action"><a href="" >[%=resource_string('action.contacts.index.edit')%]</a></li>
        <li id="delete-action"><a href="">[%=resource_string('action.contacts.index.delete')%]</a></li>
        <li id="confirm-action"><a href="" >[%=resource_string('action.contacts.index.done')%]</a></li>
        <li id="cancel-action"><a href="">[%=resource_string('action.contacts.index.cancel')%]</a></li>
        </ul>
    </dd>
    <dd class="note-info">
        <img alt="" src="/api/users/[%=user.id%]/avatar" class="photo avatar _hide"/>
    </dd>
    <dd class="note-body" id="view-box">
        <div id="note-body-box">[%=parse_note_body(note.body)%]</div>
        [% if(note.deal != undefined) { 
        	var deal = get_deal(note.deal);
        %]
        	<p><span class="relates-to-deal">Deal</span> [%=deal.name%]</p>
        [% } %]
    </dd>

    <dd class="note-body" id="edit-box">
        <span class="Field"><textarea>[%=parse_note_body(note.body)%]</textarea></span>
    </dd>
	<dd style="clear:both!important;"></dd>
</dl>
</dd>

-->



    <div class="Tabs">
        <ul>
            <li><a href="#contact-detail">[%=resource_string('action.contacts.index.detailstab')%]</a></li>
            <li><a href="#contact-notes">[%=resource_string('action.contacts.index.notestab')%]</a></li>
            <li><a href="#contact-tasks">[%=resource_string('action.contacts.index.taskstab')%]</a></li>
        </ul>
    </div>


    <div id="contact-detail" class="contact-information contact-tab-panel hide">
      [%

      with(contact){
          var j=0;

          if(info!=''){
            %]<dl><dt>[%=resource_string('label.contacts.index.details.information')%]</dt>[%
              /* Show First */
              %]
              <dd>[%=info%]</dd>
              </dl>[%
          }
          if(emailAddresses!=null){
              %]<dl><dt>[%=resource_string('label.contacts.index.details.email')%]</dt>[%
              /* Show First */
              %]<dd><strong class="type">[%=emailAddresses.emailAddress[0].type.value%]</strong><a href="mailto:[%=emailAddresses.emailAddress[0].email%]">[%=emailAddresses.emailAddress[0].email%]</a></dd>[%


              if(emailAddresses.emailAddress.length>1){
                  /* Show Others */
                  $.each(emailAddresses.emailAddress,function(i,n){
                      if(i!=0){
                          %]<dd><span class="type">[%=n.type.value%]</span><a href="mailto:[%=n.email%]">[%=n.email%]</a></dd>[%
                      }

                  });

              }
              %]</dl>[%
          }

          if(phoneNumbers!=null){
                  %]<dl><dt>[%=resource_string('label.contacts.index.details.phone')%]</dt>[%
                  /* Show First */
                  %]<dd><strong class="type">[%=phoneNumbers.phoneNumber[0].type.value%]</strong><a href="callto://[%=phoneNumbers.phoneNumber[0].number%]">[%=phoneNumbers.phoneNumber[0].number%]</a></dd>[%
                   if(phoneNumbers.phoneNumber.length>1){
                      /* Show Others */
                      $.each(phoneNumbers.phoneNumber,function(i,n){
                          if(i!=0){
                          %]<dd><span class="type">[%=n.type.value%]</span><a href="callto://[%=n.number%]">[%=n.number%]</a></dd>[%
                          }

                      });

                  }
                  %]</dl>[%
              }

              if(websites!=null){
                  %]<dl><dt>[%=resource_string('label.contacts.index.details.website')%]</dt>[%
                  /* Show First */
                  %]<dd><strong class="type">[%=websites.website[0].type.value%]</strong><a href="http://[%=websites.website[0].url%]" target="blank">[%=websites.website[0].url%]</a></dd>[%
                  if(websites.website.length>1){
                    /* Show Others */
                    $.each(websites.website,function(i,n){
                        if(i!=0){
                        %]<dd><span class="type">[%=n.type.value%]</span><a href="http://[%=n.url%]" target="blank">[%=n.url%]</a></dd>[%
                        }

                    });
                }
                  %]</dl>[%
              }


				if(instantMessengers!=null){
	                  %]<dl><dt>[%=resource_string('label.contacts.index.details.messenger')%]</dt>[%
	                  /* Show First */
	                  %]<dd><strong class="type">[%=imTypes.types[instantMessengers.instantMessenger[0].product].title%]</strong><a href="[%=resource_string(imTypes.types[instantMessengers.instantMessenger[0].product].protocol,instantMessengers.instantMessenger[0].account)%]" target="blank">
[%=instantMessengers.instantMessenger[0].account%]
		</a></dd>[%
	                  if(instantMessengers.instantMessenger.length>1){
	                    /* Show Others */
	                    $.each(instantMessengers.instantMessenger,function(i,n){
	                        if(i!=0){
	                        %]<dd><span class="type">[%=imTypes.types[instantMessengers.instantMessenger[i].product].title%]</span><a href="[%=resource_string(imTypes.types[instantMessengers.instantMessenger[i].product].protocol,instantMessengers.instantMessenger[i].account)%]" target="blank">[%=n.account%]</a></dd>[%
	                        }

	                    });
	                }
	                  %]</dl>[%
	              }

              if(addresses!=null){
                  %]<dl><dt>[%=resource_string('label.contacts.index.details.address')%]</dt>[%
                  /* Show First */
                  %]<dd><strong class="type">[%=addresses.address[0].type.value%]</strong><span class="data">[%=format_address(addresses.address[0])%]</span></dd>[%
                   if(addresses.address.length>1){

                      /* Show Others */
                      $.each(addresses.address,function(i,n){
                          if(i!=0){
                          %]<dd><span class="type">[%=n.type.value%]</span><span class="data">[%=format_address(n)%]</span></dd>[%
                          }

                      });

                  }
                   %]</dl>[%
              }

      }
      %]
    </div>


    <div id="contact-notes" class="contact-tab-panel hide">
        <div id="id-add-note-container" class="show-hide " rel="id-add-note-panel">
            <div id="id-add-note-panel" class="_hide">
                <h2 class="title hide"><span>[%=resource_string('action.contacts.index.addnote')%]</span></h2>
                <form action="/api/notes" id="add-note-form">
                    <span class="Field ClearedField">
                        <textarea id="add-note-body" class="expanding"/>
                    </span>
					<span class="Field ClearedField" id="note-contact-field">
						<label for="note-deal">Associate with a deal?</label>
                        <select id="add-note-deal" name="add-note-deal">
							<option value="-1">Do not associate</option>
							 [%
                                  $.each(deals.deal,function(i,n){
									if(is_in_progress(n)){

                                      %]<option value="[%=n.id%]">[%=n.name%]</option>[%
									}
                                  });
                            %]
						</select>
                    </span>
                    <div class="Actions">
                        <ul>
                            <li><input type="button" value="[%=resource_string('action.contacts.index.addnote')%]" id="add-note-action"/></li>
                        </ul>
                    </div>
                </form>
            </div>
        </div>
        <div class="" id="contact-notes-list">
			<p>NOTES GO HERE</p>
        </div>

    </div>




    <div id="contact-tasks" class="contact-tab-panel hide">
        <div id="id-add-task-container" class="show-hide " rel="id-add-note-panel">
            <div id="id-add-task-panel" class="_hide">
                <form id="add-task-form" action="/api/task" name="add-task-form">
					<span class="Field ClearedField"><input type="text" name="description" id="add-task-title"></span>
					<fieldset style="clear: both;">
						<span class="Field"><label>Type</label> <select name="taskType">
							[% 								
							$.each(task_types,function(i,n){
								%]
								<option value="[%=n.id%]">
									[%=n.name%]
								</option>
								[%
							}); 
							%]
						</select></span> <span class="Field"><label>Assigned To</label> <select name="assignTo">
						[%
                            $.each(users,function(o,p){
if(p.enabled=='true'){
                        %]
                            <option value="[%=p.id%]">[%=user_fullname(p)%]</option>
                        [%
}
                            });
                        %]
						</select></span> 
						<span class="Field">
                            <label>Due</label>
                            <input type="text" name="due"/>
                        </span>
						<span class="Field ClearedField" id="note-contact-field">
							<label for="note-deal">Associate with a deal?</label>
	                        <select id="add-task-deal" name="add-note-deal">
								<option value="-1">Do not associate</option>
								 [%
	                                  $.each(deals.deal,function(i,n){
											if(is_in_progress(n)){
	                                      %]<option value="[%=n.id%]">[%=n.name%]</option>[%
											}
	                                  });
	                            %]
							</select>
	                    </span>
					</fieldset>
					<div class="Actions">
						<ul>
							<li>
								<input type="button" id="add-task-action" value="Add Task">
							</li>
						</ul>
					</div>
				</form>
            </div>
    </div>

        <div id="contact-tasks-list">
			
			
			<div class="Actions">
                <ul>
                    <li><a id="show_me_more_notes" href="#">Show me [%=pages.note%] more</a></li>
                </ul>
            </div>
        </div>
    </div>