<?php 	if( count($this->subadmins) < 1) : ?>
<?php 		echo $this->translate('No SubAdmins exist') ?>
<?php 	else : ?>

<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><input type="checkbox" id="checkToggle" title='Toggle Selection'/></td>
			<td><b><?php echo $this->translate('Username') ?></b></td>
			<td><b><?php echo $this->translate('Company Name') ?></b></td>
			<td><b><?php echo $this->translate('Date Created') ?></b></td>
			<td><b><?php echo $this->translate('Options') ?></b></td>
		</tr>
	
<?php 		foreach( $this->subadmins as $row ) : ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['id'] ?>">
			<td><input type="checkbox" class="subadminids" name="subadminids[]" value="<?php echo $row['id'] ?>" /></td>
			<td><a href="#" class="subadminActionEdit"><?php echo $row['Username'] ?></a></td>
			<td><?php echo $row['Company'] ?></td>
			<td><?php echo $row['DateCreate'] ?></td>
			<td><a href="#" class="subadminActionDelete"><?php echo $this->translate('Delete') ?></a></td>
		</tr>
<?php 		endforeach ?>
       </tbody>
</table>
<?php endif ?>

<script>

$(function() 
{

	filterQuery = $('#subadminFilter').attr('value');

	if(filterQuery.length > 0)
		$('.divide TD').highlight(filterQuery);
	
	$('.subadminActionEdit', '#subadminListForm').bind('click', function() 
	{ 
	
		$.php( '<?php echo $this->moduleBaseUrl ?>/security/subadminedit/subadminid/' + $(this).parent().parent().attr('subadminid'))
		return false
	
	})
	
	$('.subadminActionDelete', '#Table_Subadmins').bind('click', function() {
	
		if( confirm('<?php echo $this->translate("Are you sure you want to delete this Subadmin?"); ?>') )
			$.php('<?php echo $this->moduleBaseUrl ?>/security/subadmindelete/subadminid/' + $(this).parent().parent().attr('subadminid') )
		return false
	
	})

	$('#checkToggle', '#Table_Subadmins').bind('click', function()
	{

		if($(this).attr('checked'))
			$(':checkbox').each(function() { this.checked=true })
		else
			$(':checkbox').each(function() { this.checked=false })

	})
	
	//resize parent to fit
	rows = $('#subadminListMatches').children('tbody').children('tr').length
	
	if( rows < 3 )
		rows = 3
		
	newHeightA = rows * 29
	newHeightB = $("body").innerHeight() - 220
	
	//if wants to be higher than available space then scroll
	if( newHeightA > newHeightB )
		newHeight = newHeightB
	else
		newHeight = newHeightA
	
	//set minimum height
	if( newHeight < 80 )
		newHeight = 100
		
	$('#subadminListMatches').parent().height( newHeight )

})
</script>
