<?php
if (!defined('IN_CONTEXT')) die('access violation error!');

if (!function_exists('showCategoryMenuP')) {
    function showCategoryMenuP(&$category_tree) {
        if(empty($category_tree)) $category_tree = array();
        foreach ($category_tree as $category) {
    ?>
    <li>
    <?php
            if (sizeof($category->slaves['ProductCategory']) > 0) {
    ?>
    <a href="<?php echo Html::uriquery('mod_product', 'prdlist', array('cap_id' => $category->id)); ?>">
    <?php echo $category->name; ?></a>
    <ul>
	    <?php showCategoryMenuP($category->slaves['ProductCategory']); ?>
    </ul>
    <?php
            } else {
    ?>
    <a href="<?php echo Html::uriquery('mod_product', 'prdlist', array('cap_id' => $category->id)); ?>">
    <?php echo $category->name; ?></a>
    <?php
            }
    ?>
    </li>
    <?php
        }
    }
}
$id_seed = Toolkit::randomStr();
?>


<div class="list_main category">
	<div class="prod_type">
	<div class="pro_type_02">
		<ul>
			<?php showCategoryMenuP($categories); ?>
			<div class="blankbar1"></div>
		</ul>		
	</div>
	</div>
	<div class="list_bot"></div>
</div>
<div class="blankbar"></div>

<script type="text/javascript" language="javascript">
/**
 * for menu-drop type
 */
var type = "<?php echo trim(ParamHolder::get('product_category_type',''));?>";
if (type == 'click') {
	$(function(){
		$('.pro_type_02 li:has(ul)').click(function(event){
	    	if (this == event.target) {
	        	if ($(this).children().is(':hidden')) {
	                $(this).css({background:'url(<?php echo P_TPL_WEB; ?>/images/minus.gif) no-repeat left 13px','text-indent':'16px','padding-top':'3px'})
	                .children().show();
	                
	              	$(this).siblings().each(function (){
	              		$(this).find("ul").hide();
	              		if ($(this).children().is("ul")){
	              			$(this).css({background:'url(<?php echo P_TPL_WEB; ?>/images/plus.gif) no-repeat left 13px','text-indent':'16px','padding-top':'3px'});
	              	    }
	              	});
	            } else {
	                $(this).css({background:'url(<?php echo P_TPL_WEB; ?>/images/plus.gif) no-repeat left 13px','text-indent':'16px','padding-top':'3px'})
	                .find("ul").hide();
	            }  
	        }
		}).css('cursor','pointer').find("ul").hide().click();
	          
	    $('.pro_type_02 li:has(ul)').css({background:'url(<?php echo P_TPL_WEB; ?>/images/plus.gif) no-repeat left 13px','text-indent':'16px','padding-top':'3px'});
	        	
	    $('.pro_type_02 li:not(:has(ul))').css({cursor: 'pointer','list-style-image':'none'});
	});
} else {
 	$(".pro_type_02>ul").droppy();
	$(".pro_type_02 ul ul li:last-child").css("border","0px");
}
</script>

