<script type="text/javascript" src="includes/jscript/statesdropdown.js"></script>
<script type="text/javascript" src="includes/jscript/pwstrength.js"></script>
<script type="text/javascript">
{literal}
jQuery(document).ready(function(){
    jQuery("#subaccount").click(function () {
        if (jQuery("#subaccount:checked").val()!=null) {
            jQuery(".subaccountfields").show();
        } else {
            jQuery(".subaccountfields").hide();
        }
    });
});
{/literal}
function deleteContact() {ldelim}
if (confirm("{$LANG.clientareadeletecontactareyousure}")) {ldelim}
window.location='clientarea.php?action=contacts&delete=true&id={$contactid}';
{rdelim}{rdelim}
</script>

{include file="$template/clientareadetailslinks.tpl"}

		<div class="bigheader">
			<h2>{$LANG.clientareanavcontacts}</h2>
		</div><!-- .bigheader -->

{if $contactid}
<form method="post" action="{$smarty.server.PHP_SELF}?action=contacts">


  		<div class="feildset">
		
			<div class="col1">


				<div>
					<label>
						<span>{$LANG.clientareachoosecontact}:</span>
						<select name="id" onchange="submit()">
							      {foreach item=contact from=$contacts}
							      <option value="{$contact.id}"{if $contact.id eq $contactid} selected="selected"{/if}>{$contact.name} - {$contact.email}</option>
								  {/foreach}
						</select>
					</label>
				</div>


</div>
</div>

</form>

{if $successful}
			<div class="notice notice-success">
				<div class="inside">
					<p>{$LANG.changessavedsuccessfully}</p>
				</div>
			</div>
{/if}

{if $errormessage}
			<div class="notice notice-error">
				<div class="inside">
					<p>{$errormessage}</p>
				</div>
			</div>
{/if}

<form method="post" action="{$smarty.server.PHP_SELF}?action=contacts&id={$contactid}">
  <input type="hidden" name="submit" value="true" />
  
  
  		<div class="feildset">
		
			<div class="col2">
			
				<div>
					<label>
						<span>{$LANG.clientareafirstname}: ({$LANG.required})</span>
						<input name="firstname" value="{$contactfirstname}" placeholder="{$LANG.addcontact_firstname}" type="text" tabindex="1" requred="required" autofocus="autofocus" />
					</label>
				</div>
			
			
				<div>
					<label>
						<span>{$LANG.clientareaemail}: ({$LANG.required})</span>
						<input name="email" value="{$contactemail}" placeholder="{$LANG.addcontact_email}" type="email" tabindex="3" requred="required" />
					</label>
				</div>	
				
				
				<div>
					<label>
						<span>{$LANG.clientareacountry}: ({$LANG.required})</span>
						
						{$countriesdropdown}
					</label>
				</div>							

				<div>
					<label>
						<span>{$LANG.clientareaaddress1}: ({$LANG.required})</span>
						<input name="address1" value="{$contactaddress1}" placeholder="{$LANG.addcontact_address1}" type="text" tabindex="5" requred="required" />
					</label>
				</div>				

				<div>
					<label>
						<span>{$LANG.clientareacity}: ({$LANG.required})</span>
						<input name="city" value="{$contactcity}" placeholder="{$LANG.addcontact_city}" type="text" tabindex="7" requred="required" />
					</label>
				</div>	
				
				
				<div>
					<label>
						<span>{$LANG.clientareapostcode}: ({$LANG.required})</span>
						<input name="postcode" value="{$contactpostcode}" placeholder="{$LANG.addcontact_postcode}" type="text" tabindex="9" requred="required" />
					</label>
				</div>							
												
			
			
			</div><!-- .col2 -->
			
			
			<div class="col2 nomarginright">
			
				<div>
					<label>
						<span>{$LANG.clientarealastname}: ({$LANG.required})</span>
						<input name="lastname" value="{$contactlastname}" placeholder="{$LANG.addcontact_lastname}" type="text" tabindex="2" requred="required" />
					</label>
				</div>			
			
			
				<div>
					<label>
						<span>{$LANG.clientareacompanyname}:</span>
						<input name="companyname" value="{$contactcompanyname}" placeholder="{$LANG.addcontact_company}" type="text" tabindex="4" />
					</label>
				</div>
				
				<div>
					<label>
						<span>{$LANG.clientareaphonenumber}: ({$LANG.required})</span>
						<input name="phonenumber" value="{$contactphonenumber}" placeholder="{$LANG.addcontact_phone}" type="tel" tabindex="6" requred="required" />
					</label>
				</div>							

				
				<div>
					<label>
						<span>{$LANG.clientareaaddress2}: ({$LANG.required})</span>
						<input name="address2" value="{$contactaddress2}" placeholder="{$LANG.addcontact_address2}" type="text" tabindex="8" requred="required" />
					</label>
				</div>
				

				
				<div>
					<label>
						<span>{$LANG.clientareastate}: ({$LANG.required})</span>
						<input name="state" value="{$contactstate}" placeholder="{$LANG.addcontact_state}" type="text" tabindex="10" requred="required" />
					</label>
				</div>
																								
			
			</div><!-- .col2 -->
			
			<div class="clear">&nbsp;</div>
			
			<div class="col1">
			
				<div>
					<label>
						<span>{$LANG.subaccountactivate}:</span>
						<input type="checkbox" name="subaccount" id="subaccount"{if $subaccount} checked{/if} /> <label for="subaccount">{$LANG.subaccountactivatedesc}</label>
					</label>
				</div>
				
				
				
				
				<div class="subaccountfields"{if !$subaccount} style="display:none;"{/if}>
					<label>
						<span>{$LANG.clientareapassword}:</span>
						<input type="password" name="password" id="newpw" />
					</label>
				</div>
				
				<div class="subaccountfields"{if !$subaccount} style="display:none;"{/if}>
					<label>
						<span>{$LANG.clientareaconfirmpassword}:</span>
						<input type="password" name="password2" />
					</label>
				</div>
				
				
				<div class="subaccountfields"{if !$subaccount} style="display:none;"{/if}>
					<label>
						<span>{$LANG.subaccountpermissions}:</span>
						<input type="checkbox" name="permissions[]" id="permprofile" value="profile"{if in_array('profile',$permissions)} checked{/if} /> <label for="permprofile">{$LANG.subaccountpermsprofile}</label><br />
<input type="checkbox" name="permissions[]" id="permcontacts" value="contacts"{if in_array('contacts',$permissions)} checked{/if} /> <label for="permcontacts">{$LANG.subaccountpermscontacts}</label><br />
<input type="checkbox" name="permissions[]" id="permproducts" value="products"{if in_array('products',$permissions)} checked{/if} /> <label for="permproducts">{$LANG.subaccountpermsproducts}</label><br />
<input type="checkbox" name="permissions[]" id="permmanageproducts" value="manageproducts"{if in_array('manageproducts',$permissions)} checked{/if} /> <label for="permmanageproducts">{$LANG.subaccountpermsmanageproducts}</label><br />
<input type="checkbox" name="permissions[]" id="permdomains" value="domains"{if in_array('domains',$permissions)} checked{/if} /> <label for="permdomains">{$LANG.subaccountpermsdomains}</label><br />
<input type="checkbox" name="permissions[]" id="permmanagedomains" value="managedomains"{if in_array('managedomains',$permissions)} checked{/if} /> <label for="permmanagedomains">{$LANG.subaccountpermsmanagedomains}</label><br />
<input type="checkbox" name="permissions[]" id="perminvoices" value="invoices"{if in_array('invoices',$permissions)} checked{/if} /> <label for="perminvoices">{$LANG.subaccountpermsinvoices}</label><br />
<input type="checkbox" name="permissions[]" id="permtickets" value="tickets"{if in_array('tickets',$permissions)} checked{/if} /> <label for="permtickets">{$LANG.subaccountpermstickets}</label><br />
<input type="checkbox" name="permissions[]" id="permaffiliates" value="affiliates"{if in_array('affiliates',$permissions)} checked{/if} /> <label for="permaffiliates">{$LANG.subaccountpermsaffiliates}</label><br />
<input type="checkbox" name="permissions[]" id="permemails" value="emails"{if in_array('emails',$permissions)} checked{/if} /> <label for="permemails">{$LANG.subaccountpermsemails}</label><br />
<input type="checkbox" name="permissions[]" id="permorders" value="orders"{if in_array('orders',$permissions)} checked{/if} /> <label for="permorders">{$LANG.subaccountpermsorders}</label>
					</label>
				</div>
				
				
				<div>
					<label>
						<span>{$LANG.clientareacontactsemails}:</span>
						<input type="checkbox" name="generalemails" id="generalemails" value="1"{if $generalemails} checked{/if} />
              <label for="generalemails">{$LANG.clientareacontactsemailsgeneral}</label><br />
              <input type="checkbox" name="productemails" id="productemails" value="1"{if $productemails} checked{/if} />
              <label for="productemails">{$LANG.clientareacontactsemailsproduct}</label><br />
              <input type="checkbox" name="domainemails" id="domainemails" value="1"{if $domainemails} checked{/if} />
              <label for="domainemails">{$LANG.clientareacontactsemailsdomain}</label><br />
              <input type="checkbox" name="invoiceemails" id="invoiceemails" value="1"{if $invoiceemails} checked{/if} />
              <label for="invoiceemails">{$LANG.clientareacontactsemailsinvoice}</label><br />
              <input type="checkbox" name="supportemails" id="supportemails" value="1"{if $supportemails} checked{/if} />
              <label for="supportemails">{$LANG.clientareacontactsemailssupport}</label>
					</label>
				</div>	
				
				<div style="height: 20px;"></div>															
							
							  <p class="center">
    <input type="submit" value="{$LANG.clientareasavechanges}" class="button1 color1" />
    <input type="button" value="{$LANG.clientareadeletecontact}" class="button1 color2" onclick="deleteContact()" />
 							 </p>
							
							
							
							</div>
						</div>			  

</form>
{else}


			<div class="notice notice-error">
				<div class="inside">
					<p>{$LANG.clientareanocontacts}</p>
				</div>
			</div>


{/if}