<%'current_ver="cn"
sql_str="where Catalog_company_id=" & Session("DC_Manage_CompanyID")
if Session("DC_Manage_DepartmentID")<>0 then
	sql_str=sql_str & " and CatalogBig=" & Session("DC_Manage_DepartmentID")
end if
set myrs_root=server.CreateObject("adodb.recordset")
myrs_root.Open "select catalogid,catalogname,CatalogBig from DC_Title_catalog " & sql_str & " order by CatalogBig",dbconn,1,1
'i=myrs_root.RecordCount
  function UpdateStr1(str) '转化字符串
      str = Replace(str,"\","\\")
      str = Replace(str,"'","\'")
      UpdateStr1 = str
  end function
%>
<SCRIPT language="JavaScript">
function display1(Q_subtree,Q_img){
  
  if (Q_subtree.style.display=="none"){ 
       Q_subtree.style.display="";     
     Q_img.src="images/tree_collapse.gif";
    }
  else
      {
       Q_subtree.style.display="none";      
       Q_img.src="images/tree_expand.gif";
  } 
}

function del_sort(temp,rootorchild,tag){
      if(tag=="Yes"){
          var msg=window.confirm ("该目录下的问卷也会被删除,\n你真的要删除该目录吗?");
          if(msg==true){
              document.delform.id.value=temp; 
			  document.delform.rootchild.value=rootorchild;     
              document.delform.submit();  
          }
      }
      else
          alert("该目录下还有子目录,不能删除!");
}

function chang_news_sort(id,sort_name,level_name){
  document.frm_edit.type_id.value=id;
  document.frm_edit.sort_name.value=sort_name;
  document.frm_edit.level_name.value=level_name;
  document.frm_edit.old_boardname.value=sort_name;
}

</SCRIPT>
<TABLE cellSpacing=0 cols=5 cellPadding=0 width=300 border=0>  
  <TBODY>  
  <form name="delform" action="sort_ok.asp?version=<%=current_ver%>" method="post">
  <TR> 
    <TD style="line-height:16px" width=16></TD>
    <TD style="line-height:16px" width=16></TD>
    <TD style="line-height:16px" width=15></TD>
    <TD style="line-height:16px" width="230"></TD>    
    <TD style="line-height:16px" width=23></TD>    
  </TR>
  <TR> 
    <TD style="line-height:16px" width="16"><IMG src="images/tree_collapse.gif" border=no></TD>
    <TD style="line-height:16px" colSpan=4>目录名　　　　　　　　　　　　　　　　　　删除</TD>    
  </TR>
  <%n=1
  for i=1 to myrs_root.RecordCount
     	 CatalogBig=myrs_root("CatalogBig")
		 select case CatalogBig
  			case "Women"
  				c_color="#CC00CC"
			case "Handbags"
  				c_color="#00CC00"
			case "Shose"
  				c_color="#FF9900"
			case "Jewelry & Accessories"
  				c_color="#FF0000"
			case "Men"
 	 			c_color="#006600"
			case "Kids"
 	 			c_color="#660000"
  		 end select
	  
	  set myrs_child=server.CreateObject("adodb.recordset")
      myrs_child.Open "select id,typename from DC_Title_type where catalogID=" & myrs_root("catalogid") & " order by id",dbconn,1,1
      if myrs_child.RecordCount=0 then  
  %>
          <TR> 
          
      <TD style="line-height:16px" width="16"><IMG src="images/<%if i=myrs_root.RecordCount then%>tree_end.gif<%else%>tree_split.gif<%end if%>"></TD>
          
      <TD style="line-height:16px" width="16"><IMG src="images/tree_leaf.gif" border=0 width="15" height="16"></TD>
          
      <TD style="line-height:16px" colSpan=2><A href="#here" onclick="javascript:chang_news_sort('<%=myrs_root("catalogid")%>','<%=UpdateStr1(myrs_root("catalogname"))%>','root');"><%=myrs_root("catalogname")%></A>(<font color="<%=c_color%>"><%'=CatalogBig
	  	if CatalogBig<>"" then
			departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"A_Manage_Department","A_M_D_Name"," where A_M_D_ID=" & CatalogBig)
			if departM=0 then
				response.write "-"
			else
				totalput = UBound(D_data_Dep)
				rs_dep=split(D_data_Dep(0),",")
				response.write rs_dep(0)
			end if
		end if
	  %></font>)</TD>
          
      <TD style="line-height:16px" width="23"><a href="javascript:del_sort('<%=myrs_root("catalogid")%>','root','Yes')"><b>×</b></a></TD>
          </TR>
    <%else%>
          <TR> 
          <TD style="line-height:16px" width="16"><img src="images/<%if i=myrs_root.RecordCount then%>tree_end.gif<%else%>tree_split.gif<%end if%>" border=no width="16" height="16"></TD>
          <TD style="line-height:16px" width="16"><SPAN id=zhugan<%=n%> style="CURSOR: hand;" onclick="javascript:display1(document.all.subtree<%=n%>,document.all.img<%=n%>);"><IMG src="images/tree_collapse.gif" border=no name=img<%=n%>></SPAN></TD>
          <TD style="line-height:16px" colSpan=2><A href="#here" onclick="javascript:chang_news_sort('<%=myrs_root("catalogid")%>','<%=UpdateStr1(myrs_root("catalogname"))%>','root');"><%=myrs_root("catalogname")%></A>(<font color="<%=c_color%>"><%'=CatalogBig
		if CatalogBig<>"" then
			departM=ObjDCW.read_record(D_data_Dep,DataPathFile,"A_Manage_Department","A_M_D_Name"," where A_M_D_ID=" & CatalogBig)
			if departM=0 then
				response.write "-"
			else
				totalput = UBound(D_data_Dep)
				rs_dep=split(D_data_Dep(0),",")
				response.write rs_dep(0)
			end if
		end if
		  %></font>)</TD>
          <TD style="line-height:16px" width="23"><a href="javascript:del_sort('<%=myrs_root("catalogid")%>','root','No')"><b>×</b></a></TD>
          </TR>
          <TR id="subtree<%=n%>"><TD style="line-height:16px" colspan=5>
          <TABLE cellSpacing=0 cols=5 cellPadding=0 width=100% border=0>
          <tbody>
          <%for j=1 to myrs_child.RecordCount%>
              <TR> 
              <TD style="line-height:16px" width="16"><%if i=myrs_root.RecordCount then%>&nbsp;<%else%><img src="images/tree_vertline.gif" border=0><%end if%></TD>
              <TD style="line-height:16px" width="16"><IMG src="images/<%if j=myrs_child.RecordCount then%>tree_end.gif<%else%>tree_split.gif<%end if%>"></TD>
              <TD style="line-height:16px" width="15"><img src="images/tree_leaf.gif" border=0 width="15" height="16"></TD>
              <TD style="line-height:16px" width="230"><A href="#here" onclick="javascript:chang_news_sort('<%=myrs_child("id")%>','<%=UpdateStr1(myrs_child("typename"))%>','child');"><%=myrs_child("typename")%></a></TD>
              <TD style="line-height:16px" width="23"><a href="javascript:del_sort('<%=myrs_child("id")%>','child','Yes')"><b>×</b></a></TD>
              </TR>               
          <%myrs_child.MoveNext
              if myrs_child.EOF then exit for
              next%></tbody>
          </TABLE></TD>
          </TR>   
      <%end if%>
  
  <%  myrs_child.Close 
      set myrs_child=nothing
      myrs_root.MoveNext
          if myrs_root.EOF then exit for
  n=n+1
  next
      myrs_root.Close 
      set myrs_root=nothing
  %>
  <input type="hidden" name="id"><input type="hidden" name="rootchild"><input type="hidden" name="sort_action" value="del">
  </form>
  </TBODY>
</TABLE>
