<ul id="nav_secondary">
	<li class="nav-category">
		<span><?php print $this->translate('System')?></span>
	</li>	

	<li GroupID="" groupType="all" DomainName="" id="folder_all" class="<?php echo ($this->currentDomain == '' ? ' current' : '') ?>">
		<a class="groupLink" href="#">
			<span class="label">
				<span class="labelname"><?php echo $this->translate('All Users') ?></span>
				<?php echo ($this->numTotalAccounts==0) ? '<span class="unread" style="display:none;">' : '<span class="unread">'; ?>
				<strong><?php echo $this->numTotalAccounts; ?></strong>
			</span>
			</span>
		</a>
	</li>

<?php if($this->global['install_type'] == 'server' && $this->userData['UMasterAdmin'] == 1 ) : ?>
	<li GroupID="" DomainName="external" id="external" class="">
		<a class="groupLink" href="#">
			<span class="label">
				<span class="labelname">External Accounts</span>
				<?php echo ($this->numExtAccounts==0) ? '<span class="unread" style="display:none;">' : '<span class="unread">'; ?>
				<strong><?php echo $this->numExtAccounts; ?></strong>
			</span>
			</span>
		</a>
	</li>
<?php endif; ?>
<div id="domainsList">
    <li id="folder_actions" class="nav-category">
        <span><?php print $this->translate('Domains')?></span>
<?php if( $this->userData['UMasterAdmin'] == 1 ) : ?>
        <span id="remove_domain" class="folder-remove" title="<?php echo $this->translate('Delete Current Domain')?>"><a class="<?php echo $this->currentGroup=='All'?'disabled':'enabled' ?>"><?php echo $this->translate('Delete Current Domain')?></a></span>
        <span id="add_domain" class="folder-add" title="<?php echo $this->translate('Add New Domain')?>"><a><?php echo $this->translate('Add New Domain')?></a></span>
<?php endif; ?>
    </li>

<?php foreach( $this->domains as $domain ) : ?>

<li GroupID="" groupType="domain" DomainName="<?php echo $domain['DomainName'] ?>" id="Domain-Group" class="<?php echo ($this->currentDomain == $domain['DomainName'])? ' current' : '' ?>">
	<a id="domain" class="groupLink" href="#">
		<span class="label">
			<span class="<?php echo ($domain['enabled'] == 1)? 'labelname' : 'domain_disabled' ?>"><?php echo $domain['DomainName'] ?></span>
			<?php echo ($domain['totalUsers']==0) ? '<span class="unread" style="display:none;">' : '<span class="unread">'; ?>
			<strong><?php echo $domain['totalUsers']; ?></strong>
		</span>
		</span>
	</a>
</li>
<?php endforeach; ?>
</div>
<div id="groupsList">
<li id="folder_actions" class="nav-category">
<?php if( $this->userData['UMasterAdmin'] == 1 ) : ?>
	<span><?php print $this->translate('Groups')?></span>

	<span id="remove_group" class="folder-remove" title="<?php echo $this->translate('Delete Current Group')?>"><a class="<?php echo $this->currentGroup=='All'?'disabled':'enabled' ?>"><?php echo $this->translate('Delete Current Group')?></a></span>
	<span id="add_group" class="folder-add" title="<?php echo $this->translate('Add New Group')?>"><a><?php echo $this->translate('Add New Group')?></a></span>
<?php endif; ?>
</li>

<?php foreach( $this->userGroups as $userGroup ) : ?>
<?php 
//skip blank (special group from A5 ) 
if( strlen($userGroup['GroupName']) == 0 )
{

		continue;

}
?>
<?php if( $userGroup['GroupName'] == 'default' ) continue; // the default group ?>

<li GroupID="" groupType="user" groupName="<?php echo $userGroup['GroupName'] ?>" id="Group-Group" class="<?php echo ($this->currentDomain == $userGroup['GroupName'])? ' current' : '' ?>">
	<a id="group" class="groupLink" href="#">
		<span class="label groupIcon">
			<span class="labelname"><?php echo $userGroup['GroupName'] ?></span>
			<?php echo ($userGroup['totalUsers']==0) ? '<span class="unread" style="display:none;">' : '<span class="unread">'; ?>
			<strong><?php echo $userGroup['totalUsers']; ?></strong>
		</span>
		</span>
	</a>
</li>
<?php endforeach; ?>
</div>
</ul>

<ul id="folder_actions">
<?php 	if( $this->userData['UMasterAdmin'] == 1) : ?>
  <li id="add_domain" title='<?php print $this->translate('Add New Domain')?>'><a><?php echo ($this->global['install_type']=='server'?$this->translate('Add New Domain'):$this->translate('Add New Group')) ?></a></li>
  <li id="remove_domain" title='<?php print $this->translate('Delete Domain')?>'><a class="<?php echo $this->currentGroup=='All'?'disabled':'enabled' ?>"><?php//echo ($this->global['install_type']=='server'?$this->translate('Delete Domain'):$this->translate('Delete Group')) ?></a></li>
  <li id="add_group" title='<?php print $this->translate('Add New Group')?>'><a><?php echo ($this->global['install_type']=='server'?$this->translate('Add New Domain'):$this->translate('Add New Group')) ?></a></li>
  <li id="remove_group" title='<?php print $this->translate('Delete Group')?>'><a class="<?php echo $this->currentGroup=='All'?'disabled':'enabled' ?>"><?php//echo ($this->global['install_type']=='server'?$this->translate('Delete Domain'):$this->translate('Delete Group')) ?></a></li>
<?php 	endif; ?>
<?php 	if( $this->global['install_type'] == 'server' && $this->userData['UMasterAdmin'] == 1) : ?>
  <li id="folder_lock"><a class="disabled" title="<?php echo $this->translate('Lock Domain') ?>"><?php echo $this->translate('Lock Domain') ?></a></li>
  <li id="folder_unlock"><a class="disabled" title="<?php echo $this->translate('Un-Lock Domain')?>"><?php echo $this->translate('Un-Lock Domain') ?></a></li>
<?php 	endif; ?>
  <li id="error" style="display:none"><a><?php echo $this->translate('Error') ?></a></li>
</ul>

<script type="text/javascript" language="JavaScript">	

var currentlyEditingAGroup = false
$( function() 
{                            
	$('#Users #secondary').data('lastposition', 0);
	$('#Users #secondary').hover(function() { $(this).scrollTo($(this).data('lastposition'));}, function() {$(this).data('lastposition', $(this).attr('scrollTop'));});

	$('a.groupLink').bind('click', function() {
        listUsersClick(this)
    } )

    $('#domainsList a.groupLink').bind('click', function() {
        $("#Users #remove_domain").show()
        $("#Users #remove_group").hide()
    })

    $("#groupsList a.groupLink").bind('click', function() {
        $("#Users #remove_group").show()
        $("#Users #remove_domain").hide()
    })

    $("#folder_all").bind('click', function() {
        $("#Users #remove_group").hide()
        $("#Users #remove_domain").hide()
    })

    $("#external").bind('click', function() {
        $("#Users #remove_group").hide()
        $("#Users #remove_domain").hide()
    })

<?php if( $this->userData['UMasterAdmin'] == 1 ) : ?>

<?php if($this->global['install_type'] == 'server') : ?>
	$('#Users #add_group a, #Users #action_contact_newgroup a').bind('click', function() { return addGroup('user') } );
	$('#Users #add_domain a, #Users #action_contact_newdomain a').bind('click', function() { return addGroup('domain') } );
	$('#Users #remove_group a, #Users #action_delete a').bind('click', function() { removeDomain(this); $(".groupLink", "#folder_all", "#Users").trigger('click'); } );
	$('#Users #remove_domain a, #Users #action_delete a').bind('click', function() { removeDomain(this); $(".groupLink", "#folder_all", "#Users").trigger('click'); } );
<?php else : ?>
	$('#Users #add_group a, #Users #action_contact_newgroup a').bind('click', function() { return addGroup('user') } );
	$('#Users #add_domain a, #Users #action_contact_newdomain a').bind('click', function() { return addGroup('user') } );
	$('#Users #remove_group a, #Users #action_delete a').bind('click', function() { removeDomain(this); $(".groupLink", "#folder_all", "#Users").trigger('click'); } );
	$('#Users #remove_domain a, #Users #action_delete a').bind('click', function() { removeDomain(this); $(".groupLink", "#folder_all", "#Users").trigger('click'); } );
<?php endif ?>

<?php if ($this->userData['UMasterAdmin'] == 1): ?>
	$('#Users #folder_lock a').bind('click', function() { lockDomain(this) });
    $('#Users #folder_unlock a').bind('click', function() { unLockDomain(this) });
<?php endif; ?>

	$("#search_anything").show();

<?php else : ?>

    $("#Users #add_group a").removeClass('enabled');
    $("#Users #add_domain a").removeClass('enabled');
	$("#Users #add_group a").addClass('disabled');
	$("#Users #add_domain a").addClass('disabled');
	$("#Users #add_group a").hide();
	$("#Users #add_domain a").hide();
	$("#Users #remove_group a").removeClass('enabled');
	$("#Users #remove_domain a").removeClass('enabled');
	$("#Users #remove_group a").addClass('disabled');
	$("#Users #remove_domain a").addClass('disabled');
    $("#Users #remove_group a").hide();
    $("#Users #remove_domain a").hide();

<?php if($this->userData['USearch'] == 1) : ?>
	$("#search_anything").show();
<?php endif ?>

<?php endif ?>        
	$.php('<?php echo $this->moduleBaseUrl ?>/domain/fetch/page/1/total/<?php echo $this->domainsTotalPages; ?>/pageSize/<?php echo $this->DOMAINS_PER_PAGE; ?>');
})

</script> 