
<?php 
echo $this->Html->script('jstz.min');
?>

<script type="text/javascript">
var timezone;

var tz = jstz.determine(); // Determines the time zone of the browser client
timezone = tz.name(); //'Asia/Kolhata' for Indian Time.

</script>


<?php echo $finalposition.'~~~'?>


				<div class="moreresults<?php echo $comment[0]['Wallcomment']['id']; ?>"></div> 
 							
							<?php
								$ww_root=$this->webroot;
									$wallcommentLike = ClassRegistry::init('Wallcommentlike');
									
	                                $conut='';
	                                $arr_comments=$comments;
	                                foreach ($arr_comments as $comment):
                                
									if($wallcommentLike->checkme($comment['Wallcomment']['id'],$loggedUser['id'])){
										$lun = 'Liked';
										$fun_n = 'unlike_by_wall_id2';
									}else{
										$lun = 'Like';
										$fun_n = 'like_by_wall_id2';
									}
									
									if($comment['Wallcomment']['user_id'] == $loggedUser['id']){
										$del = 'Delete';
									}else{
									$del = '';
									}
							//pr($profileInfo);
							?>
							<div class="single-wall-display ml60 cbox" id="data_<?php echo $comment['Wallcomment']['id'];?>" >
									<div class="row-fluid">
										<div class="span1">
										
										<?php if ($comment['Wallcomment']['parent_id']==0){?>
                                        	<img src="<?php echo $profileInfolink[$comment['Wallcomment']['user_id']];?>" width="50px" height="50px">
                                        <?php }elseif(!empty($wall['Prof']['link1'])){?>
                                            <img src="<?php echo $wall['Prof']['link1'];?>" width="50px" height="50px">
                                        <?php }else {
                                             echo $this->Html->image('profile.jpg',array('style'=>'width="50px" height="50px"'));
                                        }?>	
										</div>
										<div class="span11" style="position: relative;">
											<?php 
											if(!empty($del)){
												?>
												<div class="topright">
													<i class='fa fa-times'></i><span class="btnn" onclick="dd('wallcomments','delete','<?php echo $comment['Wallcomment']['id']; ?>');"><?php //echo $del;?></span>
												</div>
												<?php
											}
											?>
											<div class="w98p">
												<span class="profile-name">
												
												 <?php // pr($profileInfo['[$comment]']);die();?>
												
													<?php echo $this->Html->link($profileInfo[$comment['Wallcomment']['user_id']],array('controller'=>'profiles','action'=>'about',base64_encode($comment['Wallcomment']['user_id'])));?> 
												</span>
												<?php 
													echo $comment['Wallcomment']['comment'];
													$tot = $wallcommentLike->countwallcommentlikes($comment['Wallcomment']['id']);
												?>
											</div>
											
											<div class="bort mrt5 pdt5 pdr5">
												<span class="cash"><?php 
												
												$adte=$comment['Wallcomment']['created'];
												$localtime=timeAgo($comment['Wallcomment']['created']);
												if($localtime=='Hadi'){
													echo getTimeZoneConvert($adte,$timezone);
												}else{
													echo timeAgo($adte);
											}
												
												//echo timeAgo($comment['Wallcomment']['created']);
												
												
												
												?></span>
								<div class="small-like" onclick="<?php echo $fun_n?>('<?php echo $ww_root?>wallcommentlikes','<?php echo $comment['Wallcomment']['id']; ?>',<?php echo $tot;?>)" id="<?php echo 'lkunl'.$comment['Wallcomment']['id'] ?>" style="cursor:pointer;"> <?php echo $lun; ?>(<?php echo $tot; ?>)</div>
											</div>
										</div>
									</div>
							</div>
							
							<?php
                                endforeach;
                        
                        ?>

								 <?php 
                                        
                                        function timeAgo($time_ago)
                                        {
                                        	$time_ago = strtotime($time_ago);
                                        	$cur_time   = time();
                                        	$time_elapsed   = $cur_time - $time_ago;
                                        	$seconds    = $time_elapsed ;
                                        	$minutes    = round($time_elapsed / 60 );
                                        	$hours      = round($time_elapsed / 3600);
                                        	$days       = round($time_elapsed / 86400 );
                                        	 
                                        
                                        	// Seconds
                                        	if($seconds <= 60){
                                        
                                        		if($seconds<=10){
                                        			return "just now";
                                        		}
                                        		else{
                                        			return "$seconds seconds ago";
                                        		}
                                        	}
                                        	//Minutes
                                        	else if($minutes <=60){
                                        		if($minutes==1){
                                        			return "one minute ago";
                                        		}
                                        		else{
                                        			return "$minutes minutes ago";
                                        		}
                                        	}
                                        	//Hours
                                        	else if($hours <=24){
                                        		if($hours==1){
                                        			return "an hour ago";
                                        		}else{
                                        			return "$hours hrs ago";
                                        		}
                                        	}
                                        	//Days
                                        
                                        
                                        	else if($days >=1){
                                        		if($days==1){
                                        			return "Yesterday";
                                        		}else{
                                        			return 'Hadi';
                                        		}
                                        
                                        
                                        	}
                                        
                                        
                                        
                                        }
                                        
                                        
                                        ?>