
<?php
/**
 * Product list toolbar
 *
 * @see Mage_Catalog_Block_Product_List_Toolbar
 */
?>
<?php
$storeId = Mage::app()->getStore()->getId(); // return current store id //echo Mage::app()->getRequest()->getParam('order');exit;
$list_check_String=Mage::getStoreConfig('catalog/frontend/list_per_page_values',$storeId);
$list_array = explode(",",$list_check_String);
$flag_list_status = in_array($_GET['limit'],$list_array);
?>
<?php if($this->getCollection()->getSize()): ?>
<div class="toolbar">

    <?php if( $this->isExpanded() ): ?>
    <div class="sorter">
        <?php if( $this->isEnabledViewSwitcher() ): ?>
        <div class="view-mode">
            <?php $_modes = $this->getModes(); ?>
            <?php if($_modes && count($_modes)>1): ?>           
            <?php foreach ($this->getModes() as $_code=>$_label): ?>
                <?php if($this->isModeActive($_code)): ?>
                    <span title="<?php echo $_label ?>" class="button button-active button-<?php echo strtolower($_code); ?> first"><?php //echo $_label ?></span>&nbsp;
                <?php else: ?>
                    <a href="<?php echo $this->getModeUrl($_code) ?>" title="<?php echo $_label ?>" class="button button-<?php echo strtolower($_code); ?> last"><?php //echo $_label ?></a>&nbsp;
                <?php endif; ?>
            <?php endforeach; ?>
            <?php endif; ?>
        </div>
        <?php endif; ?>
    
       <div class="sort-by">
      <label class="left"><?php echo $this->__('Sort By') ?></label>
        <div class="dropdown left dropdown-select" onchange="setLocation(this.value)">
          <a title="Sort By" data-close-others="false" data-delay="1000" data-hover="dropdown" data-toggle="dropdown" class="dropdown-toggle button" href="#"> 
             <?php if(Mage::app()->getRequest()->getParam('order')=="") { ?>
             <?php echo Mage::getStoreConfig('catalog/frontend/default_sort_by'); } else {?>
             <?php echo Mage::app()->getRequest()->getParam('order');} ?> 
             <span class="arrow"></span> 
          </a>
          <ul class="dropdown-menu">
            <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>               
              <li>
                <a href="<?php echo $this->getOrderUrl($_key, 'asc') ?>"
                    <?php if($this->isOrderCurrent($_key)){ ?> class="sort_icon selected" <?php } else {?> class="sort_icon"<?php } ?> >
                    <?php echo $this->__($_order) ?>
                </a>
              </li>
            <?php endforeach; ?>
          </ul>           
        </div> <!--dropdown left dropdown-select-->
            <?php if($this->getCurrentDirection() == 'desc'): ?>
                <a class="button-arrow button-desc left" href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"></a>
            <?php else: ?>
                <a class="button-arrow button-asc left" href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"></a>
            <?php endif; ?>
    </div> <!--sort-by--> 
    </div> <!--sorter-->
    <?php endif; ?>

    <div class="pager"> 
    <?php echo $this->getPagerHtml() ?> 
<!-- BEGIN LIMITER -->
    <div class="limiter">
      <label><?php echo $this->__('View: ') ?></label>
        <div class="dropdown left dropdown-select">
          <a title="Sort By" data-close-others="false" data-delay="1000" data-hover="dropdown" data-toggle="dropdown" class="dropdown-toggle button" href="#"> 
             <?php if((Mage::app()->getRequest()->getParam('mode')=='grid')&&(Mage::app()->getRequest()->getParam('limit')=="")){?>
                <?php echo Mage::getStoreConfig('catalog/frontend/grid_per_page');}?>

             <?php if((Mage::app()->getRequest()->getParam('mode')=='list')&&(Mage::app()->getRequest()->getParam('limit')=="")){?>
                <?php echo Mage::getStoreConfig('catalog/frontend/list_per_page');}?>
    
             <?php if((Mage::app()->getRequest()->getParam('mode')=='grid')&&(Mage::app()->getRequest()->getParam('limit')!="")){
                 if(!$flag_list_status){
                    echo Mage::getStoreConfig('catalog/frontend/grid_per_page');
                 } else { 
                    echo Mage::app()->getRequest()->getParam('limit');}}
             ?>

             <?php if((Mage::app()->getRequest()->getParam('mode')=='list')&&(Mage::app()->getRequest()->getParam('limit')!="")){
                 if(!$flag_list_status){
                    echo Mage::getStoreConfig('catalog/frontend/list_per_page');
                 } else { 
                    echo Mage::app()->getRequest()->getParam('limit');}}
            ?>
    
            <?php if((Mage::app()->getRequest()->getParam('mode')=="")&&(Mage::app()->getRequest()->getParam('limit')=="")){?>
                <?php echo Mage::getStoreConfig('catalog/frontend/grid_per_page');}?>
    
            <?php if((Mage::app()->getRequest()->getParam('mode')=="")&&(Mage::app()->getRequest()->getParam('limit')!="")){
               echo Mage::app()->getRequest()->getParam('limit');
             } 
            ?>
            <span class="arrow"></span>
        </a>
        <ul class="dropdown-menu">           
          <?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?>                
            <li>
              <a href="<?php echo $this->getLimitUrl($_key) ?>"
                 <?php if($this->isLimitCurrent($_key)){ ?> class="sort_icon selected" <?php } else {?> class="sort_icon"<?php } ?> >
                 <?php echo $_limit ?>
              </a>
            </li>
          <?php endforeach; ?>           
        </ul> <!--dropdown-menu-->
      </div> <!--dropdown left dropdown-select-->
    </div>  <!--limiter-->
  </div> <!--pager-->
       
</div> <!--toolbar-->
<?php endif ?>
