<?php session_start(); ?>
<?php include '../controller/notifyCode.php'; ?>

<ul class="notification-body">
	<?php 
	if ($inbox) {
		foreach($inbox as $not){
	      if(strlen($not['msg']) >10) {
      $message =  substr($not['msg'], 0, 10)." ...";
  }else{
  	$message = $not['msg'];
  }
	 ?>
<li>
		<span class="unread">
			<a href="javascript:void(0);" class="msg" id="<?php echo $not['mail_id'] ?>">
				<img src="userImage/<?php echo $not['picture'] ?>" alt="" class="air air-top-left margin-top-5" width="40" height="40" />
				<span class="from"><?php echo $not['first_name'] ?> <?php echo $not['last_name'] ?><i class="icon-paperclip"></i></span>
				<time>a few moment ago</time>
				<span class="subject"><?php echo $not['subject'] ?></span>
				<span class="msg-body"><?php echo $message; ?> </span>
			</a>
		</span>
	</li>

	 <?php 
	}
}
	  ?>
	

</ul>

<script type="text/javascript">
	function getMail($this,mySelector) {
		//console.log($this.closest("tr").attr("id"));
		var id = $(this.id).selector
		loadURL("ajax/email-opened.php?::="+mySelector+"", $('#inbox-content > .table-wrap'));
	}


	$(".msg").click(function() {
		$this = $(this);
		var mySelector = $(this.id).selector;
		getMail($this,mySelector);
	});
</script>