<?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]['Profileslatecomment']['id']; ?>"></div> 
 <?php 
 $ww_root=$this->webroot;
             
                     
                                $wallcommentLike = ClassRegistry::init('Profileslatecommentlike');
                                
                                $conut='';
                                $arr_comments=$comments;
                                foreach ($arr_comments as $comment):
                                
                                /*echo '<pre>';
                                print_r($comment);
                                echo '<pre>';*/
                                //pr($arr_comments);die();
                                        if($wallcommentLike->checkme($comment['Profileslatecomment']['id'],$loggedUser['id'])){
                                                $lun = 'Liked';
                                                $fun_n = 'unlike_by_wall_id2';
                                        }else{
                                                $lun = 'Like';
                                                $fun_n = 'like_by_wall_id2';
                                        }
                                        if($comment['Profileslatecomment']['user_id'] == $loggedUser['id'] || $wall['Profileslate']['user_id'] == $loggedUser['id']):
                                                $del = "<i class='fa fa-times'></i>";
                                        else:
                                                $del = '';
                                        endif;
                                       // pr($profileInfo2);
                                        ?>
                                
                            <li class="row-fluid cbox" id="data_<?php echo $comment['Profileslatecomment']['id'];?>" >
                                                <div class="span11 offset1">
                                                        <div class="shdw brd pd5 mrb5" >
                                                                <div class="row-fluid">
                                                                        <div class="" style="max-height: 50px; max-width: 50px; width: 7%; float: left;">
										                                        <?php if ($comment['Profileslatecomment']['parent_id']==0){?>
										                                        	<?php if (!empty($profileInfolink[$comment['Profileslatecomment']['user_id']])){?>
										                                        	<img src="<?php echo $profileInfolink[$comment['Profileslatecomment']['user_id']];?>" width="50px" height="50px">
										                                        	<?php }else {
										                                        		echo $this->Html->image('profile.jpg',array('style'=>'width="50px" height="50px"'));
										                                        	}?>
										                                        	
                                        										<?php }elseif(!empty($wall['Profiless']['link1'])){?>
                                                                                        <img src="<?php echo $wall['Profiless']['link1'];?>" width="50px" height="50px">
                                                                                <?php }else {
                                                                                        echo $this->Html->image('profile.jpg',array('style'=>'width="50px" height="50px"'));
                                                                                }?>	
                                                                        </div>
                                                                        <div class=" prelative" style="width: 93%; float: right; padding-left: 1%;">
                                                                                <span class="topright"><a onclick="ddp('<?php echo $ww_root?>profileslatecomments','delete','<?php echo $comment['Profileslatecomment']['id']; ?>');"><?php echo $del;?></a></span>
                                                                                <div class="w97p fnt80">
                                                                                        <span class="profile-name">
																						<?php 
																							if (!empty($profileInfo[$comment['Profileslatecomment']['user_id']])){
																								echo $profileInfo[$comment['Profileslatecomment']['user_id']];
																							}else {
																								echo 'Annoymous';
																							}
																							
																							
																							?>: 
																						</span>
                                                                                        <?php echo $comment['Profileslatecomment']['comment']?>
                                                                                </div>
                                                                                <div class="divline"></div>

                                                                                <span class="fl fnt80 cash">
                                                                                <?php 
                                                                                
                                                                                $adte=$comment['Profileslatecomment']['created'];
                                                                                $localtime=timeAgo($comment['Profileslatecomment']['created']);
                                                                                if($localtime=='Hadi'){
                                                                                	echo getTimeZoneConvert($adte,$timezone);
                                                                                }else{
                                                                                	echo timeAgo($adte);
                                                                                }
                                                                                        
                                                                                        $tot = $wallcommentLike->countwallcommentlikes($comment['Profileslatecomment']['id']); 
                                                                                ?>
                                                                                </span>
                                                                                <div class="tar fnt80"><span onclick="<?php echo $fun_n?> &nbsp;('<?php echo $ww_root?>profileslatecommentlikes','<?php echo $comment['Profileslatecomment']['id']; ?>',<?php echo $tot;?>)"id="<?php echo 'lkunl'.$comment['Profileslatecomment']['id'] ?>" class="cmlikespid"><?php echo $lun; ?>(<?php echo $tot; ?>)</span> </div>
                                                                        </div>
                                                                </div>
                                                        </div>
                                                </div>
                                        </li>
                                        
                                        <?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';
                                        		}
                                        
                                        
                                        	}
                                        
                                        
                                        
                                        }
                                        
                                        
                                        ?>