<? $this->load->view( $this->aSystemVar['template_viewer_root'] . '_header') ?>
<script type="text/javascript">
	function getLetterBody( iLetterId, iSenderId )
	{

		var container = document.getElementById('letter_body_' + iLetterId );
		container.style.display = 'block';

		serverQuery( setLetterBody, '<?=site_url('async/get_mail_body')?>/' + iLetterId );

		function setLetterBody( sText )
		{
			var sNav;
			var sFinalText;
			sNav = '';
			sNav += '<div class="letterNav">';
			sNav += '<span>';
			sNav += '<a href="javascript:void(0);" onclick="hideBlock(\'letter_body_' + iLetterId + '\');">hide</a>';
			sNav += '</span>';
			sNav += '<span>';
			sNav += '<? echo anchor('mailbox/compose/\'+iSenderId+\'', 'reply')?>';
			sNav += '</span>';
			sNav += '</div>';

			sFinalText = sNav + sText + sNav;
			container.innerHTML = sFinalText;
			return true;
		}

		return true;

	}


</script>
	<div class="colCapt">
		<?= $this->lang->line('inbox'); ?>
	</div>
<div id="breadcrumb">
	<span><?= anchor( base_url(true), $this->lang->line('home') ) ?></span>
	<span class="divider"><?= $this->config->item('breadcrumb_divider') ?></span>
	<span><?= $this->lang->line('inbox') ?></span>
</div>
<div>
			<div class="toolBar"><?= anchor('mailbox/outbox/',$this->lang->line('outbox'))?></div>
			<?= form_open('mailbox/inbox', array( 'id' => 'letter_list') ); ?>
				<div class="marginbottom10">
					<div class="head">
						<div class="clearBoth"></div>
						<div class="firstCol">&nbsp;</div>
						<div class="secondCol" style="border-left:1px solid #FCFCDD;">&nbsp;</div>
						<div class="thirdCol"><?= $this->lang->line('from') ?>:</div>
						<div class="forthCol"><?= $this->lang->line('subject'); ?>:</div>
						<div class="fifthCol"><?= $this->lang->line('date'); ?>:</div>
						<div class="clearBoth"></div>
					</div>
					<div>
						<?
							$i = 1;
						 ?>
						<? foreach( $data['LetterList'] as $aLetter ): ?>
						<?
							if( ($i%2) == 0 )
							{
								$sClassPref = 'even';
							}
							else
							{
								$sClassPref = 'odd';
							}
						?>
						<div class="<?= $sClassPref ?>_mailboxLine <?= $aLetter['Status'] ?>">
							<div class="clearBoth"></div>
							<div class="firstCol"><input type="checkbox" name="LetterId[]" value="<?= $aLetter['Id']?>" style="vertical-align:middle;" class="checkbox" /></div>
							<div class="secondCol"><img src="<?= $this->config->item('design_pic_url') ?>icons/<?= $aLetter['Status'] ?>.gif" alt="<?= $aLetter['Status'] ?>" style="vertical-align:middle;" /></div>
							<div class="thirdCol"><?= anchor('user/profile/' . $aLetter['SenderName'], $aLetter['SenderName'], ' target="_blank"' ); ?></div>
							<div class="forthCol"><a href="javascript:void(0);" onclick="getLetterBody('<?=$aLetter['Id']?>', '<?=$aLetter['SenderId']?>' );"><?=$aLetter['Subject']?></a></div>
							<div class="fifthCol"><?= $aLetter['DateSend'] ?></div>
							<div class="clearBoth"></div>
						</div>
						<div id="letter_body_<?=$aLetter['Id']?>" style="display:none;" class="letterBody" >
							<?= $this->lang->line('loading'); ?> ...
						</div>
						<? $i++; ?>
						<? endforeach; ?>
					</div>
				</div>
			<?= form_close(); ?>
			<div class="marginbottom5">
				<a href="javascript: void(0);" onClick="javascript: setCheckbox('letter_list', true );" ><?= $this->lang->line('check_all'); ?></a>
				<a href="javascript: void(0);" onClick="javascript: setCheckbox('letter_list', false );" ><?= $this->lang->line('uncheck_all'); ?></a>
			</div>
			<div>
				<a href="" OnClick="javascript: getElementById('letter_list').submit(); return false;"><?= $this->lang->line('delete'); ?></a>
			</div>

</div>
<? $this->load->view( $this->aSystemVar['template_viewer_root'] . '_footer') ?>