<% Option Explicit %>
<!--#include file="../../Inc/Function.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<!--#include file="../../Inc/Cls_DB.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0602") then Call ReturnError2()
%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>虚拟目录管理</title>
</head>
<link href="../../CSS/css.css" rel="stylesheet">
<script language="JavaScript" src="../JS/PublicJS.js"></script>
<body onselectstart="return false;" topmargin="0" leftmargin="0" oncontextmenu="showMenu(MouseRightMenu);return false;">
<%
Dim UpFilesPath,FS,FolderObj,SubFolderObj,FolderItem,Files,DMenuConfigObj
Set DMenuConfigObj = Conn.Execute("Select DoMain from Config")
if SysRootDir <> "" then
	UpFilesPath = "/" & SysRootDir & "/"
else
	UpFilesPath = "/"
end if
Set FS = Server.CreateObject("Scripting.FileSystemObject")
Set FolderObj = FS.GetFolder(Server.MapPath(UpFilesPath))
Set SubFolderObj = FolderObj.SubFolders
%>
<table id="FolderList" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> 
      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="../Images/Folder.gif" width="18" height="18"></td>
          <td><span id="ShowRootPath" Path="<% = UpFilesPath %>" onClick="ClickMainFolder(this);" class="TempletSelectItem">系统根目录</span></td>
  </tr>
</table>
</td>
  </tr>
<%
For Each FolderItem in SubFolderObj
%>
  <tr>
    <td> 
      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img Depth="1" Extend="False" onClick="ExtendFolder(this);" src="../Images/folder%2B%2B.gif" width="18" height="18"></td>
          <td><img src="../Images/Folder.gif" width="18" height="18"></td>
          <td><span Click="False" Path="<%= UpFilesPath & FolderItem.Name%>" onClick="ClickFolder(this);" class="TempletItem"><% = FolderItem.Name %></span></td>
  </tr>
</table>
</td>
  </tr>
<%
Next
%>
</table>
</td>
  </tr>
</table>
<!-- 鼠标右键菜单 -->
<div id=MouseRightMenu onclick="ClickMenu(this);" onmouseover="MouseOverRightMenu();" onmouseout="MouseOverRightMenu();" class="menu"> 
  <div class="MouseRightItem" id="Refresh" ExeFunction="window.parent.location.reload();">刷新</div>
</div>
</body>
</html>
<%
Set FS = Nothing
Set FolderObj = Nothing
Set SubFolderObj = Nothing
%>
<script language="JavaScript">
var CurrPath='';
function ClickMainFolder(Obj)
{
	for (var i=0;i<document.all.length;i++)
	{
		if (document.all(i).Click!=null)
		{
			if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
			document.all(i).parentElement.parentElement.children(1).children(0).src='../Images/Folder.gif';
		}
	}
	Obj.className='TempletSelectItem';
	parent.frames['OpreateWindow'].location='DummyList.asp?Path='+Obj.Path;
}

function ClickFolder(Obj)
{
	for (var i=0;i<document.all.length;i++)
	{
		if (document.all(i).Click!=null)
		{
			if (document.all(i).className=='TempletSelectItem') document.all(i).className='TempletItem';
			document.all(i).parentElement.parentElement.children(1).children(0).src='../Images/Folder.gif';
		}
	}
	ShowRootPath.className='TempletItem';
	Obj.className='TempletSelectItem';
	Obj.parentElement.parentElement.children(1).children(0).src='../Images/Folderk.gif';
	parent.frames['OpreateWindow'].location='DummyList.asp?Path='+Obj.Path;
}

function ExtendFolder(Obj)
{
	var ReturnValue='';
	var ParentFolder=Obj.parentElement.parentElement.children(2).children(0).Path;
	for (var i=0;i<document.all.length;i++)
	{
		if (document.all(i).Extend!=null)
		{
			document.all(i).parentElement.parentElement.children(1).children(0).src='../Images/Folder.gif';
			document.all(i).parentElement.parentElement.children(2).children(0).className='TempletItem';
		}
	}
	if (Obj.Extend=='False')
	{
		Obj.src='../Images/folder--.gif';
		Obj.parentElement.parentElement.children(1).children(0).src='../Images/Folderk.gif';
		Obj.parentElement.parentElement.children(2).children(0).className='TempletSelectItem';
		ReturnValue=SendDataToServer('FolderFileOperate.asp?Type=ExtendFolder&Path='+Obj.parentElement.parentElement.children(2).children(0).Path);
		if ((ReturnValue.length)!=0)
		{
			var InsertTRPosition=Obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.rowIndex;
			var SubFolderStr=UnEnCodeResponseStr(ReturnValue)
			var SubFolderArray=SubFolderStr.split('$');
			for (var k=0;k<SubFolderArray.length;k++)
			{
				var FolderDepth=parseInt(Obj.Depth);
				var SubFolderStr=GetSubFolderHtml(Obj.parentElement.parentElement.children(2).children(0).Path,SubFolderArray[k],FolderDepth);
				var TRObj=document.all.FolderList.insertRow(InsertTRPosition+1);
				var TDObj=TRObj.insertCell(0);
				TDObj.innerHTML=SubFolderStr;
				InsertTRPosition++;
			}
		}
		Obj.Extend='True';
	}
	else
	{
		Obj.parentElement.parentElement.children(1).children(0).src='../Images/Folderk.gif';
		Obj.parentElement.parentElement.children(2).children(0).className='TempletSelectItem';
		Obj.src='../Images/folder++.gif';
		ReturnValue=SendDataToServer('FolderFileOperate.asp?Type=ExtendFolder&Path='+Obj.parentElement.parentElement.children(2).children(0).Path);
		if ((ReturnValue.length)!=0)
		{
			var InsertTRPosition=Obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.rowIndex;
			var SubFolderStr=UnEnCodeResponseStr(ReturnValue)
			var SubFolderArray=SubFolderStr.split('$');
			for (var k=0;k<SubFolderArray.length;k++)
			{
				var FolderDepth=parseInt(Obj.Depth);
				var TRObj=document.all.FolderList.deleteRow(InsertTRPosition+1);
			}
		}
		Obj.Extend='False';
	}
	parent.frames['OpreateWindow'].location='DummyList.asp?Path='+Obj.parentElement.parentElement.children(2).children(0).Path;
}

function UnEnCodeResponseStr(UnicodeStr)
{
	var TempStr='';
	var UnicodeArray=UnicodeStr.split('*');
	for (var i=0;i<=UnicodeArray.length-1;i++)
	{
		TempStr=TempStr+String.fromCharCode(UnicodeArray[i]);
	}
	return TempStr;
}

function GetSubFolderHtml(ParentFolder,SubFolder,FolderDepth) 
{
	var TempStr=''
	TempStr = TempStr + '<table border="0" cellspacing="0" cellpadding="0"><tr><td>';
	for (var i=0;i<FolderDepth;i++)
	{
		TempStr = TempStr + '<img src="../Images/folderHr.gif" width="18" height="18">';
	}
	TempStr = TempStr + '<img Extend="False" Depth="'+(FolderDepth+1)+'" onClick="ExtendFolder(this);" src="../Images/folder%2B%2B.gif" width="18" height="18"></td>';
	TempStr = TempStr + '<td><img src="../Images/Folder.gif" width="18" height="18"></td>';
	TempStr = TempStr + '<td><span Click="False" Path=' + ParentFolder + '/' + SubFolder + ' onClick="ClickFolder(this);" class="TempletItem">' + SubFolder + '</span></td>';
	TempStr = TempStr + '</tr></table>'
	return TempStr;
}
</script>