<%
include("language.html")
%>
<noscript><center><H2><%=LANG["error_nojavascript"]%></H2></center></noscript>
<%
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 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
%>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache, must-revalidate" />
<link rel="Shortcut Icon" href="images/logo.ico" type="image/x-icon">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<head>
<title>
Wing FTP Server - Web Client
<%
local nType = c_GetLicenseInfo()
if nType >= 5 then
	print("(UNREGISTERED)")
end
%>
</title>
</head>
<script language="javascript" src="include/checkflash.js"></script>
<script language="javascript" src="include/common.js?v=1"></script>
<script language="javascript">
isIphone = navigator.userAgent.toLowerCase().indexOf('iphone')==-1? 0:1;
if(isIphone == 0)
{
	isIphone = navigator.userAgent.toLowerCase().indexOf('ipod')==-1? 0:1;
}
else
{
	isIphone = navigator.userAgent.toLowerCase().indexOf('ipad')==-1? 1:0;
}
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_PPT = null;
var _TIMER_KEEPLIVE = null;
var EXPTag = "session expired";
var ppt_showing = false;
var ppt_timervalue = 5000;
var ppt_startppt = "<%=LANG['button_startppt']%>";
var ppt_stopppt = "<%=LANG['button_stopppt']%>";
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 videolist_show = false;
var last_uploadsize = 0;
var last_lefttime = -1;
var auto_overwrite = false;
var appletSavePath = "none";
var bigfilesize = 0;
var moreaction_show = 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;

<% 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 'ed2kurl':		ed2kurl();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']%>");
	//window.location = "logout.html";
	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("videolist_div");
	clear_imageGroup();
	$("waitingdiv").style.display = "";
	var nowquota = 0;
	var maxquota = 0;
	var readfile = 0;

	selectedRow = null;
	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_dir = xmlFieldValue(myrow,"dir");
				f_md5 = "";
				if(readfile == 1)
				{
					f_md5 = xmlFieldValue(myrow,"md5");
				}
				filesize = f_size;

				total_size += parseInt(f_size);

				if(f_dir == 1)
				{
					f_dir = "<%=LANG['list_directory']%>";
					if(isIE)
						f_img = "<img _src='icons/directory.gif'> ";
					else
						f_img = "<img src='icons/directory.gif'> ";
					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(extIcons[file_ext] == true)
							f_img = "<img _src='icons/"+ file_ext +".gif'> ";
						else
							f_img = "<img _src='icons/default.gif'> ";
					}
					else
					{
						if(extIcons[file_ext] == true)
							f_img = "<img src='icons/"+ file_ext +".gif'> ";
						else
							f_img = "<img src='icons/default.gif'> ";
					}
					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+"' fsize='"+filesize+"' name=\""+htmlencode(f_name)+"\"><input type='checkbox' id='cid_"+i+"' cid='"+i+"' flag='list'> "+f_img+htmlencode(f_name)+"</td>";
				htmltext += "<td>"+f_size+"</td>";
				htmltext += "<td>"+f_dir+"</td>";
				htmltext += "<td>"+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;
		}
	}

	$("statbar").innerHTML = "<%=LANG['headbar_txt1']%><span title='"+htmlencode(now_dir)+"'>"+htmlencode(now_dir.substr(0,100))+(now_dir.length > 100 ? "...":"")+"</span>&nbsp;&nbsp;&nbsp;<%=LANG['headbar_txt2']%>"+file_num+"<%=LANG['headbar_txt3']%>"+dir_num+"<%=LANG['headbar_txt4']%>"+fileSize(total_size);

	$("favorites_add").style.display = "";
	$("favorites_del").style.display = "none";
	for (var i=0; i<$("bookmark").options.length; i++)
	{
		if($("bookmark").options[i].value == now_dir)
		{
			$("favorites_add").style.display = "none";
			$("favorites_del").style.display = "";
		}
	}

	if($("bookmark").options.length > 0)
	{
		$("bookmark").options[0].selected = true;
	}

	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:9px;color: #444;' title='"+strUsedQuota+"'>"+strUsedQuota+"</div>";
	}

	if(total_num > 0)
	{
		if(last_field == 0)
		{
			sortTable(null,'listtable', 0, 'filename');

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

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

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

			if(reverse_sort == 1)
				sortTable(null,'listtable', 3);
		}
		else
		{
			sortTable(null, "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";

	if(lastArrow != null)
		lastArrow.style.backgroundImage="";
}


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;
	}
	
	var screen_width = getBrowerWidth() > 1024 ? getBrowerWidth():1024;
	row_filenum = parseInt(screen_width / 200);
	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[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+"' onclick='clickCheckbox(this);'></td><td id='"+f_md5+"' class='picalign'><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_isdir == "<%=LANG['list_directory']%>")
					{
						f_icon = "<img _src='icons/directory_b.gif'>";
					}
					else
					{
						if(extIcons[f_ext] == true)
							f_icon = "<img _src='icons/"+ f_ext +"_b.gif'>";
						else
							f_icon = "<img _src='icons/default_b.gif'>";
					}
				}
				else
				{
					if(f_isdir == "<%=LANG['list_directory']%>")
					{
						f_icon = "<img src='icons/directory_b.gif'>";
					}
					else
					{
						if(extIcons[f_ext] == true)
							f_icon = "<img src='icons/"+ f_ext +"_b.gif'>";
						else
							f_icon = "<img src='icons/default_b.gif'>";
					}
				}
				f_img = "<div class='rect'><table style='width:100%;height:100%;'><tr><td class='boxalign'><input type='checkbox' "+ischecked+" ccid='"+i+"' 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+htmlencode(f_filename.substr(0,20))+(f_filename.length > 20 ? "...":"");
			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(isEdge) offset = 2;

	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();
		moreaction_show = false;
		$("action_div").style.visibility = "hidden";
		$("menu_div2").style.visibility = "hidden";
		$("menu_div").style.visibility = ""; 
		$("menu_div").style.top = evt.clientY - 150; 
		$("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)
			{
				var f_name = htmldecode(selectedRow.cells[0].getAttribute("name"));

				if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
				{
					$("uplinkitem").style.display = "";
				}
				else
				{
					$("uplinkitem").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 = "";
			}
		}
		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(isEdge) offset = 2;

	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><%=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'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21'><span><em><%=LANG['create_cancel']%></em></span></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=320 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",selectTime_callback,320,320);
}

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 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-left:10px;' colspan=2><textarea id='weblink_text' style='width:480px;height:85px' disabled tabindex='35'> </textarea></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'> <span><em><img src='images/clean.gif' align='absmiddle' id='btn_clear_date' onclick='clearTime();' title='Clean' style='border: 1px solid #666; padding:0px; cursor:pointer;' tabindex='37'>&nbsp;</em></span> <%=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'> <%=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'> <button onclick='generateRandom();' title='<%=LANG['str_generate_pass']%>'><span style='vertical-align:middle;'><em><img src='images/password.gif' align='absmiddle'>&nbsp;</em></span></button> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:6px;'><input type='checkbox' id='enable_sendmail' tabindex='40' onclick='enableSendMail();' value='1' disabled> <%=LANG['str_sendmail']%>:</td><td><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:30px;'><%=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:30px;'><%=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 align='center'><td height='50' colspan=2><button id='btn_submit' type='submit' onclick='update_weblink();' tabindex='44'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='45'><span><em><%=LANG['str_close']%></em></span></button></td></tr></table>",null,530,400);

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

	if(selectedRow.cells[2].innerHTML != "<%=LANG['list_directory']%>")
	{
		alert("<%=LANG['error_no_dir']%>");
		return;
	}
	else
	{
		var f_name = selectedRow.cells[0].getAttribute("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-left:10px;' colspan=2><textarea id='uploadlink_text' style='width:480px;height:85px' disabled tabindex='35'> </textarea></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'> <span><em><img src='images/clean.gif' align='absmiddle' id='btn_clear_date' onclick='clearTime();' title='Clean' style='border: 1px solid #666; padding:0px; cursor:pointer;' tabindex='37'>&nbsp;</em></span> <%=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'> <button onclick='generateRandom();' title='<%=LANG['str_generate_pass']%>'><span style='vertical-align:middle;'><em><img src='images/password.gif' align='absmiddle'>&nbsp;</em></span></button> <%=LANG['str_optional']%></td></tr><tr><td style='padding-left:6px;'><input type='checkbox' id='enable_sendmail' tabindex='40' onclick='enableSendMail();' value='1' disabled> <%=LANG['str_sendmail']%>:</td><td><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:30px;'><%=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:30px;'><%=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:30px;display:none' colspan=2><input type='checkbox' id='enable_notify' tabindex='44' value='1' disabled> <%=LANG['str_sendnotify']%></td></tr><tr align='center'><td height='50' colspan=2><button id='btn_submit' type='submit' onclick='update_uploadlink();' tabindex='45'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='46'><span><em><%=LANG['str_close']%></em></span></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 = 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($("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()
{
	if($("enable_uploadlink").checked)
	{
		var f_name = selectedRow.cells[0].getAttribute("name");
		ajaxRequest("uplink","operation=add&filename="+urlEncode(f_name) );
	}
	else
	{
		var f_name = selectedRow.cells[0].getAttribute("name");
		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;
			$("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;
			$("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 = selectedRow.cells[0].getAttribute("name");
			var filename = urlEncodeSpecial(f_name);

			$("enable_uploadlink").checked = true;
			$("uploadlink_text").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 = "";

//				if(resultArray[4] != null && resultArray[4] != "")
//					$("mail_address").value = resultArray[4];
//				else
//					$("mail_address").value = "";
//
//				if(resultArray[5] != null && resultArray[5] != "")
//					$("sender_mail_address").value = resultArray[5];
//				else
//					$("sender_mail_address").value = "";
//
//				if(resultArray[5] != null && trim(resultArray[5]) == "yes")
//					$("enable_notify").checked = true;
//				else
//					$("enable_notify").checked = false;

			}

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

			if($("expiretime").value != "")
			{
				if(compareDate($("expiretime").value) == true)
					$("expiretime").style.color = "#FF0000";
			}
			$("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 localaddress = weblink_url;
	if(localaddress == "")
		localaddress = location.href.replace(/\#/g,"");

	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)+"&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;
			$("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;
			$("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;
			$("expiretime").disabled = false;
			$("downloadlimit").disabled = false;
			$("downloadpass").disabled = false;
			$("enable_sendmail").disabled = false;
			//$("mail_address").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($("expiretime").value != "")
			{
				if(compareDate($("expiretime").value) == true)
					$("expiretime").style.color = "#FF0000";
			}

			if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
				$("weblink_text").value = localaddress + "?download&weblink="+strWebLink;
			else
				$("weblink_text").value = localaddress + "?download&weblink="+strWebLink+"&realfilename="+filename;
		}
	}
	catch(e){}
}

function ed2kurl()
{
	var ed2k_url = xmlhttp.responseText;
	ed2k_url = ed2k_url.replace("\n","");
	try
	{
		if(trim(ed2k_url) == "")
		{
			alert("<%=LANG['error_ed2k']%>");
		}
		else
		{
			var f_name = selectedRow.cells[0].getAttribute("name");
			var filename = htmldecode(f_name);
			filename = urlEncodeSpecial(f_name);
			var localaddress = location.href.replace(/\#/g,"");
			var downloadURL = localaddress + "?download&filename="+filename+"&UID=<%=_SESSION_ID%>&nowpath="+urlEncodeSpecial(now_dir)+"&r="+Math.random();
			$("urlcontent").value = "ed2k://|file|"+f_name+"|"+ed2k_url+"|s="+downloadURL+"|/";
			$("urltitle").innerHTML = "<%=LANG['label_ed2kurl']%>";
			$("ed2kurl_btn").innerHTML = "<span><em><%=LANG['button_httpurl']%></em></span>";
			$("ed2kurl_btn").onclick = function()
			{
				$("urlcontent").value = downloadURL;
				$("urltitle").innerHTML = "<%=LANG['label_httpurl']%>";
				$("ed2kurl_btn").innerHTML = "<span><em><%=LANG['button_ed2kurl']%></em></span>";
				$("ed2kurl_btn").onclick = function()
				{
					ajaxRequest("ed2kurl","filename="+f_name);
				}
			}
		}
	}
	catch(e){}
}

function createFolder()
{
	showMessagebox("<%=LANG['create_title']%>","<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'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21'><span><em><%=LANG['create_cancel']%></em></span></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><span style='width:110px;display:-moz-inline-box;display:inline-block;'><%=LANG['rename_oldname']%>:</span><input type='text' style='width:180px' id='oldname' value='"+htmlencode(filename)+"' disabled><br><span style='width:110px;display:-moz-inline-box;display:inline-block;'><%=LANG['rename_newname']%>:</span><input type='text' style='width:180px' id='newname' tabindex='30' value='"+htmlencode(filename)+"' maxlength='128'><br><br><button id='btn_submit' type='submit' onclick='return renameFile_submit()' tabindex='20'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21'><span><em><%=LANG['create_cancel']%></em></span></button>");
	$("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;
		var isFlashInstalled = DetectFlashVer(11, 4, 0);
		if( isFormDataSupported == false && isFlashInstalled == 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='modify"+frametag+"'></iframe>",closeUploader,700,390);
}

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'><span><em><%=LANG['upload_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();return false;' tabindex='21'><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()
{
	if(last_field == -1)
		window.location = "main.html";
	else
		window.location = "main.html?sort="+last_field+"&r="+Number(reverse_sort);

	return false;
}

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 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[2].innerHTML == "<%=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,55)+(f_name.length > 55 ? "...":"")+"</span>","<iframe src='editor.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+urlEncodeSpecial(filename)+"&r="+Math.random()+"' width=720 height=520 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,720,520);
	}
}

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) )
		{
			show_picture(filename);
		}
	}
	else if(!isIE && f_ext == "pdf")
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			var pdf_url = encodeURIComponent("/?download&filename="+filename+"&UID=<%=_SESSION_ID%>&r="+Math.random());
			showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,85))+(f_name.length > 85 ? "...":"")+"</span>","<iframe src='/pdfjs-dist/web/viewer.html?file="+pdf_url+"' width=1120 height=760 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 1120, 760);
		}
	}
	else if(checkvideo() && (f_ext == "mp4" || f_ext == "mov") )
	{
		if(checkFilePermission(checkfileURL) )
		{
			var frametag = new Date().getTime();
			showMessagebox("<span title='"+htmlencode(f_name)+"'>"+htmlencode(f_name.substr(0,85))+(f_name.length > 85 ? "...":"")+"</span>","<iframe src='videoplayer.html?dir="+urlEncodeSpecial(now_dir)+"&filename="+filename+"&r="+Math.random()+"' width=980 height=560 border=0 frameborder=0 id='modify"+frametag+"'></iframe>", null, 980, 560);
		}
	}
	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,45))+(f_name.length > 45 ? "...":"")+"</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") )
	{
		if(checkFilePermission(checkfileURL) )
		{
			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="+filename+"&r="+Math.random()+"' width=720 height=520 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,720,520);
		}
	}
	else
	{
		download_url = "/?download&filename="+filename+"&UID=<%=_SESSION_ID%>&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()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['error_nofile']%>");
		return;
	}

	if(selectedRow.cells[2].innerHTML == "<%=LANG['list_directory']%>")
	{
		openDirectory()
	}
	else
	{
		var f_name = selectedRow.cells[0].getAttribute("name");
		var filename = htmldecode(f_name);
		filename = urlEncodeSpecial(filename);
		var filesize = selectedRow.cells[0].getAttribute("fsize");
		download_url = "/?download&filename="+filename+"&UID=<%=_SESSION_ID%>&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 != "")
		{
			if(selectedRow == null)
			{
				deleteFile(1);
				return;
			}
			else
			{
				alert("<%=LANG['multifiles_tip']%>");
			}
		}

		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 != "")
		{
			alert("<%=LANG['multifiles_tip']%>");

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

			if(selectedRow == null)
				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));
	selectedRow = null;
	unselectAll();
	$("pasteitem").style.display = "";
	$("pasteitem2").style.display = "";
	$("pasteitem3").style.display = "";
}

function pasteFile()
{
	ajaxRequest("paste","");
}

function changePassword()
{
	showMessagebox("<%=LANG['item_changepass']%>","<br><table id='listhead2' width='100%' border='0' cellpadding='2' cellspacing='3'><tr><td style='padding-left:20px;'><%=LANG['old_password']%>: </td><td><input type='password' id='oldpassword' style='width:160px' tabindex='28'></td></tr><tr><td style='padding-left:20px;'><%=LANG['new_password']%>: </td><td><input type='password' id='newpassword' style='width:160px' tabindex='29'><br><span style='font-size:9px;color:#777'><%=LANG['str_password_strength']%>:<img src='images/pass_strength0.gif' id='pass_strength' border='0' align='absmiddle'></span></td></tr><tr><td style='padding-left:20px;'><%=LANG['newpass_confirm']%>: </td><td><input type='password' id='newpass_confirm' style='width:160px' tabindex='30'></td><tr><td colspan=2 height=25>&nbsp;</td></tr><tr align='center'><td colspan=2><button id='btn_submit' type='submit' onclick='changePassword_submit()' tabindex='20'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.location.reload();' tabindex='21'><span><em><%=LANG['create_cancel']%></em></span></button></td></tr>",changePasswordCancel,360,220);
	$("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(checkPasswordStrong(newpassword) < 2)
	//{
	//	if(confirm("<%=LANG['str_weak_password']%>"))
	//		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()
{
	//window.open("help/english/index.html","_blank"); 
	gotoUrl("help/english/index.html", true);
}

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

btnHover = function(){
      var buttonObj = document.body.getElementsByTagName("button");
      for (var i=0; i<buttonObj.length; i++) {
			if(buttonObj[i].className != "mybutton")
			{
				buttonObj[i].onmouseover=function(){
						this.className = "buttonhover";
				}
				buttonObj[i].onmouseout=function(){
						this.className = this.className.replace(/\bbuttonhover\b/,'');
				}
			}
      }
}
if(window.attachEvent && isIE)
	window.attachEvent("onload", btnHover);


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=620 height=430 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,620,430);
}

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 != "")
		{
			alert("<%=LANG['multifiles_tip']%>");

			if(selectedRow == null)
				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'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21'><span><em><%=LANG['create_cancel']%></em></span></button>",null,380,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[2].innerHTML == "<%=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><%=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'><span><em><%=LANG['create_submit']%></em></span></button>&nbsp;&nbsp;&nbsp;<button id='btn_cancel' onclick='top.closewindow();' tabindex='21'><span><em><%=LANG['create_cancel']%></em></span></button>",null,330,180);
	$("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=720 height=520 border=0 frameborder=0 id='modify"+frametag+"'></iframe>",null,720,520);
	}
}

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()
{
	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");
		$("bookmark").options.length = 0;
		$("bookmark").options[0] = new Option("=== <%=LANG["str_bookmarks"]%> ===", "");
		$("favorites_add").style.display = "";
		$("favorites_del").style.display = "none";
		for (var i=0; i<bookmarkArray.length; i++)
		{
			var strBookmark = bookmarkArray[i];
			if(strBookmark != "")
			{
				$("bookmark").options[i+1] = new Option(strBookmark, strBookmark);
				if(strBookmark == now_dir)
				{
					$("favorites_add").style.display = "none";
					$("favorites_del").style.display = "";
				}
			}
		}
	}
	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: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>
<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_close.png" style="float:right;margin-right:20px;" onclick="close_picture();" alt="<%=LANG["button_closepicture"]%>" title="<%=LANG["button_closepicture"]%>">

<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="videodiv" style="position:absolute; z-index:104; 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="videodiv2" style="position:absolute; z-index:105; width:100%; top:20px; left:0px; text-align:center; display:none;">
<div id="videodiv3"></div><br>
<button onclick='close_video();'><span><em><%=LANG["button_closemedia"]%></em></span></button>&nbsp;
<button onclick='show_videolist();' id="videolist_btn"><span><em><%=LANG["button_showmedia"]%></em></span></button>
<div id="videolist_div" style="position:absolute; visibility:hidden; text-align:left; background-color:#FFF; border:1px solid #CCC; width:240px; height:120px; padding:2px; overflow-y:auto;">
</div>
</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:200px;" onclick="return false;">
	<div class="menu_out">
	<div class="menu_in">
	<ul>
    <li style="margin-top:0px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="downloadFile_ext();"><img src="images/open.gif">&nbsp;&nbsp;<%=LANG["item_download"]%></li>
	<li id="weblinkitem" style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showDownloadUrl();"><img src="images/geturl.gif">&nbsp;&nbsp;<%=LANG["item_geturl"]%></li>
	<li id="uplinkitem" style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showUploadUrl();"><img src="images/addlink.png">&nbsp;&nbsp;<%=LANG["uploadlink_title"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="editFile();"><img src="images/edit.gif">&nbsp;&nbsp;<%=LANG["item_edit"]%></li>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="deleteFile(0);"><img src="images/delete.gif">&nbsp;&nbsp;<%=LANG["item_delete"]%></li>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="renameFile();"><img src="images/rename.gif">&nbsp;&nbsp;<%=LANG["item_rename"]%></li>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="zipFile(0);"><img src="images/compress.gif">&nbsp;&nbsp;<%=LANG["item_zip"]%></li>
    <li id="unzipitem" style="margin-top:4px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="unzipFile();"><img src="images/uncompress.gif">&nbsp;&nbsp;<%=LANG["item_unzip"]%></li>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="cutFile(0);"><img src="images/cut.gif">&nbsp;&nbsp;<%=LANG["item_cut"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="copyFile(0);"><img src="images/copy.gif">&nbsp;&nbsp;<%=LANG["item_copy"]%></li>
	<li id="pasteitem" style="margin-top:4px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="pasteFile();"><img src="images/paste.gif">&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
			local icon_path = "images/extbutton.gif"
			if val.extbutton_icon ~= nil then
				icon_path = val.extbutton_icon
			end			
			print("<li style='margin-top:4px;' onmouseover='menuMouseOver(this)' onmouseout='menuMouseOut(this)' onclick='"..val.extbutton_func.."'><img src='"..icon_path.."' width='16' height='16'>&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:158px;" onclick="return false;">
	<div class="menu_out">
	<div class="menu_in">
	<ul>
    <li style="margin-top:0px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="checkUpload();"><img src="images/upload.gif">&nbsp;&nbsp;<%=LANG["item_upload"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="createFolder();"><img src="images/newdir.gif">&nbsp;&nbsp;<%=LANG["item_mkdir"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="newText();"><img src="images/newtxt.gif">&nbsp;&nbsp;<%=LANG["item_newtxt"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="goTo();"><img src="images/goto.gif">&nbsp;&nbsp;<%=LANG["item_goto"]%></li>
	<li id="pasteitem2" style="margin-top:4px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="pasteFile();"><img src="images/paste.gif">&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
			local icon_path = "images/extbutton.gif"
			if val.extbutton_icon ~= nil then
				icon_path = val.extbutton_icon
			end
			print("<li style='margin-top:4px;' onmouseover='menuMouseOver(this)' onmouseout='menuMouseOut(this)' onclick='"..val.extbutton_func.."'><img src='"..icon_path.."' width='16' height='16'>&nbsp;&nbsp;"..val.extbutton_name.."</li>")
		end
	end
	%>
	</ul>
	</div>
	</div>
</div>


<div id="action_div" style="position:absolute; visibility:hidden; background-color:#FFF; width:200px; top:108px; left:378px;" onclick="return false;">
	<div class="menu_out">
	<div class="menu_in">
	<ul>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="cutFile(0);"><img src="images/cut.gif">&nbsp;&nbsp;<%=LANG["item_cut"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="copyFile(0);"><img src="images/copy.gif">&nbsp;&nbsp;<%=LANG["item_copy"]%></li>
	<li id="pasteitem3" style="margin-top:4px;display:none;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="pasteFile();"><img src="images/paste.gif">&nbsp;&nbsp;<%=LANG["item_paste"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="goTo();"><img src="images/goto.gif">&nbsp;&nbsp;<%=LANG["item_goto"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="renameFile();"><img src="images/rename.gif">&nbsp;&nbsp;<%=LANG["item_rename"]%></li>

	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showDownloadUrl();"><img src="images/geturl.gif">&nbsp;&nbsp;<%=LANG["item_geturl"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="showUploadUrl();"><img src="images/addlink.png">&nbsp;&nbsp;<%=LANG["uploadlink_title"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="editFile();"><img src="images/edit.gif">&nbsp;&nbsp;<%=LANG["item_edit"]%></li>
	<li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="newText();"><img src="images/newtxt.gif">&nbsp;&nbsp;<%=LANG["item_newtxt"]%></li>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="zipFile(0);"><img src="images/compress.gif">&nbsp;&nbsp;<%=LANG["item_zip"]%></li>
    <li style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="unzipFile();"><img src="images/uncompress.gif">&nbsp;&nbsp;<%=LANG["item_unzip"]%></li>
	<li id="favorites_add" style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="addBookmark();" title="<%=LANG["add_bookmark_tip"]%>"><img src="images/favorites.png">&nbsp;&nbsp;<%=LANG["add_bookmark"]%></li>
	<li id="favorites_del" style="margin-top:4px;" onmouseover="menuMouseOver(this)" onmouseout="menuMouseOut(this)" onclick="delBookmark();" title="<%=LANG["del_bookmark_tip"]%>"><img src="images/favorites_del.png">&nbsp;&nbsp;<%=LANG["del_bookmark"]%></li>
	<%
	for _,val in pairs(_SERVER) do
		if val.extbutton_name ~= nil and val.extbutton_func ~= nil then
			local icon_path = "images/extbutton.gif"
			if val.extbutton_icon ~= nil then
				icon_path = val.extbutton_icon
			end
			print("<li style='margin-top:4px;' onmouseover='menuMouseOver(this)' onmouseout='menuMouseOut(this)' onclick='"..val.extbutton_func.."'><img src='"..icon_path.."' width='16' height='16'>&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_bg.gif"> 
			  <table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr> 
				  <td width="13"><img src="images/coner_left.gif" width="13" height="66"></td>
				  <td height="66" valign="bottom" style="background:url(images/bg.jpg) no-repeat right bottom;">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
					  <tr>
						<td width="303" id="main_logo_td"><img src="images/<%=c_GetDomainSmallLogo()%>" width="303" height="55"></td>
						<td align="right">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr> 
							<%
							if nType >= 5 then
								print("<td style='color:#000;font-weight:bold;'>(UNREGISTERED COPY)</td><td width='20'>&nbsp;</td>")
							end
							%>
							  <td>[<%=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_help.gif" class="cur" onclick="clientHelp();" alt="<%=LANG["item_help"]%>" title="<%=LANG["item_help"]%>" tabindex="-1"></td>
							  <td style="color:#FFF; cursor:pointer;" onclick="clientHelp();"><%=LANG["item_help"]%></td>
							  <% if enable_changepass == true then %>
							  <td width="15">&nbsp;</td>
							  <td><input type="image" src="images/ico_pass.gif" class="cur" onclick="changePassword();" alt="<%=LANG["item_changepass"]%>" title="<%=LANG["item_changepass"]%>" tabindex="8"></td>
							  <td style="color:#FFF; cursor:pointer;" onclick="changePassword();"><%=LANG["item_changepass"]%></td>
							  <% end %>
							  <td width="15">&nbsp;</td>
							  <td><input type="image" src="images/ico_quit.gif" class="cur" onclick="signOut();" alt="<%=LANG["item_logout"]%>" title="<%=LANG["item_logout"]%>" tabindex="9"></td>
							  <td style="color:#FFF; cursor:pointer;" onclick="signOut();"><%=LANG["item_logout"]%></td>
							  <td width="10">&nbsp;</td>
							</tr>
						  </table>
						</td>
					  </tr>
					</table></td>
				<td width="13"><img src="images/coner_right.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;"> 


		<div style="width:100%; padding-top:2px; overflow-x:hidden;">
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr valign="top"><td width="518">
			<input type="image" src="images/icon_back.gif" alt="<%=LANG["item_goup"]%>" title="<%=LANG["item_goup"]%>" onclick="goUp()" class="cur" tabindex="1" id="first_button"> &nbsp;<input type="image" src="images/icon_home.gif" alt="<%=LANG["item_gohome"]%>" title="<%=LANG["item_gohome"]%>" onclick="goHome()" class="cur" tabindex="2"> &nbsp;<input type="image" src="images/icon_refresh.gif" alt="<%=LANG["item_refresh"]%>" title="<%=LANG["item_refresh"]%>" onclick="Refresh()" class="cur" tabindex="3"> &nbsp;<input type="image" src="images/icon_upload.gif" alt="<%=LANG["item_upload"]%>" title="<%=LANG["item_upload"]%>" onclick="checkUpload()" class="cur" tabindex="4"> &nbsp;<input type="image" src="images/icon_download.gif" alt="<%=LANG["item_download"]%>" title="<%=LANG["item_download"]%>" onclick="downloadFile_ext()" class="cur" tabindex="5"> &nbsp;<input type="image" src="images/icon_delete.gif" alt="<%=LANG["item_delete"]%>" title="<%=LANG["item_delete"]%>" onclick="deleteFile(0)" class="cur" tabindex="6"> &nbsp;<input type="image" src="images/icon_newdir.gif" alt="<%=LANG["item_mkdir"]%>" title="<%=LANG["item_mkdir"]%>" onclick="createFolder()" class="cur" tabindex="7"> &nbsp;<input type="image" src="images/icon_search.gif" alt="<%=LANG["str_search"]%>" title="<%=LANG["str_search"]%>" onclick="openSearch()" class="cur" tabindex="-1"> &nbsp;<input type="image" src="images/icon_thumb.gif" alt="<%=LANG["item_change_thumb"]%>" title="<%=LANG["item_change_thumb"]%>" onclick="change_viewmode(true)" class="cur" id="thumbmode" tabindex="-1" /><input type="image" src="images/icon_list.gif" alt="<%=LANG["item_change_list"]%>" title="<%=LANG["item_change_list"]%>" onclick="change_viewmode(false)" class="cur" style="display:none;" id="listmode" tabindex="-1" />&nbsp;<button class="mybutton" style="margin-top:6px;" onclick="clickMore();" alt="<%=LANG["str_more_actions"]%>" title="<%=LANG["str_more_actions"]%>" id="action_btn" tabIndex="-1"><span style="vertical-align:middle;"><em><img src="images/plusicon.gif" align="absmiddle">&nbsp;<%=LANG["str_more_actions"]%></em></span></button></td>
			<td align="right" style="padding-top:6px; ">
			<b><%=LANG["multifiles_action"]%>:</b>
			&nbsp;<button class="mybutton" onclick="zipFile(1);" title="<%=LANG["item_mzip"]%>" id="mzip_btn" tabIndex="-1"><span style="vertical-align:middle;"><em><img src="images/compress.gif" align="absmiddle">&nbsp;<%=LANG["item_mzip"]%></em></span></button>&nbsp;<button class="mybutton" onclick="deleteFile(1);" title="<%=LANG["item_mdelete"]%>" id="mdelete_btn" tabIndex="-1"><span style="vertical-align:middle;"><em><img src="images/delete.gif" align="absmiddle">&nbsp;<%=LANG["item_mdelete"]%></em></span></button>&nbsp;<button class="mybutton" onclick="cutFile(1);" title="<%=LANG["item_mcut"]%>" id="mcut_btn" tabIndex="-1"><span style="vertical-align:middle;"><em><img src="images/cut.gif" align="absmiddle">&nbsp;<%=LANG["item_mcut"]%></em></span></button>&nbsp;<button class="mybutton" onclick="copyFile(1);" title="<%=LANG["item_mcopy"]%>" id="mcopy_btn" tabIndex="-1"><span style="vertical-align:middle;"><em><img src="images/copy.gif" align="absmiddle">&nbsp;<%=LANG["item_mcopy"]%></em></span></button>
			</td></tr>
			<tr><td height="25">
			&nbsp;<b><%=LANG["str_chkbox_select"]%>:</b> <span onclick="selectAll();" class="cur"><%=LANG["str_chkbox_all"]%></span>, <span onclick="unselectAll();" class="cur"><%=LANG["str_chkbox_none"]%></span>
			</td>
			<td align="right">
			<select id="bookmark" style="width:150px;" onchange="changeDirectory(this)">
				<option value="">=== <%=LANG["str_bookmarks"]%> ===</option>
			</select>
			&nbsp;&nbsp;<span id="statbar"></span>
			</td></tr>
			</table>

			<table id="listhead" width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">
			<tr>
			<td width="<%=cellwidth[1]%>" onmouseover="className='listhead2';" onmouseout="className='listhead';" class="listhead" onmousedown="sortTable(this,'listtable', 0, 'filename');SetLastField(0);showthumb();"><div class="resizeblock" onmousedown="dragHead(this);">&nbsp;</div><%=LANG["thread_name"]%></td>
			<td 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 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 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="#00CC33"><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 width="100%" valign="top"></td>
		<td width="13" valign="top"><img src="images/coner_right1.gif" width="13" height="12"></td>
	  </tr>
	</table></td>
</tr>
</table>
      
  </td>
  </tr>
	<tr> 
	<td align="center">
	  <a href="https://www.wftpserver.com/" target="_blank">Wing FTP Server</a> ©2003-2020 <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("<%=_GET['redir']%>"));
<% end %>

ajaxRequest("dir","r="+Math.random());
_TIMER_KEEPLIVE = setInterval("keeplive()",1000*300);

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 == "" || $("videodiv").style.display == "" || $("uploadingDiv_mask").style.display == "")
		{
		}
		else
		{
			if($("menu_div").style.visibility == "hidden" && $("menu_div2").style.visibility == "hidden")
			{
				var evt = getEvent();
				moreaction_show = false;
				$("action_div").style.visibility = "hidden";
				$("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($("action_div").style.visibility == "" || $("action_div").style.visibility == "visible")
	{
		if(element.id != "action_btn" && moreaction_show == true)
		{
			clickMore();
		}
	}

	if($("videolist_div").style.visibility == "" || $("videolist_div").style.visibility == "visible")
	{
		if(element.id != "videolist_btn" && videolist_show == true)
		{
			close_videolist();
		}
	}

}

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(isEdge || isIE11)
{
	try
	{
		$("listview_div").style.height = "74vh";
		$("thumbview_div").style.height = "74vh";
	}
	catch(e)
	{
	}
}

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

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

		if(__zIndex != null && __zIndex == 100 && $("picturediv").style.display == "none")
		{
			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='modify"+frametag+"'></iframe>",closeUploader,700,390);
			}
		}

	}

	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']%>");
					//window.location = "logout.html";
					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();'><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();'><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 
%>