<table id="aliasesListMatches" class="aliases">

		<tr class="header">
          <td><input type="checkbox" id="checkToggle" title='Toggle Selection'/></td> 
          <td><b><?php echo $this->translate('Alias') ?></b></td> 
          <td><b><?php echo $this->translate('Divert To') ?></b></td> 
          <td><b><?php echo $this->translate('Options') ?></b></td> 
        </tr>

	<?php foreach($this->aliaseslist as $alias) :?>
	<tr class="divide aliasRow">
		<td><input type="checkbox" id="checkEntry" name='id[]' value='<?php echo $alias['id'] ?>'/></td>
		<td><?php echo $alias['AliasName']; ?></td>
		
		<?php if(!empty($alias['AliasMailDir'])) :?>
		<td><?php echo $alias['AliasMailDir']; ?></td>		
		<?php else :?>
		<td><?php echo $alias['AliasTo']; ?></td>
		<?php endif ?>
		<td><a class='deleteAlias' href="#" id='<?php echo $alias['id'] ?>'><?php echo $this->translate('Delete') ?></a></td>
	</tr>
	<?php endforeach ?>

</table>

<script>

$(function() {

	var tabId = "#Email_Aliases";
	$(".deleteAlias").live("click", function() {
		$.php('<?php echo $this->moduleBaseUrl ?>/services/aliasdelete/id/' + $(this).attr('id'));
		$(this).parent().parent().fadeOut();
		return false;
	
	});

	filterQuery = $('#aliasFilter', tabId).attr('value');

	if(filterQuery.length > 0) {
		$('.divide TD', tabId).highlight(filterQuery);
	}

	$("#checkToggle", tabId).bind("click", function() {

		if($(this).attr('checked')) {

			$(":checkbox", tabId).each(function() {
				this.checked = true;
			});

		} else {

			$(":checkbox", tabId).each(function() {
				this.checked = false;
			});
		
		}

	})
});
</script>
