function Upload(type)
{
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	window.location='upload.aspx?Path='+currpath+'&type='+type;
}
function UpBtn()
{
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	Webdisk.ContentPane.UpBtn(currpath,IsUpBtnOpr_callback);
}
function IsUpBtnOpr_callback(res)
{
	var bRet = res.value;
	alert(bRet);
	//window.location='ContentPane.aspx?path='+bRet;
}
function GoRoot()
{
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	Webdisk.ContentPane.GoRoot(currpath,IsGoRootOpr_callback);
}
function IsGoRootOpr_callback(res)
{
	var bRet = res.value;
	window.location='ContentPane.aspx?path='+bRet;
}
function zipfile()
{
	if (document.getElementById("HdnSelectedValues").value=="")
	{
		swal("系统提示信息", "请勾选多个目录或文件进行压缩!", "info");
		return;
	}
	$('#loadingModal').show();
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"Zip",path1:currpath,str:document.getElementById("HdnSelectedValues").value},IszipfileOpr_callback
        )
}
function IszipfileOpr_callback(res)
{
	$('#loadingModal').hide();
	var bRet = res;
	if ((bRet.charAt(0) != "0") && (bRet.charAt(0) != "1"))
	{
		swal("系统提示信息",bRet, "error");
	}
	else
	{
		var rowcount=document.getElementById("rowcount").value;
		var currpath;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		var ss=bRet.split("`");
		var subtmp=ss[0];
		var txttmp=ss[1];
		var size=ss[2];
		var user=ss[3];
		var cache=ss[4];
		var copy=ss[5];
		
		AddRow(rowcount,currpath,txttmp,bRet.charAt(0),"1",size,user,cache,copy,"");
				
		/*var info=document.getElementById("info").innerHTML;
		var first=info.indexOf("：")
		var second=info.indexOf("个")
		document.getElementById("info").innerHTML=info.substring(0,first)+parseInt(parseInt(info.substring(first+1,second))+1)+info.substring(second,info.length);
		rowcount++;
		document.getElementById("rowcount").value=rowcount;*/
	}
}
function deletefile2(noteid)
{
	$("#chkSelect"+noteid).attr("checked",'true');
	document.getElementById("HdnSelectedValues").value="`"+$("#chkSelect"+noteid).val();
	deletefile();
}
function deletefile()
{
	if (document.getElementById("HdnSelectedValues").value=="")
	{
		swal("系统提示信息", "请勾选多个目录或文件再进行删除!", "info");
		return;
	}
	$("#suredel").modal('show');
	document.getElementById('btnsuredel').onclick = function (){
		$("#suredel").modal('hide');
		var currpath;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		$.post(
            "ajax.aspx",
            {action:"del",path1:currpath,HdnSelectedValues:document.getElementById("HdnSelectedValues").value},IsdeletefileOpr_callback
        )
	}
}
function IsdeletefileOpr_callback(res)
{
	location.reload();
	document.all.loading.style.display='none';
	var bRet = res;
	if (bRet.charAt(0) != "")
	{
		swal("系统提示信息", bRet, "error");
	}
	else
	{
		
	}
}
function unzipfile()
{
	if (document.getElementById("HdnSelectedValues").value=="")
	{
		swal("系统提示信息", "请勾选多个目录或文件进行解压!", "info");
		return;
	}
	$("#loadingModal").show();
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"Unzip",path1:currpath,str:document.getElementById("HdnSelectedValues").value},IsunzipfileOpr_callback
        )
}
function IsunzipfileOpr_callback(res)
{
	$('#loadingModal').hide();
	var bRet = res;
	if ((bRet.charAt(0) != "0") && (bRet.charAt(0) != "1"))
	{
		swal("系统提示信息",bRet, "error");
	}
	else
	{
		var ss=bRet.split("`");
		for(var i=0;i<ss.length-1;i++)
		{
			var rowcount=document.getElementById("rowcount").value;
			var currpath;
			if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
			var txttmp=ss[i].substring(1,ss[i].length);
			
			AddRow(rowcount,currpath,txttmp,ss[i].charAt(0),"0","","","","","");
					
			/*var info=document.getElementById("info").innerHTML;
			var first=info.indexOf("：")
			var second=info.indexOf("个")
			document.getElementById("info").innerHTML=info.substring(0,first)+parseInt(parseInt(info.substring(first+1,second))+1)+info.substring(second,info.length);
			rowcount++;
			document.getElementById("rowcount").value=rowcount;*/
		}
	}
}
function shareuser(url)
{
window.open(url,'','scrollbars=yes,resizable=no,status=no,toolbar=no,menubar=no,location=no,width=700,height=500');
}
function cutfile2(noteid,type)
{
	$("#chkSelect"+noteid).attr("checked",'true');
	document.getElementById("HdnSelectedValues").value="`"+$("#chkSelect"+noteid).val();
	cutfile(type);
}
function cutfile(type)
{
	var txttype;
	if (type=="1") 
	{txttype="移动";document.getElementById("copytype").value="1";} else {txttype="复制";document.getElementById("copytype").value="2";}
	if (document.getElementById("HdnSelectedValues").value=="")
	{
		swal("系统提示信息", "请勾选多个目录或文件再进行"+txttype+"!", "info");
		return;
	}
	$('#move').modal('show');
	$('#moveLabel').text(txttype+'到……');
	$('#moveText').text('选择要'+txttype+'到的目标路径');
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"GetAllPath",path:currpath},get_Result_CallBack, "json"
        )
	document.all.selpath.value="/";
}
function get_Result_CallBack(response)
{
    if (response != null)
    {
        document.all("vpath").length=0;
           $.each(response, function (i, item) {
　　　　        var name= item.path;
　　　　　　    var id= item.path;
　　　　　　    document.all("vpath").options.add(new Option(name,id));
　　　　    });
    } 
	document.all.selpath.value=document.all.vpath.value;
    return
}
function setvalue(str){
	var name=str;
　　var id=str;
　　document.all("vpath").options.add(new Option(name,id));
　　document.all("vpath").value=str;
	document.all.selpath.value=str;
}
function moveto()
{
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	if (document.all.selpath.value!=currpath)
	{
		document.getElementById("butmove").disabled="disabled";
		document.getElementById("loading2").style.display="";
		$.post(
            "ajax.aspx",
            {action:"MoveTo",path1:currpath,str1:document.getElementById("HdnSelectedValues").value,str2:document.getElementById("selpath").value,type:document.getElementById("copytype").value},IsOprEnd_callback
        )
	}
}
function IsOprEnd_callback(res)
{
	document.all.loading2.style.display='none';
	document.getElementById("butmove").disabled="";
	$('#move').modal('hide');
	var bRet = res;
	if ((bRet != "") && (bRet != "1") && (bRet != "2"))
	{
		swal("系统提示信息", bRet, "error");
	}
	if (bRet == "1")
	{
		if (document.getElementById("DataGrid")!=null)
		{
			var dll=document.getElementById("DataGrid");
			cleanWhitespace(dll);
			objID=document.getElementsByName("checkbox");
			
			for (var i=objID.length-1 ;i>=0;i--)
			{
				
				if(objID[i].checked==true)
				{
					dll.deleteRow(i+1);
				}
			}
		}
		else
		{
			var dll=document.getElementById("content");
			cleanWhitespace(dll);
			objID=document.all.checkbox;
			for (var i=objID.length-2 ;i>=0;i--)
			{
				if(objID[i].checked)
				{
					dll.removeChild(dll.childNodes[i]);
				}
			}
		}
		document.getElementById("HdnSelectedValues").value="";
	}
	toastr.options = {
			timeOut: 2000,
			progressBar: true,
			showMethod: "slideDown",
			hideMethod: "slideUp",
			showDuration: 200,
			hideDuration: 200
		};

	toastr.success('操作已完成');
}
function IsOpr_callback(res)
{
	document.Form1.HdnSelectedValues.value="";
	document.all.loading.style.display='none';
	var bRet = res.value;
	if (bRet.charAt(0) != "0")
	{
		var d = new dialog();d.init();
		d.set('src','pics/dlgico_excal.gif');
		d.set('title','系统提示信息');
		d.event(bRet, 'window.close();','','');	
	}
	else document.getElementById("info").innerHTML=bRet.substring(1,bRet.length);
}
function insertAt(parentNode,newNode,index)
{
	if(!parentNode.hasChildNodes()){
		parentNode.appendChild(newNode);
		return newNode;
	}
	try{
		parentNode.insertBefore(newNode,parentNode.childNodes[index]);
	}catch(e){
		return null;
	}
	return newNode;
}

function newdirbox()
{
	document.all.txttmp1.value="";
	document.all.txttmp.value="";
	$('#newdir').modal('show');
	$('#ModalLabel').text("新建文件夹");
	document.getElementById('butnewdir').onclick = function (){
		if (document.getElementById("txttmp").value!="")
		{
			document.getElementById("butnewdir").disabled="disabled";
			document.getElementById("loading").style.display="";
			newdirboxok();
		}
	}
	document.getElementById('text1').onkeydown = function (e) {
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which;
            if (code == 13) {
                $("#butnewdir").click();
            }
        }
	document.getElementById('text2').onkeydown = function (e) {
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which;
            if (code == 13) {
                $("#butnewdir").click();
            }
        }
}
function newdirboxok()
{

	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"newFolder",path1:currpath,name:document.getElementById("txttmp").value,note:document.getElementById("txttmp1").value},Isnewdir_callback
        )
}
function Isnewdir_callback(res)
{
	document.all.loading.style.display='none';
	document.getElementById("butnewdir").disabled="";
	$('#newdir').modal('hide');
	var bRet = res;
	if ((bRet != "0") && (bRet != "1"))
	{
		swal("系统提示信息", bRet, "error");
		document.getElementById("txttmp").value="";document.getElementById("txttmp1").value="";
	}
	else
	{
		var rowcount=document.getElementById("rowcount").value;
		var currpath;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		var txttmp=document.getElementById("txttmp").value;
		
		//if (document.getElementById("nospace")!=null) document.getElementById("nospace").style.display='none';
		AddRow(rowcount,currpath,txttmp,bRet,"0","","","",document.getElementById("txttmp1").value,document.getElementById("txttmp1").value);
		
		var info=document.getElementById("info").innerHTML;
		var first=info.indexOf("：")
		var second=info.indexOf("个")
		document.getElementById("info").innerHTML=info.substring(0,first)+"："+parseInt(parseInt(info.substring(first+1,second))+1)+info.substring(second,info.length);
		rowcount++;
		document.getElementById("rowcount").value=rowcount;
	}
	document.getElementById("txttmp").value="";document.getElementById("txttmp1").value="";
}
function RenameInit(noteid)
{
	var oldname=$('#a'+noteid).text();
	document.getElementById("txttmp1").value=oldname;
	document.getElementById("spanid").value=noteid;
	document.getElementById("noteid").value=noteid;
	document.all.modalshow1.style.display='';
	document.all.modalshow2.style.display='none';
	$('#newdir').modal('show');
	
	if (oldname.indexOf(".")==-1)
	{
		$('#ModalLabel').text("文件夹改名");
		$('#modalshow2').hide();
		$('#text1').val(oldname);
		$('#butnewdir').bind('click',function(){
			Rename();
		});
	}
	else
	{
		var s=oldname.lastIndexOf(".");
		var s1=oldname.substring(0,s);
		$('#ModalLabel').text("文件改名");
		$('#modalshow2').hide();
		$('#text1').val(s1);
		$('#ModalText1').text("输入新名称（不包括扩展名）");
		$('#butnewdir').bind('click',function(){
			Rename();
		});
	}
	document.getElementById('text1').onkeydown = function (e) {
		var theEvent = window.event || e;
		var code = theEvent.keyCode || theEvent.which;
		if (code == 13) {
		   Rename();
		}
	}
}
function Rename()
{
	if ((document.getElementById("txttmp1").value!="") && (document.getElementById("txttmp").value!=""))
	{
		document.getElementById("butnewdir").disabled="disabled";
		document.getElementById("loading").style.display="";
		if (((document.getElementById("txttmp1").value.indexOf(".")==-1) && (document.getElementById("txttmp1").value!=document.getElementById("txttmp").value)) || ((document.getElementById("txttmp1").value.indexOf(".")!=-1) && (document.getElementById("txttmp1").value.substring(0,document.getElementById("txttmp1").value.lastIndexOf("."))!=document.getElementById("txttmp").value)))
		var currpath;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		$.post(
            "ajax.aspx",
            {action:"RenameFile",path1:currpath,oldname:document.getElementById("txttmp1").value,newname:document.getElementById("txttmp").value},IsRename_callback
        )
	}
}
function IsRename_callback(res)
{
	document.all.loading.style.display='none';
	document.getElementById("butnewdir").disabled="";
	$('#newdir').modal('hide');
	var bRet = res;
	if (bRet != "")
	{
		swal("系统提示信息", bRet, "error");
		document.getElementById("txttmp").value="";
		document.getElementById("txttmp1").value="";
	}
	else
	{
		var currpath,txttmp;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		var oldname=document.getElementById("txttmp1").value;
		if (oldname.indexOf(".")!=-1)
		{
			var s=oldname.lastIndexOf(".");
			var s1=oldname.substring(s,oldname.length);
			txttmp=document.getElementById("txttmp").value+s1;
		}
		else txttmp=document.getElementById("txttmp").value;
		
		if (document.getElementById("DataGrid")!=null)
		{
			if (txttmp.indexOf(".")==-1) $("#chk"+$("#spanid").val()).html("<div id='chk"+ $("#spanid").val() + "' class='custom-control custom-checkbox mr-0'><input class='custom-control-input' type=checkbox name=checkbox id=chkSelect"+$("#spanid").val()+" onClick='AddRemoveValues(this)' value='"+currpath+txttmp+"/'><label class='custom-control-label' for='chkSelect"+  $("#spanid").val() + "'></label>");
			else $("#chk"+$("#spanid").val()).html("<div id='chk"+ $("#spanid").val() + "' class='custom-control custom-checkbox mr-0'><input class='custom-control-input' type=checkbox name=checkbox id=chkSelect"+$("#spanid").val()+" onClick='AddRemoveValues(this)' value='"+currpath+txttmp+"'><label class='custom-control-label' for='chkSelect"+  $("#spanid").val() + "'></label>");

			if (txttmp.indexOf(".")==-1) 
			{
				$("#a"+$("#spanid").val()).attr("href","ContentPane.aspx?Path="+currpath+"/"+txttmp+"/"); 
				$("#a"+$("#spanid").val()).text(txttmp);
			}
			else 
			{
				var tmp=$("#a"+$("#spanid").val()).attr("href");
				var reg=new RegExp(oldname,"gi");
				tmp=tmp.toString().replace(reg,txttmp);
				
				$("#a"+$("#spanid").val()).attr("href",tmp); 
				$("#a"+$("#spanid").val()).text(txttmp);
			}
		}
		else
		{
			if (txttmp.indexOf(".")==-1) $("#chk"+$("#spanid").val()).html("<div id='chk"+ $("#spanid").val() + "' class='custom-control custom-checkbox mr-2'><input class='custom-control-input' type=checkbox name=checkbox id=chkSelect"+$("#spanid").val()+" onClick='AddRemoveValues(this)' value='"+currpath+txttmp+"/'><label class='custom-control-label' for='chkSelect"+  $("#spanid").val() + "'></label>");
			else $("#chk"+$("#spanid").val()).html("<div id='chk"+ $("#spanid").val() + "' class='custom-control custom-checkbox mr-2'><input class='custom-control-input' type=checkbox name=checkbox id=chkSelect"+$("#spanid").val()+" onClick='AddRemoveValues(this)' value='"+currpath+txttmp+"'><label class='custom-control-label' for='chkSelect"+  $("#spanid").val() + "'></label>");


			if (txttmp.indexOf(".")==-1) 
			{
				$("#a"+$("#spanid").val()).attr("href","ContentPane.aspx?Path="+currpath+"/"+txttmp+"/"); 
				$("#a"+$("#spanid").val()).text(txttmp);
				$("#c"+$("#spanid").val()).attr("href","ContentPane.aspx?Path="+currpath+"/"+txttmp+"/"); 
			}
			else 
			{
				var tmp=$("#a"+$("#spanid").val()).attr("href");
				var reg=new RegExp(oldname,"gi");
				tmp=tmp.toString().replace(reg,txttmp);
				
				$("#a"+$("#spanid").val()).attr("href",tmp); 
				$("#a"+$("#spanid").val()).text(txttmp);
			}
		}
		rowcount++;
		document.getElementById("rowcount").value=rowcount;
	}
	document.getElementById("txttmp").value="";
	document.getElementById("txttmp1").value="";
}
function AddNoteInit(spanid)
{
	var oldname=$('#a'+spanid).text();
	document.getElementById("txttmp").value=oldname;
	document.getElementById("spanid").value=spanid;
	var notetxt;
	if (document.getElementById("DataGrid")!=null) notetxt=$('#b'+spanid).html();
	else notetxt=$('#c'+spanid).attr('title');
	document.all.txttmp1.value=notetxt;
	document.all.modalshow1.style.display='none';
	document.all.modalshow2.style.display='';

	$('#newdir').modal('show');
	$('#ModalLabel').text("添加/修改注释");
		$('#modalshow1').hide();
		$('#text2').val(notetxt);
		$('#butnewdir').bind('click',function(){
			AddNote();
		});
	document.getElementById('text2').onkeydown = function (e) {
		var theEvent = window.event || e;
		var code = theEvent.keyCode || theEvent.which;
		if (code == 13) {
		   AddNote();
		}
	}
}
function AddNote()
{
	Init();
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"AddNote",Path:currpath,name:document.getElementById("txttmp").value,content:document.getElementById("text2").value},IsAddNote_callback
        )
}
function IsAddNote_callback(res)
{
	document.all.loading.style.display='none';
	document.getElementById("butnewdir").disabled="";
	$('#newdir').modal('hide');
	var bRet = res;
	if (bRet != "")
	{
		swal("系统提示信息", bRet, "error");
		document.getElementById("txttmp").value="";
	}
	else
	{
		var bRet = res.value;
		if (document.getElementById("DataGrid")!=null) $("#b"+$("#spanid").val()).html(document.getElementById("txttmp1").value);
		else $('#c'+$("#spanid").val()).attr('title',document.getElementById("txttmp1").value);
	}
	document.getElementById("txttmp").value="";
}
function AddRow(rowcount,currpath,txttmp,share,fileordir,size,user,cache,copy,note)
{
	if (currpath.substring(currpath.length-1,currpath.length)!="/") currpath=currpath+"/";
	if (document.getElementById("DataGrid")!=null)
	{		
		var dll=document.getElementById("DataGrid");
		var _tr=dll.insertRow(1);
		//_tr.setAttribute("className","GridItem");
		//_tr.setAttribute("class","GridItem");
		_tr.setAttribute("id","DataGrid_"+rowcount);
		_tr.onmouseover=function() {this.className='table-active'};
		_tr.onmouseout=function() {this.className=''};
		
		var _td=_tr.insertCell(0);
		_td.setAttribute("align","Center");
		if (fileordir=="0") _td.innerHTML="<div class='custom-control custom-checkbox mr-0'><input type=checkbox class='custom-control-input' name=checkbox id=chkSelect"+rowcount+" onClick='AddRemoveValues(this)' value='"+user+currpath+txttmp+"/'><label class='custom-control-label' for='chkSelect"+ rowcount+ "'></label></div>";
		else _td.innerHTML="<div class='custom-control custom-checkbox mr-0'><input type=checkbox class='custom-control-input' name=checkbox id=chkSelect"+rowcount+" onClick='AddRemoveValues(this)' value='"+currpath+txttmp+"'><label class='custom-control-label' for='chkSelect"+ rowcount + "'></label></div>";
		
		var _td=_tr.insertCell(1);
		_td.setAttribute("align","Center");
		if (share == "0") _td.innerHTML="<img src=pics/folder.gif>"; else _td.innerHTML="<img src=pics/shared.GIF>";
		if (fileordir=="1") _td.innerHTML="<img src=filetype/zip.gif>";
		
		var _td=_tr.insertCell(2);
		if (fileordir=="0") _td.innerHTML="<a id='a"+rowcount+"' href='ContentPane.aspx?Path="+currpath+txttmp+"/'>"+txttmp+"</a><div id=b"+rowcount+" style='color:#7F7F7F'>"+note+"</div>";
		else _td.innerHTML="<a href='ContentPane.aspx?down=ok&filepath="+user+currpath+txttmp+"' id='a"+rowcount+"'>"+txttmp+"</a><div id=b"+rowcount+" style='color:#7F7F7F'>"+note+"</div>";
		
		var _td=_tr.insertCell(3);
		_td.setAttribute("align","right");
		var _tn=document.createTextNode(size);
		_td.appendChild(_tn);
		
		var d = new Date();
		var _td=_tr.insertCell(4);
		_td.setAttribute("align","Center");
		_td.innerHTML=d.getFullYear()+"/"+(d.getMonth() + 1)+"/"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
		
		var _td=_tr.insertCell(5);
		_td.setAttribute("align","Center");
		_td.innerHTML="<div class='dropdown ml-0'><a href='javascript:void(0)' id='clickindex"+rowcount+"' onmouseover='this.click()' class='btn btn-outline-light btn-sm' data-toggle='dropdown'> <img src='pics/other.png' height='15'/></a><div class='dropdown-menu dropdown-menu-right'><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();RenameInit('"+rowcount+"')\"><img src='pics/button9.png' width='15'/>&nbsp;&nbsp;改名</a><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();AddNoteInit('"+rowcount+"')\"><img src='pics/button11.png' width='15'/>&nbsp;&nbsp;注释</a> <div class='dropdown-divider'></div><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();deletefile2('"+rowcount+"')\"><img src='pics/button4_1.png' width='15'/>&nbsp;&nbsp;删除</a><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();cutfile2('"+rowcount+"','1')\"><img src='pics/button4_2.png' width='15'/>&nbsp;&nbsp;移动到...</a><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();cutfile2('"+rowcount+"','2')\"><img src='pics/button4_3.png' width='15'/>&nbsp;&nbsp;复制到...</a><div class='dropdown-divider'></div><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();toShare2('"+rowcount+"')\"><img src='pics/button6.png' width='15'/>&nbsp;&nbsp;设置共享</a><div class='dropdown-divider'></div><a class='dropdown-item' href='javascript:void(0)' onclick=\"$('#clickindex"+rowcount+"').click();infobox('"+txttmp+"','','','"+note+"')\"><img src='pics/button10.png' width='15'/>&nbsp;&nbsp;属性</a></div></div>";
		
	}
	else
	{
		window.location="ContentPane.aspx?Path="+getUrlParam('path');
	}
}
function newfile()
{
	document.all.modalshow1.style.display='';
	document.all.modalshow2.style.display='none';
	$('#newdir').modal('show');
	$('#ModalLabel').text("新建文本文件");
	$('#modalshow2').hide();
	$('#ModalText1').text("输入新文件名（不包括扩展名）");
	document.getElementById('butnewdir').onclick = function (){
		if (document.getElementById("txttmp").value!="")
		{
			document.getElementById("butnewdir").disabled="disabled";
			document.getElementById("loading").style.display="";
			newfileok();
		}
	}
	document.getElementById('text1').onkeydown = function (e) {
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which;
            if (code == 13) {
                $("#butnewdir").click();
            }
        }
}
function newfileok()
{
	var currpath;
	if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"newFile",path1:currpath,name:document.getElementById("txttmp").value},Isnewfile_callback
        )
}
function Isnewfile_callback(res)
{
	document.all.loading.style.display='none';
	document.getElementById("butnewdir").disabled="";
	$('#newdir').modal('hide');
	var bRet = res;
	if ((bRet != "0") && (bRet != "1"))
	{
		swal("系统提示信息", bRet, "error");
	}
	else
	{
		var currpath;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		var txttmp=document.getElementById("txttmp").value;
		window.open("editfile.aspx?filepath="+currpath+txttmp+".txt");
	}
	document.getElementById("txttmp").value="";document.getElementById("txttmp1").value="";
}
function shorturl(url,code)
{
	$.post(
            "ajax.aspx",
            {action:"SetShortUrl",url:url,code:code},IsurlOpr_callback
        )
}
function IsurlOpr_callback(res)
{
	var bRet = res;
	std_playUrl2(bRet);
}
function Init()
{
	document.all.loading.style.top =Math.round((document.body.clientHeight-100)/2)+document.body.scrollTop-50;
	document.all.loading.style.left =Math.round((document.body.clientWidth-100)/2)-100;
	document.all.loading.style.display='';
}
function checkselect()
{
	if (document.Form1.HdnSelectedValues.value=="")
	{
		var d = new dialog();d.init();
		d.set('src','pics/dlgico_excal.gif');
		d.set('title','系统提示信息');
		d.event("请勾选一个或多个文件再操作！", 'window.close();','','');	
		return false;
	}
	return true;
}

function getUrlParam(paramName){	
	var s=location.search;
	if(s!=null){
	var sarr=s.substr(1).split("&");
	var tarr;
	for(i=0;i<sarr.length;i++){
	tarr=sarr[i].split("=");
	if(tarr.length==2&&tarr[0].toLowerCase()==paramName){
	return tarr[1];
	}
	}
	return "";
	}
}
function cleanWhitespace(element) {
	for (var i = 0; i < element.childNodes.length; i++) {
		var node = element.childNodes[i];
		if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
		node.parentNode.removeChild(node);
	}
}
function searchgoto(){
	window.location="searchfile.aspx?action=ContentPane&Path="+getUrlParam('path');
}
function searchgoto2(){
	if (getUrlParam('path')=="") window.location="searchfile_out.aspx?action=myPane&Path="+getUrlParam('username')+"/";
	else window.location="searchfile_out.aspx?action=myPane&Path="+getUrlParam('path');
}
function show(tips,flag,url){
var my_tips=document.all.mytips;
if(flag){
	if (my_tips.style.display=="none") 
	{
		my_tips.style.display="";
		if (url!=null){my_tips.innerHTML="<div align=center><img src='"+url+"' width=100 height=100 onload=DrawImage(this)><br>"+tips+"</div>";}
		else{ my_tips.innerHTML=tips;}
	}
	my_tips.style.left=event.clientX+10;
	my_tips.style.top=event.clientY+10;
}
else 
{
my_tips.style.display="none";
}
}
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
	flag=true;
		if(image.width/image.height>= 120/80){
			if(image.width>120){  
				ImgD.width=100;
				ImgD.height=(image.height*100)/image.width;
			}else{
				ImgD.width=image.width;  
				ImgD.height=image.height;
			}
		
			}
			else{
				if(image.height>100){  
					ImgD.height=100;
					ImgD.width=(image.width*100)/image.height;     
				}else{
					ImgD.width=image.width;  
					ImgD.height=image.height;
			}
		}
	}
}
function btnover(obj){
obj.className="butdiv";
}
function btnout(obj){
obj.className="";
}
function std_playUrl(txt,url) {
	if (txt.charAt(txt.length-1)=="#") 
	{
		txt=document.getElementById("a"+txt.substring(0,txt.length-1)).href;
		shorturl(txt,url);
		return false;
	}
	txt=document.getElementById("a"+txt).href;
	txt=url.replace("{fileurl}",txt);
	std_playUrl2(txt);
}
function std_playUrl2(txt) {
	var textarea = document.createElement("textarea");
	var currentFocus = document.activeElement;
	document.getElementById("copyurl").appendChild(textarea);
	textarea.value = txt;
	textarea.focus();
	if (textarea.setSelectionRange)
		textarea.setSelectionRange(0, textarea.value.length);
	else
		textarea.select();
	try {
		var flag = document.execCommand("copy");
	} catch (eo) {
		var flag = false;
	}
	document.getElementById("copyurl").removeChild(textarea);
	currentFocus.focus();
	return flag;
}


var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which,id,optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
var ss;
ss = which.split(",");
menuobj.innerHTML="";
for(var i=0;i<ss.length;i++) menuobj.innerHTML=menuobj.innerHTML+linkset[ss[i]].replace("{fileurl}",id);
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
if (rightedge<menuobj.contentwidth)
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

function AddRemoveValues(oChk) { 
if(oChk.checked)
document.getElementById("HdnSelectedValues").value += "`" + oChk.value; 
else
document.getElementById("HdnSelectedValues").value = document.getElementById("HdnSelectedValues").value.replace("`" + oChk.value,"");
}

function checkAll()
{
   var a = document.getElementsByTagName("input");
   var check = document.getElementById("chkSelect");
   for (var i=0; i<a.length; i++)
   {
      if (a[i].type == "checkbox" && a[i].name=="checkbox") a[i].click();
   }
}
function toShare2(noteid) {
	$("#chkSelect"+noteid).attr("checked",'true');
	document.getElementById("HdnSelectedValues").value="`"+$("#chkSelect"+noteid).val();
	toShare();
}
//共享
function toShare() {
	var parames = new Array();
	
	if ($('#HdnSelectedValues').val()=="") {
		if (getUrlParam('path')=="")
			parames.push({ name: "sharelist", value: "`/"});
		else
			parames.push({ name: "sharelist", value: "`" +getUrlParam('path')});
	}
	else parames.push({ name: "sharelist", value: $('#HdnSelectedValues').val()});
	if (getUrlParam('path')=="") Post("share.aspx?path=/", parames);
	else Post("share.aspx?path="+getUrlParam('path'), parames);
	return false;
}
function toCode2(noteid) {
	$("#chkSelect"+noteid).attr("checked",'true');
	document.getElementById("HdnSelectedValues").value="`"+$("#chkSelect"+noteid).val();
	toCode();
}
//提取
function toCode() {
	if ($('#HdnSelectedValues').val()=="")
	{
		swal("系统提示信息", "请勾选文件进行提取操作！", "info");
	}
	else{
		var parames = new Array();
		parames.push({ name: "sharelist", value: $('#HdnSelectedValues').val()});
		if (getUrlParam('path')=="") Post("code.aspx?path=/", parames);
		else Post("code.aspx?path="+getUrlParam('path'), parames);
		return false;
	}
}
function toSend2(noteid) {
	$("#chkSelect"+noteid).attr("checked",'true');
	document.getElementById("HdnSelectedValues").value="`"+$("#chkSelect"+noteid).val();
	toSend();
}
//转发
function toSend() {
	if ($('#HdnSelectedValues').val()=="")
	{
		swal("系统提示信息", "请勾选文件进行转发操作！", "info");
	}
	else{
		var parames = new Array();
		parames.push({ name: "sharelist", value: $('#HdnSelectedValues').val()});
		if (getUrlParam('path')=="") Post("send.aspx?path=/", parames);
		else Post("send.aspx?path="+getUrlParam('path'), parames);
		return false;
	}
}
/*
*功能： 模拟form表单的提交
*参数： URL 跳转地址 PARAMTERS 参数
*/
function Post(URL, PARAMTERS) {
	//创建form表单
	var temp_form = document.createElement("form");
	temp_form.action = URL;
	//如需打开新窗口，form的target属性要设置为'_blank'
	temp_form.target = "_self";
	temp_form.method = "post";
	temp_form.style.display = "none";
	//添加参数
	for (var item in PARAMTERS) {
		var opt = document.createElement("textarea");
		opt.name = PARAMTERS[item].name;
		opt.value = PARAMTERS[item].value;
		temp_form.appendChild(opt);
	}
	document.body.appendChild(temp_form);
	//提交数据
	temp_form.submit();
}
//-------------mypane
function outlogin()
{
	$('#userlogin').modal('show');
	document.getElementById('butlogin').onclick = function (){
		if (document.getElementById("pass").value!="")
		{
			document.getElementById("butlogin").disabled="disabled";
			document.getElementById("loading2").style.display="";
			$.post(
            "ajax.aspx",
            {action:"OutLogin",password:document.getElementById("pass").value,ValidateCode:document.getElementById("ValidateCode").value},Isoutlogin_callback
			)
		}
	}
}
function Isoutlogin_callback(res)
{
	document.all.loading2.style.display='none';
	document.getElementById("butlogin").disabled="";
	$('#userlogin').modal('hide');
	var bRet = res;
	if (bRet != "")
	{
		swal("系统提示信息", bRet, "error");
	}
	else
	{
		window.location="userindex.aspx";
	}
}
var outtype="";
function uploadfile(type)
{
	document.all.pathurl.value=document.all.hidpath.value;
	outtype=type;
	$.post(
            "ajax.aspx",
            {action:"UploadFile",path:document.all.hidpath.value},Isuploadfile_callback
        )
}
function Isuploadfile_callback(res)
{
	var bRet = res;
	if (bRet != "")
	{
		swal("系统提示信息", bRet, "error");
	}
	else window.location='upload_out.aspx?out=1&Path='+document.all.hidpath.value+'&type='+outtype;
}
function newdirbox2()
{
	document.all.txttmp1.value="";
	document.all.txttmp.value="";
	$('#newdir').modal('show');
	$('#ModalLabel').text("新建文件夹");
	document.getElementById('butnewdir').onclick = function (){
		if (document.getElementById("txttmp").value!="")
		{
			document.getElementById("butnewdir").disabled="disabled";
			document.getElementById("loading").style.display="";
			newdirboxok2();
		}
	}
}
function newdirboxok2()
{
	var currpath;
	if (getUrlParam('path')=="") currpath=getUrlParam('username')+"/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"AddDir",path:currpath,name:document.getElementById("txttmp").value,note:document.getElementById("txttmp1").value},Isnewdir2_callback
        )
}
function Isnewdir2_callback(res)
{
	document.all.loading.style.display='none';
	document.getElementById("butnewdir").disabled="";
	$('#newdir').modal('hide');
	var bRet = res;
	if (bRet != "")
	{
		swal("系统提示信息", bRet, "error");
	}
	else window.location.reload();
}
function newfile2()
{
	document.all.txttmp1.value="";
	document.all.txttmp.value="";
	$('#newdir').modal('show');
	$('#ModalLabel').text("新建文本文件");
	$('#modalshow2').hide();
	$('#ModalText1').text("输入新文件名（不包括扩展名）");
	document.getElementById('butnewdir').onclick = function (){
		if (document.getElementById("txttmp").value!="")
		{
			document.getElementById("butnewdir").disabled="disabled";
			document.getElementById("loading").style.display="";
			newfileok2();
		}
	}
	document.getElementById('text1').onkeydown = function (e) {
            var theEvent = window.event || e;
            var code = theEvent.keyCode || theEvent.which;
            if (code == 13) {
                $("#butnewdir").click();
            }
        }
}
function newfileok2()
{

	var currpath;
	if (getUrlParam('path')=="") currpath=getUrlParam('username')+"/";else currpath=getUrlParam('path');
	$.post(
            "ajax.aspx",
            {action:"AddFile",path:currpath,name:document.getElementById("txttmp").value},Isnewfile2_callback
        )
}
function Isnewfile2_callback(res)
{
	document.all.loading.style.display='none';
	document.getElementById("butnewdir").disabled="";
	$('#newdir').modal('hide');
	var bRet = res;
	if (bRet != "")
	{
		swal("系统提示信息", bRet, "error");
	}
	else 
	{
		var currpath;
		if (getUrlParam('path')=="") currpath="/";else currpath=getUrlParam('path');
		var txttmp=document.getElementById("txttmp").value;
		window.open("editfile.aspx?filepath="+currpath+txttmp+".txt");
	}
	document.getElementById("txttmp").value="";document.getElementById("txttmp1").value="";
}
function downfile()
{
	if (confirm('多个文件需要使用迅雷进行批量下载，您确定要使用吗？'))
	{
		
			var str=location.href.toLowerCase();
			str=str.substr(0,str.indexOf("contentpane.aspx")+16);
			var arrTmp = document.getElementById("HdnSelectedValues").value.split("`"); 
			var strname="";
			var tmpstr="";
			var urls = [];
			for(var i = 1; i < arrTmp.length; i++) 
			{ 
				if (arrTmp[i].substr(arrTmp[i].length-1,1)!="/")
				{
					strname=arrTmp[i];
					strname=strname.substr(strname.lastIndexOf("/")+1);
					if ((arrTmp[i].substr(0,1)!="/") && (arrTmp[i].substr(0,3)!="%2f")) tmpstr=arrTmp[i];else tmpstr=document.getElementById("usernamestr").value+arrTmp[i];
					 urls.push({name:strname,url:str+"?down=ok&filepath="+tmpstr});
				}
			} 
			  thunderLink.newTask({
                downloadDir: '', // 指定当前任务的下载目录，迅雷会在用户剩余空间最大的磁盘根目录中创建这个目录。若不填此项，会下载到用户默认下载目录
                tasks: urls
            });
		
	}
}
function infobox(name,time,size,note)
{
	$('#shuxing').modal('show');
	if (size=="")
	{
		$('#infotitle').text("文件夹属性");$('#inforow1').text(name);$('#inforow4').hide();$('#inforow3').text(time);$('#inforow5').text(note);
		if (note=="") $('#inforow6').hide();else $('#inforow6').show();
	}
	else{
		$('#infotitle').text("文件属性");$('#inforow1').text(name);$('#inforow2').text(size);$('#inforow4').show();$('#inforow3').text(time);$('#inforow5').text(note);
		if (note=="") $('#inforow6').hide();else $('#inforow6').show();
	}
}