<?php echo $javascript->link('email_table'); ?>
<? App::import('Sanitize'); ?>
<?php // if (!empty($emails)):?>

<div id="emailDiv">

    <table cellpadding = "0" cellspacing = "0" class="emailtable">
        <tr>
            <th><?php __('Email Date'); ?></th>
            <th><?php __('From'); ?></th>
            <th><?php __('Subject'); ?></th>
        </tr>
	<?php
	$i = 0;
	foreach ($emails as $email):
	    $class = null;

	    if ($i % 2 == 0) {
		$class = ' class="altrow"';
	    }
	    $i++;



	    ?>

        <tr<?php echo $class;?>>
	    
            <td> <?php echo date('j M Y @ G:i', $email['Email']['udate']); ?></td>
            <td><?php
		    if(!empty($email['User']['first_name']) && !empty($email['User']['last_name'])) {
			echo $html->link($email['User']['first_name'].' '.$email['User']['last_name'], array('controller'=>'users','action'=>'view', $email['User']['id']));
		    }
		    else {
			echo $html->link($email['User']['email'], array('controller'=>'users','action'=>'view', $email['User']['id']));
		    }
		    ?>
	    </td>
	    <td><?php //echo $text->highlight($html->link($email['Email']['subject'], array('controller'=> 'emails', 'action'=>'frame/', $email['Email']['id'])), 'Quotation');
		    echo $text->highlight($html->link($email['Email']['subject'], '#', array('class'=>'viewLink', 'id'=>$email['Email']['id'])), 'Quotation');?>
		<span class='viewLink' id="<? echo $email['Email']['id']?>">(<? echo $email['Email']['id']?>)</span>
	    </td>

	</tr>

	<?php endforeach; ?>
    </table>
</div>
<?php //endif; ?>


<div id="ViewDialog">

</div>


<?php //debug($emails); ?>