<?php if( Mage::getStoreConfig('upsellslider/upsellslider_config/enabled') ){ // start enable module ?>
<?php if(count($this->getItemCollection()->getItems())): ?>
    <?php
        $auto = Mage::getStoreConfig('upsellslider/upsellslider_config/auto');
        $width_thumbnail = Mage::getStoreConfig('upsellslider/upsellslider_config/width_thumbnail');
        $height_thumbnail = Mage::getStoreConfig('upsellslider/upsellslider_config/height_thumbnail');
        $item_width = Mage::getStoreConfig('upsellslider/upsellslider_config/item_width');
        $items_show = Mage::getStoreConfig('upsellslider/upsellslider_config/items_show');
        $speed = Mage::getStoreConfig('upsellslider/upsellslider_config/speed');
        $interval = Mage::getStoreConfig('upsellslider/upsellslider_config/interval');
        $nav_ctrl = Mage::getStoreConfig('upsellslider/upsellslider_config/nav_ctrl');
        $next_back = Mage::getStoreConfig('upsellslider/upsellslider_config/next_back');
        $show_price = Mage::getStoreConfig('upsellslider/upsellslider_config/show_price');
        $review = Mage::getStoreConfig('upsellslider/upsellslider_config/review');
		$title = Mage::getStoreConfig('upsellslider/upsellslider_config/title');
    ?>
    <div class="ma-upsellslider-container">
		<?php if($title){?>
			<div class="upsellslider-title"><h2><?php echo $this->__($title) ?></h2></div>
		<?php }?>
			<ul class="bxslider">
            <?php // $this->setColumnCount(5); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
            <?php $this->resetItemsIterator() ?>
            <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
                <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
                    <?php if($_link=$this->getIterableItem()): ?>
                    <li class="ma-upsellslider-item">
						<div class="item-inner">
						<?php
							$newFromDate = Mage::getModel('catalog/product')->load($_link->getID())->getNewsFromDate();
							$newToDate = Mage::getModel('catalog/product')->load($_link->getID())->getNewsToDate();                 
							$now = date("Y-m-d H:m(worry)");
							// Get the Special Price
							$specialprice = Mage::getModel('catalog/product')->load($_link->getId())->getSpecialPrice(); 
							// Get the Special Price FROM date
							$specialPriceFromDate = Mage::getModel('catalog/product')->load($_link->getId())->getSpecialFromDate();
							// Get the Special Price TO date
							$specialPriceToDate = Mage::getModel('catalog/product')->load($_link->getId())->getSpecialToDate();
							// Get Current date
							if(($specialprice&&($specialPriceFromDate <= $now && $specialPriceToDate >= $now)&& Mage::getStoreConfig('themeoptions/themeoptions_config/sale_label')) or ($newFromDate <= $now && $newToDate >= $now && Mage::getStoreConfig('themeoptions/themeoptions_config/new_label') )){
							if($newFromDate <= $now && $newToDate >= $now && Mage::getStoreConfig('themeoptions/themeoptions_config/new_label') ) {
								echo '<div class="label-pro-sale">Hot</div>';
								//echo $now.' -- '.$newsFrom.' -- '.$newsTo;
							   }
							   if ($specialprice&&($specialPriceFromDate <= $now && $specialPriceToDate >= $now)&& Mage::getStoreConfig('themeoptions/themeoptions_config/sale_label')){
								echo '<div class="label-pro-new">New</div>';
							   } 
							  }
						?>
							<div class="images-content products">
								<a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_link->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize($width_thumbnail, $height_thumbnail) ?>" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>
								
							</div>
							<div class="box-item-content">
								<h3 class="product-name"><a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_link->getName()) ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h3>
								<?php echo $this->getReviewsSummaryHtml($_link) ?>
								<?php if( $show_price ): ?>
									<?php echo $this->getPriceHtml($_link, true, '-upsell') ?>
								<?php endif; ?>
								<?php if ($this->getConfig('addtocart')) { ?>
									<?php if($_link->isSaleable()): ?>
										<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_link) ?>')"><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; ?>
								<?php }?>
								
							</div>
						</div>	
                    </li>
                    <?php endif; ?>
                <?php endfor; ?>
            <?php endfor; ?>
            </ul>
    </div>
     <script type="text/javascript">
					$jq(document).ready(function(){
					  $jq('.ma-upsellslider-container .bxslider').bxSlider(
						{
						<?php if($auto) { ?>
						  auto: true,
						<?php } ?>
						  speed: <?php echo $speed; ?>,
						  pause: <?php echo $interval; ?>,			  
						  minSlides: 1,
						  maxSlides: <?php echo $items_show ?>,
						  slideWidth: <?php echo $item_width ?>,
						   slideMargin:30,
						<?php if ($nav_ctrl) { ?>
						  pager: true,
						<?php } else { ?> 
						  pager:false, 
						<?php } ?>
						<?php if ($next_back) { ?>
							controls: true,
						<?php } else { ?>
							controls:false,
						<?php } ?>
						moveSlides:1,
						}
					  );
					});
				</script>
<?php endif ?>
<?php } ?>