<?php
    
	$_productCollection=$this->getLoadedProductCollection();
    $columnCount = themeOptions('column_count');
    $hoverSwap = themeOptions('hover_swap');
    $this->setColumnCount($columnCount);
    $_helper = $this->helper('catalog/output'); 
	
    
?>

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
    <div class="newproducts">
        <div class="carousel">
            <div class="slider">
                <?php $i=0; foreach ($_products->getItems() as $_product): $i++; ?>
                    <div class="item slide <?php if(($i == 4 && $_products->getSize() < 5) || ($i == $_products->getSize()) ) echo 'last'?>"> 
                        <?php include('view/labels.phtml')  ?>    
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>          
                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(210) ?>" width="210" height="210" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
                        <div class="new-description">
                            <h3><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
                            <?php echo $this->getPriceHtml($_product, true) ?>                    
                        
                            <?php if($_product->isSaleable()): ?>
                                <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                            <?php else: ?>
                                <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                            <?php endif; ?>
                            <div style="clear: both;"></div>
                        </div>                    
                    </div>
                <?php endforeach; ?>
            </div>             
        </div>
        <?php if($_products->getSize() > 4): ?>
            <div class="prev new-arrow">&nbsp;</div>
            <div class="next new-arrow">&nbsp;</div>  
        <?php endif; ?>
    </div>     
    <div style="clear: both;"></div>
    <?php if($_products->getSize() > 4): ?>
        <script type="text/javascript">
            jQuery('.new-arrow.prev').addClass('disabled');
            jQuery('.carousel').iosSlider({
                desktopClickDrag: true,
                snapToChildren: true,
                infiniteSlider: false,
                navNextSelector: '.new-arrow.next',
                navPrevSelector: '.new-arrow.prev',
                lastSlideOffset: 3,
                onFirstSlideComplete: function(){
                    jQuery('.new-arrow.prev').addClass('disabled');
                },
                onLastSlideComplete: function(){
                    jQuery('.new-arrow.next').addClass('disabled');
                },
                onSlideChange: function(){
                    jQuery('.new-arrow.prev').removeClass('disabled');
                    jQuery('.new-arrow.next').removeClass('disabled');
                }
            });               
        </script>    
    <?php endif; ?>
<?php endif; ?>
