<?php
/*------------------------------------------------------------------------
 # Virtuemart Template - CleanMart
 # ------------------------------------------------------------------------
 # Copyright (C) 2009-2014 Flexible Web Design. All Rights Reserved.
 # @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
 # Author: Flexible Web Design
 # Website: http://www.flexiblewebdesign.com
 # Email: info@flexiblewebdesign.com
 -------------------------------------------------------------------------*/
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

include_once dirname(__FILE__) . '/../assets/includes/flexibleMartGlobal.php'; 

$app		=	JFactory::getApplication('site');
$template	=	$app->getTemplate(); 
$FlexibleImagePATH = 'templates/'.$template.'/html/com_virtuemart/assets/images';
$basePriceWitTax = "basePriceWitTax";
$js = "
jQuery(document).ready(function () {
	jQuery('.orderlistcontainer').hover(
		function() { jQuery(this).find('.orderlist').stop().show()},
		function() { jQuery(this).find('.orderlist').stop().hide()}
	)
});
";
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);

$js2 = " 
jQuery(function($) {
		$(document).ready(function(){
			 
			$('#FlexibleSwitchButtons a.".$params->get('category_defaultview','switch_thumb2')."').addClass('switch_active');
 			$('#FlexibleSwitchButtons a').click(function(){
				$('#FlexibleSwitchButtons a').removeClass('switch_active');
				$(this).addClass('switch_active');
					var currentTab = $(this).attr('rel');
				$('#FlexibleBrowseViews .FlexibleBrowseViews').fadeOut(300);
					$(currentTab).delay(301).fadeIn(300);
					return false;
			});
		});  
});


";
$document = JFactory::getDocument();
$document->addScriptDeclaration($js2);
/* Show child categories */
$manufacturerCheck = JRequest::getVar('virtuemart_manufacturer_id');
if (empty($this->keyword)) echo '<div class="category_description">'.$this->category->category_description.'</div>';

if ( VmConfig::get('showCategory',1) and empty($this->keyword) and empty($manufacturerCheck)) {
	if ($this->category->haschildren) {
		// Category and Columns Counter
		$iCol = 1;
		$iCategory = 1;
		// Calculating Categories Per Row
		$categories_per_row = VmConfig::get ( 'categories_per_row', 3 );
		$category_cellwidth = ' width'.floor ( 100 / $categories_per_row );
		// Separator
		$verticalseparator = " vertical-separator";
		?>


<div class="category-view ">
  <?php // Start the Output
		if(!empty($this->category->children)){
		foreach ( $this->category->children as $category ) {

			// Show the horizontal seperator
			if ($iCol == 1 && $iCategory > $categories_per_row) { ?>
  <div class="horizontal-separator"></div>
  <?php }

			// this is an indicator wether a row needs to be opened or not
			if ($iCol == 1) { ?>
  <div class="flexible-row">
    <?php }

			// Show the vertical seperator
			if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
				$show_vertical_separator = ' ';
			} else {
				$show_vertical_separator = $verticalseparator;
			}

			// Category Link
			$caturl = JRoute::_ ( 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id );

				// Show Category ?>
    <div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
      <div class="FWcategorybox"> <a id="FWcategorynameImage"  href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
        <?php // if ($category->ids) {
								echo $category->images[0]->displayMediaThumb("",false);
							//} ?>
        </a> <a id="FWcategorynamelink" href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>"> <?php echo $category->category_name ?> </a> </div>
    </div>
    <?php
			$iCategory ++;

		// Do we need to close the current row now?
		if ($iCol == $categories_per_row) { ?>
    <div class="clear"></div>
  </div>
  <?php
			$iCol = 1;
		} else {
			$iCol ++;
		}
	}
	}
	// Do we need a final closing row tag?
	if ($iCol != 1) { ?>
  <div class="clear"></div>
</div>
<?php } ?>
</div>
<?php }
}

  
?>
<?php if (!$params->get('category_show_percentage',1)) {
	$doc = JFactory::getDocument();
	$doc->addStyleDeclaration('.FlexiblePercentage { display:none;} ');
}
?>
<div class="browse-view">
  <?php 
 // Show child categories
if (!empty($this->products)) {
	
	?>
  <?php // Category and Columns Counter
$iBrowseCol = 1;
$iBrowseProduct = 1;

// Calculating Products Per Row
$BrowseProducts_per_row = $this->perRow;
$Browsecellwidth = ' width'.floor ( 100 / $BrowseProducts_per_row );

// Separator
$verticalseparator = " vertical-separator";
?>
  <div class="categoryTitleTop">
    <?php if ($this->search ==null) { ?>
    <h2 class="FlexibleCategiryTitle floatleft"> <?php echo $this->category->category_name; ?> </h2>
    <?php } else { ?>
    <h2 class="FlexibleCategiryTitle floatleft width55"> <?php echo JText::_('COM_VIRTUEMART_SEARCH') ?>: <?php echo $this->keyword; ?> </h2>
    <?php } ?>
    <?php if ($params->get('category_switch',1)) { ?>
    <div id="FlexibleSwitchButtons" class="width15 floatright">
      <?php if ($params->get('category_disable_multigrid',1)) { ?><a id="switch_buttons" href="javascript:void(0);" class="switch_thumb3" rel="#MultiView"></a><?php } ?>
      <?php if ($params->get('category_disable_grid',1)) { ?><a id="switch_buttons" class="switch_thumb2" href="javascript:void(0);" rel="#GridView"></a><?php } ?>
      <?php if ($params->get('category_disable_list',1)) { ?><a id="switch_buttons" class="switch_thumb1" href="javascript:void(0);" rel="#ListView"></a><?php } ?>
    </div>
    <?php } ?>
    <?php if ($params->get('category_pagination',1)) { ?>
    <div class="orderby-displaynumber width30 floatright">
      <div class="width100 floatright"> <span class="pagedropdown"><?php echo $this->vmPagination->getLimitBox(); ?></span>
        <?php if ($params->get('category_results_counter',1)) { ?>
        <span class="pagedropdownResults"><?php echo $this->vmPagination->getResultsCounter();?></span>
        <?php } ?>
      </div>
    </div>
    <?php } ?>
    <div class="clear"></div>
  </div>
  <div class="orderby-displaynumber header_shadow">
    <div class="width50 floatleft">
      <?php if ($params->get('category_sort_by',1)) { echo $this->orderByList['orderby']; } ?>
      <?php if ($params->get('category_sort_by_manufacturer',1)) { echo $this->orderByList['manufacturer']; } ?>
    </div>
    <div class="clear"></div>
  </div>
  <div id="bottom-pagination"  class="vm-pagination">
    <div class="floatright FlexiblePagination"><?php echo $this->vmPagination->getPagesLinks(); ?></div>
  </div>
  <div class="clear"></div>
  <div id="FlexibleBrowseViews" class="category-default">
   <?php // Start the Output
$BrowseTotalProducts = 0;
$k = 1;	
foreach ( $this->products as $product ) {
   $BrowseTotalProducts ++;
}
?>
<?php if ($params->get('category_disable_list',1)) { ?>
    <div id="ListView" class="FlexibleBrowseViews" <?php 
    	if ($params->get('category_defaultview') == "switch_thumb2" || $params->get('category_defaultview') == "switch_thumb3") { 
			echo 'style="display:none;"';
		} elseif ($params->get('category_defaultview') == "switch_thumb1") {
			echo 'style="display:block;"';
		}
		?>>
     
<?php
$m = 0;
foreach ( $this->products as $product ) {
	$uniqueID = $k++;
	$m++
	// Show Products ?>
      <div class="FWBrowseListContainerOut productdetails-view">
        <div class="FlexibleListBrowseV1ProductNameResponsive"> <?php echo JHTML::link($product->link, $product->product_name, array ('title' => $product->product_name, 'class' => 'FlexibleBrowseProductNameLink'  )); ?> </div>
        <div class="clear"> </div>
        <div class="FlexibleListBrowseV1Picture width25 floatleft uniqueID<?php echo $uniqueID ?>">
          <div class="FlexibleListBrowseV1PictureInner"> <?php echo JHTML::link($product->link, $product->images[0]->displayMediaThumb('class="browseProductImage" id="FlexibleImageParent'. $uniqueID .'"  border="0" title="'.$product->product_name.'" ',false,'')); ?> 
            <!-- START quickLook Code -->
            <div class="FlexibleProductHoverShadow">
              <?php if ($params->get('category_list_quicklook',1)) { ?>
              <div class="FlexibleProductHoverShadowButtons"> <a class="FlexibleProductHoverShadowQUICK font2 flexibleModal" title="<?php echo $product->product_name; ?>" href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&tmpl=component&flexiblelayout=quicklook&virtuemart_category_id=' . $product->virtuemart_category_id);?>"><?php echo JText::_("PLG_FLEXIBLE_QUICKLOOK"); ?></a> </div>
              <?php } ?>
            </div>
            <!-- FINISH quickLook Code --> 
            
          </div>
          <?php if ($params->get('category_list_addpictures',1) and (!empty($product->images[1]))) { ?>
               
          <ul class="FlexibleBrowseAdditionalImages">
            <?php // will load the additional images in the category browse page. 
$i = 0;
foreach ($product->images as $image) {
$ImageId = $i++;
?>
             <li><?php echo $product->images[$ImageId]->displayMediaThumb('class="FlexibleTinyImage" style="max-height:30px; max-width:30px;" rel="FlexibleImageParent'. $uniqueID. '"',false,'',true,false,false,0,0); ?></li>
            <?php } ?>
          </ul>
          <div class="clear"></div>
          <?php }?>
        </div>
        <?php
						// CHECK IF THE PRODUCT IS NEW OR OLD. IF THE PRODUCT WAS CREATED LESS THAN 1 WEEK AGO, IT WILL HAVE "NEW" BADGE.
						$category_new_timeframe = $params->get('category_new','+2 week');(!$basePriceWitTax)?die():'';
						$createddate = strtotime(($product->created_on) . " ".$category_new_timeframe."");  // +1 week can anything you want:  +2 week, +1 month, +24 hour   so on..
						$today = strtotime(date("Y-m-d G:i:s")); //todays date
						if ($createddate > $today) {
							$NEWorOLD = "FlexibleNew";
							} else {
							$NEWorOLD = "";
							}
						if ($product->product_special == 1) {
							$SpecialOrNOT = "FlexibleSpecial";
							} else {
							$SpecialOrNOT = "";
							}
						$DiscountORnot = '';
						if(abs($product->prices['discountAmount'])) {		
							$DiscountORnot = "FlexibleDiscount";
							} else {
							 $DiscountORnot = '';
							}
						
						 
						 ?>
        <div class="FlexibleBadge">
          <?php // Shows "SOLD OUT" badge STARTS. Below lines show the "SOLD OUT" badge in Browse page. "Display stock level" and "Displays 'Notify Me' instead of 'Add To Cart' button" options must be enabled in the VM Configuration ?>
          <span class="<?php if ($params->get('category_discount',1)) { echo $DiscountORnot; } ?>"></span>
          <?php if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')  ){?>
          <?php if ((($product->product_in_stock - $product->product_ordered) < 1) && $params->get('category_soldout',1)) { ?>
          <span class="FlexibleSoldOutBadge"></span>
          <?php }?>
          <?php } // Shows "out of stock" text ENDS?>
          <span class="<?php echo $NEWorOLD; ?>"></span><span class="<?php if ($params->get('category_featured',1)) { echo $SpecialOrNOT;} ?>"></span></div>
        <div class="floatleft width40">
          <div class="FlexibleListViewMiddle">
            <div class="FlexibleListBrowseV1ProductName"> <?php echo JHTML::link($product->link, $product->product_name, array ('title' => $product->product_name, 'class' => 'FlexibleBrowseProductNameLink'  )); ?> </div>
            
			<?php if ($params->get('category_list_manufac',1)) { 
			$db = JFactory::getDbo();
			$query = $db->getQuery(true);
			$query
				->select($db->quoteName('a.file_url'))
				->from($db->quoteName('#__virtuemart_medias', 'a'))
				->join('INNER', $db->quoteName('#__virtuemart_manufacturer_medias', 'b') . ' ON (' . $db->quoteName('b.virtuemart_manufacturer_id') . ' = '. $product->virtuemart_manufacturer_id[0].')')
				->where($db->quoteName('a.virtuemart_media_id') . ' = '.$db->quoteName('b.virtuemart_media_id')); 
			$db->setQuery($query);
			$results = $db->loadRow();
?>
            <div class="FlexibleCategoryManufacturerLogoList"> <a title="<?php echo $product->mf_name; ?>" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $product->virtuemart_manufacturer_id[0]); ?>"><?php echo ($results [0]) ? '<img src="'.JURI::root () . $results [0].'" alt="'.$this->product->mf_name.'" />':$product->mf_name; ?></a> </div>
            <?php } ?>
            <?php // Rating Start
                 	if($this->showRating && $params->get('category_list_ratings',1)){
						echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>'showRating', 'product'=>$product));
					} //End Rating ?>
            <?php if ($params->get('category_list_sku',1)) { ?>
            <div class="FlexibleCategoryProductSKUListView"> <?php echo JTEXT::_('COM_VIRTUEMART_CART_SKU');?>: <?php echo $product->product_sku; ?> </div>
            <?php } ?>
            <?php // Product Short Description
						if(!empty($product->product_s_desc) and $params->get('category_list_shortdesc',1)) { ?>
            <p class="product_s_desc"> <?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 100, '...') ?> </p>
            <?php } ?>
            <div class="FlexibleListBrowseV1ProductDetailsButton">
              <div id="flexibleButton" class="font2">
                <?php // Product Details Button
				if ($params->get('category_list_productdetails',1)) {
					echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'flexibleButton'));
				}
					?>
              </div>
            </div>
          </div>
        </div>
        <div class="FlexibleCategoryProduct width30 floatright">
          <div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
              <?php echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$this->currency)); ?>		  
			</div>
          <?php // Add To Cart Button
				if ($params->get('category_addtocart_list',1)) {
					$customFieldCheck = 1;
					if (!empty($product->customfieldsSorted['addtocart'])) {
						foreach ($product->customfieldsSorted['addtocart'] as $field) {
							if ($field->field_type == "A" || $field->field_type == "E" || $field->field_type == "C") {
							 	$customFieldCheck = 0;		
							}
						}
					}
					
				if (!VmConfig::get('use_as_catalog', 0) and !empty($product->prices['salesPrice']) and ($params->get('category_list_addtocart',1))) {?>
          <div class="FlexibleWebaddtocart-area">
            <form method="post" class="product js-recalculate" action="index.php" >
               <div class="FlexibleCategory-product-fields">
                <?php if ($params->get('category_list_customfield',1) && $customFieldCheck) 
                			echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>'addtocart'));
					?>	
					
              	</div>
              <div class="Flexibleaddtocart-bar">
                <?php // Add the button ?>
                <div class="addtocart-bar">
                  <?php // Display the quantity box

			$stockhandle = VmConfig::get ('stockhandle', 'none');
			if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) {
				?>
                  <a href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?>" class="notify"><?php echo JText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?></a>
                  <?php } else { ?>
                  <?php
				// Display the add to cart button
				?>
                  <div class="FlexibleCSS3Button"> <span class="FlexibleCSS3ButtonInner">
                    <?php if ($customFieldCheck) { ?>
                    <input class="addtocart-button FlexibleCSS3Button-text" type="submit" title="<?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?>" value="<?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?>" name="addtocart" />
                    <?php } else { ?>
                    <a href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id );?>" class="FlexibleCSS3Button-text" title="<?php echo JTEXT::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'); ?>" /><?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?></a>
                    <?php } ?>
                    <span class="FlexibleCSS3Button-symbol"></span> <span class="FlexibleCSS3Button-slide-icon"></span> </span>
                    <?php 
				if ($customFieldCheck) { 
				 if ($params->get('category_list_quantitybox',1)) { ?>
                    <span class="FlexibleCSS3ButtonQuantity"> <span class="quantity-controls js-recalculate FlexibleMinus">
                    <input type="button" class="quantity-controls quantity-minus"/>
                    </span> <span class="quantity-box FlexibleInput">
                   <?php 
$init = 1;
if(isset($viewData['init'])){
	$init = $viewData['init'];
}

if(!empty($product->min_order_level) and $init<$product->min_order_level){
	$init = $product->min_order_level;
}

$step=1;
if (!empty($product->step_order_level)){
	$step=$product->step_order_level;
	if(empty($product->min_order_level) and !isset($viewData['init'])){
		$init = $step;
	}
}

$maxOrder= '';
if (!empty($product->max_order_level)){
	$maxOrder = ' max="'.$product->max_order_level.'" ';
}

				 
				 ?>
				<input type="text" class="quantity-input js-recalculate" name="quantity[]"
					   onblur="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   onclick="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   onchange="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   onsubmit="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   value="<?php echo $init; ?>" init="<?php echo $init; ?>" step="<?php echo $step; ?>" <?php echo $maxOrder; ?> />
                    </span> <span class="quantity-controls js-recalculate FlexiblePlus">
                    <input type="button" class="quantity-controls quantity-plus"/>
                    </span> </span>
                    <?php } else { ?>
                    <input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="1"/>
                    <?php } 
				  } else { ?>
                    <span class="FlexibleCSS3ButtonQuantity ChooseProductVariant"> <?php echo JTEXT::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'); ?> </span>
                    <?php } ?>
                  </div>
                  <?php // Display the add to cart button END ?>
                  <input type="hidden" name="option" value="com_virtuemart"/>
                  <input type="hidden" name="view" value="cart"/>
                  <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>"/>
                  <input type="hidden" class="pname" value="<?php echo htmlentities($product->product_name, ENT_QUOTES, 'utf-8') ?>"/>
                  <?php
			$itemId=vRequest::getInt('Itemid',false);
			if($itemId){
				echo '<input type="hidden" name="Itemid" value="'.$itemId.'"/>';
			} ?>
                  <?php } ?>
                  <div class="clear"></div>
                </div>
                <div class="clear"></div>
              </div>
            </form>
          </div>
          <?php } }  // Add To Cart Button END ?>
        </div>
        <div class="clear"></div>
        <div class="image-shadow2"></div>
      </div>
      <?php	 
}
// Do we need a final closing row tag?
 ?>
    </div>
<?php } ?>
<?php if ($params->get('category_disable_grid',1)) { ?>
    <div id="GridView" class="FlexibleBrowseViews default" <?php 
    	if ($params->get('category_defaultview') == "switch_thumb1" || $params->get('category_defaultview') == "switch_thumb3") { 
			echo 'style="display:none;"';
		} elseif ($params->get('category_defaultview') == "switch_thumb2") {
			echo 'style="display:block;"';
		}
		?>>
      <?php // Start the Output
$m = 0;
foreach ( $this->products as $product ) {
	$uniqueID = $k++;
	$m++;
	// Show the horizontal seperator
	if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
      <?php }
	// this is an indicator wether a row needs to be opened or not
	if ($iBrowseCol == 1) { ?>
      <div class="flexible-row">
        <?php }
	// Show the vertical seperator
	if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
		$show_vertical_separator = ' ';
	} else {
		$show_vertical_separator = $verticalseparator;
	} // Show Products 


	
	?>
        <div id="FlexibleBrowseThumbRow" class="Number<?php echo $m;?> floatleft<?php echo $Browsecellwidth ?>" style="position:relative;">
          <div class="FlexibleBrowseThumbProductInner">
            <div class="FlexibleHover2 effect10 uniqueID<?php echo $uniqueID ?>">
              <div class="figure"> <?php echo JHTML::link($product->link, $product->images[0]->displayMediaThumb('class="browseProductImage" id="FlexibleImageParent'. $uniqueID .'"  border="0" title="'.$product->product_name.'" ',false,'')); ?> 
                <!-- START quickLook Code -->
                <div class="figcaption">
                  <?php // Add to Cart button, starts 
	// if ($params->get('category_grid_tinyaddtocart',1) and (!VmConfig::get('use_as_catalog', 0)) and (empty($product->customfieldsCart)) and !empty($product->prices['salesPrice'])) {
		 ?>
                  <div class="Flexibleaddtocart-bar">
                    <?php // Add the button ?>
                    <form method="post" class="product" action="index.php">
                      <div class="addtocart-bar">
                        <?php // Display the quantity box
				  
			 
					if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and  !$product->images[0]->file_is_downloadable) { //price is or not check-START
                    $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id.'&tmpl=component');
                     ?>
                        <a class="FlexibleAskforPrice flexibleModal" style="display:block !important;" href="<?php echo $url ?>"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ASKPRICE') ?></a>
                        <?php } //price is or not check-END 
				  
			if ($params->get('category_grid_addtocart',1) and (!$product->prices['salesPrice']<=0)) {
			$stockhandle = VmConfig::get ('stockhandle', 'none');
			if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) {
				?>
                        <a href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?>" class="notify" style="display:block !important;"><?php echo JText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?></a>
                        <?php } else { ?>
                        <?php
				// Display the add to cart button
				?>
                        <div class="FlexibleCSS3Button" style="width:100%;"> <span class="FlexibleCSS3ButtonInner">
                          <?php
						    if (empty($product->customfieldsSorted['addtocart'])) {	 ?>
                          <input class="addtocart-button FlexibleCSS3Button-text" type="submit" title="<?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?>" value="<?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?>" name="addtocart" />
                          <?php } else { ?>
                          <a href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id );?>" class="FlexibleCSS3Button-text" title="<?php echo JTEXT::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'); ?>" /><?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?></a>
                          <?php } ?>
                          <span class="FlexibleCSS3Button-symbol"></span> <span class="FlexibleCSS3Button-slide-icon"></span> </span>
                          <?php 
				  if (empty($product->customfieldsSorted['addtocart'])) {	
				 	if ($params->get('category_grid_quantitybox',1)) { ?>
                          <span class="FlexibleCSS3ButtonQuantity"> <span class="quantity-controls js-recalculate FlexibleMinus">
                          <input type="button" class="quantity-controls quantity-minus"/>
                          </span> <span class="quantity-box FlexibleInput">
                          <?php 
$init = 1;
if(isset($viewData['init'])){
	$init = $viewData['init'];
}

if(!empty($product->min_order_level) and $init<$product->min_order_level){
	$init = $product->min_order_level;
}

$step=1;
if (!empty($product->step_order_level)){
	$step=$product->step_order_level;
	if(empty($product->min_order_level) and !isset($viewData['init'])){
		$init = $step;
	}
}

$maxOrder= '';
if (!empty($product->max_order_level)){
	$maxOrder = ' max="'.$product->max_order_level.'" ';
}

				 
				 ?>
				<input type="text" class="quantity-input js-recalculate" name="quantity[]"
					   onblur="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   onclick="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   onchange="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   onsubmit="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::_ ('COM_VIRTUEMART_WRONG_AMOUNT_ADDED')?>');"
					   value="<?php echo $init; ?>" init="<?php echo $init; ?>" step="<?php echo $step; ?>" <?php echo $maxOrder; ?> />
                          </span> <span class="quantity-controls js-recalculate FlexiblePlus">
                          <input type="button" class="quantity-controls quantity-plus"/>
                          </span> </span>
                          <?php } else { ?>
                          <input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="1"/>
                          <?php } 
				  } else { ?>
                          <span class="FlexibleCSS3ButtonQuantity ChooseProductVariant"> <?php echo JTEXT::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'); ?> </span>
                          <?php } ?>
                        </div>
                        <?php // Display the add to cart button END ?>
                        <input type="hidden" name="option" value="com_virtuemart"/>
                        <input type="hidden" name="view" value="cart"/>
                        <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>"/>
                        <input type="hidden" class="pname" value="<?php echo htmlentities($product->product_name, ENT_QUOTES, 'utf-8') ?>"/>
                        <?php
			$itemId=vRequest::getInt('Itemid',false);
			if($itemId){
				echo '<input type="hidden" name="Itemid" value="'.$itemId.'"/>';
			} ?>
                        <?php 
				  } 
				} 
			?>
                        <div class="clear"></div>
                      </div>
                    </form>
                    <div class="clear"></div>
                  </div>
                </div>
                <?php if (!($params->get('category_grid_quicklook',1) || $params->get('category_grid_moreinfo',1) || $params->get('category_grid_tinyaddtocart',1))) {	 ?>
                <style type="text/css">
				  		#FlexibleBrowseViews .effect15 .figure:hover .figcaption {
							height: 100%;
						}
				  </style>
                <?php } ?>
                <!-- FINISH quickLook Code --> 
                
              </div>
              <div class="FlexibleBrowseThumbProductLower">
                <div class="clear"></div>
                <?php if ($params->get('category_grid_quicklook',1)) { ?>
                <a class="FlexibleQUICKLook flexibleModal" title="<?php echo $product->product_name; ?>" href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&tmpl=component&flexiblelayout=quicklook&virtuemart_category_id=' . $product->virtuemart_category_id);?>"
                    <?php if (!empty($product->customfieldsCart) || empty($product->prices['salesPrice']) || (($product->product_in_stock - $product->product_ordered) < 1)) {	 ?>
                    	style="width:auto;float:none;"
                        <?php } ?>
                     ><?php echo JText::_("PLG_FLEXIBLE_QUICKLOOK"); ?></a>
                <?php } ?>
                 <!-- The "Average Customer Rating" Part STARTS -->
                <?php 
                 	if($this->showRating && $params->get('category_grid_ratings',1)){
					echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>'showRating', 'product'=>$product));
					} ?>
                <!-- The "Average Customer Rating" Part ENDS -->
                <div class="clerfix"></div>
                <?php if ($params->get('category_grid_sku',1)) { ?>
                <div class="FlexibleCategoryProductSKUGridView"> <?php echo JTEXT::_('COM_VIRTUEMART_CART_SKU');?>: <?php echo $product->product_sku; ?> </div>
                <?php } ?>
               
                
                <div class="clear"></div>
                
                <!-- START NEW, ON Sale Bade Code -->
                <?php
						// CHECK IF THE PRODUCT IS NEW OR OLD. IF THE PRODUCT WAS CREATED LESS THAN 1 WEEK AGO, IT WILL HAVE "NEW" BADGE.
						$category_new_timeframe = $params->get('category_new','+2 week');
						$createddate = strtotime(($product->created_on) . " ".$category_new_timeframe.""); // +1 week can anything you want:  +2 week, +1 month, +24 hour   so on..
						$today = strtotime(date("Y-m-d G:i:s")); //todays date
						if ($createddate > $today) {
							$NEWorOLD = "FlexibleNew";
							} else {
							$NEWorOLD = "";
							}
						if ($product->product_special == 1) {
							$SpecialOrNOT = "FlexibleSpecial";
							} else {
							$SpecialOrNOT = "";
							}
						$DiscountORnot = '';
						if(abs($product->prices['discountAmount'])) {		
							$DiscountORnot = "FlexibleDiscount";
							} else {
							 $DiscountORnot = '';
							}
						
						 ?>
                <div class="FlexibleBadge">
                  <?php // Shows "SOLD OUT" badge STARTS. Below lines show the "SOLD OUT" badge in Browse page. "Display stock level" and "Displays 'Notify Me' instead of 'Add To Cart' button" options must be enabled in the VM Configuration ?>
                  <span class="<?php if ($params->get('category_discount',1)) { echo $DiscountORnot; } ?>"></span>
                  <?php	if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')  ){?>
                  <?php if ((($product->product_in_stock - $product->product_ordered) < 1) && $params->get('category_soldout',1)) { ?>
                  <span class="FlexibleSoldOutBadge"></span>
                  <?php }?>
                  <?php } // Shows "out of stock" text ENDS?>
                  <span class="<?php echo $NEWorOLD; ?>"></span><span class="<?php if ($params->get('category_featured',1)) { echo $SpecialOrNOT;} ?>"></span></div>
                <!-- FINICH NEW, ON Sale Bade Code -->
                
            <?php if ($params->get('category_grid_manufac',1)) { 
			$db = JFactory::getDbo();
			$query = $db->getQuery(true);
			$query
				->select($db->quoteName('a.file_url'))
				->from($db->quoteName('#__virtuemart_medias', 'a'))
				->join('INNER', $db->quoteName('#__virtuemart_manufacturer_medias', 'b') . ' ON (' . $db->quoteName('b.virtuemart_manufacturer_id') . ' = '. $product->virtuemart_manufacturer_id[0].')')
				->where($db->quoteName('a.virtuemart_media_id') . ' = '.$db->quoteName('b.virtuemart_media_id')); 
			$db->setQuery($query);
			$results = $db->loadRow();
?>
            <div class="FlexibleCategoryManufacturerLogoGrid"> <a title="<?php echo $product->mf_name; ?>" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $product->virtuemart_manufacturer_id[0]); ?>"><?php echo ($results [0]) ? '<img src="'.JURI::root () . $results [0].'" alt="'.$this->product->mf_name.'" />':$product->mf_name; ?></a> </div>
            <?php } ?>
                <div class="FlexibleBrowseProductName"> <?php echo JHTML::link($product->link, $product->product_name, array ('title' => $product->product_name, 'class' => 'FlexibleBrowseProductNameLink'  )); ?> </div>
                <div class="product-price marginbottom12 noAskQuestion" id="productPrice<?php echo $product->virtuemart_product_id ?>">
              		<?php echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$this->currency)); ?>		  
				</div>
                <div style="clear:both"></div>
                <?php if ($params->get('category_grid_addpictures',1) and (!empty($product->images[1]))) {  ?>
                <ul class="FlexibleBrowseAdditionalImages">
                  <?php // will load the additional images in the category browse page. 
$i = 0;
foreach ($product->images as $image) {
$ImageId = $i++;
?>
                  
                   <li><?php echo $product->images[$ImageId]->displayMediaThumb('class="FlexibleTinyImage" style="max-height:30px; max-width:30px;" rel="FlexibleImageParent'. $uniqueID. '"',false,'',true,false,false,0,0); ?></li>
                  <?php } ?>
                </ul>
                <?php }?>
                <div class="clearfix"></div>
              </div>
            </div>
            <!-- end of flexibleWebOut --> 
          </div>
        </div>
        <!-- end of product -->
        <?php
   // Do we need to close the current row now?
   if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {?>
        <div class="clear"></div>
      </div>
      <!-- end of row -->
      <?php
      $iBrowseCol = 1;
   } else {
      $iBrowseCol ++;
   }
   $iBrowseProduct ++;
} // end of foreach ( $this->products as $product )
// Do we need a final closing row tag?
if ($iBrowseCol != 1) { ?>
      <div class="clear"></div>
    </div>
    <?php
}
?>
  </div>
<?php } ?>
<?php if ($params->get('category_disable_multigrid',1)) { ?>
  <div id="MultiView" class="FlexibleBrowseViews default" <?php 
    	if ($params->get('category_defaultview') == "switch_thumb1" || $params->get('category_defaultview') == "switch_thumb2") { 
			echo 'style="display:none;"';
		} elseif ($params->get('category_defaultview') == "switch_thumb3") {
			echo 'style="display:block;"';
		}
		?>>
    <?php // Start the Output
$this->perRow = $this->perRow + 1;
$BrowseProducts_per_row = $this->perRow;
$Browsecellwidth = ' width'.floor ( 100 / $BrowseProducts_per_row );
$m = 0;
foreach ( $this->products as $product ) {
	$uniqueID = $k++;
	$m++;
	// Show the horizontal seperator
	if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
    <?php }

	// this is an indicator wether a row needs to be opened or not
	if ($iBrowseCol == 1) { ?>
    <div class="flexible-row">
      <?php }
	// Show the vertical seperator
	if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
		$show_vertical_separator = ' ';
	} else {
		$show_vertical_separator = $verticalseparator;
	} // Show Products 


	
	?>
      <div id="FlexibleBrowseThumbRow" class="Number<?php echo $m;?> floatleft<?php echo $Browsecellwidth ?>" style="position:relative;">
        <div class="FlexibleBrowseThumbProductInner">
          <div class="FlexibleBrowseThumbProductInner2 uniqueID<?php echo $uniqueID ?>">
            <div class="FlexibleThumbBrowseV1Pic"> <?php echo JHTML::link($product->link, $product->images[0]->displayMediaThumb('class="browseProductImage" id="FlexibleImageParent'. $uniqueID .'"  border="0" title="'.$product->product_name.'" ',false,'')); ?> 
              <?php if ($params->get('category_multi_addpictures',1) and (!empty($product->images[1]))) {  ?>
            <ul class="FlexibleBrowseAdditionalImages">
              <?php // will load the additional images in the category browse page. 
					$i = 0;
					foreach ($product->images as $image) {
					$ImageId = $i++;
					?>
				<li><?php echo $product->images[$ImageId]->displayMediaThumb('class="FlexibleTinyImage" style="max-height:30px; max-width:30px;" rel="FlexibleImageParent'. $uniqueID. '"',false,'',true,false,false,0,0); ?></li>
              <?php } ?>
            </ul>
            <?php }?>
              <!-- START quickLook Code -->
              <div class="FlexibleProductHoverShadow">
                <?php if ($params->get('category_multi_quicklook',1) || $params->get('category_multi_moreinfo',1) || $params->get('category_multi_tinyaddtocart',1)) {	 ?>
                <div class="FlexibleProductHoverShadowButtons">
                  <?php // Add to Cart button, starts  
			 
				if ((!VmConfig::get('use_as_catalog', 0)) and !empty($product->prices['salesPrice']) and ($params->get('category_multi_tinyaddtocart',1))) {
			$stockhandle = VmConfig::get ('stockhandle', 'none');
			if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) {
				$button_lbl = JText::_ ('COM_VIRTUEMART_CART_NOTIFY');
				$button_cls = 'notify-button';
				$button_name = 'notifycustomer';
				?>
                  <div class="QuicBuyNotifyMe">
                    <?php 
				if (empty($product->prices['salesPrice']) and VmConfig::get('askprice', 1))  { //price is or not check-START
                   $urlNotifyOrAskQuestion = JRoute::_('index.php?option=com_virtuemart&tmpl=component&view=productdetails&task=askquestion&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id.'');
				    } else {
					$urlNotifyOrAskQuestion = JRoute::_ ('index.php?option=com_virtuemart&tmpl=component&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id);
					}//price is or not check-END ? = >
			?>
                    <a href="<?php echo $urlNotifyOrAskQuestion; ?>" class="notify QuicBuyNotifyMeA flexibleModal" title="<?php echo JText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?>"></a> </div>
                  <?php } else { 
				  		 if (empty($product->customfieldsSorted['addtocart'])) { ?>
                  <div class="addtocart-area">
                    <form method="post" class="product" action="index.php">
                      <div class="addtocart-bar">
                        <input type="hidden" class="quantity-input" name="quantity[]" value="1"/>
                        <?php
						// Add the button
						$button_lbl = '';
						$button_cls = ''; //$button_cls = 'addtocart_button';
						?>
                        <?php // Display the add to cart button ?>
                        <span class="addtocart-button">
                        <input class="addtocart-button" type="submit" title="<?php echo JTEXT::_('COM_VIRTUEMART_CART_ADD_TO');?>" value="" name="addtocart">
                        </span> </div>
                      <input type="hidden" name="option" value="com_virtuemart"/>
                      <input type="hidden" name="view" value="cart"/>
                      <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>"/>
                      <input type="hidden" class="pname" value="<?php echo htmlentities($product->product_name, ENT_QUOTES, 'utf-8') ?>"/>
                      <?php
                      $itemId=vRequest::getInt('Itemid',false);
                      if($itemId){
                          echo '<input type="hidden" name="Itemid" value="'.$itemId.'"/>';
                      } ?>
                    </form>
                  </div>
                  <?php } else { ?>
                  <a href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id );?>" class="addtocart-button-CartVariant" title="<?php echo JTEXT::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT'); ?>"> </a>
                  <?php } 
				  			} 
								} // Add to cart button ends ?>
                  <?php if ($params->get('category_multi_quicklook',1)) { ?>
                  <a class="FlexibleProductHoverShadowQUICK font2 flexibleModal" title="<?php echo $product->product_name; ?>" href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&tmpl=component&flexiblelayout=quicklook&virtuemart_category_id=' . $product->virtuemart_category_id);?>" <?php if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) { ?>style="width:auto;float:none;"<?php } ?>><?php echo JText::_("PLG_FLEXIBLE_QUICKLOOK"); ?></a>
                  <?php } ?>
                  <div class="clear"></div>
                  <?php if ($params->get('category_multi_moreinfo',1)) { ?>
                  <a class="FlexibleProductHoverShadowInfoLink font2" title="<?php echo $product->product_name; ?>" href="<?PHP echo JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id );?>"><?php echo JText::_("PLG_FLEXIBLE_MORE_INFO"); ?></a>
                  <?php } ?>
                </div>
                <?php } ?>
              </div>
              <?php if ($params->get('category_multi_quicklook',1) && !$params->get('category_multi_tinyaddtocart',1)) {	 ?>
              <style type="text/css">
				  		#MultiView div.FlexibleProductHoverShadowButtons .FlexibleProductHoverShadowQUICK {
							width: 116px;
						}
				  </style>
              <?php } ?>
              
              <!-- FINISH quickLook Code --> 
              
              <!-- START NEW, ON Sale Bade Code -->
              <?php
						// CHECK IF THE PRODUCT IS NEW OR OLD. IF THE PRODUCT WAS CREATED LESS THAN 1 WEEK AGO, IT WILL HAVE "NEW" BADGE.
						$category_new_timeframe = $params->get('category_new','+2 week');
						$createddate = strtotime(($product->created_on) . " ".$category_new_timeframe.""); // +1 week can anything you want:  +2 week, +1 month, +24 hour   so on..
						$today = strtotime(date("Y-m-d G:i:s")); //todays date
						if ($createddate > $today) {
							$NEWorOLD = "FlexibleNew";
							} else {
							$NEWorOLD = "";
							}
						if ($product->product_special == 1) {
							$SpecialOrNOT = "FlexibleSpecial";
							} else {
							$SpecialOrNOT = "";
							}
						$DiscountORnot = '';
						if(abs($product->prices['discountAmount'])) {		
							$DiscountORnot = "FlexibleDiscount";
							} else {
							 $DiscountORnot = '';
							}
						
						 ?>
              <div class="FlexibleBadge">
                <?php // Shows "SOLD OUT" badge STARTS. Below lines show the "SOLD OUT" badge in Browse page. "Display stock level" and "Displays 'Notify Me' instead of 'Add To Cart' button" options must be enabled in the VM Configuration ?>
                <span class="<?php if ($params->get('category_discount',1)) { echo $DiscountORnot; } ?>"></span>
                <?php	if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')  ){?>
                <?php if ((($product->product_in_stock - $product->product_ordered) < 1) && $params->get('category_soldout',1)) { ?>
                <span class="FlexibleSoldOutBadge"></span>
                <?php }?>
                <?php } // Shows "out of stock" text ENDS?>
                <span class="<?php echo $NEWorOLD; ?>"></span><span class="<?php if ($params->get('category_featured',1)) { echo $SpecialOrNOT;} ?>"></span></div>
              <!-- FINICH NEW, ON Sale Bade Code --> 
              
            </div>
            
            <div class="clear"></div>
            <?php if ($params->get('category_multi_manufac',1)) { 
			$db = JFactory::getDbo();
			$query = $db->getQuery(true);
			$query
				->select($db->quoteName('a.file_url'))
				->from($db->quoteName('#__virtuemart_medias', 'a'))
				->join('INNER', $db->quoteName('#__virtuemart_manufacturer_medias', 'b') . ' ON (' . $db->quoteName('b.virtuemart_manufacturer_id') . ' = '. $product->virtuemart_manufacturer_id[0].')')
				->where($db->quoteName('a.virtuemart_media_id') . ' = '.$db->quoteName('b.virtuemart_media_id')); 
			$db->setQuery($query);
			$results = $db->loadRow();
?>
            <div class="FlexibleCategoryManufacturerLogoGrid"> <a title="<?php echo $product->mf_name; ?>" href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $product->virtuemart_manufacturer_id[0]); ?>"><?php echo ($results [0]) ? '<img src="'.JURI::root () . $results [0].'" alt="'.$this->product->mf_name.'" />':$product->mf_name; ?></a> </div>
            <?php } ?>
            <!-- The "Average Customer Rating" Part STARTS -->
            <?php 
                 	if($this->showRating && $params->get('category_multi_ratings',1)){
						echo shopFunctionsF::renderVmSubLayout('rating',array('showRating'=>'showRating', 'product'=>$product));
					} ?>
            <!-- The "Average Customer Rating" Part ENDS -->
            <?php if ($params->get('category_multi_sku',1)) { ?>
            <div class="FlexibleCategoryProductSKUGridView"> <?php echo JTEXT::_('COM_VIRTUEMART_CART_SKU');?>: <?php echo $product->product_sku; ?> </div>
            <?php } ?>
            <div class="FlexibleBrowseProductName"> <?php echo JHTML::link($product->link, $product->product_name, array ('title' => $product->product_name, 'class' => 'FlexibleBrowseProductNameLink'  )); ?> </div>
            <div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
              		<?php echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$product,'currency'=>$this->currency)); ?>		  
			</div>
            <div style="clear:both"></div>
          </div>
          <!-- end of flexibleWebOut --> 
        </div>
      </div>
      <!-- end of product -->
      <?php
   // Do we need to close the current row now?
   if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {?>
      <div class="clear"></div>
    </div>
    <!-- end of row -->
    <?php
      $iBrowseCol = 1;
   } else {
      $iBrowseCol ++;
   }
   $iBrowseProduct ++;
} // end of foreach ( $this->products as $product )
// Do we need a final closing row tag?
if ($iBrowseCol != 1) { ?>
    <div class="clear"></div>
  </div>
  <?php
}
?>
</div>
<?php } ?>
</div>
<div class="clear"></div>
<Br/>
<?php if ($params->get('category_pagination_bottom',1)) { ?>
<div id="bottom-pagination"  class="vm-pagination"><?php echo $this->vmPagination->getPagesLinks(); ?> <br/>
  <?php if ($params->get('category_results_counter',1)) { ?>
  <span><?php echo $this->vmPagination->getPagesCounter(); ?></span>
  <?php } ?>
</div>
<?php } ?>
<?php
} elseif (!empty($this->search)) {
	echo "<h2 class='FlexibleCategiryTitle floatleft width60'>".JText::_('COM_VIRTUEMART_SEARCH')."</h2><br/><br/>".JText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : <strong>' . $this->keyword . '</strong>' : '')."<br/><br/>";
} else {
	/*
	# Text to show in case the category is empty. 
	# for language translation -- create language INI rule, like this: COM_VIRTUEMART_EMPTY_CATEGORY="No product to display"
	*/
	
	// Language Translation  (uncomment the below line)
	//echo '<h5 style="margin: 50px 0;text-align: center;">'.JText::_('COM_VIRTUEMART_EMPTY_CATEGORY') .'</h5>'; 
	
	//Static Text (uncomment the below line)
	//echo '<h5 style="margin: 50px 0;text-align: center;">No product to display</h5>';
}
?>
</div>
