<?php if($this->getConfig('enabled')){ // start enable module?>
	<?php $this->getProducts() ?>
	<?php $_productCollection=$this->getProductCollection() ?>
	<div class="ma-featuredproductslider-container">
		<?php				
			if ( !$this->getConfig('width_thumbnail') ){
				$w_thumbnail = 135;
			} else {
				$w_thumbnail = $this->getConfig('width_thumbnail');
			}
			if( !$this->getConfig('height_thumbnail') ){
				$h_thumbnail = 135;
			 }
			else {
				$h_thumbnail = $this->getConfig('height_thumbnail');
			}
		?>
		<?php if($this->getConfig('title')){?>
			<div class="ma-bestseller-sldier-title"><h2><?php echo $this->getConfig('title')?></h2></div>
		<?php }?>
		<?php if(!$_productCollection->count()): ?> 
			<div class="ma-bestseller-slider">	
				<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
			</div>
		<?php else: ?>
				<ul class="bxslider">
					<?php $_collectionSize = $_productCollection->count() ?>
					<?php $i=0; foreach ($_productCollection as $_product): ?>
						<li class="featuredproductslider-item">
						
						<div class="item-container">
								<div class="top-item">
									<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h2>
									<?php if($this->getConfig('review')): ?>
									    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
									<?php endif; ?>
								</div>
								<div class="item-inner">
									<?php
		$newFromDate = Mage::getModel('catalog/product')->load($_product->getID())->getNewsFromDate();
		$newToDate = Mage::getModel('catalog/product')->load($_product->getID())->getNewsToDate();                 
		$now = date("Y-m-d H:m(worry)");
		// Get the Special Price
		$specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice(); 
		// Get the Special Price FROM date
		$specialPriceFromDate = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialFromDate();
		// Get the Special Price TO date
		$specialPriceToDate = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialToDate();
		// Get Current date
		if ($specialprice&&($specialPriceFromDate <= $now && $specialPriceToDate >= $now)&& Mage::getStoreConfig('themeoptions/themeoptions_config/sale_label')){
			echo "<span class='sale'></span>";
			}else{
			if($newFromDate <= $now && $newToDate >= $now && Mage::getStoreConfig('themeoptions/themeoptions_config/new_label') ) {
				echo "<span class='new'></span>";
				//echo $now.' -- '.$newsFrom.' -- '.$newsTo;
			}
		}
	?>
								<a class="quickview-button" rel="<?php echo (int) $_product->getId() ?>" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->__('Details') ?>">
									<?php echo $this->__('details') ?>
								</a>
								<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($w_thumbnail, $h_thumbnail); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>
					
								<div class="price-container">
									<?php if( $this->getConfig('show_price') ): ?>
										<?php echo $this->getPriceHtml($_product, true) ?>
									<?php endif; ?>
								</div>
								
								<div class="actions">
								    <?php if ($this->getConfig('addtocart')) { ?>
									<?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; ?>
								    <?php }?>
								    <?php if( $this->getConfig('addtowishlist') || $this->getConfig('addtocompare') ){?>
									<ul class="add-to-links">
									    <?php if( $this->getConfig('addtowishlist')): ?>
										<?php if ($this->helper('wishlist')->isAllow()) : ?>
										    <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" title="<?php echo $this->__('Add to Wishlist') ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
										<?php endif; ?>
									    <?php endif; ?>
									    <?php if( $this->getConfig('addtocompare')): ?>
										<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
										    <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" title="<?php echo $this->__('Add to Compare') ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
										<?php endif; ?>
									    <?php endif; ?>
									</ul>
								    <?php }?>
								</div>
								<?php if( $this->getConfig('description')){?>
								    <div class="ma-desc">
									<?php if(!$this->getConfig('maxlength')){?>
									    <?php echo nl2br($this->htmlEscape($_product->getShortDescription())) ?>
									<?php } else {?>
									    <?php echo nl2br(cut_string_featuredproductslider($this->htmlEscape($_product->getShortDescription()),$this->getConfig('maxlength'))) ?>			            
									<?php }?>			                    
								    </div>
								<?php }?>
									    <?php $i++;?>	
								</div>
							</div>
						</li>                    
					<?php endforeach; ?>
				</ul>

<script type="text/javascript">
	$jq(document).ready(function(){
	  $jq('.bxslider').bxSlider(
		{
		<?php if($this->getConfig('auto')) { ?>
		  auto: true,
		<?php } ?>
		  speed: <?php echo $this->getConfig('speed') ?>,
		  pause: <?php echo $this->getConfig('interval') ?>,			  
		  minSlides: 2,
		  maxSlides: <?php echo $this->getConfig('items_show') ?>,
		  slideWidth: <?php echo $this->getConfig('item_width') ?>,
		  slideMargin: 5,
		<?php if ($this->getConfig('nav_ctrl')) { ?>
		  pager: true,
		<?php } else { ?> 
		  pager:false, 
		<?php } ?>
		<?php if ($this->getConfig('next_back')) { ?>
			controls: true,
		<?php } else { ?>
		    controls:false,
		<?php } ?>
		      infiniteLoop: false
		}
	  );
	});
</script>
			
		<?php endif; ?>
	</div> 
<?php } ?>


