<%
include("language.html")
%>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="0" />
<%
if _SESSION["username"] ~= nil and _SESSION["currentpath"] ~= nil then

local plugin_dir = c_GetAppPath().."/webclient/plugins"

for isdir,plugin in c_GetFileDir(plugin_dir) do
	if isdir == true and c_FileExist(plugin_dir.."/"..plugin.."/setting.html") then
		include("plugins/"..plugin.."/setting.html")
	end
end

local enable_changepass, changepass_firstlogon = c_CanChangePass(_SESSION["username"])
local enable_sendmessage = c_CanSendMessage()
local enable_online_edit = c_CanOnlineEdit()
local weblink_url = c_GetWeblinkURL()
local http_keepalive = c_HttpKeepAlive()

local imageDate = c_GetFileTime(c_GetAppPath().."/webclient/images/"..c_GetDomainLogo())

local cellwidth = {"500", "120", "150", "180"}
for i=1,4 do
	local index = i - 1
	if _COOKIE["cellwidth"..index] ~= nil and tonumber(_COOKIE["cellwidth"..index]) ~= "" then
		cellwidth[i] = tonumber(_COOKIE["cellwidth"..index])
		if cellwidth[i] < 80 then
			cellwidth[i] = 80
		end
		if cellwidth[i] > 1920 then
			cellwidth[i] = 1920
		end
	end
end
%>
<head>
<title>
Wing FTP Server - Web Client
<%
local nType = c_GetLicenseInfo()
if nType >= 5 then
	print("(UNREGISTERED)")
end
%>
</title>
</head>
<link rel="Shortcut Icon" href="images/logo.ico" type="image/x-icon">
<link rel="stylesheet" href="css/bulma.min.css" type="text/css">
<link rel="stylesheet" href="css/allfonts.min.css" type="text/css">
<link rel="stylesheet" href="css/style.css?v=4" type="text/css" />
<script language="javascript" src="include/checkflash.js"></script>
<script language="javascript" src="include/common.js?v=8"></script>

<script language="javascript">
isIphone = navigator.userAgent.toLowerCase().indexOf('iphone')==-1? 0:1;
isAndroid = navigator.userAgent.toLowerCase().indexOf('android')==-1? 0:1;
isWindowsPhone = navigator.userAgent.toLowerCase().indexOf('windows phone')==-1? 0:1;
if(isIphone || isAndroid || isWindowsPhone)
{
	if(navigator.cookieEnabled)
		location = 'main_m.html';
}

var _TIMER_UPLOADING = null;
var _TIMER_KEEPLIVE = null;
var EXPTag = "session expired";
var viewmode = false;
var row_filenum = 5;
var now_dir = "/";
var now_image = "";
var file_num = 0;
var dir_num = 0;
var total_num = 0;
var thumb_num = 0;
var total_size = 0;
var selectedRow = null;
var lastObj = null;
var start_time = 0;
var uploading = false;
var upload_file = "";
var upload_filename = "";
var imageGroup = new Array();
var imgMap = null;
var imgMap2 = null;
var imglist = null;
var imglist2 = null;
var download_url = "";
var last_uploadsize = 0;
var last_lefttime = -1;
var auto_overwrite = false;
var txt_filename = "";
var last_field = -1;
var reverse_sort = 0;
var enable_online_edit = "<%=enable_online_edit%>";
var weblink_url = "<%=weblink_url%>";
var isEdge = navigator.userAgent.toLowerCase().indexOf("edg") > -1 && !isIE;
var isIE11 = navigator.userAgent.toLowerCase().indexOf("trident") > -1;
var overwriteFolders = {};
var thumb_flag = 0;
var copycutFiles = "";

<% if _GET["sort"] ~= nil and _GET["r"] ~= nil and string.len(_GET["sort"]) <= 2 and string.len(_GET["r"]) <= 2 then %>
	last_field = parseInt("<%=_GET['sort']%>");
	reverse_sort = parseInt("<%=_GET['r']%>");
<% end %>



var charArray = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
function generateRandom() 
{
    var result = "";
	for(var i = 0; i < 8; i++) 
	{
		var index = 0;
		index = Math.ceil(Math.random()*(charArray.length-1) );
		result += charArray[index];
	}
	$("downloadpass").value = result;
}

function clear_imageGroup() 
{
	imageGroup = null;
	imageGroup = new Array();
}

function gotoUrl(url, newTab) 
{
	var isBrowserIE = navigator.userAgent.indexOf('MSIE')==-1? 0:1;
	if (isBrowserIE) 
	{
		try
		{
			if (newTab) 
			{
				var referLink = document.createElement("a");
				referLink.href = url;
				referLink.target = "_blank";
				document.body.appendChild(referLink);
				referLink.click();
				document.body.removeChild(referLink);
			} 
			else
			{
				var referLink = document.createElement("a");
				referLink.href = url;
				document.body.appendChild(referLink);
				referLink.click();
			}
		}
		catch(e)
		{
			window.location = url;
		}
	} 
	else
	{
		if (newTab) 
		{
			window.open(url, "_blank");
		}
		else 
		{
			window.location = url;
		}
	}
}

function ajaxResponse()
{
	if (xmlhttp.readyState == 4)
	{
		ajaxlock = false;
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'chdir':		chdir();break;
					case 'mkdir':		mkdir();break;
					case 'rmdir':		rmdir();break;
					case 'rename':		rename();break;
					case 'paste':		paste();break;
					case 'dir':			showlist();break;
					case 'changepass':	changepass();break;
					case 'checkdownload':	checkdownload_Result();break;
					case 'zip':			zip();break;
					case 'unzip':		unzip();break;
					case 'rmdirfile':	rmdirfile();break;
					case 'mkfile':		mkfile();break;
					case 'weblink':		weblink();break;
					case 'weblink_update':		weblink_update_result();break;
					case 'uplink':		uplink();break;
					case 'uplink_update':		uplink_update_result();break;
					case 'bookmark':		bookmark_result();break;
				}
			}
			catch(e)
			{
				if(page != "dir")
					alert("<%=LANG['error_ajax']%>");
			}
			finally
			{
				//if(page != "dir")
				//{
					$("waitingdiv").style.display = "none";
					$("waitingdiv2").style.display = "none";
				//}
			}
		}
		else
		{
			$("waitingdiv").style.display = "none";
			$("waitingdiv2").style.display = "none";
			if(page != "")
				alert("<%=LANG['error_ajax']%>");

		}
	}
}

function uploadError()
{
	if(uploading == true)
		alert("<%=LANG['error_upload']%>");
	uploadEnd();
}

function uploadRefresh()
{
	var ajaxObject = false;
	ajaxObject = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();

	if(ajaxObject) 
	{
		ajaxObject.open("GET","uploadstat.html?r="+Math.random() );
		ajaxObject.onreadystatechange = function()
		{
			if (ajaxObject.readyState == 4) 
			{
				if(ajaxObject.status == 200)
				{
					if(uploading == true)
					{
						var result = trim(ajaxObject.responseText);
						if(result == "-1")
						{
							if((upload_filename != "" && upload_filename == upload_file) || upload_filename == "")
							{
								if(last_lefttime < 0 || last_lefttime > 4)
								{
									setTimeout("uploadError()",1000);
								}
								else
								{
									uploadEnd_ok();
									ajaxRequest("dir","");
								}
							}
							else
							{
								uploadEnd_ok();
								ajaxRequest("dir","");
							}
						}
						else if(result == "-2")
						{
							alert("<%=LANG['error_upload']%>");
							uploadEnd();
						}
						else if(result == "-3")
						{
							alert("<%=LANG['error_upload3']%>");
							uploadEnd();
							ajaxRequest("dir",'r='+Math.random());
						}
						else if(result == "-4")
						{
							alert("<%=LANG['error_upload4']%>");
							uploadEnd();
							ajaxRequest("dir",'r='+Math.random());
						}
						else if(result == "0")
						{
							alert("<%=LANG['session_expire']%>");
							uploadEnd();
						}
						else if(result != "")
						{
							try
							{
								result = result.split("/");
								var d = new Date();
								var end_time = d.getTime();
								if(parseInt(result[0]) < last_uploadsize)
								{
									result[0] = last_uploadsize;
								}
								else
								{
									last_uploadsize = result[0];
								}
								var speed = fileSize(1000*result[0]/(end_time-start_time));
								var leftsize = (result[1]-result[0]) > 0 ? (result[1]-result[0]) : 0;
								var lefttime = leftsize / (1000*result[0]/(end_time-start_time));
								var scale = round((result[0] / result[1])*100 , 2);
								upload_filename = result[2];
								last_lefttime = parseInt(lefttime);

								if(upload_filename != "" && upload_filename != upload_file)
								{
									uploadError();
									return;
								}

								upload_filename = htmlencode(upload_filename);

								$("uploadingDiv").innerHTML = "<%=LANG['uploadstat_filename']%><span title='"+upload_filename+"'>"+upload_filename.substr(0,32)+(upload_filename.length > 32 ? "...":"")+"</span><br><%=LANG['uploadstat_totalsize']%>"+fileSize(result[1])+"<br><%=LANG['uploadstat_nowsize']%>"+fileSize(result[0])+"<br><%=LANG['uploadstat_speed']%>"+speed+"/s";
								$("uploadingDiv").innerHTML += "<br><%=LANG['uploadstat_sizeleft']%>"+fileSize(leftsize)+", <%=LANG['uploadstat_timeleft']%>"+formatTime(lefttime);
								$("uploadingDiv").innerHTML += "<br><div class='progress_border'><div class='progress_bar' style='background-position:"+(100-scale)+"% 0px'>"+scale+"%</div></div>";
							}
							catch(e){}
						}
					}

				}
				delete ajaxObject;
				ajaxObject = null;
			}
		}
		ajaxObject.send("");
	}
}

function sess_expire()
{
	alert("<%=LANG['session_expire']%>");
	gotoUrl("logout.html");
}

function chdir()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	ajaxRequest("dir",'r='+Math.random());
}

function mkdir()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	alert(result);	
	top.closewindow();
	ajaxRequest("dir",'r='+Math.random());
}

function rmdir()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	alert(result);	
	ajaxRequest("dir",'r='+Math.random());
}

function rename()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	alert(result);	
	top.closewindow();
	ajaxRequest("dir",'r='+Math.random());
}

function paste()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	alert(result);	
	$("pasteitem").style.display = "none";
	$("pasteitem2").style.display = "none";
	$("pasteitem3").style.display = "none";
	ajaxRequest("dir",'r='+Math.random());
}


function showlist()
{
	clear("listview_div");
	clear_imageGroup();
	$("waitingdiv").style.display = "";
	var nowquota = 0;
	var maxquota = 0;
	var readfile = 0;

	selectedRow = null;
	$("checkall").checked = false;
	$("operation_buttons").style.display = "none";
	$("office_editing").style.display = "none";
	$("office_editing2").style.display = "none";
	file_num = 0;
	dir_num = 0;
	total_num = 0;
	total_size = 0;
	hitcount = 0;

	try
	{
		var result = trim(xmlhttp.responseText);
		if(result == EXPTag)
		{
			sess_expire();
			return;
		}

		var xmldoc = xmlhttp.responseXML;
		var row = xmldoc.getElementsByTagName("rowdata");
		var rownum = row.length;

		try
		{
			now_dir = decodeURIComponent(xmlFieldValue(xmldoc,"nowdir"));
		}
		catch(e)
		{
			now_dir = xmlFieldValue(xmldoc,"nowdir");
		}

		nowquota = xmlFieldValue(xmldoc,"nowquota");
		maxquota = xmlFieldValue(xmldoc,"maxquota");
		readfile = xmlFieldValue(xmldoc,"readfile");

		var headcell = $("listhead").rows[0].cells;
		var htmltext = "<table id='listtable' width='100%' border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed;'><thead><tr height='0'><td width='"+headcell[0].width+"'></td><td width='"+headcell[1].width+"'></td><td width='"+headcell[2].width+"'></td><td width='"+headcell[3].width+"'></td><td></td></tr></thead><tbody id='maintable'>";

		for(var i=0; i < rownum; i++)
		{
			try
			{
				var myrow = row[i];
				f_img = "";
				f_perm = xmlFieldValue(myrow,"perm");
				f_size = xmlFieldValue(myrow,"size");
				f_group = xmlFieldValue(myrow,"group");
				f_date = xmlFieldValue(myrow,"date");
				f_name = decodeURIComponent(xmlFieldValue(myrow,"name"));
				f_isdir = xmlFieldValue(myrow,"dir");
				f_dir = "<%=LANG['list_directory']%>";
				f_md5 = "";
				if(readfile == 1)
				{
					f_md5 = xmlFieldValue(myrow,"md5");
				}
				filesize = f_size;

				total_size += parseInt(f_size);

				if(f_isdir == 1)
				{
					if(isIE)
						f_img = "<img _src='icons/folder.png'> ";
					else
						f_img = "<img src='icons/folder.png'> ";

					f_size = "-";
					dir_num++;
				}
				else
				{
					var file_ext = getExtention(f_name);
					var file_name = urlEncodeSpecial(f_name);
					f_dir = "&nbsp;" + file_ext + " <%=LANG['list_filetype']%>";
					f_size = fileSize(f_size);
					if(isIE)
					{
						if(typeof(extIcons[file_ext]) != "undefined" && extIcons[file_ext] != "")
							f_img = "<img _src='icons/file_"+ extIcons[file_ext] +".png'> ";
						else
							f_img = "<img _src='icons/file_default.png'> ";
					}
					else
					{
						if(typeof(extIcons[file_ext]) != "undefined" && extIcons[file_ext] != "")
							f_img = "<img src='icons/file_"+ extIcons[file_ext] +".png'> ";
						else
							f_img = "<img src='icons/file_default.png'> ";
					}
					if(file_ext == "gif" || file_ext == "png" || file_ext == "jpg" || file_ext == "jpeg" || file_ext == "bmp")
						imageGroup.push(file_name);

					file_num++;
				}


				if(isIE)
					htmltext += "<tr class='listtr01' oncontextmenu='do_list_click(this,-1,1);' onclick='do_list_click(this,-1);' ondblclick='do_list_dblclick(this,-1);' tabIndex='-1'>";
				else
					htmltext += "<tr class='listtr01' oncontextmenu='do_list_click(this,-1,1);' onclick='do_list_click(this,-1);' tabIndex='-1'>";

				htmltext += "<td class='paddingtd' id='tr_"+i+"' md5='"+f_md5+"' isdir='"+f_isdir+"' fsize='"+filesize+"' name=\""+htmlencode(f_name)+"\"><input type='checkbox' id='cid_"+i+"' cid='"+i+"' flag='list'> "+f_img+htmlencode(f_name)+"</td>";
				htmltext += "<td class='paddingtd'>"+f_size+"</td>";
				htmltext += "<td class='paddingtd'>"+f_dir+"</td>";
				htmltext += "<td class='paddingtd'>"+f_date+"</td>";
				htmltext += "<td></td></tr>";
				
				total_num++;
				lastsortcol = -1;
				
			}
			catch(e){}
		}

		htmltext += "</tbody></table>";
		write("listview_div",htmltext);
		$("listview_div").scrollTop = 0;
	}
	catch(e)
	{
		$("waitingdiv").style.display = "none";
		$("waitingdiv2").style.display = "none";
		var result = trim(xmlhttp.responseText);
		if(result == EXPTag)
		{
			sess_expire();
			return;
		}
	}

	var strNavBar = "";
	strNavBar = "<img src=\"images/return.png\" class=\"cur\" draggable=\"false\" title=\"<%=LANG["item_goup"]%>\" onclick=\"goUp()\">&nbsp;&nbsp;<img src=\"images/home.png\" class=\"cur\" draggable=\"false\" title=\"<%=LANG["item_gohome"]%>\" onclick=\"ajaxRequest('chdir','dir=/')\"> /";
	var nowdirArray = now_dir.split("/");
	var nowdirPath = "";
	for (var i=0; i<nowdirArray.length; i++)
	{
		if(nowdirArray[i] != "")
		{
			nowdirPath += "/" + nowdirArray[i];
			if(i <= 1)
				strNavBar += " <span class=\"cur\" style=\"color:#333\" onclick=\"ajaxRequest('chdir','dir="+urlEncode(nowdirPath)+"')\">" + nowdirArray[i] + "</span>";
			else
				strNavBar += " / <span class=\"cur\" style=\"color:#333\" onclick=\"ajaxRequest('chdir','dir="+urlEncode(nowdirPath)+"')\">" + nowdirArray[i] + "</span>";
		}
	}

	$("statbar").innerHTML = strNavBar+"&nbsp;&nbsp;<span style='color:#888'><%=LANG['headbar_txt2']%>"+file_num+"<%=LANG['headbar_txt3']%>"+dir_num+"<%=LANG['headbar_txt4']%></span>";


	if(maxquota != 0)
	{
		if(parseInt(nowquota) > parseInt(maxquota))
		{
			nowquota = maxquota;
		}
		var scale = round((nowquota / maxquota)*100 , 2);
		var strUsedQuota = "<%=LANG['str_user_quota']%>: "+fileSize(nowquota)+"/"+fileSize(maxquota);
		$("diskquota").innerHTML = "<div class='progress_border2'><div class='progress_bar2' style='background-position:"+(100-scale)+"% 0px'>"+scale+"%</div></div><div style='font-size:8px;color: #666;' title='"+strUsedQuota+"'>"+strUsedQuota+"</div>";
	}

	if(total_num >= 0)
	{
		var sort_td = null;
		if(last_field >= 0 && last_field <= 3)
		{
			sort_td = $("listhead").rows[0].cells[last_field];
		}

		if(last_field == 0)
		{
			sortTable(sort_td,'listtable', 0, 'filename');

			if(reverse_sort == 1)
				sortTable(sort_td,'listtable', 0, 'filename');
		}
		else if(last_field == 1)
		{
			sortTable(sort_td,'listtable', 1, 'size');

			if(reverse_sort == 1)
				sortTable(sort_td,'listtable', 1, 'size');
		}
		else if(last_field == 2)
		{
			sortTable(sort_td,'listtable', 2);

			if(reverse_sort == 1)
				sortTable(sort_td,'listtable', 2);
		}
		else if(last_field == 3)
		{
			sortTable(sort_td,'listtable', 3);

			if(reverse_sort == 1)
				sortTable(sort_td,'listtable', 3);
		}
		else
		{
			sortTable(sort_td, "listtable", 2);
		}
	}

	thumb_num = 0;
	if(viewmode == true) showthumb();


	imglist = $("listview_div").getElementsByTagName("img");
	imgMap = null;
	imgMap = new Object();
	for(var ii=0;ii<imglist.length;ii++)
	{
		var src = imglist[ii].getAttribute('_src');
		if(src)
		{
			if(imgMap[src])
			{
				imgMap[src].push(ii);
			}
			else
			{
				imgMap[src] = new Array();
				imgMap[src].push(ii);
			}
		}
	}
	for(var imgurl in imgMap)
	{
		var imgindex = imgMap[imgurl][0];
		imglist[imgindex].onload = function(){setImageList();}
		imglist[imgindex].src = imgurl;
	}

	viewmode = getCookie("viewmode");
	change_viewmode(viewmode);
	$("waitingdiv").style.display = "none";
	$("waitingdiv2").style.display = "none";
}


function setImageList()
{
	var imgurl = event.srcElement.src;
	imgurl = "icons/"+imgurl.substr(imgurl.lastIndexOf("/")+1).toLowerCase();
	if(imgMap[imgurl] && imgMap[imgurl].length >= 1)
	{
		for(var jj=1;jj<imgMap[imgurl].length;jj++)
		{
			var imgindex = imgMap[imgurl][jj];
			imglist[imgindex].src = imgurl;
		}
	}
}


function showthumb()
{
	if(isIE)
		RemoveRow("thumbtable");
	else
		clear("thumbtable");

	if(total_num <= 0)
	{
		$("waitingdiv").style.display = "none";
		$("waitingdiv2").style.display = "none";
		return;
	}
	
	selectedRow = null;
	var screen_width = getBrowerWidth() > 1024 ? getBrowerWidth():1024;
	row_filenum = parseInt(screen_width / 180);
	var cell_width = parseInt(100/row_filenum)+"%";
	var row = $("listtable").tBodies[0].rows;
	var tr = null;
	thumb_flag++;

	for (var i=0; i < row.length; i++)
	{
		try
		{
			f_img = "";
			f_name = row[i].cells[0].getAttribute("name");
			f_filename = htmldecode(f_name);
			f_md5 = row[i].cells[0].getAttribute("md5");
			f_size = row[i].cells[1].innerHTML;
			f_isdir = row[i].cells[2].innerHTML;
			f_date = row[i].cells[3].innerHTML;
			f_ext = getExtention(f_filename);

			var ischecked = "";
			if($("cid_"+i).checked) ischecked = "checked";

			if(f_md5 != "" && (f_ext == "gif" || f_ext == "png" || f_ext == "jpg" || f_ext == "jpeg") )
			{
				f_img = "<div class='rect'><table style='width:100%;height:100%;'><tr><td class='boxalign'><input type='checkbox' "+ischecked+" ccid='"+i+"' flag='thumb' onclick='clickCheckbox(this);'></td><td id='"+f_md5+"' class='picalign'><img src='thumbimg/"+f_md5+".jpg?r="+thumb_flag+"' onerror='makethumb_req(\""+f_md5+"\",\""+htmlencode(f_filename)+"\");'></td></tr></table></div>";
			}
			else
			{
				if(isIE)
				{
					if(f_isdir == "<%=LANG['list_directory']%>")
					{
						f_icon = "<img _src='icons/folder64.png'>";
					}
					else
					{
						if(typeof(extIcons[f_ext]) != "undefined" && extIcons[f_ext] != "")
							f_icon = "<img _src='icons/file_"+ extIcons[f_ext] +"64.png'>";
						else
							f_icon = "<img _src='icons/file_default64.png'>";
					}
				}
				else
				{
					if(f_isdir == "<%=LANG['list_directory']%>")
					{
						f_icon = "<img src='icons/folder64.png'>";
					}
					else
					{
						if(typeof(extIcons[f_ext]) != "undefined" && extIcons[f_ext] != "")
							f_icon = "<img src='icons/file_"+ extIcons[f_ext] +"64.png'>";
						else
							f_icon = "<img src='icons/file_default64.png'>";
					}
				}
				f_img = "<div class='rect'><table style='width:100%;height:100%;'><tr><td class='boxalign'><input type='checkbox' "+ischecked+" ccid='"+i+"' flag='thumb' onclick='clickCheckbox(this);'></td><td class='iconalign'>" + f_icon + "</td></tr></table></div>";
			}

			if(i % row_filenum == 0)
			{
				tr = document.createElement("tr");
				tr.setAttribute('vAlign','top');
				$("thumbtable").appendChild(tr); 
			}
			var tmpcell = document.createElement("td"); 
			if(isIE)
			{
				tmpcell.onclick = function()
				{
					do_list_click(this,-2);
				}
				tmpcell.oncontextmenu = function()
				{
					do_list_click(this,-2,1);
				}
				tmpcell.ondblclick = function()
				{
					do_list_dblclick(this,-2);
				}
			}
			else
			{
				tmpcell.setAttribute('onclick','do_list_click(this,'+i+');');
				tmpcell.setAttribute('oncontextmenu','do_list_click(this,'+i+',1);');
			}
			tmpcell.setAttribute('width',cell_width);
			tmpcell.setAttribute('class','listtr03');
			tmpcell.setAttribute('className','listtr03');
			tmpcell.setAttribute('name',f_name);
			tmpcell.setAttribute('tabIndex',-1);
			tmpcell.setAttribute('fsize',row[i].cells[0].getAttribute("fsize"));
			tmpcell.setAttribute('id',"td_"+i);
			tmpcell.setAttribute('title','<%=LANG["thread_name"]%>: '+f_filename+'\r\n<%=LANG["thread_size"]%>: '+f_size+'\r\n<%=LANG["thread_modify"]%>: '+f_date);
			tmpcell.innerHTML = f_img+"<div class='rectbottom'>"+htmlencode(f_filename.substr(0,48))+(f_filename.length > 48 ? "...":""+"</div>");
			tr.appendChild(tmpcell);
			thumb_num++;
		}

		catch(e){}
	}

	if(row.length > 0 && row.length < row_filenum)
	{
		var space_num = row_filenum - row.length; 
		for(j=0;j<space_num;j++)
		{
			var tmpcell = document.createElement("td"); 
			tmpcell.setAttribute('width','20%');
			tmpcell.setAttribute('height','100');
			tr.appendChild(tmpcell); 
		}
	}
	$("thumbview_div").scrollTop = 0;

	imglist2 = $("thumbview_div").getElementsByTagName("img");
	imgMap2 = null;
	imgMap2 = new Object();
	for(var ii=0;ii<imglist2.length;ii++)
	{
		var src = imglist2[ii].getAttribute('_src');
		if(src)
		{
			if(imgMap2[src])
			{
				imgMap2[src].push(ii);
			}
			else
			{
				imgMap2[src] = new Array();
				imgMap2[src].push(ii);
			}
		}
	}
	for(var imgurl2 in imgMap2)
	{
		var imgindex = imgMap2[imgurl2][0];
		imglist2[imgindex].onload = function(){setImageThumb();}
		imglist2[imgindex].src = imgurl2;
	}

	thumbimage_req = 0;
	thumbimage_rsp = 0;
	$("waitingdiv").style.display = "none";
	$("waitingdiv2").style.display = "none";

}

function setImageThumb()
{
	var imgurl2 = event.srcElement.src;
	imgurl2 = "icons/"+imgurl2.substr(imgurl2.lastIndexOf("/")+1).toLowerCase();
	if(imgMap2[imgurl2] && imgMap2[imgurl2].length >= 1)
	{
		for(var jj=1;jj<imgMap2[imgurl2].length;jj++)
		{
			var imgindex2 = imgMap2[imgurl2][jj];
			imglist2[imgindex2].src = imgurl2;
		}
	}
}

function do_list_click(obj, cellindex, rightmouse)
{
	var evt;
	try
	{
		evt = getEvent();
		var element = evt.srcElement || evt.target;
		if(element.tagName == "INPUT")
		{
			return;
		}
	}
	catch(e){}

	var row_index = 0;
	var selectMultipleFiles = false;
	var offset = 1;

	if(cellindex >= 0)
		row_index = cellindex;
	else if(cellindex == -2)
		row_index = row_filenum*obj.parentNode.rowIndex+obj.cellIndex;
	else
		row_index = obj.rowIndex-offset;

	$("menu_div").style.visibility = "hidden";
	$("menu_div2").style.visibility = "hidden";

	if(rightmouse == 1)
	{
		var evt = getEvent();
		$("menu_div2").style.visibility = "hidden";
		$("menu_div").style.visibility = ""; 
		if(evt.clientY > document.body.clientHeight-120)
			$("menu_div").style.top = evt.clientY - 220;
		else
			$("menu_div").style.top = evt.clientY - 150;

		if(evt.clientX > document.body.offsetWidth-180)
			$("menu_div").style.left = evt.clientX-180;
		else
			$("menu_div").style.left = evt.clientX;
	}
	else
	{
		if(CtrlPressed(evt))
		{
			try
			{
				if(viewmode == true)
				{
					var checkboxObj = obj.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0];
					var id = checkboxObj.getAttribute("ccid");
					checkboxObj.checked = !checkboxObj.checked;
					$("cid_"+id).checked = checkboxObj.checked;
				}
				else
				{
					var checkboxObj = obj.childNodes[0].childNodes[0];
					checkboxObj.checked = !checkboxObj.checked;
				}
				selectMultipleFiles = true;
			}
			catch(e){}
		}
	}

	if(selectedRow != $("maintable").rows[row_index])
	{
		if(cellindex == -1)
		{
			if(lastObj != null)
				lastObj.className = "listtr01";
			selectedRow = $("maintable").rows[row_index];
			obj.className = "listtr02";
			lastObj = obj;
		}
		else
		{
			if(lastObj != null)
				lastObj.className = "listtr03";
			selectedRow = $("maintable").rows[row_index];
			obj.className = "listtr04";
			lastObj = obj;
		}

		try
		{
			if(selectedRow != null)
			{
				$("operation_buttons").style.display = "";
				var f_name = htmldecode(selectedRow.cells[0].getAttribute("name"));

				if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
				{
					$("downloaditem").style.display = "none";
					$("editoritem").style.display = "none";
					$("uplinkitem").style.display = "";
					$("bookmarkitem").style.display = "";
				}
				else
				{
					$("downloaditem").style.display = "";
					$("editoritem").style.display = "";
					$("uplinkitem").style.display = "none";
					$("bookmarkitem").style.display = "none";
				}

				var file_ext = getExtention(f_name);
				if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>" || file_ext != "zip")
				{
					$("unzipitem").style.display = "none";
				}
				else
				{
					$("unzipitem").style.display = "";
				}

				if(selectedRow.cells[2].innerHTML != "<%=LANG['list_directory']%>" && (file_ext == "doc" || file_ext == "docx" || file_ext == "xls" || file_ext == "xlsx" || file_ext == "ppt" || file_ext == "pptx" || file_ext == "dot" || file_ext == "dotx" || file_ext == "xlt" || file_ext == "xltx"))
				{
					$("office_editing").style.display = "";
					$("office_editing2").style.display = "";
				}
				else
				{
					$("office_editing").style.display = "none";
					$("office_editing2").style.display = "none";
				}
			}
		}
		catch(e){}
	}
	else
	{
		if(rightmouse == 1 || selectMultipleFiles == true)
			return false;

		if(!isIE || isWindowsPhone || isARM)
		{
			if(evt.button == 0 || evt.button == 1 || evt.button == 2)
				openFileDirectory();
			else
				downloadFile_ext();
		}
	}

	return false;
}

function do_list_dblclick(obj,cellindex)
{
	var evt;
	try
	{
		evt = getEvent();
		var element = evt.srcElement || evt.target;
		if(element.tagName == "INPUT")
		{
			return;
		}
	}
	catch(e){}

	var row_index = 0;
	var offset = 1;

	if(cellindex >= 0)
		row_index = cellindex;
	else if(cellindex == -2)
		row_index = row_filenum*obj.parentNode.rowIndex+obj.cellIndex;
	else
		row_index = obj.rowIndex-offset;

	selectedRow = $("maintable").rows[row_index];

	if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
	{
		openDirectory();
	}
	else
	{
		if(evt.keyCode != 13)
			downloadFile();
		else
			downloadFile_ext();
	}
	return false;
}

function openFileDirectory()
{
	if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
	{
		openDirectory();
	}
	else
	{
		downloadFile();
	}
}

function openDirectory()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_no_dir']%>");
		return;
	}
	var f_name = selectedRow.cells[0].getAttribute("name");
	var filename = urlEncode(htmldecode(f_name));
	ajaxRequest("chdir","dir="+filename);
}

function goUp()
{
	ajaxRequest("chdir","dir=..");
}

function goTo()
{
	showMessagebox("<%=LANG['goto_title']%>","<br><br><%=LANG['goto_path']%>: <input type='text' id='dirname' value='"+htmlencode(now_dir)+"' style='width:280px' tabindex='30'><br><br><br><br><button id='btn_submit' type='submit' onclick='goTo_submit();' tabindex='20' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button>", null, 420, 230);
	$("dirname").focus();

	if(isIE)
	{
		$("btn_submit").onclick = function(){goTo_submit();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function goTo_submit()
{
	ajaxRequest("chdir","dir="+urlEncode(htmldecode($("dirname").value)));
	top.closewindow();
}

function goHome()
{
	ajaxRequest("chdir","dir=/");
}

function changeDirectory(obj)
{
	var selectedDir = obj.options[obj.selectedIndex].value;
	if(selectedDir != null && selectedDir != "")
	{
		ajaxRequest("chdir","dir="+urlEncode(htmldecode(selectedDir)));
	}
}

function Refresh()
{
	ajaxRequest("dir",'r='+Math.random());
}

function selectTime()
{
	var strMyDate = "";
	var strMyTime = "";

	var timevalue = $("expiretime").value;
	if(timevalue != "")
	{
		var timeArray = timevalue.split(" ");
		strMyDate = timeArray[0];
		strMyTime = timeArray[1];
	}
	var frametag = new Date().getTime();
	showMessagebox("<%=LANG['str_selecttime']%>","<iframe src='select_time.html?mydate="+strMyDate+"&mytime="+strMyTime+"&seeds=" + Math.random() +"' width=340 height=285 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",selectTime_callback,340,285);
}

function selectTime_callback(str)
{
	if(str != "" && str != null)
		$("expiretime").value = str;
}

function formatLimitNumber(numbervalue)
{
	$("downloadlimit").value = numbervalue.replace(/\D/g,'');
}

function clearTime()
{
	$("expiretime").value = "";
}

function CopyWeblink()
{
	if(window.clipboardData)
	{
		window.clipboardData.setData("Text", $("weblink_text").value);
	}
	else
	{
		try
		{
			if(isFirefox || (isSafari && !isChrome))
			{
				$("ffcopy").value = $("weblink_text").value;
				$("ffcopy").select();
				$("ffcopy").setSelectionRange(0, $("ffcopy").value.length);
				document.execCommand("copy");
				$("ffcopy").value = "";
			}
			else
			{
				var copy = function (e) {
					e.preventDefault();
					if(e.clipboardData)
						e.clipboardData.setData("text/plain", $("weblink_text").value);
				}
				window.addEventListener("copy", copy);
				document.execCommand("copy");
				window.removeEventListener("copy", copy);
			}
		}
		catch(e){}
	}
}

function CopyUploadlink()
{
	if(window.clipboardData)
	{
		window.clipboardData.setData("Text", $("uploadlink_text").value);
	}
	else
	{
		try
		{
			if(isFirefox || (isSafari && !isChrome))
			{
				$("ffcopy").value = $("uploadlink_text").value;
				$("ffcopy").select();
				$("ffcopy").setSelectionRange(0, $("ffcopy").value.length);
				document.execCommand("copy");
				$("ffcopy").value = "";
			}
			else
			{
				var copy = function (e) {
					e.preventDefault();
					if(e.clipboardData)
						e.clipboardData.setData("text/plain", $("uploadlink_text").value);
				}
				window.addEventListener("copy", copy);
				document.execCommand("copy");
				window.removeEventListener("copy", copy);
			}
		}
		catch(e){}
	}
}

function showDownloadUrl()
{
	var f_name = "";
	var checkedlist = getCheckedFilelist();
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	showMessagebox("<%=LANG['weblink_title']%>","<table width='100%' border='0' cellpadding='2' cellspacing='3'><tr><td style='padding-left:10px;padding-top:15px;' align='left' colspan=2><input type='checkbox' id='enable_weblink' onclick='clickWeblink();' tabindex='34'> <b><%=LANG['enable_weblink']%></b></td></tr><tr><td style='padding:5px 0px 5px 10px;' colspan='2'><%=LANG['uploadstat_filename']%> <input type='text' value='"+htmlencode(f_name)+"' style='width:385px;color:#787878;' readonly></td></tr><tr><td style='padding-left:10px;' colspan=2><textarea id='weblink_text' style='width:460px;height:85px;font-size:9pt;word-break:break-all;' spellcheck='false' disabled tabindex='35'> </textarea><button id='btn_copylink' onclick='CopyWeblink();' class='button is-small' style='margin-left:2px;padding:3px;'  title='<%=LANG['item_copy']%>' disabled><img src='images/copy.png'></button></td></tr><tr><td style='padding-left:10px;width:140px;'><%=LANG['str_expire_on']%>:</td><td><input id='expiretime' type='text' value='' disabled onclick='selectTime();' style='width:150px;' readonly tabindex='36'> <img src='images/clean.gif' id='btn_clear_date' onclick='clearTime();' title='<%=LANG['str_clearall']%>' style='border: 1px solid #666; padding:1px; cursor:pointer; vertical-align:middle;' tabindex='37'> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:10px; width:110px;'><%=LANG['password']%></td><td><input id='downloadpass' type='text' maxlength='30' value='' disabled style='width:150px;' tabindex='39'> <img src='images/password.gif' onclick='generateRandom();' title='<%=LANG['str_generate_pass']%>' style='border: 1px solid #666; padding:1px; cursor:pointer; vertical-align:middle;'> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:10px; width:110px;'><%=LANG['str_download_limit']%>:</td><td><input id='downloadlimit' type='text' maxlength='6' value='' disabled onkeyup='formatLimitNumber(this.value);' onafterpaste='formatLimitNumber(this.value);' style='width:150px;' tabindex='38'> 1-999999 <%=LANG['str_optional']%></td></tr><tr><td style='padding-top:10px;padding-left:6px; width:146px;'><input type='checkbox' id='enable_sendmail' tabindex='40' onclick='enableSendMail();' value='1' disabled> <%=LANG['str_sendmail']%>:</td><td style='padding-top:10px;'><input id='mail_address' type='text' maxlength='256' tabindex='41' onblur=\"if(this.value=='') this.value='<%=LANG['str_multiple_emails']%>'\" onclick=\"if(this.value =='<%=LANG['str_multiple_emails']%>' ) this.value=''\" value='<%=LANG['str_multiple_emails']%>' style='padding-top:3px;width:320px;color:#898989;' disabled></td></tr><tr><td style='padding-left:23px;'><%=LANG['str_field_message']%> <%=LANG['str_optional']%>:</td><td><textarea id='mail_message' style='width:320px;height:35px' maxlength='1024' tabindex='43' disabled></textarea> </td></tr><tr><td style='padding-left:23px;'><%=LANG['str_senderemail']%>:</td><td><input id='sender_mail_address' type='text' maxlength='80' tabindex='42' style='width:180px; color:#898989;' disabled> <%=LANG['str_optional']%></td></tr><tr><td colspan=2 height=20></td></tr><tr align='center'><td colspan=2><button id='btn_submit' type='submit' onclick='update_weblink();' tabindex='44' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='45' class='button is-small'><%=LANG['str_close']%></button></td></tr></table>",null,530,420);

	$("enable_weblink").focus();

	ajaxRequest("weblink","operation=get&filename="+urlEncode(f_name) );

	if(isIE)
	{
		$("enable_weblink").onclick = function(){clickWeblink();};
		$("expiretime").onclick = function(){selectTime();};
		$("btn_clear_date").onclick = function(){clearTime();};
		$("btn_submit").onclick = function(){update_weblink();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function showUploadUrl()
{
	var f_name = "";
	var checkedlist = getCheckedDirlist(1);
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			f_name = "";
		}
		else
		{
			if(selectedRow.cells[2].innerHTML != "<%=LANG['list_directory']%>")
				f_name = "";
			else
				f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	var strNowPath = htmlencode(now_dir+"/"+f_name);
	if(now_dir == "/") 
		strNowPath = htmlencode(now_dir+f_name);

	showMessagebox("<%=LANG['uploadlink_title']%>","<table width='100%' border='0' cellpadding='2' cellspacing='3'><tr><td style='padding-left:10px;padding-top:15px;' align='left' colspan=2><input type='checkbox' id='enable_uploadlink' onclick='clickUploadLink();' tabindex='34'> <b><%=LANG['enable_uploadlink']%></b></td></tr><tr><td style='padding:5px 0px 5px 10px;' colspan='2'><%=LANG['str_app_savepath']%><input type='text' value='"+strNowPath+"' title='"+strNowPath+"' style='width:385px;color:#787878;' readonly></td></tr><tr><td style='padding-left:10px;' colspan=2><textarea id='uploadlink_text' style='width:460px;height:85px;font-size:9pt;word-break:break-all;' spellcheck='false' disabled tabindex='35'> </textarea><button id='btn_copylink' onclick='CopyUploadlink();' class='button is-small' style='margin-left:2px;padding:3px;'  title='<%=LANG['item_copy']%>' disabled><img src='images/copy.png'></button></td></tr><tr><td style='padding-left:10px;width:140px;'><%=LANG['str_expire_on']%>:</td><td><input id='expiretime' type='text' value='' disabled onclick='selectTime();' style='width:150px;' readonly tabindex='36'> <img src='images/clean.gif' id='btn_clear_date' onclick='clearTime();' title='<%=LANG['str_clearall']%>' style='border: 1px solid #666; padding:1px; cursor:pointer; vertical-align:middle;' tabindex='37'> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:10px;'><%=LANG['password']%></td><td><input id='downloadpass' type='text' maxlength='30' value='' disabled style='width:150px;' tabindex='38'> <img src='images/password.gif' onclick='generateRandom();' title='<%=LANG['str_generate_pass']%>' style='border: 1px solid #666; padding:1px; cursor:pointer; vertical-align:middle;'> <%=LANG['str_optional']%></td></tr><tr><td style='padding-top:10px;padding-left:6px; width:146px;'><input type='checkbox' id='enable_sendmail' tabindex='40' onclick='enableSendMail();' value='1' disabled> <%=LANG['str_sendmail']%>:</td><td style='padding-top:10px;'><input id='mail_address' type='text' maxlength='256' tabindex='41' onblur=\"if(this.value=='') this.value='<%=LANG['str_multiple_emails']%>'\" onclick=\"if(this.value =='<%=LANG['str_multiple_emails']%>' ) this.value=''\" value='<%=LANG['str_multiple_emails']%>' style='width:320px;color:#898989;' disabled></td></tr><tr><td style='padding-left:23px;'><%=LANG['str_field_message']%> <%=LANG['str_optional']%>:</td><td><textarea id='mail_message' style='width:320px;height:35px' maxlength='1024' tabindex='42' disabled></textarea> </td></tr><tr><td style='padding-left:23px;'><%=LANG['str_senderemail']%>:</td><td><input id='sender_mail_address' type='text' maxlength='80' tabindex='43' style='width:180px; color:#898989;' disabled> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:23px;display:none' colspan=2><input type='checkbox' id='enable_notify' tabindex='44' value='1' disabled> <%=LANG['str_sendnotify']%></td></tr><tr><td colspan=2 height=20></td></tr><tr align='center'><td colspan=2><button id='btn_submit' type='submit' onclick='update_uploadlink();' tabindex='45' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='46' class='button is-small'><%=LANG['str_close']%></button></td></tr></table>",null,530,400);

	$("enable_uploadlink").focus();

	ajaxRequest("uplink","operation=get&filename="+urlEncode(f_name) );

	if(isIE)
	{
		$("enable_uploadlink").onclick = function(){clickUploadLink();};
		$("expiretime").onclick = function(){selectTime();};
		$("btn_clear_date").onclick = function(){clearTime();};
		$("btn_submit").onclick = function(){update_uploadlink();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function enableSendMail()
{
	if($("enable_sendmail").checked)
	{
	<% if enable_sendmessage == true then %>
		$("mail_address").disabled = false;
		$("mail_message").disabled = false;
		$("sender_mail_address").disabled = false;
	<% else %>
		alert("<%=LANG['str_no_smtpconfig']%>");
	<% end %>
	}
	else
	{
		$("mail_address").disabled = true;
		$("mail_message").disabled = true;
		$("sender_mail_address").disabled = true;
	}
}



function update_uploadlink()
{
	var f_name = "";
	var checkedlist = getCheckedDirlist(1);
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			f_name = "";
		}
		else
		{
			if(selectedRow.cells[2].innerHTML != "<%=LANG['list_directory']%>")
				f_name = "";
			else
				f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	var expiretime = htmldecode($("expiretime").value);
	var downloadpass = htmldecode($("downloadpass").value);
	var sendmail = ($("enable_sendmail").checked ? "yes":"");
	var notify = ($("enable_notify").checked ? "yes":"");

	var mailaddress = htmldecode($("mail_address").value);
	if(mailaddress == "<%=LANG['str_multiple_emails']%>")
	{
		mailaddress = "";
	}
	var sender_mailaddress = htmldecode($("sender_mail_address").value);
	var mail_message = htmldecode($("mail_message").value);
	var localaddress = weblink_url;
	if(localaddress == "")
		localaddress = window.location.protocol+'//'+window.location.host;

	if(sender_mailaddress != "" && !sender_mailaddress.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/))
	{
		alert("<%=LANG['str_invalid_email']%>");
		return false;
	}

	if($("enable_uploadlink").checked)
	{
		ajaxRequest("uplink_update","filename="+urlEncode(f_name)+"&sendmail="+sendmail+"&mailaddress="+urlEncode(mailaddress)+"&sender_mailaddress="+urlEncode(sender_mailaddress)+"&mail_message="+urlEncode(mail_message)+"&localaddress="+urlEncode(localaddress)+"&expiretime="+urlEncode(expiretime)+"&notify="+notify+"&uploadpass="+urlEncode(downloadpass)+"&r="+Math.random());
	}
	top.closewindow();
}

function uplink_update_result()
{
	var result = xmlhttp.responseText;
	if(trim(result) == "Error: sending email")
	{
		alert("<%=LANG['send_email_error']%>");
	}
	else if(trim(result) == "Error: no permission")
	{
		alert("<%=LANG['make_weblink_error']%>");
	}
	else if(trim(result) == "operation successful")
	{
		alert("<%=RESULT_STR[1]%>");
	}
}

function clickUploadLink()
{
	var f_name = "";
	var checkedlist = getCheckedDirlist(1);
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			f_name = "";
		}
		else
		{
			if(selectedRow.cells[2].innerHTML != "<%=LANG['list_directory']%>")
				f_name = "";
			else
				f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	if($("enable_uploadlink").checked)
	{
		ajaxRequest("uplink","operation=add&filename="+urlEncode(f_name) );
	}
	else
	{
		ajaxRequest("uplink","operation=del&filename="+urlEncode(f_name) );
	}
}

function uplink()
{
	var result = xmlhttp.responseText;
	try
	{
		if(trim(result) == "")
		{
		}
		else if(trim(result) == "noperm")
		{
			alert("<%=LANG['make_weblink_error']%>");

			$("enable_uploadlink").checked = false;
			$("uploadlink_text").value = "";
			$("uploadlink_text").disabled = true;
			$("btn_copylink").disabled = true;
			$("expiretime").disabled = true;
			$("enable_notify").disabled = true;
			$("downloadpass").disabled = true;
			$("enable_sendmail").disabled = true;
			$("mail_address").disabled = true;
			$("mail_message").disabled = true;
			$("sender_mail_address").disabled = true;
		}
		else if(trim(result) == "deleted")
		{
			$("enable_uploadlink").checked = false;
			$("uploadlink_text").value = "";
			$("uploadlink_text").disabled = true;
			$("btn_copylink").disabled = true;
			$("expiretime").disabled = true;
			$("enable_notify").disabled = true;
			$("downloadpass").disabled = true;
			$("enable_sendmail").disabled = true;
			$("mail_address").disabled = true;
			$("mail_message").disabled = true;
			$("sender_mail_address").disabled = true;
		}
		else
		{
			var f_name = "";
			var checkedlist = getCheckedDirlist(1);
			if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
			{
				f_name = checkedlist;
			}
			
			if(f_name == "")
			{
				if(selectedRow == null)
				{
					f_name = "";
				}
				else
				{
					if(selectedRow.cells[2].innerHTML != "<%=LANG['list_directory']%>")
						f_name = "";
					else
						f_name = selectedRow.cells[0].getAttribute("name");
				}
			}

			var filename = urlEncodeSpecial(f_name);

			$("enable_uploadlink").checked = true;
			$("uploadlink_text").disabled = false;
			$("btn_copylink").disabled = false;
			$("expiretime").disabled = false;
			$("enable_notify").disabled = false;
			$("downloadpass").disabled = false;
			$("enable_sendmail").disabled = false;

			var localaddress = weblink_url;
			if(localaddress == "")
				localaddress = window.location.protocol+'//'+window.location.host;

			var strWebLink = trim(result);
			if(result.indexOf("\r\n") != -1)
			{
				var resultArray = result.split("\r\n");
				strWebLink = resultArray[0];

				if(resultArray[2] >= 0)
					$("expiretime").value = translateTime(resultArray[2]);
				else
					$("expiretime").value = "";

				if(resultArray[3] != null && resultArray[3] != "")
					$("downloadpass").value = resultArray[3];
				else
					$("downloadpass").value = "";

			}

			$("expiretime").style.color = "#000000";
			$("uploadlink_text").value = localaddress + "/uploadlink.html?linkid="+strWebLink;
		}
	}
	catch(e){}
}




function update_weblink()
{
	var is_dir = "no";
	var f_name = "";
	var checkedlist = getCheckedFilelist();
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;

		var dirlist = getCheckedDirlist(1);
		if(dirlist != "")
			is_dir = "yes";
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
			if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
				is_dir = "yes";
		}
	}

	var expiretime = htmldecode($("expiretime").value);
	var downloadlimit = htmldecode($("downloadlimit").value);
	var downloadpass = htmldecode($("downloadpass").value);
	var sendmail = ($("enable_sendmail").checked ? "yes":"");

	var mailaddress = htmldecode($("mail_address").value);
	if(mailaddress == "<%=LANG['str_multiple_emails']%>")
	{
		mailaddress = "";
	}
	var sender_mailaddress = htmldecode($("sender_mail_address").value);
	var mail_message = htmldecode($("mail_message").value);

	var localaddress = weblink_url;
	if(localaddress == "")
		localaddress = location.href.replace(/\#/g,"");

	if(sender_mailaddress != "" && !sender_mailaddress.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/))
	{
		alert("<%=LANG['str_invalid_email']%>");
		return false;
	}

	if($("enable_weblink").checked)
	{
		ajaxRequest("weblink_update","filename="+urlEncode(f_name)+"&sendmail="+sendmail+"&mailaddress="+urlEncode(mailaddress)+"&sender_mailaddress="+urlEncode(sender_mailaddress)+"&mail_message="+urlEncode(mail_message)+"&localaddress="+urlEncode(localaddress)+"&expiretime="+urlEncode(expiretime)+"&downloadlimit="+urlEncode(downloadlimit)+"&downloadpass="+urlEncode(downloadpass)+"&is_dir="+is_dir+"&r="+Math.random());
	}
	top.closewindow();
}

function weblink_update_result()
{
	var result = xmlhttp.responseText;
	if(trim(result) == "Error: sending email")
	{
		alert("<%=LANG['send_email_error']%>");
	}
	else if(trim(result) == "Error: no permission")
	{
		alert("<%=LANG['make_weblink_error']%>");
	}
	else if(trim(result) == "operation successful")
	{
		alert("<%=RESULT_STR[1]%>");
	}
}

function clickWeblink()
{
	var f_name = "";
	var checkedlist = getCheckedFilelist();
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	if($("enable_weblink").checked)
	{
		ajaxRequest("weblink","operation=add&filename="+urlEncode(f_name) );
	}
	else
	{
		ajaxRequest("weblink","operation=del&filename="+urlEncode(f_name) );
	}
}

function weblink()
{
	var result = xmlhttp.responseText;
	try
	{
		if(trim(result) == "")
		{
		}
		else if(trim(result) == "noperm")
		{
			alert("<%=LANG['make_weblink_error']%>");

			$("enable_weblink").checked = false;
			$("weblink_text").value = "";
			$("weblink_text").disabled = true;
			$("btn_copylink").disabled = true;
			$("expiretime").disabled = true;
			$("downloadlimit").disabled = true;
			$("downloadpass").disabled = true;
			$("enable_sendmail").disabled = true;
			$("mail_address").disabled = true;
			$("mail_message").disabled = true;
		}
		else if(trim(result) == "banned")
		{
			alert("<%=RESULT_STR[-3]%>");

			$("enable_weblink").checked = false;
			$("weblink_text").value = "";
			$("weblink_text").disabled = true;
			$("btn_copylink").disabled = true;
			$("expiretime").disabled = true;
			$("downloadlimit").disabled = true;
			$("downloadpass").disabled = true;
			$("enable_sendmail").disabled = true;
			$("mail_address").disabled = true;
			$("mail_message").disabled = true;
		}
		else if(trim(result) == "deleted")
		{
			$("enable_weblink").checked = false;
			$("weblink_text").value = "";
			$("weblink_text").disabled = true;
			$("btn_copylink").disabled = true;
			$("expiretime").disabled = true;
			$("downloadlimit").disabled = true;
			$("downloadpass").disabled = true;
			$("enable_sendmail").disabled = true;
			$("mail_address").disabled = true;
			$("mail_message").disabled = true;
		}
		else
		{
			var is_dir = "no";
			var f_name = "";
			var checkedlist = getCheckedFilelist();
			if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
			{
				f_name = checkedlist;

				var dirlist = getCheckedDirlist(1);
				if(dirlist != "")
					is_dir = "yes";
			}
			
			if(f_name == "")
			{
				if(selectedRow == null)
				{
					alert("<%=LANG['error_nofile']%>");
					return;
				}
				else
				{
					f_name = selectedRow.cells[0].getAttribute("name");
					if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
						is_dir = "yes";
				}
			}

			var filename = urlEncodeSpecial(f_name);

			$("enable_weblink").checked = true;
			$("weblink_text").disabled = false;
			$("btn_copylink").disabled = false;
			$("expiretime").disabled = false;
			$("downloadlimit").disabled = false;
			$("downloadpass").disabled = false;
			$("enable_sendmail").disabled = false;

			var localaddress = weblink_url;
			if(localaddress == "")
				localaddress = location.href.replace(/\#/g,"");

			var strWebLink = trim(result);
			if(result.indexOf("\r\n") != -1)
			{
				var resultArray = result.split("\r\n");
				strWebLink = resultArray[0];
				if(resultArray[1] >= 0)
					$("downloadlimit").value = resultArray[1];
				else
					$("downloadlimit").value = "";

				if(resultArray[2] >= 0)
					$("expiretime").value = translateTime(resultArray[2]);
				else
					$("expiretime").value = "";

				if(resultArray[3] != null && resultArray[3] != "")
					$("downloadpass").value = resultArray[3];
				else
					$("downloadpass").value = "";

			}

			$("downloadlimit").style.color = "#000000";
			$("expiretime").style.color = "#000000";

			if($("downloadlimit").value == "0")
				$("downloadlimit").style.color = "#FF0000";

			if(is_dir == "yes")
				$("weblink_text").value = localaddress + "?download&weblink="+strWebLink;
			else
				$("weblink_text").value = localaddress + "?download&weblink="+strWebLink+"&realfilename="+filename;
		}
	}
	catch(e){}
}

function createFolder()
{
	showMessagebox("<%=LANG['create_title']%>","<br><br><%=LANG['create_filename']%>: <input type='text' id='newdirname' style='width:210px' maxlength='128' tabindex='30'><br><br><br><br><button id='btn_submit' type='submit' onclick='createFolder_submit()' tabindex='20' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button>", null, 410, 240);
	$("newdirname").focus();

	if(isIE)
	{
		$("btn_submit").onclick = function(){createFolder_submit();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function createFolder_submit()
{
	var newname = htmldecode($("newdirname").value);
	if(newname.search(/[\\\/\<\>\:\?\"\|\*]/i) != -1)
	{
		alert("<%=LANG['error_bad_filename']%>");
		return false;
	}
	else if(newname == "")
	{
		alert("<%=LANG['error_no_dirname']%>");
		return false;
	}
	ajaxRequest("mkdir","dir="+urlEncode(newname));
}

function renameFile()
{
	var f_name = "";
	var checkedlist = getCheckedFilelist();
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	var filename = htmldecode(f_name);

	showMessagebox("<%=LANG['rename_title']%>","<br><br><span style='text-align:right;width:120px;display:-moz-inline-box;display:inline-block;'><%=LANG['rename_oldname']%>:&nbsp</span><input type='text' style='width:220px' id='oldname' value='"+htmlencode(filename)+"' disabled><br><span style='text-align:right;width:120px;display:-moz-inline-box;display:inline-block;'><%=LANG['rename_newname']%>:&nbsp</span><input type='text' style='width:220px' id='newname' tabindex='30' value='"+htmlencode(filename)+"' maxlength='128'><br><br><br><button id='btn_submit' type='submit' onclick='return renameFile_submit()' tabindex='20' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button>", null, 410, 240);
	$("newname").focus();

	if(isIE)
	{
		$("btn_submit").onclick = function(){renameFile_submit();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function renameFile_submit()
{
	var oldname = htmldecode($("oldname").value);
	var newname = htmldecode($("newname").value);
	if(oldname == newname)
	{
		closewindow();
		return true;
	}
	if(newname.search(/[\\\/\<\>\:\?\"\|\*]/i) != -1)
	{
		alert("<%=LANG['error_bad_filename']%>");
		return false;
	}
	ajaxRequest("rename","oldname="+urlEncode(oldname)+"&newname="+urlEncode(newname));
	return true;
}


function checkUpload()
{
	var xmlhttpObj = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
	var url = "checkupload.html?r="+Math.random();
	xmlhttpObj.open("GET",url,false);
	xmlhttpObj.send("");

	var result = xmlhttpObj.responseText;
	if(result == EXPTag)
	{
		sess_expire();
	}
	else if(result != "")
	{
		alert(result);
	}
	else
	{
		var isFormDataSupported = !!window.FormData;
		if( isFormDataSupported == false) 
		{
			uploadOneFile();
		}
		else
		{
			uploadFile();
		}
	}
}


function uploadFile()
{
	var frametag = new Date().getTime();
	showMessagebox("<%=LANG['upload_title']%>","<iframe src='uploader.html?r="+Math.random()+"' width=700 height=390 border=0 frameborder=0 id='fileuploader'></iframe>",closeUploader,702,392);
}

function uploadOneFile()
{
	showMessagebox("<%=LANG['upload_title']%>","<br><br><form method='post' name='uploadform' id='uploadform' onsubmit='return uploadStart();' enctype='multipart/form-data' action='uploadok.html' target='hiddenframe'><input name='filename' type='file' size='20' id='filename' tabindex='30'><br><br><br><button id='btn_submit' type='submit' tabindex='20' class='button is-info is-small'><%=LANG['upload_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();return false;' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</form>", cancelUpload);
	$("btn_submit").focus();

	if(isIE)
	{
		$("btn_cancel").onclick = function(){top.closewindow();return false;};
	}
}

function closeUploader()
{
	try
	{
		var iframeWindow = $("fileuploader").contentWindow;
		if(iframeWindow.document.getElementById("filelist").innerHTML != "")
		{
			if(confirm("<%=LANG['uploadclose_confirm']%>") == false)
			{
				return false;
			}
			else
			{
				if(last_field == -1)
					window.location = "main.html";
				else
					window.location = "main.html?sort="+last_field+"&r="+Number(reverse_sort);

				return true;
			}
		}

		if(iframeWindow.document.getElementById("infoDiv").innerHTML != "")
		{
			Refresh();
		}
	}
	catch(e)
	{
	}

	return true;
}

function cancelUpload()
{
	if(uploading == true)
	{
		if(confirm("<%=LANG['uploadclose_confirm']%>"))
		{
			if(last_field == -1)
				window.location = "main.html";
			else
				window.location = "main.html?sort="+last_field+"&r="+Number(reverse_sort);

			return true;
		}
		else
		{
			return false;
		}
	}
	return true;
}


function checkOverwrite(filename,totalfiles)
{
	if(auto_overwrite == true)
		return "1";

	try
	{
		totalfiles = parseInt(totalfiles);
	}
	catch(e)
	{
		totalfiles = 1;
	}

	var overwrite = false;
	var upFilename = htmlencode(filename);
	var listtableRows = $("listtable").tBodies[0].rows;
	for (var i=0; i < listtableRows.length; i++)
	{
		if(upFilename == listtableRows[i].cells[0].getAttribute("name"))
		{
			overwrite = true;
			break;
		}
	}
	if(overwrite == true && confirm("<%=LANG['overwrite_confirm']%> (" + listtableRows[i].cells[0].getAttribute("name") + ")") == false)
	{
		return "0";
	}

	if(totalfiles > 1 && overwrite == true && confirm("<%=LANG['str_auto_overwrite']%>") == true)
		auto_overwrite = true;

	return "1";
}

function resetOverwriteFolders()
{
	overwriteFolders = {};
}

function checkFolderOverwrite(filepath)
{
	if(filepath.indexOf("/") != -1)
	{
		var filepathArray = filepath.split("/");
		var rootFolder = htmlencode(filepathArray[0]);

		if(typeof(overwriteFolders[rootFolder]) != "undefined")
		{
			if(overwriteFolders[rootFolder] == true)
				return "1";
			else
				return "0";
		}

		var overwrite = false;
		var listtableRows = $("listtable").tBodies[0].rows;
		for (var i=0; i < listtableRows.length; i++)
		{
			if(rootFolder == listtableRows[i].cells[0].getAttribute("name"))
			{
				overwrite = true;
				break;
			}
		}

		if(overwrite == true)
		{
			overwriteFolders[rootFolder] = true;
			if(confirm("<%=LANG['overwrite_folder_confirm']%> (" + listtableRows[i].cells[0].getAttribute("name") + ")") == false)
			{
				overwriteFolders[rootFolder] = false;
				return "0";
			}
		}

	}

	return "1";
}

function uploadStart()
{
	if(uploading == false)
	{
		if($("filename").value == "")
		{
			alert("<%=LANG['error_no_uploadfile']%>");
			return false;
		}
		else
		{
			upload_filename = "";
			var tmpname = $("filename").value;
			if(tmpname.lastIndexOf("\\") != -1)
				upload_file = tmpname.substr(tmpname.lastIndexOf("\\")+1);
			else if(tmpname.lastIndexOf("\/") != -1)
				upload_file = tmpname.substr(tmpname.lastIndexOf("\/")+1);
			else
				upload_file = tmpname;
		}

		var overwrite = false;
		var upFilename = htmlencode(upload_file);
		var listtableRows = $("listtable").tBodies[0].rows;
		for (var i=0; i < listtableRows.length; i++)
		{
			if(upFilename == listtableRows[i].cells[0].getAttribute("name"))
			{
				overwrite = true;
				break;
			}
		}
		if(overwrite == true && confirm("<%=LANG['overwrite_confirm']%>") == false)
		{
			return false;
		}

		uploading = true;
		$("uploadingDiv").style.display = "";
		$("uploadingDiv").innerHTML = "<%=LANG['upload_ready']%><img src='images/loading.gif'>";
		$("uploadingDiv").focus();

		setTimeout("idleupload()",3000);
	    d = new Date();
		start_time = d.getTime();
		last_uploadsize = 0;
		last_lefttime = -1;
		return true;
	}
	else
	{
		return false;
	}
}

function idleupload()
{
	clearInterval(_TIMER_UPLOADING);
	_TIMER_UPLOADING = setInterval("uploadRefresh()",2000);
}

function uploadEnd()
{
	try
	{
		uploading=false;
		upload_file = "";
		upload_filename = "";
		clearInterval(_TIMER_UPLOADING);
		$("uploadingDiv").style.display = "none";
		$("uploadform").reset();
		location.reload();

	}
	catch(e){}
}

function uploadEnd_ok()
{
	try
	{
		uploading=false;
		upload_file = "";
		upload_filename = "";
		clearInterval(_TIMER_UPLOADING);
		$("uploadingDiv").style.display = "none";
		$("uploadform").reset();
		

	}
	catch(e){}
}

function editFile()
{
	var f_name = "";
	var checkedlist = getCheckedDirlist(0);
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_edit']%>");
			return;
		}
		else
		{
			if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
			{
				alert("<%=LANG['error_edit']%>");
				return;
			}
			f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	var filename = htmldecode(f_name);
	var frametag = new Date().getTime();
	showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name).substr(0,55)+(f_name.length > 55 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+urlEncodeSpecial(filename)+"&r="+Math.random()+"' width=1024 height=680 border=0 frameborder=0 id='texteditor'></iframe>",closeEditor,1024,680);
}

function closeEditor()
{
	try
	{
		var iframeWindow = $("texteditor").contentWindow;
		var bResult = iframeWindow.do_exitQuery();
		return bResult;
	}
	catch(e)
	{
	}

	return true;
}

function checkvideo() 
{
    return !!document.createElement('video').canPlayType;
}

function checkaudio() 
{
    return !!document.createElement('audio').canPlayType;
}

function checkFilePermission(url)
{
	var xmlhttpObj = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
	xmlhttpObj.open("GET",url,false);
	xmlhttpObj.send("");

	var result = trim(xmlhttpObj.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return false;
	}
	else if(result != "")
	{
		alert(result);
		return false;
	}
	else
	{
		return true;
	}
}

function downloadFile()
{
	var f_name = "";
	var checkedlist = getCheckedFilelist();
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	f_name = selectedRow.cells[0].getAttribute("name");
	var f_name2 = htmldecode(f_name);
	var f_ext = getExtention(f_name2);
	var filename = urlEncodeSpecial(f_name2);
	var filesize = selectedRow.cells[0].getAttribute("fsize");

	var strNowPath = htmlencode(now_dir+"/"+f_name);
	if(now_dir == "/") 
		strNowPath = htmlencode(now_dir+f_name);

	var checkfileURL = "checkdownload.html?filename="+filename+"&filesize="+filesize+"&r="+Math.random();

	if(f_ext == "gif" || f_ext == "png" || f_ext == "jpg" || f_ext == "jpeg" || f_ext == "bmp" )
	{
		if(checkFilePermission(checkfileURL) )
		{
			start_time = new Date().getTime();
			show_picture(filename);
		}
	}
	else if(!isIE && f_ext == "pdf")
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			var pdf_url = encodeURIComponent("/?download&filename="+filename+"&r="+Math.random());
			showMessagebox("<span title='"+strNowPath+"'>"+htmlencode(f_name.substr(0,75))+(f_name.length > 75 ? "...":"")+"</span>","<iframe src='/pdfjs-dist/web/viewer.html?file="+pdf_url+"' width=1024 height=680 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 1024, 680);
		}
	}
	else if(checkvideo() && (f_ext == "mp4" || f_ext == "mov") )
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			showMessagebox("<span title='"+strNowPath+"'>"+htmlencode(f_name.substr(0,75))+(f_name.length > 75 ? "...":"")+"</span>","<iframe src='videoplayer.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=1024 height=620 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 1024, 620);
		}
	}
	else if(checkaudio() && (f_ext == "mp3" || f_ext == "m4a" || f_ext == "ogg" || f_ext == "wav") )
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			showMessagebox("<span title='"+strNowPath+"'>"+htmlencode(f_name.substr(0,75))+(f_name.length > 75 ? "...":"")+"</span>","<iframe src='audioplayer.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=620 height=320 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 620, 320);
		}
	}
	else if(enable_online_edit == "1" && (f_ext == "txt" || f_ext == "cpp" || f_ext == "c" || f_ext == "h" || f_ext == "hpp" || f_ext == "lua" || f_ext == "sh"  || f_ext == "java"  || f_ext == "xml" || f_ext == "html" || f_ext == "htm" || f_ext == "js" || f_ext == "css" || f_ext == "php" || f_ext == "jsp" || f_ext == "asp" || f_ext == "pl" || f_ext == "py" || f_ext == "sql" || f_ext == "vb" || f_ext == "rb" || f_ext == "go" || f_ext == "pas" || f_ext == "json" || f_ext == "cs" || f_ext == "resx" || f_ext == "cxx" || f_ext == "pm" || f_ext == "vbs") )
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			showMessagebox("<span title='"+strNowPath+"'>"+htmlencode(f_name.substr(0,75))+(f_name.length > 75 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=1024 height=680 border=0 frameborder=0 id='texteditor'></iframe>",closeEditor,1024,680);
		}
	}
	else
	{
		download_url = "/?download&filename="+filename+"&r="+Math.random();
		if(isIE)
			checkDownload("checkdownload.html?filename="+filename+"&filesize="+filesize+"&r="+Math.random());
		else
			ajaxRequest("checkdownload","filename="+filename+"&filesize="+filesize+"&r="+Math.random());
	}
}

function downloadFile_ext(singlefile)
{
	var dirlist = getCheckedDirlist(1);
	var filelist = getCheckedDirlist(0);

	if(singlefile == null && (dirlist != "" || filelist.lastIndexOf("||") != -1) )
	{
		var strExtensionTips = "<%=LANG['download_multiple_files']%>";
		if(isFirefox) 
			strExtensionTips = "<%=LANG['download_multiple_files2']%>";
		else if(isEdge) 
			strExtensionTips = "<%=LANG['download_multiple_files3']%>";

		showMessagebox("<%=LANG['download_extension']%>","<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' style='padding:30px 10px 10px 10px;'><tr><td height=230 align='left'><div style='height:230px; overflow:auto; clear:none; line-height:25px; padding:10px; margin-top:10px;'><div style='float: left;'><img src='images/info.gif' align='absmiddle'>&nbsp;&nbsp;</div>"+strExtensionTips+"</div></td></tr><tr align='center'><td><button id='btn_submit' type='submit' onclick='top.closewindow();' tabindex='1' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='2' class='button is-small'><%=LANG['create_cancel']%></button></td></tr></table>", null, 450, 300);

		if(isIE)
		{
			$("btn_submit").onclick = function(){top.closewindow();};
			$("btn_cancel").onclick = function(){top.closewindow();};
		}

		return;
	}

	var f_name = "";
	var filesize = 0;
	if(singlefile == null && filelist != "" && filelist.lastIndexOf("||") == -1)
	{
		f_name = filelist;
		var cid = getFirstCheckedID();
		if(cid != "-1")
		{
			filesize = $("tr_"+cid).getAttribute("fsize");
		}
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
			filesize = selectedRow.cells[0].getAttribute("fsize");
			if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
			{
				openDirectory();
				return;
			}
		}
	}

	var filename = htmldecode(f_name);
	filename = urlEncodeSpecial(filename);
	download_url = "/?download&filename="+filename+"&r="+Math.random();
	if(isIE)
		checkDownload("checkdownload.html?filename="+filename+"&filesize="+filesize+"&r="+Math.random());
	else
		ajaxRequest("checkdownload","filename="+filename+"&filesize="+filesize+"&r="+Math.random());
}

function checkDownload(url)
{
	var xmlhttpObj = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
	xmlhttpObj.open("GET",url,false);
	xmlhttpObj.send("");

	var result = xmlhttpObj.responseText;
	if(result == EXPTag)
	{
		sess_expire();
	}
	else if(result != "")
	{
		alert(result);
	}
	else
	{
		window.open(download_url,"_self"); 
	}
}

function deleteFile(multiple)
{
	if(multiple == null || multiple == false || multiple == 0)
	{
		var checkedlist = getCheckedFilelist();
		if(checkedlist != "")
		{
			deleteFile(1);
			return;
		}

		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}

		var filestring = "<%=LANG['list_file']%>";
		var isdir = "0";
		if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
		{
			filestring = "<%=LANG['list_directory']%>";
			isdir = "1";
		}
		var filename = htmldecode(selectedRow.cells[0].getAttribute("name"));
		if(confirm("<%=LANG['delete_confirm']%>"+filestring+" "+filename+"' ?"+(isdir=="1"?"\r\n<%=LANG['rmdir_tip']%>":"") ))
		{
			ajaxRequest("rmdir","isdir="+isdir+"&dir="+urlEncode(filename));
			selectedRow = null;
		}
	}
	else
	{
		var dirlist = getCheckedDirlist(1);
		var filelist = getCheckedDirlist(0);
		if(dirlist == "" && filelist == "")
		{
			alert("<%=LANG['no_checkbox']%>");
			return false;
		}
		else
		{
			if(confirm("<%=LANG['mdelete_confirm']%>"))
			{
				ajaxRequest("rmdirfile","dirlist="+urlEncode(dirlist)+"&filelist="+urlEncode(filelist));
				unselectAll();
			}
		}
	}
}

function cutFile(multiple)
{
	var filename = "";
	if(multiple == null || multiple == false || multiple == 0)
	{
		var checkedlist = getCheckedFilelist();
		if(checkedlist != "")
		{
			cutFile(1);
			return;
		}

		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}

		filename = htmldecode(selectedRow.cells[0].getAttribute("name"));
	}
	else
	{
		filename = getCheckedFilelist();
		if(filename == "")
		{
			alert("<%=LANG['no_checkbox']%>");
			return false;
		}
	}
	ajaxRequest("cut","filename="+urlEncode(filename));
	copycutFiles = filename;
	selectedRow = null;
	unselectAll();
	$("pasteitem").style.display = "";
	$("pasteitem2").style.display = "";
	$("pasteitem3").style.display = "";
}

function copyFile(multiple)
{
	var filename = "";
	if(multiple == null || multiple == false || multiple == 0)
	{
		var checkedlist = getCheckedFilelist();
		if(checkedlist != "")
		{
			copyFile(1);
			return;
		}

		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}

		filename = htmldecode(selectedRow.cells[0].getAttribute("name"));
	}
	else
	{
		filename = getCheckedFilelist();
		if(filename == "")
		{
			alert("<%=LANG['no_checkbox']%>");
			return false;
		}
	}
	ajaxRequest("copy","filename="+urlEncode(filename));
	copycutFiles = filename;
	selectedRow = null;
	unselectAll();
	$("pasteitem").style.display = "";
	$("pasteitem2").style.display = "";
	$("pasteitem3").style.display = "";
}

function pasteFile()
{
	ajaxRequest("paste","filename="+urlEncode(copycutFiles));
	copycutFiles = "";
}

function changePassword()
{
	showMessagebox("<%=LANG['item_changepass']%>","<br><table width='100%' border='0' cellpadding='2' cellspacing='3'><tr><td align='right' style='padding-left:20px;padding-top:3px;'><%=LANG['old_password']%>&nbsp;&nbsp; </td><td><input type='password' id='oldpassword' autocomplete='off' style='width:170px' tabindex='28'></td></tr><tr><td colspan=2 height=8>&nbsp;</td></tr><tr><td align='right' style='padding-left:20px;padding-top:5px;'><%=LANG['new_password']%>&nbsp;&nbsp;</td><td><input type='password' id='newpassword' autocomplete='new-password' style='width:170px' tabindex='29'><br><span style='font-size:8pt;color:#777'><%=LANG['str_password_strength']%>:<img src='images/pass_strength0.gif' id='pass_strength' border='0' align='absmiddle'></span></td></tr><tr><td align='right' style='padding-left:20px;padding-top:3px;'><%=LANG['newpass_confirm']%>&nbsp;&nbsp;</td><td><input type='password' id='newpass_confirm' autocomplete='new-password' style='width:170px' tabindex='30'></td><tr><td colspan=2 height=40>&nbsp;</td></tr><tr align='center'><td colspan=2><button id='btn_submit' type='submit' onclick='changePassword_submit()' tabindex='20' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.location.reload();' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button></td></tr>",changePasswordCancel,400,240);
	$("oldpassword").focus();

	if(isIE)
	{
		$("btn_submit").onclick = function(){changePassword_submit();};
		$("btn_cancel").onclick = function(){top.location.reload();};
	}

	$("newpassword").onkeyup = inputPassword;
	$("newpassword").onafterpaste = inputPassword;
}

function changePasswordCancel()
{
	top.location.reload();
}

function inputPassword()
{
	var nPassStrong = checkPasswordStrong($("newpassword").value);
	if(nPassStrong <= 1)
	{
		$("pass_strength").src = "images/pass_strength1.gif";
	}
	else if(nPassStrong == 2 || nPassStrong == 3)
	{
		$("pass_strength").src = "images/pass_strength2.gif";
	}
	else
	{
		$("pass_strength").src = "images/pass_strength3.gif";
	}
}

function changePassword_submit()
{
	var oldpassword = $("oldpassword").value;
	var newpassword = $("newpassword").value;
	var newpass_confirm = $("newpass_confirm").value;
	if(newpassword != newpass_confirm)
	{
		alert("<%=LANG['changepass_error']%>");
		return;
	}

	if(newpassword == oldpassword)
	{
		alert("<%=LANG['changepass_error2']%>");
		return;
	}

	ajaxRequest("changepass","oldpassword="+urlEncode(oldpassword)+"&newpassword="+urlEncode(newpassword)+"&r="+Math.random() );
}

function changepass()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	alert(result);	
	top.location.reload();
}

function checkdownload_Result()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
	}
	else if(result != "")
	{
		alert(result);
	}
	else
	{
		window.open(download_url,"_self"); 
	}
}

function clientHelp()
{
	gotoUrl("help/english/index.htm", true);
}

function signOut()
{
	if(confirm("<%=LANG['signout_confirm']%>"))
	{
		gotoUrl("logout.html");
	}
}


function getLocation()
{
	if(location.href.indexOf("main.html") == -1)
		return location.href+"/main.html";
	else
		return location.href;
}

function getSessionID()
{
	return "<%=_SESSION_ID%>";
}

function getItemLabel(index)
{
	index = parseInt(index);
	var strLable = new Array('<%=LANG["upload_title"]%>','<%=LANG["thread_name"]%>','<%=LANG["thread_size"]%>','<%=LANG["thread_status"]%>',
							'<%=LANG["str_uploading"]%>','<%=LANG["str_pending"]%>','<%=LANG["upload_submit"]%>','<%=LANG["str_app_stop"]%>',
							'<%=LANG["str_browse"]%>','<%=LANG["str_clearall"]%>','<%=LANG["str_remove"]%>','<%=LANG["str_close"]%>',
							'<%=LANG["str_totalfile"]%>','<%=LANG["str_totalsize"]%>','<%=LANG["str_remaining"]%>','<%=LANG["str_complete"]%>',
							'<%=LANG["button_mode2"]%>');
	return strLable[index];
}

function closeUploadWindow()
{
	$("uploadingDiv_mask").style.display = "none";
	$("uploadingDiv2").style.display = "none";

	if(isFirefox)
	{
		goTo();
		top.closewindow();
	}
}

function openSearch()
{
	var frametag = new Date().getTime();
	showMessagebox("<%=LANG['str_searchfiles']%>","<iframe src='search.html?searchin="+urlEncodeSpecial(now_dir)+"&r="+Math.random()+"' width=750 height=480 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,750,480);
}

function checkPasswordStrong(password)
{
	var nStrong = 0;
	var bSequence = true;
	var lastCharCode = -1;
	for(var i=0; i<password.length; i++)
	{
		var charcode = password.charCodeAt(i);
		if(lastCharCode != -1 && charcode != (lastCharCode+1))
		{
			bSequence = false;
			break;
		}
		lastCharCode = charcode;
	}

	if(password.match(/[0-9]/)) nStrong++;
	if(password.match(/[A-Z]/)) nStrong++; 
	if(password.match(/[a-z]/)) nStrong++; 
	if(password.match(/[@#$%&!*)(-+=^]/)) nStrong++; 
	if(password.length >= 12) nStrong++; 
	if(password.length <= 6) nStrong--; 
	if(bSequence == true) nStrong--;

	return nStrong;
}

function menuMouseOver(obj)
{
	obj.style.color="#FFFFFF";
	obj.style.backgroundColor="#1665CB";
	obj.style.cursor="pointer"; 
}

function menuMouseOut(obj)
{
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
}

function clickCheckbox(obj)
{
	var id = obj.getAttribute("ccid");
	$("cid_"+id).checked = obj.checked;
}


function zipFile(multiple)
{
	var filelist = "";
	if(multiple == null || multiple == false || multiple == 0)
	{
		var checkedlist = getCheckedFilelist();
		if(checkedlist != "")
		{
			zipFile(1);
			return;
		}

		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}

		filelist = selectedRow.cells[0].getAttribute("name");
	}
	else
	{
		filelist = getCheckedFilelist();
		if(filelist == "")
		{
			alert("<%=LANG['no_checkbox']%>");
			return false;
		}
	}

	showMessagebox("<%=LANG['createzip_title']%>","<br><%=LANG['zip_filename']%>: <input type='text' id='zipfilename' style='width:180px' maxlength=60 tabindex='30'>  .zip<br><br><br><span style='line-height:120%;width:340px;'><img src='images/warning.gif' align='absmiddle'><%=LANG['zipfile_tip']%></span><br><br><br><input type='hidden' id='srcfilelist' value='"+htmlencode(filelist)+"'><button id='btn_submit' type='submit' onclick='zipFile_submit()' tabindex='20' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button>", null, 410, 230);
	$("zipfilename").focus();

	if(isIE)
	{
		$("btn_submit").onclick = function(){zipFile_submit();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function zipFile_submit()
{
	var zipfilename = htmldecode($("zipfilename").value) + ".zip";
	if(zipfilename.search(/[\\\/\<\>\:\?\"\|\*]/i) != -1)
	{
		alert("<%=LANG['error_bad_filename']%>");
		return false;
	}
	else if(zipfilename == ".zip")
	{
		alert("<%=LANG['error_no_filename']%>");
		return false;
	}

	var listtableRows = $("listtable").tBodies[0].rows;
	for (var i=0; i < listtableRows.length; i++)
	{
		if(zipfilename == listtableRows[i].cells[0].getAttribute("name"))
		{
			alert("<%=LANG['zipfile_exist']%>");
			return false;
		}
	}

	var filelist = htmldecode($("srcfilelist").value);
	if(filelist == "")
	{
		alert("<%=LANG['no_sourcefile']%>");
		return false;
	}
	ajaxRequest("zip","zipfile="+urlEncode(zipfilename)+"&srcfiles="+urlEncode(filelist));
	selectedRow = null;
	unselectAll();
}

function unzipFile()
{
	var f_name = "";
	var checkedlist = getCheckedDirlist(0);
	if(checkedlist != "" && checkedlist.lastIndexOf("||") == -1)
	{
		f_name = checkedlist;
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['no_zipfile']%>");
			return;
		}
		else
		{
			if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
			{
				alert("<%=LANG['no_zipfile']%>");
				return;
			}
			f_name = selectedRow.cells[0].getAttribute("name");
		}
	}

	var file_ext = getExtention(f_name);
	if(file_ext != "zip")
	{
		alert("<%=LANG['no_zipfile']%>");
		return;
	}

	if(confirm("<%=LANG['unzipfile_tip']%>"))
		ajaxRequest("unzip","zipfile="+urlEncode(f_name));
}

function zip()
{
	$("waitingdiv2").style.display = "none";
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	if(result == "")
		alert("<%=LANG['zipfile_success']%>");
	else
		alert("<%=LANG['zipfile_failed']%>"+result);
	top.closewindow();
	ajaxRequest("dir",'r='+Math.random());
}

function unzip()
{
	$("waitingdiv2").style.display = "none";
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	if(result == "")
	{
		alert("<%=LANG['zipfile_success']%>");
	}
	else
	{
		alert("<%=LANG['zipfile_failed']%>"+result);
	}
	ajaxRequest("dir",'r='+Math.random());
}

function rmdirfile()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}
	alert(result);	
	ajaxRequest("dir",'r='+Math.random());
}

function getCheckedDirlist(dir)
{ 
	var filelist = "";
	var checkboxs = document.getElementsByTagName("input");
	for(var i=0;i<checkboxs.length;i++)
	{
		if(checkboxs[i].type == "checkbox" && checkboxs[i].checked == true)
		{
			try
			{
				if(checkboxs[i].getAttribute("flag") == "list")
				{
					var cid = checkboxs[i].getAttribute("cid");
					if(dir == 1 && $("tr_"+cid).parentNode.cells[2].innerHTML == "<%=LANG['list_directory']%>")
					{
						if(filelist != "") filelist += "||";
						filelist += htmldecode($("tr_"+cid).getAttribute("name"));
					}
					if(dir == 0 && $("tr_"+cid).parentNode.cells[2].innerHTML != "<%=LANG['list_directory']%>")
					{
						if(filelist != "") filelist += "||";
						filelist += htmldecode($("tr_"+cid).getAttribute("name"));
					}
				}
			}
			catch (e){}
		}
	}
	return filelist;
}

function newText()
{
	showMessagebox("<%=LANG['newtext_title']%>","<br><br><%=LANG['text_filename']%>: <input type='text' id='newfilename' style='width:190px' maxlength='128' tabindex='30'> .txt<br><br><br><br><button id='btn_submit' type='submit' onclick='newText_submit()' tabindex='20' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21' class='button is-small'><%=LANG['create_cancel']%></button>", null, 410, 240);
	$("newfilename").focus();

	if(isIE)
	{
		$("btn_submit").onclick = function(){newText_submit();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function newText_submit()
{
	var newname = htmldecode($("newfilename").value) + ".txt";
	if(newname.search(/[\\\/\<\>\:\?\"\|\*]/i) != -1)
	{
		alert("<%=LANG['error_bad_filename']%>");
		return false;
	}
	else if(newname == ".txt")
	{
		alert("<%=LANG['error_no_filename']%>");
		return false;
	}
	txt_filename = newname;
	ajaxRequest("mkfile","filename="+urlEncode(newname));
}

function mkfile()
{
	var result = trim(xmlhttp.responseText);
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}

	if(result != "")
	{
		alert(result);
	}
	else
	{
		top.closewindow();
		ajaxRequest("dir",'r='+Math.random());

		var f_name = htmlencode(txt_filename);
		var filename = urlEncodeSpecial(txt_filename);
		var frametag = new Date().getTime();
		showMessagebox("<span title='"+f_name+"'>"+f_name.substr(0,55)+(f_name.length > 55 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=1024 height=680 border=0 frameborder=0 id='texteditor'></iframe>",closeEditor,1024,680);
	}
}

function SetLastField(field)
{
	if(last_field == field)
	{
		if(reverse_sort == 0)
			reverse_sort = 1;
		else
			reverse_sort = 0;
	}
	else
	{
		reverse_sort = 0;
	}
	last_field = field;
}

function image_resize()
{
	if(round(zoomval, 0) == 100)
	{
		resize_picture(false);
		$("lable2").title = "<%=LANG['button_fullsize']%>";
	}
	else
	{
		resize_picture(true);
		$("lable2").title = "<%=LANG['button_resetpicture']%>";
	}
}

function getBookmark()
{
	var xmlhttpObj = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
	var url = "bookmark.html?operation=get&r="+Math.random();
	xmlhttpObj.open("GET", url, false);
	xmlhttpObj.send("");

	var result = xmlhttpObj.responseText;
	if(result != "")
	{
		bookmark_show(result);
	}
}

function addBookmark(subfolder)
{
//	for (var i=0; i<$("bookmark").options.length; i++)
//	{
//		if($("bookmark").options[i].value == now_dir)
//			return false;
//	}

	if(subfolder != null && subfolder == 1 && selectedRow != null && selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
	{
		ajaxRequest("bookmark", "operation=add&r="+Math.random()+"&subfolder="+urlEncode(selectedRow.cells[0].getAttribute("name")));
	}
	else
	{
		ajaxRequest("bookmark", "operation=add&r="+Math.random());
	}

	return true;
}

function delBookmark(folder)
{
	if(folder != null)
	{
		ajaxRequest("bookmark", "operation=del&folder="+folder+"&r="+Math.random());
		return true;
	}

//	for (var i=0; i<$("bookmark").options.length; i++)
//	{
//		if($("bookmark").options[i].value == now_dir)
//		{
//			ajaxRequest("bookmark", "operation=del&r="+Math.random());
//			return true;
//		}
//	}

	return false;
}

function bookmark_result()
{
	var result = xmlhttp.responseText;
	if(result == EXPTag)
	{
		sess_expire();
		return;
	}

	bookmark_show(result);
}

function bookmark_show(strResult)
{
	try
	{
		var bookmarkArray = strResult.split("\n");
		$("dropdown-menu-bookmark").innerHTML = "";
		for (var i=0; i<bookmarkArray.length; i++)
		{
			var strBookmark = bookmarkArray[i];
			if(strBookmark != "")
			{
				$("dropdown-menu-bookmark").innerHTML += "<a href=\"#\" class=\"dropdown-item\" style=\"margin-right:16px;text-align:left;\" onclick=\"ajaxRequest('chdir','dir="+urlEncode(strBookmark)+"');\">"+htmlencode(strBookmark)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/delete.png\" title=\"<%=LANG["item_delete"]%>\" style=\"float:right;text-align:right;\" onclick=\"delBookmark('"+urlEncode(strBookmark)+"')\"></a>";
			}
		}

	}
	catch(e)
	{
	}
}

function checkExtension(rightclick) 
{
	if(!isChrome)
	{
		downloadExtension();
		return;
	}

    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            if (xhr.status == 200) {
                openOfficeEditing(rightclick);
            } else {
                downloadExtension();
            }
        }
    };
    xhr.open("GET", "chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/qowt.html");
    xhr.send("");
}

function downloadExtension()
{
	showMessagebox("<%=LANG['download_extension']%>","<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' style='padding:30px 10px 10px 10px;'><tr><td height=220 align='left'><div style='height:220px; overflow:auto; clear:none; line-height:25px; padding:10px; margin-top:10px;'><div style='float: left;'><img src='images/info.gif' align='absmiddle'>&nbsp;&nbsp;</div><%=LANG['edit_office_files']%></div></td></tr><tr align='center'><td><button id='btn_submit' type='submit' onclick='top.closewindow();' tabindex='1' class='button is-info is-small'><%=LANG['create_submit']%></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='2' class='button is-small'><%=LANG['create_cancel']%></button></td></tr></table>", null, 450, 300);

	if(isIE)
	{
		$("btn_submit").onclick = function(){top.closewindow();};
		$("btn_cancel").onclick = function(){top.closewindow();};
	}
}

function getCheckedDoc()
{
	var checkboxs = document.getElementsByTagName("input");
	for(var i=0;i<checkboxs.length;i++)
	{
		if(checkboxs[i].type == "checkbox" && checkboxs[i].checked == true)
		{
			try
			{
				if(checkboxs[i].getAttribute("flag") == "list")
				{
					var cid = checkboxs[i].getAttribute("cid");
					var file_ext = getExtention(htmldecode($("tr_"+cid).getAttribute("name")));
					if(file_ext == "doc" || file_ext == "docx" || file_ext == "xls" || file_ext == "xlsx" || file_ext == "ppt" || file_ext == "pptx" || file_ext == "dot" || file_ext == "dotx" || file_ext == "xlt" || file_ext == "xltx")
					{
						return cid;
					}
				}
			}
			catch (e){}
		}
	}
	return "";
}

function openOfficeEditing(rightclick)
{
	var f_name = "";
	var f_size = 0;
	var doc_id = getCheckedDoc();
	if(doc_id != "" && rightclick == 0)
	{
		f_name = htmldecode($("tr_"+doc_id).getAttribute("name"));
		f_size = $("tr_"+doc_id).getAttribute("fsize");
	}
	
	if(f_name == "")
	{
		if(selectedRow == null)
		{
			alert("<%=LANG['error_nofile']%>");
			return;
		}
		else
		{
			f_name = selectedRow.cells[0].getAttribute("name");
			f_size = selectedRow.cells[0].getAttribute("fsize");
		}
	}

	var f_name2 = htmldecode(f_name);
	var f_ext = getExtention(f_name2);
	var filename = urlEncodeSpecial(f_name2);

	var checkfileURL = "checkdownload.html?filename="+filename+"&filesize="+f_size+"&r="+Math.random();

	if(f_ext == "doc" || f_ext == "docx" || f_ext == "xls" || f_ext == "xlsx" || f_ext == "ppt" || f_ext == "pptx" || f_ext == "docm" || f_ext == "dot" || f_ext == "dotx" || f_ext == "pptm" || f_ext == "pot" || f_ext == "potx" || f_ext == "xlsm" || f_ext == "xlt" || f_ext == "xltx")
	{
		if(checkFilePermission(checkfileURL) )
		{
			window.open("/empty.html?download&filename="+filename+"&r="+Math.random()+"/"+f_name2, "_blank");
		}
	}
}
</script>
<body style="background:#DAE9FC;margin:0px;padding:0px;">

<div style="display:none">
<img src='images/waiting.gif'>
<img src='images/progress_border.gif'>
<img src='images/progress_bar.gif'>
<img src='images/loading.gif'>
<img src='images/loading2.gif'>
</div>

<div id="waitingdiv" style="position:absolute; z-index:1000; top:0px; left:0px; width:100%; height:100%; background:#777; filter:alpha(opacity=60); opacity:0.60; display:none;" align="center">
<div style="position:absolute; top:20%; left:40%; width:300px; height:100px;"><img src="images/loading2.gif" border="0">
<H2><b><%=LANG["update_tip"]%></b></H2></div></div>

<div id="waitingdiv2" style="position:absolute; z-index:999; top:0px; left:0px; width:100%; height:100%; background:#999; filter:alpha(opacity=60); opacity:0.60; display:none;" align="center">
<div style="position:absolute; top:20%; left:25%; width:550px; height:150px;"><br><img src="images/loading2.gif" border="0">
<H2><b><%=LANG["process_tip"]%></b></H2></div></div>


<div id="cancelupload_div" style="position:absolute; z-index:200; top:0px; left:0px; width:100%; height:100%; background:#777; filter:alpha(opacity=60); opacity:0.60; display:none;" align="center">
<div style="position:absolute; top:20%; left:40%; width:350px; height:100px;"><img src="images/loading2.gif" border="0">
<H2><b><%=LANG["cancelupload_tip"]%></b></H2></div></div>


<div id="picturediv" style="position:absolute; z-index:102; top:0px;left:0px;z-index:101;width:100%;height:100%;background-color: #000;filter:alpha(opacity=80); opacity:0.80; display:none;"></div>
<div id="picturediv2" style="position:absolute; z-index:103; width:100%; top:0px; left:0px; text-align:center; display:none; overflow:auto;">
<div id="imgloading" style="visibility:hidden;"><img src="images/loading5.gif" border="0"></div>
<div style="position:relative; z-index:104;">
<img src="images/icon_left.png" onclick="pre_picture();" alt="<%=LANG["button_prepicture"]%>" title="<%=LANG["button_prepicture"]%>">
<span id="lable1" style="padding:6px;line-height:30px;vertical-align:top;font-size:15pt;color:#FFF;font-weight:bold;">&nbsp;</span>
<img src="images/icon_right.png" onclick="next_picture();" alt="<%=LANG["button_nextpicture"]%>" title="<%=LANG["button_nextpicture"]%>">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="images/icon_zoomin.png" onclick="zoom(20);" alt="<%=LANG["button_zoomin"]%>" title="<%=LANG["button_zoomin"]%>">
<span id="lable2" onclick="image_resize();" style="padding:6px;line-height:30px;vertical-align:top;font-size:15pt;color:#FFF;font-weight:bold;cursor:pointer;" alt="<%=LANG["button_fullsize"]%>" title="<%=LANG["button_fullsize"]%>">100%</span>
<img src="images/icon_zoomout.png" onclick="zoom(-20);" alt="<%=LANG["button_zoomout"]%>" title="<%=LANG["button_zoomout"]%>">
<img src="images/icon_rotate.png" style="margin-left:20px;" onclick="rotate_picture();" alt="<%=LANG["button_rotate"]%>" title="<%=LANG["button_rotate"]%>">
<img src="images/icon_download.png" style="margin-left:30px;" onclick="down_picture();" alt="<%=LANG["item_download"]%>" title="<%=LANG["item_download"]%>">
<img src="images/icon_close.png" style="float:right;margin-right:20px;" onclick="close_picture();" alt="<%=LANG["button_closepicture"]%>" title="<%=LANG["button_closepicture"]%>">
</div>

<br>
<div id="picturediv3" style="position:relative; margin:1px auto;">
<img id="pic_prev" src="images/left_arrow.png" style="position:absolute; top:45%; left:10px; cursor:pointer; display:none;" onclick="pre_picture();">
<img id="pic_next" src="images/right_arrow.png" style="position:absolute; top:45%; right:10px; cursor:pointer; display:none;" onclick="next_picture();">
<!--<span id="picture_title" style='font-size:15pt;color:#FFF;font-weight:bold;'></span><br>-->
<img id="picture" src="images/empty.gif" border="0" align="absmiddle" style="margin-top:10px;">
</div>
<br><br><br><br>
</div>


<div id="uploadingDiv" style="position:absolute; width:340px; height:120px; left:100px top:100px; padding:20px; line-height:20px; background:#FFF; z-index:90; display:none; border:1px solid #999;">
</div>



<div id="uploadingDiv_mask" style="position:absolute; z-index:1000; top:0px; left:0px; width:100%; height:3000px; background:#777; filter:alpha(opacity=60); opacity:0.60; display:none;" align="center">
</div>

<div id="uploadingDiv2" style="position:absolute; width:500px; height:300px; padding:0px; margin:0px; line-height:20px; background:#FFF; z-index:1002; display:none;  "></div>



<div id="menu_div" style="position:absolute; visibility:hidden; background-color:#FFF; width:220px; z-index:201;" onclick="return false;">
	<div class="menu_out">
	<div class="menu_in">
	<ul>
    <li id="downloaditem" style="margin-top:0px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="downloadFile_ext(1);">
		<span class="icon"><i class="fas fa-download"></i></span>&nbsp;&nbsp;<%=LANG["item_download"]%>
	</li>
	<li id="office_editing" style="margin-top:6px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="checkExtension(1);">
		<span class="icon"><i class="fas fa-pencil-alt"></i></span>&nbsp;&nbsp;<%=LANG["item_office_editing"]%>
	</li>
	<li id="weblinkitem" style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showDownloadUrl();">
		<span class="icon"><i class="fas fa-link"></i></span>&nbsp;&nbsp;<%=LANG["item_geturl"]%>
	</li>
	<li id="uplinkitem" style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showUploadUrl();">
		<span class="icon"><i class="fas fa-cloud-upload-alt"></i></span>&nbsp;&nbsp;<%=LANG["uploadlink_title"]%>
	</li>
	<li id="bookmarkitem" style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="addBookmark(1);">
		<span class="icon"><i class="fas fa-bookmark"></i></span>&nbsp;&nbsp;<%=LANG["add_bookmark"]%>
	</li>
	<li id="editoritem" style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="editFile();">
		<span class="icon"><i class="fas fa-edit"></i></span>&nbsp;&nbsp;<%=LANG["item_edit"]%></li>
    <li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="deleteFile(0);">
		<span class="icon"><i class="fas fa-trash"></i></span>&nbsp;&nbsp;<%=LANG["item_delete"]%>
	</li>
    <li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="renameFile();">
		<span class="icon"><i class="fas fa-file-code"></i></span>&nbsp;&nbsp;<%=LANG["item_rename"]%>
	</li>
    <li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="zipFile(0);">
		<span class="icon"><i class="fas fa-archive"></i></span>&nbsp;&nbsp;<%=LANG["item_zip"]%>
	</li>
    <li id="unzipitem" style="margin-top:6px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="unzipFile();">
		<span class="icon"><i class="fas fa-box-open"></i></span>&nbsp;&nbsp;<%=LANG["item_unzip"]%>
	</li>
    <li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="cutFile(0);">
		<span class="icon"><i class="fas fa-cut"></i></span>&nbsp;&nbsp;<%=LANG["item_cut"]%>
	</li>
	<li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="copyFile(0);">
		<span class="icon"><i class="fas fa-copy"></i></span>&nbsp;&nbsp;<%=LANG["item_copy"]%>
	</li>
	<li id="pasteitem" style="margin-top:6px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="pasteFile();">
		<span class="icon"><i class="fas fa-paste"></i></span>&nbsp;&nbsp;<%=LANG["item_paste"]%>
	</li>
	<%
	for _,val in pairs(_SERVER) do
		if (val.need_selectfile ~= nil and val.need_selectfile == true and val.extbutton_name ~= nil and val.extbutton_func ~= nil) or (val.singlefile ~= nil and val.singlefile == true) then		
			print("<li style='margin-top:6px;' onmouseover='menuMouseOver(this)' onmouseout='menuMouseOut(this)' onclick='"..val.extbutton_func.."'><span class='icon'><i class='fas fa-plug'></i></span>&nbsp;&nbsp;"..val.extbutton_name.."</li>")
		end
	end
	%>
	</ul>
	</div>
	</div>
</div>

<div id="menu_div2" style="position:absolute; visibility:hidden; background-color:#FFF; width:200px; z-index:202;" onclick="return false;">
	<div class="menu_out">
	<div class="menu_in">
	<ul>
    <li onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="checkUpload();">
		<span class="icon"><i class="fas fa-upload"></i></span>&nbsp;&nbsp;<%=LANG["item_upload"]%>
	</li>
	<li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="createFolder();">
		<span class="icon"><i class="fas fa-folder-plus"></i></span>&nbsp;&nbsp;<%=LANG["item_mkdir"]%>
	</li>
	<li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showUploadUrl();">
		<span class="icon"><i class="fas fa-cloud-upload-alt"></i></span>&nbsp;&nbsp;<%=LANG["uploadlink_title"]%>
	</li>
	<li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="newText();">
		<span class="icon"><i class="far fa-file-alt"></i></span>&nbsp;&nbsp;<%=LANG["item_newtxt"]%>
	</li>
	<li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="addBookmark();">
		<span class="icon"><i class="fas fa-bookmark"></i></span>&nbsp;&nbsp;<%=LANG["add_bookmark"]%>
	</li>
	<li style="margin-top:6px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="goTo();">
		<span class="icon"><i class="far fa-folder-open"></i></span>&nbsp;&nbsp;<%=LANG["item_goto"]%>
	</li>
	<li id="pasteitem2" style="margin-top:6px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="pasteFile();">
		<span class="icon"><i class="fas fa-paste"></i></span>&nbsp;&nbsp;<%=LANG["item_paste"]%>
	</li>
	<%
	for _,val in pairs(_SERVER) do
		if val.need_selectfile ~= nil and val.need_selectfile == false and val.extbutton_name ~= nil and val.extbutton_func ~= nil then
			print("<li style='margin-top:6px;' onmouseover='menuMouseOver(this)' onmouseout='menuMouseOut(this)' onclick='"..val.extbutton_func.."'><span class='icon'><i class='fas fa-plug'></i></span>&nbsp;&nbsp;"..val.extbutton_name.."</li>")
		end
	end
	%>
	</ul>
	</div>
	</div>
</div>


<%
for _,val in pairs(_SERVER) do
	if val.exthtml ~= nil then
		print(val.exthtml)
	end
end
%>

<div id="main_interface">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td height="100%" style="padding:5px;"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
	<tr> 
	  <td height="100%" valign="top" bgcolor="#FFFFFF">
	  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		  <tr> 
			<td height="66" background="images/top_bg2.gif"> 
			  <table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr> 
				  <td width="13"><img src="images/coner_left2.gif" width="13" height="66"></td>
				  <td height="66" style="vertical-align:middle;">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					  <tr>
						<td class="subtitle is-5" style="color:#CCC;">
							<img src="images/<%=c_GetDomainLogo()%>?t=<%=imageDate%>" style="color:#CCC; margin-left:8px; margin-top:8px;">
						</td>
						<td align="right" style="vertical-align:middle;">
						<table border="0" cellspacing="0" cellpadding="0" style="margin-top:12px;">
							<tr> 
							<%
							if nType >= 5 then
								print("<td style='color:#000;font-weight:bold;'>(UNREGISTERED COPY)</td><td width='20'>&nbsp;</td>")
							end
							%>
							  <td style="color:#4C4C4C; vertical-align:middle;">[<%=LANG["welcome"]%>, <b><%=_SESSION["username"]%></b>]</td>
							  <td width="20">&nbsp;</td>
							  <td id="diskquota">&nbsp;</td>
							  <td width="20">&nbsp;</td>
							  <td><input type="image" src="images/ico_search.png" class="cur" onclick="openSearch();" title="<%=LANG["str_search"]%>" draggable="false" tabindex="-1"></td>
							  <td style="color:#4C4C4C; cursor:pointer; font-size:9pt; padding-left:4px; vertical-align:middle;" onclick="openSearch();"><%=LANG["str_search"]%></td>
							  <% if enable_changepass == true then %>
							  <td width="15">&nbsp;</td>
							  <td><input type="image" src="images/ico_changepass.png" class="cur" onclick="changePassword();" title="<%=LANG["item_changepass"]%>" draggable="false" tabindex="8"></td>
							  <td style="color:#4C4C4C; cursor:pointer; font-size:9pt; padding-left:4px; vertical-align:middle;" onclick="changePassword();"><%=LANG["item_changepass"]%></td>
							  <% end %>
							  <td width="15">&nbsp;</td>
							  <td><input type="image" src="images/ico_help.png" class="cur" onclick="clientHelp();" title="<%=LANG["item_help"]%>" draggable="false" tabindex="-1"></td>
							  <td style="color:#4C4C4C; cursor:pointer; font-size:9pt; padding-left:4px; vertical-align:middle;" onclick="clientHelp();"><%=LANG["item_help"]%></td>
							  <td width="15">&nbsp;</td>
							  <td><input type="image" src="images/ico_quit.png" class="cur" onclick="signOut();" title="<%=LANG["item_logout"]%>" draggable="false" tabindex="9"></td>
							  <td style="color:#4C4C4C; cursor:pointer; font-size:9pt; padding-left:4px; vertical-align:middle;" onclick="signOut();"><%=LANG["item_logout"]%></td>
							  <td width="10">&nbsp;</td>
							</tr>
						  </table>
						</td>
					  </tr>
					</table></td>
				<td width="13"><img src="images/coner_right2.gif" width="13" height="66"></td>
			</tr>
		</table></td>
	</tr>
	<tr> 
	<td height="100%"> 
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<tr> 
		<td width="13" style="background:url(images/left.gif) repeat-y;"><div style="width:13px;"></div></td>
		<td id="viewspace" bgcolor="#FFFFFF" valign="top" style="height:500px; padding-top:3px;"> 

			<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr valign="top"><td width="518" style="padding:5px;">

			<button class="button is-small is-info" onclick="checkUpload()">
			  <span class="icon"><i class="fas fa-upload"></i></span>
			  <span><%=LANG["item_upload"]%></span>
			</button>

			<span class="dropdown is-hoverable">
				<button class="button is-small is-info is-outlined" aria-haspopup="true" aria-controls="dropdown-menu-add">
				  <span class="icon"><i class="fas fa-folder-plus"></i></span>
				  <span><%=LANG["str_app_add"]%></span>
				</button>

			  <div class="dropdown-menu dropdown-content" style="width:250px;" id="dropdown-menu-add" role="menu">
				  <a href="#" class="dropdown-item" onclick="createFolder()">
					<span class="icon-text has-text-info"><span class="icon"><i class="fas fa-folder-plus"></i></span><span><%=LANG["item_mkdir"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="newText();">
					<span class="icon-text has-text-info"><span class="icon"><i class="far fa-file-alt"></i></span><span><%=LANG["item_newtxt"]%></span></span>
				  </a>
			  </div>
			</span>

			<span class="dropdown is-hoverable">
				<button class="button is-small is-info is-outlined" aria-haspopup="true" aria-controls="dropdown-menu-bookmark">
				  <span class="icon"><i class="fas fa-bookmark"></i></span>
				  <span><%=LANG["str_bookmarks"]%></span>
				</button>

			  <div class="dropdown-menu dropdown-content" id="dropdown-menu-bookmark" role="menu">
			  </div>
			</span>

			<button class="button is-small is-info is-outlined" id="pasteitem3" style="display:none;" onclick="pasteFile();">
			  <span class="icon"><i class="fas fa-paste"></i></span>
			  <span><%=LANG["item_paste"]%></span>
			</button>

			<button class="button is-small is-info is-outlined" id="office_editing2" style="display:none;" onclick="checkExtension(0);">
			  <span class="icon"><i class="fas fa-pencil-alt"></i></span>
			  <span><%=LANG["item_office_editing"]%></span>
			</button>

			<span id="operation_buttons" style="display:none">

			<button class="button is-small is-info is-outlined" onclick="renameFile();">
			  <span class="icon"><i class="fas fa-file-code"></i></span>
			  <span><%=LANG["item_rename"]%></span>
			</button>

			<button class="button is-small is-info is-outlined" onclick="deleteFile()">
			  <span class="icon"><i class="fas fa-trash"></i></span>
			  <span><%=LANG["item_delete"]%></span>
			</button>

			<button class="button is-small is-info is-outlined" onclick="cutFile();">
			  <span class="icon"><i class="fas fa-cut"></i></span>
			  <span><%=LANG["item_cut"]%></span>
			</button>

			<button class="button is-small is-info is-outlined" onclick="copyFile();">
			  <span class="icon"><i class="fas fa-copy"></i></span>
			  <span><%=LANG["item_copy"]%></span>
			</button>

			<button class="button is-small is-info is-outlined" onclick="downloadFile_ext()">
			  <span class="icon"><i class="fas fa-download"></i></span>
			  <span><%=LANG["item_download"]%></span>
			</button>

			</span>

			<span class="dropdown is-hoverable">
				<button class="button is-small is-info is-outlined" aria-haspopup="true" aria-controls="dropdown-menu-more">
				  <span class="icon"><i class="fas fa-plus-circle"></i></span>
				  <span><%=LANG["str_more_actions"]%></span>
				</button>

			  <div class="dropdown-menu dropdown-content" style="width:260px;" id="dropdown-menu-more" role="menu">
				  <a href="#" class="dropdown-item" onclick="editFile();">
					<span class="icon-text has-text-info"><span class="icon"><i class="fas fa-edit"></i></span><span><%=LANG["item_edit"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="showDownloadUrl();">
					<span class="icon-text has-text-info"><span class="icon"><i class="fas fa-link"></i></span><span><%=LANG["item_geturl"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="showUploadUrl();">
					<span class="icon-text has-text-info"><span class="icon"><i class="fas fa-cloud-upload-alt"></i></span><span><%=LANG["uploadlink_title"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="zipFile();">
					<span class="icon-text has-text-info"><span class="icon"><i class="fas fa-archive"></i></span><span><%=LANG["item_zip"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="unzipFile();">
					<span class="icon-text has-text-info"><span class="icon"><i class="fas fa-box-open"></i></span><span><%=LANG["item_unzip"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="addBookmark();">
					<span class="icon-text has-text-info"><span class="icon"><i class="far fa-bookmark"></i></span><span><%=LANG["add_bookmark"]%></span></span>
				  </a>
				  <a href="#" class="dropdown-item" onclick="goTo();">
					<span class="icon-text has-text-info"><span class="icon"><i class="far fa-folder-open"></i></span><span><%=LANG["item_goto"]%></span></span>
				  </a>
					<%
					for _,val in pairs(_SERVER) do
						if val.extbutton_name ~= nil and val.extbutton_func ~= nil then
							print("<a href='#' class='dropdown-item' onclick='"..val.extbutton_func.."'><span class='icon-text has-text-info'><span class='icon'><i class='fas fa-plug'></i></span><span>"..val.extbutton_name.."</span></span></a>")
						end
					end
					%>
			  </div>

			</span>


			</td>	
			</tr>

			<tr><td style="padding:8px;">
				<span id="listmode">
				<img src="images/list_on.png" class="cur" draggable="false" title="<%=LANG["item_change_list"]%>">
				<img src="images/thumbnail_off.png" class="cur" draggable="false" title="<%=LANG["item_change_thumb"]%>" onclick="change_viewmode(true)">
				</span>
				<span id="thumbmode" style="display:none;">	
				<img src="images/list_off.png" class="cur" draggable="false" title="<%=LANG["item_change_list"]%>" onclick="change_viewmode(false)">
				<img src="images/thumbnail_on.png" class="cur" draggable="false" title="<%=LANG["item_change_thumb"]%>">
				</span>
				<span id="statbar" style="margin-left:18px;"></span>
			</td>
			</tr>

			</table>

			<table id="listhead" width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
			<tr>
			<td align="center" width="<%=cellwidth[1]%>" onmouseover="className='listhead2';" onmouseout="className='listhead';" class="listhead" onmousedown="sortTable(this,'listtable', 0, 'filename');SetLastField(0);showthumb();"><span style="float:left; margin:5px 2px 2px 6px;"><input type="checkbox" id="checkall" onclick="selectAll(this);" title="<%=LANG["str_chkbox_select"]%> <%=LANG["str_chkbox_all"]%>/<%=LANG["str_chkbox_none"]%>"></span><div class="resizeblock" onmousedown="dragHead(this);">&nbsp;</div><%=LANG["thread_name"]%></td>
			<td align="center" width="<%=cellwidth[2]%>" onmouseover="className='listhead2';" onmouseout="className='listhead';" class="listhead" onmousedown="sortTable(this,'listtable', 1, 'size');SetLastField(1);showthumb();"><div class="resizeblock" onmousedown="dragHead(this);">&nbsp;</div><%=LANG["thread_size"]%></td>
			<td align="center" width="<%=cellwidth[3]%>" onmouseover="className='listhead2';" onmouseout="className='listhead';" class="listhead" onmousedown="sortTable(this,'listtable', 2);SetLastField(2);showthumb();"><div class="resizeblock" onmousedown="dragHead(this);">&nbsp;</div><%=LANG["thread_type"]%></td>
			<td align="center" width="<%=cellwidth[4]%>" onmouseover="className='listhead2';" onmouseout="className='listhead';" class="listhead" onmousedown="sortTable(this,'listtable', 3);SetLastField(3);showthumb();"><div class="resizeblock" onmousedown="dragHead(this);">&nbsp;</div><%=LANG["thread_modify"]%></td>
			<td id="blanktd" class="listhead"></td>
			</tr>
			</table>
		</div>


		<div id="listview_div" style="width:100%; height: 85%; overflow:auto; overflow-x:hidden;">
			<table id="listtable" width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
			<thead><tr height="0">
			<td width="500"></td>
			<td width="120"></td>
			<td width="150"></td>
			<td width="180"></td>
			<td></td>
			</tr></thead>
			<tbody id="maintable"></tbody>
			</table>
		</div>


		<div id="thumbview_div" style="width:100%; height: 85%; overflow:auto; overflow-x:hidden; display:none;">
			<table width="100%" border="0" cellpadding="0" cellspacing="0" border="0">
			<tbody id="thumbtable"></tbody>
			</table>
		<div>


		</td>
	  <td width="13" style="background:url(images/right.gif) repeat-y;"><div style="width:13px;"></div></td>
	</tr>
  </table></td>
</tr>
</table></td>
</tr>
<tr>
  <td height="12" background="images/bottom_bg.gif" bgcolor="#CCCCCC">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr> 
		<td width="13" valign="top"><img src="images/coner_left1.gif" width="13" height="12"></td>
		<td valign="top"><div></div></td>
		<td width="13" valign="top"><img src="images/coner_right1.gif" width="13" height="12"></td>
	  </tr>
	</table>
	</td>
</tr>
</table>
  <input id="ffcopy" style="position:absolute; left:-100px; outline:none; border:0px; color:rgba(0,0,0,0.0); background-color:transparent;">   
  </td>
  </tr>
	<tr> 
	<td align="center">
	  <a href="https://www.wftpserver.com/" target="_blank">Wing FTP Server</a> ©2003-2026 <b>wftpserver.com</b> All Rights Reserved
	</td>
	</tr>
</table>
</div>

<iframe name='hiddenframe' id='hiddenframe' src='empty.html' style='display:none'></iframe>
</body>
</html>
<script>

<% if changepass_firstlogon == true then %>
	alert("<%=LANG['str_changepass_firstlogon']%>");
	changePassword();
<% end %>

<% if _GET["redir"] ~= nil then %>
	ajaxRequest("chdir","dir="+urlEncode("<%=specialhtml_encode(_GET['redir'])%>"));
<% end %>

ajaxRequest("dir","r="+Math.random());

<% if http_keepalive == true then %>
	_TIMER_KEEPLIVE = setInterval("keeplive()",1000*300);
<% end %>

getBookmark();

document.oncontextmenu=function(){
	var evt = getEvent();
	var element = evt.srcElement || evt.target;
	if((element.tagName =="INPUT" || element.tagName == "TEXTAREA"))
	{
		return true;
	}
	else
	{
		if((top.__zIndex != null && top.__zIndex > 100) || $("picturediv").style.display == "" || $("uploadingDiv_mask").style.display == "")
		{
		}
		else
		{
			if($("menu_div").style.visibility == "hidden")
			{
				var evt = getEvent();
				$("menu_div").style.visibility = "hidden";
				$("menu_div2").style.visibility = ""; 
				$("menu_div2").style.top = evt.clientY; 
				$("menu_div2").style.left = evt.clientX; 
			}
		}
		return false;
	}
}

document.body.onclick=function(){
	var evt = getEvent();
	var element = evt.srcElement || evt.target;
	$("menu_div").style.visibility = "hidden";
	$("menu_div2").style.visibility = "hidden";

	if(element.tagName == "INPUT" && element.type == "checkbox")
	{
		var box_checked = false;
		var officefile_checked = false;
		var checkboxs = document.getElementsByTagName("input");
		for(var i=0;i<checkboxs.length;i++)
		{
			if(checkboxs[i].type == "checkbox")
			{
				try
				{
					if(officefile_checked == false && checkboxs[i].getAttribute("flag") == "list")
					{
						var cid = checkboxs[i].getAttribute("cid");
						if($("tr_"+cid).parentNode.cells[2].innerHTML != "<%=LANG['list_directory']%>")
						{
							var file_ext = getExtention(htmldecode($("tr_"+cid).getAttribute("name")));
							if(file_ext == "doc" || file_ext == "docx" || file_ext == "xls" || file_ext == "xlsx" || file_ext == "ppt" || file_ext == "pptx" || file_ext == "dot" || file_ext == "dotx" || file_ext == "xlt" || file_ext == "xltx")
							{
								officefile_checked = true;
							}
						}
					}

					if(viewmode == false)
					{
						if(checkboxs[i].checked == true && checkboxs[i].getAttribute("flag") == "list")
						{
							box_checked = true;
							break;
						}
					}
					else
					{
						if(checkboxs[i].checked == true && checkboxs[i].getAttribute("flag") == "thumb")
						{
							box_checked = true;
							break;
						}
					}
				}
				catch(e){}
			}
		}
		if(box_checked == false)
		{
			$("checkall").checked = false;
			if(selectedRow == null)
			{
				$("operation_buttons").style.display = "none";
				$("office_editing").style.display = "none";
				$("office_editing2").style.display = "none";
			}
		}
		else
		{
			$("operation_buttons").style.display = "";
			if(officefile_checked == true)
			{
				$("office_editing").style.display = "";
				$("office_editing2").style.display = "";
			}
		}
	}

}

if(isOpera)
	document.onkeypress = myKeyDown;
else
	document.onkeydown = myKeyDown;


if(isFirefox)
{
	$("viewspace").style.height = ((window.screen.height-270) > 500 ? (window.screen.height-270) : 500) + "px";
}

if(isSafari && !isChrome)
{
	$("listview_div").style.height = "80%";
	$("thumbview_div").style.height = "80%";
}

if(isEdge || isIE11)
{
	try
	{
		$("listview_div").style.height = "74vh";
		$("thumbview_div").style.height = "74vh";
	}
	catch(e)
	{
	}
}

	var files = null;
	var currentIndex = 0;
	var totalFiles = 0;
	var showUploader = false;

	function FileDragHover(e) {
		e.stopPropagation();
		e.preventDefault();
		e.target.className = (e.type == "dragover" ? "hover" : "");

		if(showUploader == false && __zIndex != null && __zIndex == 100 && $("picturediv").style.display == "none")
		{
			showUploader = true;
			var xmlhttpObj = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();
			var url = "checkupload.html?r="+Math.random();
			xmlhttpObj.open("GET",url,false);
			xmlhttpObj.send("");

			var result = xmlhttpObj.responseText;
			if(result == "")
			{
				var frametag = new Date().getTime();
				showMessagebox("<%=LANG['upload_title']%>","<iframe src='uploader_h5.html?r="+Math.random()+"' width=700 height=390 border=0 frameborder=0 id='fileuploader'></iframe>",closeUploader,702,392);
			}

			showUploader = false;
		}

	}

	function FileSelectHandler(e) {

		e.stopPropagation();
		e.preventDefault();

		if(uploading == true || $("uploadingDiv2").style.display != "none")
		{
			return false;
		}

		FileDragHover(e);

	}

	function cancelUploadFile() {
		var result = cancelUpload();
		if(result == true)
		{
			$("uploadingDiv2").innerHTML = "";
			$("uploadingDiv2").style.display = "none";
			$("uploadingDiv_mask").style.display = "none";
			ajaxRequest("dir","");
		}
	}


	function UploadFile(file) {

		var xhr = new XMLHttpRequest();

		var progress =  $("progressDiv").appendChild(document.createElement("p"));
		progress.innerHTML = "&nbsp;&nbsp;0% " + file.name;

		if($("progressDiv").offsetHeight < $("progressDiv").scrollHeight)
		{
			$("progressDiv").scrollTop = $("progressDiv").scrollHeight - $("progressDiv").offsetHeight;
		}

		xhr.upload.addEventListener("progress", function(e) {
			var pc = parseInt(100 - (e.loaded / e.total * 100));
			progress.style.backgroundPosition = pc + "% 0";
			if(progress.className != "failure")
			{
				progress.innerHTML = "&nbsp;&nbsp;" + (100 - pc) + "% " + file.name;
			}
		}, false);

		xhr.onreadystatechange = function(e) {
			if (xhr.readyState == 4) {
				var result = xhr.responseText;
				if(result == "-2" || xhr.status != 200)
				{
					progress.className = "failure";
					progress.innerHTML = "&nbsp;&nbsp; " + file.name + "<br><%=LANG['error_upload']%>";
				}
				else if(result == "-3")
				{
					progress.className = "failure";
					progress.innerHTML = "&nbsp;&nbsp; " + file.name + "<br><%=LANG['error_upload3']%>";
				}
				else if(result == "-4")
				{
					progress.className = "failure";
					progress.innerHTML = "&nbsp;&nbsp; " + file.name + "<br><%=LANG['error_upload4']%>";
				}
				else if(result == "0")
				{
					alert("<%=LANG['session_expire']%>");
					gotoUrl("logout.html");
				}
				else
				{
					progress.className = "success";
					progress.innerHTML = "&nbsp;&nbsp;100% " + file.name;
				}

				currentIndex++;
				if(currentIndex < files.length)
				{
					UploadFile(files[currentIndex]);
				}
				else
				{
					uploading = false;
					$("progressDiv").innerHTML += "<div style='text-align:center; padding:10px;'><button id='btn_closewindow' onclick='cancelUploadFile();' class='button1'><span><em>&nbsp;&nbsp;<%=LANG['str_close']%>&nbsp;&nbsp;</em></span></button></div>";

					if($("progressDiv").offsetHeight < $("progressDiv").scrollHeight)
					{
						$("progressDiv").scrollTop = $("progressDiv").scrollHeight - $("progressDiv").offsetHeight;
					}
				}
			}
		};


		if(checkOverwrite(file.name,totalFiles) == "0")		
		{
			currentIndex++;
			if(currentIndex < files.length)
			{
				UploadFile(files[currentIndex]);
			}
			else
			{
				uploading = false;
				$("progressDiv").innerHTML += "<div style='text-align:center; padding:10px;'><button id='btn_closewindow' onclick='cancelUploadFile();' class='button1'><span><em>&nbsp;&nbsp;<%=LANG['str_close']%>&nbsp;&nbsp;</em></span></button></div>";

				if($("progressDiv").offsetHeight < $("progressDiv").scrollHeight)
				{
					$("progressDiv").scrollTop = $("progressDiv").scrollHeight - $("progressDiv").offsetHeight;
				}
			}

			return false;
		}


		xhr.open("POST", "uploadok.html", true);
		var fd = new FormData();
		fd.append("name", file.name);
		fd.append("file", file);
		xhr.send(fd);

	}


	// initialize
	function Init() {

		var filedrag = document.body;

		var xhr = new XMLHttpRequest();
		if (xhr.upload) {

			filedrag.addEventListener("dragover", FileDragHover, false);
			filedrag.addEventListener("dragleave", FileDragHover, false);
			filedrag.addEventListener("drop", FileSelectHandler, false);
			filedrag.style.display = "block";
		}

	}

	// call initialization file
	if (window.File && window.FileList && window.FileReader) {
		Init();
	}


<%
for _,val in pairs(_SERVER) do
	if val.extjs ~= nil then
		print(val.extjs)
	end
end
%>

</script>
<% 
else
	print("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>")
	print("<script>top.location='login.html';</script>")
end 
%>
<noscript><center><H2><%=LANG["error_nojavascript"]%></H2></center></noscript>