	<?php
		function cut_string4($string,$number){
			if(strlen($string) <= $number) {
				return $string;
			}
			else {	
				if(strpos($string," ",$number) > $number){
					$new_space = strpos($string," ",$number);
					$new_string = substr($string,0,$new_space)."..";
					return $new_string;
				}
				$new_string = substr($string,0,$number)."..";
				return $new_string;
			}
		}
	?>
<?php if($this->getConfig('enabled')){ // start enable module?> 
	<?php $this->getProducts() ?>
	<?php $_productCollection=$this->getProductCollection() ?>
	<div class="ma-mosview-products">  <!-- start mt products list -->
		<?php if($this->getConfig('title')){?>
			<div class="ma-title"><h2><?php echo $this->getConfig('title')?></h2></div>
		<?php }?>
		<?php if(!$_productCollection->count()): ?> <!-- start if exist product -->
			<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
		<?php else: ?>
			<div class="category-products">
			    <?php $_collectionSize = $_productCollection->count() ?>
			    <?php if( !$this->getConfig('items') ) { $_columnCount = 1 ; } else { $_columnCount = $this->getConfig('items'); }?>
			    <?php $i=0; foreach ($_productCollection as $_product): ?>
			        <?php if ( $i++ % $_columnCount==0): ?>
			        <ul class="products-grid row<?php if( $i == 1 ) echo ' first';?>">
			        <?php endif ?>
			        	<?php 
			        		if ( !$this->getConfig('width') ){
			        			$w=135;
			        		} else {
			        			$w = $this->getConfig('width');
			        		}
			        		if( !$this->getConfig('height') ){
			        			$h=135;
							 }
			        		else {
			        			$h = $this->getConfig('height');
			        		}
			        	?>
			            <li class="item col-md-4 col-sm-4 col-sms-12<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
							<div class="item-inner">
							<div class="left-products">
								<div class="products">
									<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
										<span class="product-image">
											<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(120,120); ?>" width="120" height="120" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
										</span>
										<span class="product-image image-rotator">
											<?php 
											$product = Mage::getModel('catalog/product')->load($_product->getId());
											if ($product->getRotatorImage() && $product->getRotatorImage() !='no_selection') {
												//$imageTooltipResize = $this->getResizedUrl($imagetTooltip,600,400);
												$image = Mage::helper('catalog/image')->init($product, 'rotator_image')->resize(120, 120);
											} else {
												$image = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(120, 120);
											}
											?>
											<img src="<?php echo $image ?>" width="120" height="120" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
										 </span>			
									</a>
								</div>
							</div>
								<div class="products-des">		
									<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; ?>
									<?php echo $this->getPriceHtml($_product, true) ?>
									<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) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
												<?php endif; ?>
												<?php } ?>
												<?php if( $this->getConfig('addtocompare') ){?>
												<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
													<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
												<?php endif; ?>
												<?php }?>
											</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_string4($this->htmlEscape($_product->getShortDescription()),$this->getConfig('maxlength'))) ?>			            
										<?php }?>			                    
									</div>
									<?php }?>
								</div>
							</div>
			            </li>
			        <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
			        </ul>
		        <?php endif ?> <!--  -->
		        <?php endforeach ?>
		        <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>			
			</div>		
		<?php endif; ?> <!-- end exist product -->
	</div> <!-- end products list -->
<?php } ?>


