<dl class="allcats">
<?php foreach($channels as $ch){?>
	<dd>
    	<span class="channel" onclick="showcat(this)"><input type="checkbox" onclick="selectChBox('ch<?=$ch->channel_id?>')" id="ch<?=$ch->channel_id?>" /><?=$ch->channel_name?></span>
        <ul class="catlist" style="display:none">
			<?php $a=0; foreach($treeCats[$ch->channel_id] as $cat){$a++;?>
        	<li>
                <input class="ch<?=$ch->channel_id?>" type="checkbox" name="cats[<?=$ch->channel_id?>][][cat_id]" value="<?=$cat['cat_id']?>" >&nbsp;<?=$cat['cat_name']?>
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][cat_list_tpl]" value="<?=$cat['cat_list_tpl']?>" />
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][cat_index_tpl]" value="<?=$cat['cat_index_tpl']?>" />
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][cat_preview_tpl]" value="<?=$cat['cat_preview_tpl']?>" />
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][cat_name]" value="<?=$cat['old_name']?>" />
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][description]" value="<?=$cat['description']?>" />
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][cat_keywords]" value="<?=$cat['cat_keywords']?>" />
                <input type="hidden" name="catd[<?=$ch->channel_id?>][<?=$cat['cat_id']?>][cat_dir]" value="<?=$cat['cat_dir']?>" />
            </li>
			<?php }?>
       </ul>
    </dd>
<?php }?>
	<dt class="channel"><a href="javascript:selectCats()">全选</a> <a href="javascript:unsetCats()">取消</a></dt>
</dl>

<script language="javascript">
	function selectCats(){
		$("input[@type='checkbox']").each(function(){
			$(this).attr("checked",true);
		});
	}
	function unsetCats(){
		$("input[@type='checkbox']").each(function(){
			$(this).attr("checked",false);
		});
	}
	function selectChBox(channel){
		var type	=	$("#"+channel).attr('checked');
		$("."+channel).attr("checked",type);	
	}
	function showcat(thisobj){
		var obj	=	$(thisobj).next("ul");
		obj.slideToggle("fast");
	}
</script>
