<?php
/**
 * @package		Joomla.Site
 * @subpackage	com_content
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
$pageClass = $this->params->get('pageclass_sfx');

?>

<div class="blog<?php echo $this->escape($this->params->get('pageclass_sfx')); ?> clearfix">

	<?php if ($this->params->get('show_page_heading')) : ?>
	<h1 class="componentheading">
		<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
	<?php endif; ?>

	<?php if ($this->params->def('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
	<div class="category-desc clearfix">

		<?php if ($this->params->get('show_description_image') && $this->category->image) : ?>
		<img src="<?php echo $this->baseurl . $cparams->get('image_path') . '/' . $this->category->image; ?>" class="image_<?php echo $this->category->image_position; ?>" />
		<?php endif; ?>

		<?php if ($this->params->get('show_description') && $this->category->description) :
			echo $this->category->description;
		endif; ?>

		<?php if ($this->params->get('show_description_image') && $this->category->image) : ?>
		<div class="wrap_image">&nbsp;</div>
		<?php endif; ?>

	</div>
	<?php endif; ?>

	<?php $leadingcount=0 ; ?>
    <?php if (!empty($this->lead_items)) : ?>
	<div class="items-leading">	
	
		<?php foreach ($this->lead_items as &$item) : ?>
			<div class="leading leading-<?php echo $leadingcount; ?> clearfix">
				<?php $this->item = &$item;
				echo $this->loadTemplate('item'); ?>
			</div>
			<?php
			$leadingcount++;
			?>
		<?php endforeach; ?>
	</div>
	
	<?php endif; ?>
	  
   <?php
     $introcount=(count($this->intro_items));
     $counter=0;
    ?>
    
	  <?php if (!empty($this->intro_items)) : ?>
	
	<?php 
	
	   if ($introcount) :
		
		if ($this->columns == 0) :
			$this->columns = 1;
		endif;
		$rowcount = ceil ($introcount / $this->columns);
		$ii = $leadingcount;
		for ($y = 0; $y < $rowcount ; $y++) : 
	
			
		?>
			<div class="items-row cols-<?php echo $this->columns; ?> <?php echo 'row-'.$y ; ?> clearfix">
				<?php for ($z = 0; $z < $this->columns && $ii < ($introcount+$leadingcount) ; $z++, $ii++) : ?>
					<div class="item column<?php echo $z; ?>" >
						<?php $this->item =&$this->intro_items[$ii];
						echo $this->loadTemplate('item'); ?>
					</div>
				<?php endfor; ?>
			</div>
		<?php endfor;
	endif; 
	    endif;
	?>

	<?php if (!empty($this->link_items)) : ?>
	<div class="items-more clearfix">
		<?php echo $this->loadTemplate('links'); ?>
	</div>
	<?php endif; ?>

	<?php if ($this->params->def('show_pagination', 2) == 1  || ($this->params->get('show_pagination') == 2 && $this->pagination->get('pages.total') > 1)) : ?>
	<div class="pagination clearfix">
		<?php if( $this->pagination->get('pages.total') > 1 ) : ?>
		<p class="counter">
			<span><?php echo $this->pagination->getPagesCounter(); ?></span>
		</p>
		<?php endif; ?>
		<?php if ($this->params->def('show_pagination_results', 1)) : ?>
			<?php echo $this->pagination->getPagesLinks(); ?>
		<?php endif; ?>
	</div>
	<?php endif; ?>

</div>