<?php
/**
 * Adodis Blog package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2012 - 2013 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// Joomla predefined function for tooltip
JHtml::_('behavior.tooltip');

// Joomla predefined function for modal
JHTML::_('behavior.modal');

$path	 	= JURI::root();
$itemid  	= JRequest::getVar('Itemid', 0, '', 'int');
require_once JPATH_COMPONENT.'/helpers/videos.php';
?>

<div>
	<h1>
	<?php
		echo JText::_('ADODIS_BLOG_COMMENTS_INNER');
		if($this->params->get('show_comment_count', 1)){
			if($this->items['0']->count_comment)
				echo ' ('.$this->items['0']->count_comment.')';
			else
				echo ' (0)';
		}
	?>
	</h1>
</div>
 <?php
$k	= 0;
$i	= 0;
foreach( $this->items as $key=>$value) {
	if($value->ct_comment){
		if($i<5){
			$valveAvailable = 0;
?>	<div id="adodis-blog_cmt<?php echo $i;?>">
		<div class="adodis-blog_bgitem_container" style="background-color:<?php echo $this->settings->bg_color;?>;" >
			<div class="adodis-blog_bgauthor_details  comment adodis-blog_comment_fl">
				<?php
					if($this->params->get('show_comment_author', 1)){
						echo JText::_('ADODIS_COMMENT_POSTED_BY').' ';
						?>
						<b>
							<?php
							if($value->ct_comment_by) {
								echo $value->ct_comment_by;
							} else{
								echo $value->ct_comment_by_name;
							}
							?>
						</b>
						<?php
					}
					if($this->params->get('show_comment_post_date', 1)) {
						echo JText::_('ADODIS_BLOG_ON');
				?><b>
					<?php
						echo date("l, F j, Y, g:i A", strtotime($value->ct_created_date) );
					?>
				</b>
				<?php } ?>
			</div>
			<?php
			if($this->params->get('show_like_dislike', 1)){
			?>
				<div id="comment_title_like_<?php echo $i; ?>" class="comment_title_like adodis-blog_likedis_con">
					<div id="displikes_<?php echo $i; ?>" style="display:none;float:left;"></div>
					<span title="Like" class="likesdislikes adodis-blog_span_likedis" onclick="likedislikes('<?php echo $value->ct_id; ?>','1','<?php echo $i; ?>')">
						<img src="components/com_adodisblog/assets/images/feedback/top.gif" />
					</span>
					<span title="Dislike" class="adodis-blog_span_likedis" onclick="likedislikes('<?php echo $value->ct_id; ?>','0','<?php echo $i; ?>')">
						<img src="components/com_adodisblog/assets/images/feedback/bot.gif" />
					</span>
					<span class="adodis-blog_span_likedis_count" id="total_like_<?php echo $i; ?>"><?php echo $value->total_likes;?></span>
				</div>
			<?php
			}
			?>
			<br style="clear:both;"/>
			<div>
				<?php echo $value->ct_comment;?>
			</div>
		</div>
	</div>
<?php
		}else{
			$valveAvailable = $i;
			?>
			<div id="adodis-blog_cmt<?php echo $i;?>" class="adodis-blog_blockdata">
				<div class="adodis-blog_bgitem_container" style="background-color:<?php echo $this->settings->bg_color;?>;" >
					<div class="adodis-blog_bgauthor_details comment adodis-blog_comment_fl">
						<?php
							if($this->params->get('show_comment_author', 1)){
								echo JText::_('ADODIS_BLOG_POSTED_BY').' ';
								?>
								<b>
									<?php
									if($value->ct_comment_by) {
										echo $value->ct_comment_by;
									} else{
										echo $value->ct_comment_by_name;
									}
									?>
								</b>
								<?php
							}
							if($this->params->get('show_comment_post_date', 1)) {
								echo JText::_('ADODIS_BLOG_ON');
						?><b>
							<?php
								echo date("l, F j, Y, g:i A", strtotime($value->ct_created_date) );
							?>
						</b>
						<?php } ?>
					</div>
					<?php
					if($this->params->get('show_like_dislike', 1)){
					?>
						<div id="comment_title_like_<?php echo $i; ?>" class="comment_title_like adodis-blog_likedis_con">
							<div id="displikes_<?php echo $i; ?>" style="display:none;float:left;"></div>
							<span title="Like" class="likesdislikes adodis-blog_span_likedis" onclick="likedislikes('<?php echo $value->ct_id; ?>','1','<?php echo $i; ?>')">
								<img src="components/com_adodisblog/assets/images/feedback/top.gif" />
							</span>
							<span title="Dislike" class="adodis-blog_span_likedis" onclick="likedislikes('<?php echo $value->ct_id; ?>','0','<?php echo $i; ?>')">
								<img src="components/com_adodisblog/assets/images/feedback/bot.gif" />
							</span>
							<span class="adodis-blog_span_likedis_count" id="total_like_<?php echo $i; ?>"><?php echo $value->total_likes;?></span>
						</div>
					<?php
					}
					?>
					<br style="clear:both;"/>
					<div>
						<?php echo $value->ct_comment;?>
					</div>
				</div>
			</div>
			<?php
		}
	} else {
		$valveAvailable = 0;
?>
		<div class="adodis-blog_bgitem_container" style="background-color:<?php echo $this->settings->bg_color;?>;" >
			<p><?php echo JText::_('ADODID_BLOG_NO_COMMENT_POSTED');?></p>
		</div>
<?php }
$k = 1 - $k;
$i++;
}
if($valveAvailable){
?>
	<span id="adodis-blog_readmore_link" onclick="readMore();">Read More</span>
	<input type="hidden" id="totalcmt"name="totalcmt" value="<?php echo $i?>" />
	<input type="hidden" id="totalcmt_dis"name="totalcmt_dis" value="5" />
<?php
}
// Function for check odd or even
function checkNum($num)
{
  return ($num%2) ? true : false;
}
?>
<input type="hidden" name="sitepath" id="sitepath" value="<?php echo JURI::ROOT(); ?>" />