<%
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, user-scalable=0">
<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;

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("edge") > -1 && !isIE;
var isIE11 = navigator.userAgent.toLowerCase().indexOf("trident") > -1;
var overwriteFolders = {};
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);	
	$("pasteitem3").style.display = "none";
	ajaxRequest("dir",'r='+Math.random());
}

function scrollViewDiv()
{
	$("listview_div").style.marginTop = $("viewspace").clientHeight + 10;
	$("thumbview_div").style.marginTop = $("viewspace").clientHeight + 10;
}

function showlist()
{
	window.scrollTo(0,-100);

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

	selectedRow = null;
	$("operation_buttons").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;

		selectedRow = null;
		file_num = 0;
		dir_num = 0;
		total_num = 0;
		total_size = 0;

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

		readfile = xmlFieldValue(xmldoc,"readfile");

		var htmltext = "<table id='listtable' width='100%' border='0' cellpadding='5' cellspacing='0' style='table-layout:fixed;word-wrap:break-word;'><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 = f_dir = xmlFieldValue(myrow,"dir");
				f_md5 = "";
				if(readfile == 1)
				{
					f_md5 = xmlFieldValue(myrow,"md5");
				}
				filesize = f_size;

				total_size += parseInt(f_size);

				if(f_isdir == 1)
				{
					f_dir = "<%=LANG['list_directory']%>";
					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++;
				}


				htmltext += "<tr class='listtr01' oncontextmenu='do_list_click(this,-1,1);' onclick='do_list_click(this,-1);'>";

				htmltext += "<td width='58%' height='26' class='paddingtd' id='tr_"+i+"' md5='"+f_md5+"' name='"+htmlencode(f_name)+"' fsize='"+filesize+"' dir='"+f_dir+"' date='"+f_date+"' perm='"+f_perm+"' group='"+f_group+"'>"+f_img+htmlencode(f_name)+"</td>";
				htmltext += "<td width='2%'></td><td width='17%' style='vertical-align:middle;'>"+f_size+"</td><td style='display:none;'>"+f_dir+"</td><td width='23%' style='vertical-align:middle;'>"+f_date+"</td><td></td>";
				
				htmltext += "<td></td></tr>";
				
				total_num++;
				lastsortcol = -1;
				
			}
			catch(e){}
		}

		htmltext += "</tbody></table><br><br><br><br>";
		write("listview_div",htmltext);
		$("listview_div").scrollTop = 0;
	}
	catch(e)
	{
		$("waitingdiv").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;<span style='color:#888'><%=LANG['headbar_txt2']%>"+file_num+"<%=LANG['headbar_txt3']%>"+dir_num+"<%=LANG['headbar_txt4']%></span>";

	scrollViewDiv();


	if(total_num >= 0)
	{
		if(last_field == 0)
		{
			sortTable($("listhead").rows[0].cells[0],'listtable', 0, 'filename');

			if(reverse_sort == 1)
				sortTable($("listhead").rows[0].cells[0],'listtable', 0, 'filename');
		}
		else if(last_field == 2)
		{
			sortTable($("listhead").rows[0].cells[1],'listtable', 2, 'size');

			if(reverse_sort == 1)
				sortTable($("listhead").rows[0].cells[1],'listtable', 2, 'size');
		}
		else if(last_field == 4)
		{
			sortTable($("listhead").rows[0].cells[2],'listtable', 4);

			if(reverse_sort == 1)
				sortTable($("listhead").rows[0].cells[2],'listtable', 4);
		}
		else
		{
			sortTable(null, 'listtable', 3);
		}
	}

	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";
}


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 = window.screen.width + 2;
	if(isIphone && isPortrait == false)
	{
		screen_width = window.screen.height + 2;
	}

	row_filenum = parseInt(screen_width / 170);
	if(row_filenum < 2)
		row_filenum = 2;
	var cell_width = parseInt(100/row_filenum)+"%";
	var row = $("listtable").tBodies[0].rows;
	var tr = null;

	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[2].innerHTML;
			f_dir = row[i].cells[0].getAttribute("dir");
			f_date = row[i].cells[0].getAttribute("date");
			f_ext = getExtention(f_filename);

			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 align='center' class='rectalign' id='"+f_md5+"'><img src='thumbimg/"+f_md5+".jpg?r=1' onerror='makethumb_req(\""+f_md5+"\",\""+htmlencode(f_filename)+"\");'></td></tr></table></div>";
			}
			else
			{
				if(isIE)
				{
					if(f_dir == "<%=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_dir == "<%=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 align='center' class='rectalign'>" + 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','50%');
			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";

	scrollViewDiv();
}

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 row_index = 0;

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

	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[0].getAttribute("dir") == "<%=LANG['list_directory']%>")
				{
					$("uplinkitem").style.display = "";
				}
				else
				{
					$("uplinkitem").style.display = "none";
				}

				var file_ext = getExtention(f_name);
				if(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>" || file_ext != "zip")
					$("unzipitem").style.display = "none";
				else
					$("unzipitem").style.display = "";
			}
		}
		catch(e){}
	}
	else
	{
		if(rightmouse == 1)
			return false;
		if(!isIE || isWindowsPhone)
			openFileDirectory();
	}

	scrollViewDiv();
	return false;
}

function do_list_dblclick(obj,cellindex)
{
	var row_index = 0;
	if(cellindex >= 0)
		row_index = cellindex;
	else if(cellindex == -2)
		row_index = row_filenum*obj.parentNode.rowIndex+obj.cellIndex;
	else
		row_index = obj.rowIndex;
	selectedRow = $("maintable").rows[row_index];

	if(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>")
		openDirectory();
	else
		downloadFile();
	return false;
}

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

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

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:190px' tabindex='30'><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>");
	$("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=320 height=285 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",selectTime_callback,320,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()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_nofile']%>");
		return;
	}

	var 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;' 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:250px;color:#787878;' readonly></td></tr><tr><td style='padding-left:10px;' colspan=2><textarea id='weblink_text' style='width:320px;height:85px;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='28%'><%=LANG['str_expire_on']%>:</td><td><input id='expiretime' type='text' value='' disabled onclick='selectTime();' style='width:160px;' 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:160px;' 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:127px;' tabindex='38'> 1-999999 <%=LANG['str_optional']%></td></tr><tr><td style='padding-top:10px;padding-left:6px;'><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:240px;color:#898989;' disabled></td></tr><tr><td style='padding-left:30px;'><%=LANG['str_field_message']%> <%=LANG['str_optional']%>:</td><td><textarea id='mail_message' style='width:240px;height:35px' maxlength='1024' tabindex='43' disabled></textarea> </td></tr><tr><td style='padding-left:30px;'><%=LANG['str_senderemail']%>:</td><td><input id='sender_mail_address' type='text' maxlength='80' tabindex='42' style='width:185px; 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,380,410);

	$("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 = "";
	if(selectedRow == null)
	{
		f_name = "";
	}
	else
	{
		if(selectedRow.cells[0].getAttribute("dir") != "<%=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;' 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:250px;color:#787878;' readonly></td></tr><tr><tr><td style='padding-left:10px;' colspan=2><textarea id='uploadlink_text' style='width:320px;height:85px;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='28%'><%=LANG['str_expire_on']%>:</td><td><input id='expiretime' type='text' value='' disabled onclick='selectTime();' style='width:160px;' 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:160px;' 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-top:10px;padding-left:6px;'><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:240px;color:#898989;' disabled></td></tr><tr><td style='padding-left:30px;'><%=LANG['str_field_message']%> <%=LANG['str_optional']%>:</td><td><textarea id='mail_message' style='width:240px;height:35px' maxlength='1024' tabindex='42' disabled></textarea> </td></tr><tr><td style='padding-left:30px;'><%=LANG['str_senderemail']%>:</td><td><input id='sender_mail_address' type='text' maxlength='80' tabindex='43' style='width:185px; color:#898989;' disabled> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:30px;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,380,380);

	$("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 = "";
	if(selectedRow == null)
	{
		f_name = "";
	}
	else
	{
		if(selectedRow.cells[0].getAttribute("dir") != "<%=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 = "";
	if(selectedRow == null)
	{
		f_name = "";
	}
	else
	{
		if(selectedRow.cells[0].getAttribute("dir") != "<%=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 = "";
			if(selectedRow == null)
			{
				f_name = "";
			}
			else
			{
				if(selectedRow.cells[0].getAttribute("dir") != "<%=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 f_name = selectedRow.cells[0].getAttribute("name");
	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 is_dir = "no";
	if(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>")
		is_dir = "yes";

	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()
{
	if($("enable_weblink").checked)
	{
		var f_name = selectedRow.cells[0].getAttribute("name");
		ajaxRequest("weblink","operation=add&filename="+urlEncode(f_name) );
	}
	else
	{
		var f_name = selectedRow.cells[0].getAttribute("name");
		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 f_name = selectedRow.cells[0].getAttribute("name");
			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(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>")
				$("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:180px' maxlength='128' tabindex='30'><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>");
	$("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()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_nofile']%>");
		return;
	}

	var f_name = selectedRow.cells[0].getAttribute("name");
	var filename = htmldecode(f_name);

	showMessagebox("<%=LANG['rename_title']%>","<br><br><span style='width:90px;display:-moz-inline-box;display:inline-block;'><%=LANG['rename_oldname']%>:</span><input type='text' style='width:190px' id='oldname' value='"+htmlencode(filename)+"' disabled><br><span style='width:90px;display:-moz-inline-box;display:inline-block;'><%=LANG['rename_newname']%>:</span><input type='text' style='width:190px' id='newname' tabindex='30' value='"+htmlencode(filename)+"' maxlength='128'><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, 360, 230);
	$("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=370 height=360 border=0 frameborder=0 id='fileuploader'></iframe>",closeUploader,370,360);
}

function uploadOneFile()
{
	showMessagebox("<%=LANG['upload_title']%>","<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='button1'><span><em><%=LANG['upload_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();return false;' tabindex='21' class='button1'><span><em><%=LANG['create_cancel']%></em></span></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_m.html";
				else
					window.location = "main_m.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_m.html";
			else
				window.location = "main_m.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 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()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_nofile']%>");
		return;
	}

	if(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>")
	{
		alert("<%=LANG['error_edit']%>");
		return;
	}
	else
	{
		var 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,30)+(f_name.length > 30 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+urlEncodeSpecial(filename)+"&r="+Math.random()+"' width=380 height=390 border=0 frameborder=0 id='texteditor'></iframe>",closeEditor,380,390);
	}
}

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()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_nofile']%>");
		return;
	}

	var 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 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" && window.screen.width >= 1024)
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			var pdf_url = encodeURIComponent("/?download&filename="+filename+"&r="+Math.random());
			showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,65))+(f_name.length > 65 ? "...":"")+"</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();
			if(window.screen.width >= 1024)
			{
				showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,65))+(f_name.length > 65 ? "...":"")+"</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
			{
				showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,30))+(f_name.length > 30 ? "...":"")+"</span>","<iframe src='videoplayer.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&width=360&height=280&r="+Math.random()+"' width=380 height=300 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 380, 300);
			}
		}
	}
	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='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,30))+(f_name.length > 30 ? "...":"")+"</span>","<iframe src='audioplayer.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=380 height=300 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 380, 300);
		}
	}
	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();
			if(window.screen.width >= 1024)
			{
				showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,65))+(f_name.length > 65 ? "...":"")+"</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
			{
				showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,30))+(f_name.length > 30 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=380 height=390 border=0 frameborder=0 id='texteditor'></iframe>",closeEditor,380,390);
			}
		}
	}
	else
	{
		filename = urlEncode(f_name2);
		download_url = "/?download&filename="+filename+"&r="+Math.random();
		if(isFirefox)
		{
			download_url = "/?download&filename="+filename;
		}
		checkDownload("checkdownload.html?filename="+filename+"&filesize="+filesize+"&r="+Math.random());
	}
}

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

	if(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>")
	{
		openDirectory()
	}
	else
	{
		var f_name = selectedRow.cells[0].getAttribute("name");
		var filename = htmldecode(f_name);
		filename = urlEncode(filename);
		var filesize = selectedRow.cells[0].getAttribute("fsize");
		download_url = "/?download&filename="+filename+"&r="+Math.random();
		if(isFirefox)
		{
			download_url = "/?download&filename="+filename;
		}
		checkDownload("checkdownload.html?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[0].getAttribute("dir") == "<%=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();
	$("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();
	$("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=30>&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,370,230);
	$("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/user_guide_for_mobile_version.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();

	if(isIphone || isWindowsPhone || isAndroid)
	{
		showMessagebox("<%=LANG['str_searchfiles']%>","<iframe src='search_m.html?searchin="+urlEncodeSpecial(now_dir)+"&r="+Math.random()+"' width=395 height=470 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,395,470);
	}
	else
	{
		showMessagebox("<%=LANG['str_searchfiles']%>","<iframe src='search_m.html?searchin="+urlEncodeSpecial(now_dir)+"&r="+Math.random()+"' width=700 height=470 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,700,470);
	}
}

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:150px' maxlength=60 tabindex='30'>  .zip<br><br><br><span style='line-height:120%;width:310px;'><img src='images/warning.gif' align='absmiddle'><%=LANG['zipfile_tip']%></span><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,360,220);
	$("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()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_nofile']%>");
		return;
	}

	var f_name = htmldecode(selectedRow.cells[0].getAttribute("name"));
	var file_ext = getExtention(f_name);
	if(selectedRow.cells[0].getAttribute("dir") == "<%=LANG['list_directory']%>" || 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:150px' maxlength='128' tabindex='30'> .txt<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);
	$("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,30)+(f_name.length > 30 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=380 height=390 border=0 frameborder=0 id='texteditor'></iframe>",closeEditor,380,390);
	}
}

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()
{
//	for (var i=0; i<$("bookmark").options.length; i++)
//	{
//		if($("bookmark").options[i].value == now_dir)
//			return false;
//	}

	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)
	{
	}
}
</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:15%; 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:15%; width:300px; height:100px;"><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:15%; width:300px; 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();" title="<%=LANG["button_prepicture"]%>">
<span id="lable1" style="padding:3px;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();" title="<%=LANG["button_nextpicture"]%>">
&nbsp;&nbsp;
<img src="images/icon_zoomin.png" onclick='zoom(20);' title="<%=LANG["button_zoomin"]%>">
<span id="lable2" onclick="image_resize();" style="padding:3px;line-height:30px;vertical-align:top;font-size:15pt;color:#FFF;font-weight:bold;cursor:pointer;" title="<%=LANG["button_fullsize"]%>">100%</span>
<img src="images/icon_zoomout.png" onclick='zoom(-20);' title="<%=LANG["button_zoomout"]%>">
<img src="images/icon_rotate.png" style="margin-left:10px;" onclick="rotate_picture();" alt="<%=LANG["button_rotate"]%>" title="<%=LANG["button_rotate"]%>">
<img src="images/icon_close.png" style="float:right;margin-right:10px;" onclick='close_picture();' 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>
<div style="position:relative; z-index:105;">
<img src="images/icon_download.png" style="margin-left:20px;" onclick="down_picture();" alt="<%=LANG["item_download"]%>" title="<%=LANG["item_download"]%>">
</div>
<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="main_interface">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td height="100%">
	<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="100%"> 
	<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
		<tr> 
		<td bgcolor="#FFFFFF" valign="top"> 
			
			<div id="viewspace" style="position:fixed; background-color:#FFF;">

			  <table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr> 
				  <td height="66" style="vertical-align:middle;" background="images/top_bg2.gif">
					<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>
							<td><input type="image" src="images/ico_search.png" class="cur" onclick="openSearch();" title="<%=LANG["str_search"]%>" draggable="false" tabindex="-1"></td>							
							  <% if enable_changepass == true then %>
							  <td width="20">&nbsp;</td>
							  <td><input type="image" src="images/ico_changepass.png" class="cur" onclick="changePassword();" title="<%=LANG["item_changepass"]%>" draggable="false" tabindex="8"></td>
							  <% end %>
							  <td width="20">&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 width="20">&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 width="20">&nbsp;</td>
							</tr>
						  </table>
						</td>
					  </tr>
					</table></td>
			</tr>
		</table>

			<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr valign="top"><td id="td_toolbar" 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" id="button_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>

			<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>

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

			<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>

			<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="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="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>

			</span>

			<span class="dropdown is-hoverable">
				<button class="button is-small is-info is-outlined" aria-haspopup="true" aria-controls="dropdown-menu-more" id="button_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="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>
			  </div>

			</span>

			</td>	
			</tr>

			<tr><td style="padding:12px;">
				<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);scrollViewDiv();">
				</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);scrollViewDiv();">
				<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; padding-top:5px;">
			<tr>
			<td align="center" width="60%" class="listhead" onmousedown="sortTable(this,'listtable', 0, 'filename');SetLastField(0);showthumb();"><div class="resizeblock">&nbsp;</div><%=LANG["thread_name"]%></td>
			<td align="center" width="17%" class="listhead" onmousedown="sortTable(this,'listtable', 2, 'size');SetLastField(2);showthumb();"><div class="resizeblock">&nbsp;</div><%=LANG["thread_size"]%></td>
			<td align="center" width="23%" class="listhead" onmousedown="sortTable(this,'listtable', 4);SetLastField(4);showthumb();"><div class="resizeblock">&nbsp;</div><%=LANG["thread_modify"]%></td>
			<td id="blanktd" class="listhead"></td>
			</tr>
			</table>
		</div>


		<div id="listview_div" style="width: 100%; overflow-y:scroll; overflow-x:hidden; margin-top:10px;">
			<table id="listtable" width="100%" border="0" cellpadding="2" cellspacing="0">
			<tbody id="maintable"></tbody>
			</table>
		</div>


		<div id="thumbview_div" style="width: 100%; overflow:scroll; display:none; margin-top:10px;">
			<table width="100%" border="0" cellpadding="2" cellspacing="0" border="0">
			<tbody id="thumbtable"></tbody></table>
		<div>


		</td>
	</tr>
  </table></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>

</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();

function orientationChange()
{
	switch(window.orientation) 
	{
		case 0:
		case 180:
			isPortrait = true;
			showthumb();
		break;
		case -90:
		case 90:
			isPortrait = false;
			showthumb();
		break;
	}
}

orientationChange();

if(isFirefox)
{
	var mqOrientation = window.matchMedia("(orientation: portrait)");
	mqOrientation.addListener(function() { orientationChange(); });
}
else
{
	window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", orientationChange, false);
}

scrollViewDiv();


$("button_add").ontouchend = function(){
	var displaystyle = window.getComputedStyle($("dropdown-menu-add"), null).getPropertyValue("display");
	if(displaystyle == "none")
		$("dropdown-menu-add").style.display = "";
	else
		$("dropdown-menu-add").style.display = "none";

	return true;
}

$("button_more").ontouchend = function(){
	var displaystyle = window.getComputedStyle($("dropdown-menu-more"), null).getPropertyValue("display");
	if(displaystyle == "none")
		$("dropdown-menu-more").style.display = "";
	else
		$("dropdown-menu-more").style.display = "none";

	var displayX = round($("button_more").getBoundingClientRect().left, 0);
	if(displayX > 180)
		$("dropdown-menu-more").style.left = 180-displayX;

	return true;
}


<%
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>