$_helper    = $this->helper('catalog/output');
    $_category  = $this->getCurrentCategory();
    $cat = Mage::getModel('catalog/category')->load($_category->getId());
    $subcats = $cat->getChildren();  
    $subcat= explode(',',$subcats);
    $_columnCount=3;
    $_collectionSize = count($subcat);
   
    $catlevel=$_category->getLevel();
     // $_category->setDisplayMode('PAGE');
   
   
    if($subcats!="" && $catlevel<4){>
    
}
else
{  //product display
    $cat = Mage::getModel('catalog/category')->load($_category->getId());
    $subcats = $cat->getChildren();  
    $subcat= explode(',',$subcats);
    foreach($subcat as $subCatid){
        $_subcategory = Mage::getModel('catalog/category')->load($subCatid);
        if($_subcategory->getIsActive())
        {
        //Mage::register('current_category', $_subcategory);
        echo '
'. $_subcategory->getName().'
';
         $collection = $_subcategory->getProductCollection();
        
         $products = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($_subcategory)->addAttributeToFilter('visibility', 4)->addAttributeToSelect('*');
         $products->getSelect()->order(new Zend_Db_Expr('RAND()'))->limit(3);
         $products->load();
         $_product = null;
       
        ////////////////////////////////////////////////
        ?>
        count()): ?>
        
__('There are no products matching the selection.') ?>
        
                
                
                |  | 
                count() ?>
                
                
                
                
                
                getId()?>);" onmouseover="show_sp_button(getId()?>);" class="depttitle dept_box"> 
 
                
                
                
getReviewsSummaryHtml($_product, 'short') ?>
 
 getId()?>);" onmouseover="show_sp_button(getId()?>);" class="dept_list_sp_div" name="SP_getId()?>" id="SP_getId()?>" style="visibility: hidden;">
 
 
 
 | 
                
                
                
               
                
                
                
        
       
       
        $script='       
       
    
       
                ////////////////////////////////////////////////
        }
    }
   
?>
   
                $script.="";
        echo $script;
        ?>
           
}
?>