<?php 	if( $this->logs[0] < 1) : ?>
	<table id="subadminListMatches" class="aliases">
		<tbody>
			<tr class="subadminRow divide">
			<td>
<?php 		echo $this->translate('0 Log matches found') ?>
			</td>
			</tr>
		</tbody>
	</table>
<?php 	elseif($this->log == 'Log_Virus') : ?>
<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><b><?php echo $this->translate('Account') ?></b></td>
			<td><b><?php echo $this->translate('Virus') ?></b></td>
			<td><b><?php echo $this->translate('IP') ?></b></td>
			<td><b><?php echo $this->translate('Date') ?></b></td>
		</tr>
<?php foreach( $this->logs[1] as $row ) : ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['id'] ?>">
			<td title='<?php echo $row['MessageID'] ?>'><?php echo $row['EmailFrom'] ?> <font color='grey'>&gt;</font> <?php echo $row['Account'] ?></td>
			<td><?php echo $row['VirusName'] ?></td>
			<td><?php echo $row['LogIP'] ?></td>
			<td><?php echo $row['LogDate'] ?></td>			
		</tr>
<?php endforeach ?>
       </tbody>
</table>
<?php 	elseif($this->log == 'Log_RecvMail') : ?>
<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><b><?php echo $this->translate('Account') ?></b></td>
			<td><b><?php echo $this->translate('IP') ?></b></td>
			<td><b><?php echo $this->translate('Date') ?></b></td>
		</tr>
<?php foreach( $this->logs[1] as $row ) : ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['id'] ?>">
			<td title='<?php echo $row['MessageID'] ?>'><?php echo $row['EmailFrom'] ?> <font color='grey'>&gt;</font> <?php echo $row['Account'] ?></td>			
			<td><?php echo $row['LogIP'] ?></td>
			<td><?php echo $row['LogDate'] ?></td>			
		</tr>
<?php endforeach ?>
       </tbody>
</table>
<?php 	elseif($this->log == 'Log_SendMail') : ?>
<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><b><?php echo $this->translate('Account') ?></b></td>
			<td><b><?php echo $this->translate('IP') ?></b></td>
			<td><b><?php echo $this->translate('Date') ?></b></td>
		</tr>
<?php foreach( $this->logs[1] as $row ) : ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['id'] ?>">
			<td title='<?php echo $row['MessageID'] ?>'><?php echo $row['Account'] ?> <font color='grey'>&gt;</font> <?php echo $row['EmailTo'] ?></td>			
			<td><?php echo $row['LogIP'] ?></td>
			<td><?php echo $row['LogDate'] ?></td>			
		</tr>
<?php endforeach ?>
       </tbody>
</table>
<?php 	elseif($this->log == 'Log_Spam') : ?>
<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><b><?php echo $this->translate('Account') ?></b></td>
			<td><b><?php echo $this->translate('Type') ?></b></td>
			<td><b><?php echo $this->translate('IP') ?></b></td>
			<td><b><?php echo $this->translate('Date') ?></b></td>
		</tr>
<?php foreach( $this->logs[1] as $row ) : ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['id'] ?>">
			<td><?php echo $row['EmailFrom'] ?> <font color='grey'>&gt;</font> <?php echo $row['Account'] ?></td>
			<td>
			<?php if($this->log == 'Log_Spam') :?>
				<?php if ($row['LogType'] == '1') :?>
					Marked
				<?php elseif ($row['LogType'] == '2') :?>
					Reject
				<?php elseif ($row['LogType'] == '3') :?>
					Moved
				<?php elseif ($row['LogType'] == '4') :?>
					RBL
				<?php elseif ($row['LogType'] == '5') :?>
					DKIM
				<?php endif ?>
			<?php endif ?>
			</td>
			
			<td><?php echo $row['LogIP'] ?></td>
			<td><?php echo $row['LogDate'] ?></td>
			
		</tr>
<?php endforeach ?>
       </tbody>
</table>
<?php 	else : ?>
<table id="subadminListMatches" class="aliases">
	<tbody>
		<tr class="header">
			<td><b><?php echo $this->translate('Account') ?></b></td>
			<td><b><?php echo $this->translate('Type') ?></b></td>
			<td><b><?php echo $this->translate('IP') ?></b></td>
			<td><b><?php echo $this->translate('Date') ?></b></td>
		</tr>
<?php foreach( $this->logs[1] as $row ) : ?>
		<tr class="subadminRow divide" subadminid="<?php echo $row['id'] ?>">
			<td><?php echo $row['Account'] ?></td>
			<td>
<?php if($this->log == 'Log_Login') :?>
	<?php if ($row['LogType'] == '1') :?>
		POP3
	<?php elseif ($row['LogType'] == '2') :?>
		POP3 SSL
	<?php elseif ($row['LogType'] == '3') :?>
		IMAP
	<?php elseif ($row['LogType'] == '4') :?>
		IMAP SSL
	<?php elseif ($row['LogType'] == '5') :?>
		Webmail
	<?php elseif ($row['LogType'] == '6') :?>
		CalDAV
	<?php elseif ($row['LogType'] == '7') :?>
		ActiveSync
	<?php elseif ($row['LogType'] == '8') :?>
		CalDAV
	<?php endif ?>
<?php endif ?>
			</td>
			<td><?php echo $row['LogIP'] ?></td>
			<td><?php echo $row['LogDate'] ?></td>
		</tr>
<?php endforeach ?>
       </tbody>
</table>
<?php endif ?>

<select name="paginationSearch" style='display:none;'>
<?php echo $this->pagination ?>
</select>

<script>

$(function() 
{

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

	if(filterQuery.length > 0) {
		var element = filterQuery.split(" ");
		
		for(i in element) {
			if(element[i] == '')
				continue;
			$('.divide TD').highlight( element[i] );						
		}
		
	}	
	
	//resize parent to fit
	rows = $('#subadminListMatches').children('tbody').children('tr').length
	
	if( rows < 3 )
		rows = 3
		
	newHeightA = rows * 29
	newHeightB = $("body").innerHeight() - 230
	
	//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 );
	
	// Display our results
	<?php if($this->log == 'Log_Login') :?>
		var log = "<?php echo $this->translate('Logins') ?>";
	<?php elseif($this->log == 'Log_RecvMail') :?>
		var log = "<?php echo $this->translate('Received Mail') ?>";
	<?php elseif($this->log == 'Log_SendMail') :?>
		var log = "<?php echo $this->translate('Sent Mail') ?>";
	<?php elseif($this->log == 'Log_Spam') :?>
		var log = "<?php echo $this->translate('Spam') ?>";
	<?php elseif($this->log == 'Log_Virus') :?>
		var log = "<?php echo $this->translate('Viruses') ?>";
	<?php endif ?>

	var logCount = '<?php echo $this->logs[0] ?>';
	
	// Last, update how many rows we matched
	$('#primary_header H1').html("Logs - " + log + " &gt; <?php echo ucfirst($this->view) ?> view &gt; <span class='logCount'>" + logCount + "</span> results");

	$('#pageResults').html("<span class='logCount'><?php echo $this->logs[0] ?></span> results");
	
	// Hide pagination if 0 results
	if(logCount == 0)
		$('.mail_row_paginator_aliases', '#searchLogs').hide();
	else
		$('.mail_row_paginator_aliases', '#searchLogs').show();
	
	$("SELECT[name=page]").html( $("SELECT[name=paginationSearch]").html() );
	
	// Last, select the page we are on
	<?php if(!empty($this->index)) :?>
		$("OPTION[value=<?php echo $this->index ?>]").attr('selected', true);
	<?php endif ?>
	
	$("SPAN.logCount").format({format:"#,###", locale:"us"});
	
	// Select the search query
	$("OPTION[value=<?php echo $this->log ?>]").attr('selected', true);
	$("OPTION[value=<?php echo $this->view ?>]").attr('selected', true);

	// Scroll to the top for matches
	$("#log-table").scrollTo(0);
	
})
</script>
