<?php include 'header.tpl.php';?>

<script>
var obj_cur=null;//当前选定的对象d
var obj_cur_type="";//当前选定的对象类型:目录或文件
var obj_cur_name=""//当前选定的对象名称
var obj_form=document.frmMain;
var obj_cur_id=0;
//=============================================函数区=================================
// 打开文件夹
function on_dir_open(msg_id)
{
	obj_form.me_folder_id.value=msg_id;
	frmExecute("opendir");
}
//打开文件
function on_file_open()
{
	if(obj_form.win_objid.value!="")
	{
		on_win_set(obj_cur_name);
	}else{
		window.open("<?php echo WEB_URL?>"+obj_cur_name,'_blank');
	}
}
function on_win_set(msg_path)
{
	strname=obj_form.win_objid.value;
	obj=parent.document.getElementById(strname);
	if(obj){
		obj.value=msg_path;
		strx=obj_form.win_type.value;
		parent.div_hide("win"+strx+"_"+strname);
	}else{
		if(window.opener){
			obj=window.opener.document.getElementById(strname);
			if(obj){
				obj.value=msg_path;
				window.close();
			}
		}
	}
}
//打开
function on_open()
{
	if(!obj_cur) return;
	if(!obj_cur_name&&obj_cur_name==""&&obj_cur_name=="undefined") return;
	if(obj_cur_type=="dir")
		on_dir_open(obj_cur_id);
	else
	{
		on_file_open();
	}
	
}
//复制文件
function on_copy()
{
	obj_form.paste_source.value=obj_cur_id;
	obj_form.paste_type.value=obj_cur_type;
	obj_form.paste_act.value="copy";
}
//剪贴文件
function on_cut()
{
	obj_form.paste_source.value=obj_cur_id;
	obj_form.paste_type.value=obj_cur_type;
	obj_form.paste_act.value="cut";
}
//显示新建文件夹文本框
function show_new_dirbox()
{
	obj_form.new_dirname.value="新建文件夹";
	div_show("createdirDialog");
	obj.style.left=50;
	obj_form.new_dirname.focus;
}
//新建文件夹
function on_dir_create()
{
	newname=obj_form.new_dirname.value;
	if(newname=="")
	{
		alert("文件夹名不能为空!");
		return;
	}
	frmExecute("createdir");

}
//显示重命名文本框
function show_rename_box()
{
	if(obj_cur_name=="") return;
	str_name=obj_cur_name;
	if(str_name!=""){
		str_name=str_name.replace("\\","/");
		arr_name=str_name.split("/");
		lng_length=arr_name.length-1;
		str_name=arr_name[lng_length];
	}
	obj_form.rename.value=str_name;
	div_show("renameDialog");
	obj_form.rename.focus;
}
//显示网络抓取文本框
function show_webfile_box()
{
	div_show("wegfileDialog");
}

//重命名
function on_rename()
{
	newname=obj_form.rename.value;
	if(newname=="")
	{
		alert("新名字不能为空!");
		return;
	}
	if(newname==obj_cur_name) return;
	obj_form.rename_source.value=obj_cur_id;
	obj_form.rename_type.value=obj_cur_type;
	frmExecute("rename");
}
function on_up_webfile()
{
	frmExecute("up_webfile");
}
//删除
function on_del()
{
	obj_form.del_source.value=obj_cur_id;
	obj_form.del_type.value=obj_cur_type;
	frmExecute("delete");
}
//显示列表样式
function show_viewmod()
{
	obj=document.getElementById("div_viewmod");
	if(obj.style.display!="none")
		obj.style.display="none";
	else
		obj.style.display="";
}

//设置交点
function on_set_focus(msg_objid,msg_type,msg_id,msg_name)
{
	var obj_new=document.getElementById(msg_objid);
	if(!obj_new) return;
	isfocus=true;
	if(obj_cur)
	{
		if(obj_cur.id==obj_new.id) return;
		obj_cur.style.backgroundColor="#ffffff";
		obj_cur.style.color="#000000";
	}
	obj_cur=obj_new;
	obj_cur_type=msg_type;
	obj_cur_name=msg_name;
	obj_cur_id=msg_id;
	obj_cur.style.backgroundColor="#0066CC";
	obj_cur.style.color="#ffffff";
	obj=document.getElementById("menuopen");
	if(obj) obj.style.color="black";
	obj=document.getElementById("menucopy");
	if(obj) obj.style.color="black";
	obj=document.getElementById("menucut");
	if(obj) obj.style.color="black";
	obj=document.getElementById("menudel");
	if(obj) obj.style.color="black";
	obj=document.getElementById("menurename");
	if(obj) obj.style.color="black";
}
function on_viewmod(msg_mod)
{
	obj_form.viewmod.value=msg_mod;
	frmExecute("list");
}
</script>

<style>
.menu0 {
position:absolute;
text-align:left;
width:180px;
border:1px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
}
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:180px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:1 outset buttonhighlight;
}
</style>
<div class="pMenu">
<li onclick="javascript:show_viewmod()" style="cursor:pointer">显示</a></li>
<li><a href="javascript:div_show('objUpfile');div_hide('objUpfileup');div_show('objUpfileclose');" id="objUpfileup">本地上传</a><a href="javascript:div_hide('objUpfile');div_show('objUpfileup');div_hide('objUpfileclose');" id="objUpfileclose" style="display:none">关闭</a></li>
<li><a href="javascript:show_webfile_box();" id="objwebfile">网络抓取</a></li>
<li><a href="file_file.php?win_objid=<?php echo $get_win_objid;?>&win_type=<?php echo $get_win_type;?>">服务器</a></li>
</div>
<div id="objUpfile" style="float:left;width:100%;display:none">
	<iframe name="frmupfile" width="100%" height="200px" src="<?php echo WEB_URL?>/plus/dialog/upload_upfile.php?folder_id=<?php echo $get_me_folder_id;?>" frameborder=0></iframe>
</div>
<div class="pTopPath">
　路径：<?php echo $page_folder_path;?>
</div>

<?php
include "upload.".$get_viewmod.".tpl.php";
?>

<div id="div_menu" class="menu0" style="position:absolute; top:0; left:0;display:none" onMouseover="on_menu_mouseover(event);" onMouseout="on_menu_mouseout(event)" onClick="jumptoie5();">
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	  <td width="13%" align="center" background="<?php echo DIALOG_URL?>/mod/images/menubg.gif"></td>
	  <td width="87%" valign="middle">
		 <div class="buyokmenu" onclick="javascript:on_open();" style="border-bottom:1px #cccccc solid;padding-bottom:5px" id="menuopen">打开</div>
		<div class="buyokmenu" onclick="javascript:on_copy();" id="menucopy">复制</div>
		<div class="buyokmenu" onclick="javascript:on_cut();" id="menucut">剪贴</div>
		<div class="buyokmenu" onclick="javascript:frmExecute('paste');" style="border-bottom:1px #cccccc solid;padding-bottom:5px" id="menupast">粘贴</div>
		<div class="buyokmenu" onclick="javascript:show_rename_box();" id="menurename">重命名</div>
		<div class="buyokmenu" onclick="javascript:show_new_dirbox();" id="menudir" style="color:black">文件夹</div>
		<div class="buyokmenu" onclick="javascript:frmExecute('list');" style="border-bottom:1px #cccccc solid;padding-bottom:5px;color:black" id="menurefresh">刷新</div>
		<div class="buyokmenu" onclick="javascript:on_del()" id="menudel">删除</div>
	</td>
  </tr>
</table>
</div>

<div id="div_viewmod" class="viewmod" style="position:absolute; top:30px; left:18px;display:none">
<li onmousemove="this.style.background='highlight';this.style.color='#ffffff';" onmouseout="this.style.background='#ffffff';this.style.color='#000000';" onclick="on_viewmod('default')">列表</a></li>
<li onmousemove="this.style.background='highlight';this.style.color='#ffffff';" onmouseout="this.style.background='#ffffff';this.style.color='#000000';" onclick="on_viewmod('pic')">略图</li>
</div>

<div class="divDialog" style="display:none;width:300px;" id="renameDialog">
	<div class="body">
		<div class="val">
		重命名：<input type="text" name="rename" value=""><br>
		<input type="button" name="btn_rename" value="确定" onclick="on_rename();">　<input type="button" name="btn_rename_cancel" value="取消" onclick="div_hide('renameDialog');">
		</div>
	</div>
</div>
<div class="divDialog" style="display:none;width:300px;" id="createdirDialog">
	<div class="body">
		<div class="val">
		文件夹：<input type="text" name="new_dirname" value=""><br>
		<input type="button" name="btn_new_dir" value="确定" onclick="on_dir_create();">　<input type="button" name="btn_newdir_cancel" value="取消" onclick="div_hide('createdirDialog');">
		</div>
	</div>
</div>
<div class="divDialog" style="display:none;width:430px;" id="wegfileDialog">
	<div class="body">
		<div class="val">
		网址：<input type="text" name="up_webfile" value="" size=50><br>
		<input type="button" name="btn_up_webfile" value="确定" onclick="on_up_webfile();">　<input type="button" name="btn_newdir_cancel" value="取消" onclick="div_hide('wegfileDialog');">
		</div>
	</div>
</div>
<script>
document.onclick=function(e) {
	obj_menu=document.getElementById("div_menu");
	if(obj_menu) obj_menu.style.display= "none";
	obj=document.getElementById("objview");
	if(obj) obj.style.display="none";
}
document.oncontextmenu=function(e)
{
	obj_menu=document.getElementById("div_menu");
	if(!e) e=event;
	if(obj_menu)
	{
		//判断剪贴内容框中是否有内容，有则设paste菜单为有效
		if(obj_form.paste_source.value!="")
		{
			obj_paste=document.getElementById("menupast");
			if(obj_paste) obj_paste.style.color="black";
		}
		var rightedge = document.body.clientWidth-e.clientX;
		var bottomedge = document.body.clientHeight-e.clientY;
		if (rightedge < obj_menu.offsetWidth)
			obj_menu.style.left = document.body.scrollLeft + e.clientX - obj_menu.offsetWidth;
		else
			obj_menu.style.left = document.body.scrollLeft + e.clientX;
		if (bottomedge < obj_menu.offsetHeight)
			obj_menu.style.top = document.body.scrollTop + e.clientY - obj_menu.offsetHeight;
		else
			obj_menu.style.top = document.body.scrollTop + e.clientY;

		obj_menu.style.display="";
	}
	return false;
} 

function on_menu_mouseover(event) {
	//ie与firefox不同
	obj=event.srcElement ? event.srcElement : event.target;
	if (obj.className == "buyokmenu") {
		obj.style.backgroundColor = "highlight";
		if(obj.style.color=="black")obj.style.color = "white";
	   }
}
function on_menu_mouseout(event) {
	//ie与firefox不同
	obj=event.srcElement ? event.srcElement : event.target;
	if (obj.className == "buyokmenu") {
		obj.style.backgroundColor = "";
		if(obj.style.color=="white") obj.style.color = "black";
	   }
}


</script>
<input type="hidden" name="me_folder_id" value="<?php echo $get_me_folder_id?>">
<input type="hidden" name="viewmod" value="<?php echo $get_viewmod?>">
<input type="hidden" name="win_objid" value="<?php if(isset($get_win_objid)) echo $get_win_objid;?>">
<input type="hidden" name="win_type" value="<?php if(isset($get_win_type)) echo $get_win_type;?>">
<input type="hidden" name="paste_source" value="<?php if(isset($get_paste_source)) echo $get_paste_source;?>">
<input type="hidden" name="paste_act" value="<?php if(isset($get_paste_act)) echo $get_paste_act;?>">
<input type="hidden" name="paste_type" value="<?php if(isset($get_paste_type)) echo $get_paste_type;?>">
<input type="hidden" name="rename_source" value="">
<input type="hidden" name="rename_type" value="">
<input type="hidden" name="del_type" value="">
<input type="hidden" name="del_source" value="">
<?php include 'footer.tpl.php';?>		
