function showoff(){getId("rightmenu").style.display="none";}

function fileok(secid)
{
	var secvalue=getId("geturl").value;
	if(secid&&secvalue=="")
	{
		DvWnd.open('返回错误','../admin_help.asp?id=98',0,500,200,1,{bgc:'#ffffff',opa:0.6});
		return false;
	}
	if(parent.window.frmright)
	{
		var obj=parent.window.frmright.getId(secid);
		var obj2=parent.window.frmright.getId(secid+"type");
		var obj3=parent.window.frmright.getId(secid+"size");
		if(obj){obj.value=secvalue;}
		if(obj2){obj2.value=getId("FileType").value;}
		if(obj3){obj3.value=getId("FileSize").value;}
		getFid("bgs").style.display="none";
		getFid("showMsg_Id").style.display="none";
	}
	else
	{
		var obj=getFid(secid);
		var obj2=getFid(secid+"type");
		var obj3=getFid(secid+"size");
		if(obj){obj.value=secvalue;}
		if(obj2){obj2.value=getId("FileType").value;}
		if(obj3){obj3.value=getId("FileSize").value;}
		wndClose();
	}	
}

function fileset(obj,FileUrl,FileType,i)
{
	var ispic=false;
	var defw;
	var pictypestr="jpg,gif,bmp,png";
	if(pictypestr.indexOf(FileType)>=0){ispic=true;}
	var pic=getId("filepic");
	getId("filesx").style.display="none";
	
	if(ispic)
	{
		pic.src=FileUrl+"?_i="+Math.random();
	}
	else
	{
		pic.src="filepic/big_"+FileType+".gif";
	}
	if(FileType!="文件夹"){pic.alt="点击浏览";pic.onclick=function(){window.open(FileUrl);}}
	pic.onerror=function(){pic.src="filepic/big_def.gif";}
}

function fileset2(obj,FileUrl,FilePath,FileType,FileSize,i,e)
{
	var unFileUrl=unescape(FileUrl);
	var esFileUrl=escape(FileUrl);
	var isfile=true;
	var ispic=false;
	var istxt=false;
	var pictypestr="jpg,gif,bmp,png";
	var txttypestr="asp,html,htm,txt,js,css,xml";
	if(pictypestr.indexOf(FileType)>=0){ispic=true;}
	if(txttypestr.indexOf(FileType)>=0){istxt=true;}
	var nowid=getId("nowid");
	if(FileType=="文件夹"){isfile=false;}
	nowid.value=i;	
	var pic=getId("filepic");
	if(isfile)
	{
		getId("geturl").value=unFileUrl;
		getId("FileType").value=FileType.toUpperCase();
		getId("FileSize").value=FileSize;
		
	}
	var oldid=getId("oldid");
	if(getId("file"+oldid.value))
	{
		getId("file"+oldid.value).className="filelist";
	}
	getId("file"+i).className="fileliston";
	oldid.value=i;
	if(ispic)
	{
		getId("filesx").style.display="";
		getId("filesx").innerHTML="图片尺寸："+pic.width+"×"+pic.height;
	}
	var cbutton=parseInt(e.button);
	var browstr=browserck();	
	if(browstr=="TT"||browstr=="IE6"){rbutton=0;}else{rbutton=2;}	
	if(cbutton==rbutton||cbutton>2)
	{		
		var rhtml='<table>';
		rhtml+='<tr><td><a href="?FilePath='+FilePath+'&_i='+Math.random()+'">刷新</a></td></tr>';
		if(isfile){	rhtml+='<tr><td><a href="'+unFileUrl+'" target="_blank">打开</a></td></tr>';}	
		if(istxt){rhtml+='<tr><td><a href="javascript:Editfile(\''+esFileUrl+'\')">编辑</a></td></tr>';}
		if(ispic){rhtml+='<tr><td><a href="javascript:CutPic(\''+esFileUrl+'\',1)">图片裁切[等比]</a></td></tr>';}
		if(ispic){rhtml+='<tr><td><a href="javascript:CutPic(\''+esFileUrl+'\',2)">图片裁切[自由]</a></td></tr>';}
		rhtml+='<tr><td><a href="javascript:Rname(\''+esFileUrl+'\','+isfile+')">重命名</a></td></tr>';
		rhtml+='<tr><td><a href="javascript:Addwjjia(\''+escape(FilePath)+'\')">新建文件夹</a></td></tr>';
		rhtml+='<tr><td><a href="javascript:Delwj(\''+esFileUrl+'\',\''+escape(FilePath)+'\')">删除</a></td></tr>';
		rhtml+='</table>';
		var theY=e.clientY;
		getId("rightmenu").style.display="";
		if(theY>300)
		{getId("rightmenu").style.top=theY-110;}
		else
		{getId("rightmenu").style.top=theY;}
		getId("rightmenu").style.left=e.clientX;
		getId("rightmenu").innerHTML=rhtml;
		var theH=getId("rightmenu").style.height;
	}
}

function browserck()
{
	var s=window.navigator.userAgent;
	if(s.indexOf("Tencent")>0)
		return "TT";
	else if(s.indexOf("Firefox")>0)
		return "FF";
	else if(s.indexOf("Chrome")>0)
		return "GG";
	else if(s.indexOf("MSIE 6.0")>0)
		return "IE6";
	else if(s.indexOf("MSIE 7.0")>0)
		return "IE7";	
	else
		return "IE";			
}

function showright(obj)
{
	var obj2=getId("right");
	if(obj2.style.display=="none")
	{
		obj2.style.display="";
		obj.src="filepic/R.gif";
		setCookie("upfile_right","")
	}
	else
	{
		obj2.style.display="none";
		obj.src="filepic/L.gif";
		setCookie("upfile_right","close")
	}
}

function changlist()
{
	var obj=getId("lefts");
	if(obj.className=="filelist2")
	{
		obj.className="filelist1"
		setCookie("upfile_filelist","filelist1")
	}
	else
	{
		obj.className="filelist2"
		setCookie("upfile_filelist","filelist2")
	}
}

function filelistset()
{
	var obj=getId("lefts");
	var a=getCookie("upfile_filelist");
	if(a)obj.className=a;
}
	
function Editfile(FilePath)
{
	DvWnd.open('文件 '+unescape(FilePath)+" 编辑",'index.asp?action=Editfile&FilePath='+FilePath+'&_i='+Math.random(),0,900,500,1,{bgc:'#ffffff',opa:0.6})
}

function CutPic(picPath,cases)
{//1为等比 2为自由
	if(cases==1)DvWnd.open('图片 '+unescape(picPath)+" 裁切",'index.asp?action=CutPic&picPath='+picPath+'&auto=1&_i='+Math.random(),0,900,555,1,{bgc:'#ffffff',opa:0.6})
	if(cases==2)DvWnd.open('图片 '+unescape(picPath)+" 裁切",'index.asp?action=CutPic&picPath='+picPath+'&_i='+Math.random(),0,900,555,1,{bgc:'#ffffff',opa:0.6})
}


function Rname(FilePath,isfile)
{
	DvWnd.open('文件重命名','index.asp?action=Rname&FilePath='+escape(FilePath)+'&isfile='+isfile+'&_i='+Math.random(),0,500,100,1,{bgc:'#ffffff',opa:0.6})
}

function formatName(id)
{
	var obj=getId(id);
	if(obj.value==""){alert("请输入文件名");obj.focus();return false;}
	if(IsStr(obj.value)!=obj.value.length)
	{
		alert("1、文件名不符合标准；\n2、只能是字母、数字、点和下划线的组合；\n3、不能含有汉字、空格和其他符号。");
		obj.focus();
		return false;
	}
	
}

function IsStr(w)
{
	var str = "abcdefghijklmnopqrstuvwxyz_1234567890."
	 w = w.toLowerCase();
	var j = 0;
	for(i=0;i < w.length;i++){
		if(str.indexOf(w.substr(i,1)) != -1){
			j++;
		}
	}
	return j;
}

function Addwjjia(FilePath)
{
	DvWnd.open('新建文件夹','index.asp?action=Addwjjia&FilePath='+escape(FilePath)+'&_i='+Math.random(),0,400,100,1,{bgc:'#ffffff',opa:0.6})
}

function upFiles(FilePath)
{
	DvWnd.open('文件上传','index.asp?action=upFiles&FilePath='+escape(FilePath)+'&_i='+Math.random(),0,600,300,1,{bgc:'#ffffff',opa:0.6})
}

function Delwj(DelPath,FilePath)
{
	if(confirm("确定删除？"))
	{
		ajax2("index.asp","action=Delwj&FilePath="+escape(DelPath));
		location.href="?FilePath="+FilePath;
	}
}

function dels(FilePath)
{
	var obj=getName("delfiles");
	var delstr="";
	var num=obj.length;
	var havefile=false;
	for(i=0;i<num;i++)
	{
		if(obj[i].checked)havefile=true;
	}
	if(havefile&&confirm("确定删除选定文件？\n此操作将不可恢复，请慎重选择？"))
	{
		if(confirm("请再次确认！"))
		{
			for(i=0;i<num;i++){if(obj[i].checked){ajax2("index.asp","action=Delwj&FilePath="+obj[i].value);}}
			if(havefile){location.href="?FilePath="+FilePath;}
		}
	}
}

function GetWebPic(FilePath)
{
	DvWnd.open('远程抓图','index.asp?action=GetWebPic&FilePath='+escape(FilePath)+'&_i='+Math.random(),0,600,100,1,{bgc:'#ffffff',opa:0.6})
}

function checkpicUrl()
{
	var obj=getId("picUrl");
	var objs=obj.value.toLowerCase();
	if(objs==""){alert("请输入图片地址！");obj.focus();return false;}
	if(objs.indexOf(".gif")<0&&objs.indexOf(".jpg")<0&&objs.indexOf("http://")<0&&objs.indexOf("/")<0){alert("请输入完整的图片地址，只支持GIF、JPG图片抓取！");obj.focus();return false;}	
	lock_button("Submit1","Submit2","loading","<img src=filepic/loading.gif> 文件保存中，请稍候……");
}

function upFileOption()
{
	var UpFileNum = getId("UpFileNum").value;
	if (UpFileNum=='')
	UpFileNum=5;
	var k,i,Optionstr,n=0;
	Optionstr=""
	for(k=0;k<UpFileNum;k++)
	{
		n=n+1;
		if(UpFileNum==1)
			{Optionstr = Optionstr+'文 件：<input type="file" size="30" name="File'+n+'" /><br>';}
		else
			{Optionstr = Optionstr+'文 件'+n+'：<input type="file" size="30" name="File'+n+'" /><br>';}
		if(n==UpFileNum)break;
	}
	getId("FilesList").innerHTML = Optionstr;
}

function upFileOk(FilePath)
{
	parent.location.href="index.asp?FilePath="+FilePath;
	wndClose();
}

function getRadioValue(name)
{
	var obj=getName(name);
	var re="0";
	if(obj)
	{
		for(i=0;i<obj.length;i++){if(obj[i].checked)re=obj[i].value;}
	}
	return re;
}

function upFileCk()
{
	var obj,objv,objvarr,havefile=false,suobig_w="",suobig_h="";
	var UpFileNum=getId("UpFileNum").value;
	var FilePath=getId("FilePath").value;
	var AllowSize=getId("AllowSize").value;
	var AllowTypes=getId("AllowTypes").value;
	var shuipic_c=getRadioValue("shuipic_c");	
	var suobig_c=getRadioValue("suobig_c");	
	if(getId("suobig_w"))suobig_w=getId("suobig_w").value;
	if(getId("suobig_h"))suobig_h=getId("suobig_h").value;
	var nameType=getRadioValue("nameType");
	setCookie("fileup_shuipic_c",shuipic_c);
	setCookie("fileup_suobig_c",suobig_c);
	setCookie("fileup_suobig_w",suobig_w);
	setCookie("fileup_suobig_h",suobig_h);
	setCookie("fileup_nameType",nameType);	
	for(i=1;i<=UpFileNum;i++)
	{
		obj=getId("file"+i);
		objv=obj.value.toUpperCase();
		objvarr=objv.split(".");
		objs=objvarr[objvarr.length-1];
		if(objv!="")
		{
			havefile=true;
			if(AllowTypes=="NOT"){alert("当前目录不允许上传文件！");return false;}
			if(AllowTypes.indexOf(objs)<0&&AllowTypes!="ALL"){alert("错误文件格式，允许格式："+AllowTypes);obj.focus();return false;}
		}
	}
	if(!havefile){alert("请至少上传一个文件！");getId("file1").focus();return false;}
	lock_button("Submit1","Submit2","loading","<img src=filepic/loading.gif> 文件保存中，请稍候……");		
}