var cmsg, pmsg, retstr, validstr, cdirretstr;

function opendir(nfvalue)
{document.mainform.faction.value='1';
document.mainform.nf.value=nfvalue;
document.mainform.submit();}


function checkSelected(x) {
	if (x == -1) {
		alert("执行该操作之前您必须选择一个目录或文件.")
		return false; }
	else return true;
}
function checkFolder(values) {
	if (values.indexOf('.')<1) {
		return true; }
	else return false;
}
function GoInstallExamples() {
	if (document.mainform.InstallDemos.selectedIndex != 1) {
		alert("You must first select a demo to install before choosing this action.");
	}
	else {
		document.instexform.exnum.value = document.mainform.InstallDemos.selectedIndex;
		// alert ("==" + document.mainform.InstallDemos.selectedIndex);
		document.instexform.submit();
	}
}

function makeonefile(currdir) {
	pmsg = "请输入一个新的文件名：";
	validstr = "在此输入新文件名";
	newfilestr = prompt(pmsg,validstr);
		if (newfilestr != null) {
			document.makeonefiles.nf.value = currdir;
			document.makeonefiles.newfile.value = newfilestr;
			document.makeonefiles.submit();
		}
}
function createdir(currdir) {
	pmsg = "请输入一个新的目录名：";
	validstr = "在此输入新目录名";
	cdirretstr = prompt(pmsg,validstr);
		if (cdirretstr != null) {
			document.cdir.nf.value = currdir;
			document.cdir.newdir.value = cdirretstr;
			document.cdir.submit();
		}
}
function editfile(editthis) {
	document.editform.file2edit.value = editthis;
	document.editform.submit();
}
function newfile(thisdir) {
	document.newfileform.fcurrdir.value = thisdir;
	document.newfileform.submit();
}
function dfile(file2d) {
	document.downloadfileform.file2download.value = file2d;
	document.downloadfileform.submit();
}
function viewfile(file2view) {
//	file2view = file2view.replace("/","\\")
	document.viewfileform.f2v.value = file2view;
	document.viewfileform.submit();
}

function renfile(currentfolder,file2ren) {
	pmsg = "请输入新文件名或按<取消>放弃。\n";
	pmsg = pmsg + "并且不要包含路径.\n";
	retstr = prompt(pmsg,"在词输入一个新的文件名或文件夹名");
		if (retstr != null) {
			document.renameform.nf.value = currentfolder;
			document.renameform.fsel.value = file2ren;
			document.renameform.newname.value = retstr;
			document.renameform.submit(); }
}

function delfile(currentfolder,file2del) {
	cmsg = "如果你选择的是一个目录，该目录下所有的文件都将被删除.\n"
	cmsg = cmsg + "你确定删除 " + file2del + "吗？"
	if (confirm(cmsg)) {
		document.deleteform.nf.value = currentfolder;
		document.deleteform.fsel.value = file2del;
		document.deleteform.submit();
	}
}
function CheckData()
{
	if((jtrim(document.FileUploads.file1.value)=="")&&(jtrim(document.FileUploads.file2.value)=="")&&(jtrim(document.FileUploads.file3.value)=="")&&(jtrim(document.FileUploads.file4.value)=="")&&(jtrim(document.FileUploads.file5.value)==""))
	{
		alert("请选择上传文件。")
		return false;
	}
	return true;
}
function jtrim(s)
{
	var i,b=0,e=s.length;
	for(i=0;i<s.length;i++) if(s.charAt(i)!=' '){b=i;break;}
	if(i==s.length) return "";
	for(i=s.length-1;i>b;i--) if(s.charAt(i)!=' '){e=i;break;}
	return s.substring(b,e+1);
}