<?php
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.cn iDreamSoft
 * @author coolmoo <idreamsoft@qq.com>
 */
!defined('iPATH') && exit('What are you doing?'); 
iCMS_admincp_head();
?>
<script type="text/javascript">
$(function(){
	$("#clist tr").mouseover(function(){
	  $(this).find("td").css("background-color","#F2F9FD");
	}).mouseout(function(){
	  $(this).find("td").css("background-color","#FFFFFF");
	});
});
function expand(cid,level,obj){
	$.ajax({type: "POST",url: "<?=__SELF__?>?do=ajax",dataType:"json",
	   data: "action=getsubcatalog&cid="+cid+"&level="+level,
	   success: function(json){
			$("#catalog_"+cid).after(json.html);
			$(obj).attr("ids"+cid,json.ids); 
			obj.src="admin/images/desc.gif";
			obj.onclick=function(){fold(cid,level,obj)}
	   }
	}); 
}
function fold(cid,level,obj){
	var cidArray	= $(obj).attr("ids"+cid).split(',');
	for (i=0;i<cidArray.length;i++){
		$("#catalog_"+cidArray[i]).remove();
	}
	obj.src="admin/images/add.gif";
	obj.onclick=function(){expand(cid,level,obj)}
}
</script>

<div class="container" id="cpcontainer">
  <script type="text/javascript">admincpnav('首页&nbsp;&raquo;&nbsp;栏目&nbsp;&raquo;&nbsp;栏目管理');</script>
  <div class="itemtitle">
    <h3>栏目管理</h3>
    <ul class="tab1" id="submenu">
      <li<?php if($operation=="expand"){?> class="current"<?php }?>><a href="<?=__SELF__?>?do=catalog&operation=expand"><span>展开所有栏目</span></a></li>
      <li<?php if($operation=="fold"){?> class="current"<?php }?>><a href="<?=__SELF__?>?do=catalog&operation=fold"><span>收缩所有栏目</span></a></li>
    </ul>
  </div>
  <table class="tb tb2 nobdb" id="tips">
    <tr>
      <th colspan="15" class="partition">技巧提示</th>
    </tr>
    <tr>
      <td class="tipsblock"><ul id="tipslis">
          <li>点击ID后面数字，可查看该栏目</li>
          <li>点击<img src="admin/images/add.gif"/> 可展开下级</li>
        </ul></td>
    </tr>
  </table>
  <form name="cpform" method="post" action="<?=__SELF__?>?do=catalog&operation=post" id="cpform" >
    <input type="hidden" name="action" value="edit" />
    <table class="tbL tb tb2 ">
      <tr>
        <th>显示顺序</th>
        <th>栏目名称</th>
        <th>管理</th>
      </tr>
      <tbody id="clist">
      <?php if($operation=="fold"){
      	  echo $catalog->row("0",0);
      }elseif($operation=="expand"){
	      echo $catalog->all();
      }
      ?>
	  </tbody>
      <tr class="nobg">
        <td colspan="14"><div class="fixsel">
            <input type="submit" class="btn" name="editsubmit" value="提交"  />
          </div></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html>