<%
include("language.html")
if _SESSION["logined"] ~= nil then
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Add Administrator</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%
local admin = ""
if _GET["username"] ~= nil then
	admin = c_GetAdmin(_GET["username"])
	if admin == nil then
		print("<script>alert('Admin does not exist!');top.closewindow();</script>")
		exit()
	else
		if (_SESSION["admin_readonly"] ~= nil and _SESSION["admin_readonly"] == 1) or (_SESSION["admin_domainadmin"] ~= nil and _SESSION["admin_domainadmin"] == 1) then
			admin.password = ""
			admin.two_factor_code = ""
		end
		admin = json.encode_s(admin)
	end
end
%>
<style type="text/css">
a {text-decoration:none;}
a,a:visited {color:#000;background:inherit;}
img {border:0px;}
<%if _COOKIE["admin_lang"] == "schinese" or _COOKIE["admin_lang"] == "tchinese" or _COOKIE["admin_lang"] == "japanese" then%>
body,td,span {margin:0;padding:0;font:12px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%else%>
body,td,span {margin:0;padding:0;font:11px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%end%>
input,select,textarea{margin:4px;}
input,textarea{background-color:expression((this.disabled && this.disabled==true)?"#D4D0C8":"")}
td{line-height:20px;}

button{
border:none;background:none;padding:0;
margin:0;width:auto;overflow:visible;text-align:center;
white-space:nowrap;height:24px;line-height:24px;
cursor:pointer;
color:#000;
margin-left:2px;
margin-top:2px;
}
button span, button em{
display:block;height:24px;line-height:22px;margin:0;
}	
button span{
font-size:8pt;
padding-left:12px;
background:url("images/button_left.gif") no-repeat 0 0;
}
<%if _COOKIE["admin_lang"] == "schinese" or _COOKIE["admin_lang"] == "tchinese" or _COOKIE["admin_lang"] == "japanese" then%>
button em{
font-style:normal;padding-right:14px;
background:url("images/button.gif") no-repeat 101% 0;
}
<%else%>
button em{
font-style:normal;padding-right:10px;
background:url("images/button.gif") no-repeat 100% 0;
}
<%end%>
button:hover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}
button span:hover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}
.buttonhover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}


.listhead
{
		border-top: 1px solid white; border-right: 1px solid #ACA899; border-left: 1px solid white; border-bottom: 2px solid #E1E2E3;
		font: 12px/22px arial; cursor: hand; text-align: center; background-color: #EFEFEF; overflow:hidden; height:18px;
}

.listhead2
{
		border-top: 1px solid white; border-right: 1px solid #ACA899; border-left: 1px solid white; border-bottom: 2px solid #FCC247;
		font: 12px/22px arial; cursor: hand; text-align: center; background-color: #FAF9F4; overflow:hidden; height:18px;
}

.listtr01
{
		background-color: #FFFFFF;
		text-align: left;
		padding: 3px;
}

.listtr02
{
		background-color: #3366CC;
		color: #FFF;
		text-align: left;
		padding: 3px;
}

.resizeblock{
	background-color:transparent;
	width:2px;
	float:right;
	cursor:e-resize;
}



#tabDiv {
	width: 636px;
	margin: 0px auto 0px auto;
	position: relative;
	border:1px solid transparent;
	border:1px solid #E6E6E6;
}
#tabDiv ul {
	padding: 0px;
	position: absolute;
	margin: 4px;
}
#tabDiv li {
	list-style-type: none;
	float: left;
	margin-right: 1px;
	height: 24px;
	line-height: 24px;
	padding: 0px;
}
#tabDiv li a {
	display: block;
	text-decoration: none;
	padding-right: 10px;
	padding-left: 10px;
}
.tagContent {
	clear:both;
	float:none;
	margin-top: 27px;
	border: 1px solid #919B9C;
}
.tagContent div {
	margin-top: 0px;
	height: 380px;
	background-image: url('images/tabbg.gif');
	background-repeat: repeat-x;
	background-color: #fff;
	padding: 12px;
	display: none;
}
.selectedTag {
	background-image: url('images/tableft.gif');
	background-repeat: no-repeat;
	background-position: left top;
}
.selectedTag a {
	background-image: url('images/tabright.gif');
	background-repeat: no-repeat;
	background-position: right top;
	color:#000;
}
.normalTag {
	background-image: url('images/tableft.gif');
	background-repeat: no-repeat;
	background-position: left bottom;
}
.normalTag a {
	background-image: url('images/tabright.gif');
	background-repeat: no-repeat;
	background-position: right bottom;
	color:#49658F
}
.emptyTag { width:20px;}
</style>

<script language="javascript" src="include/common.js"></script>
<script language="javascript" src="include/json.js"></script>
<script language="javascript">
var ajaxlock = false;
var selectedRow = null;
var lastObj = null;
var lastObjIndex = -1;

var xmlhttp,page,post;
xmlhttp = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();

function ajaxRequest(pagename,poststring,method)
{
	if(ajaxlock == false)
	{	
		delete xmlhttp;
		xmlhttp = isIE ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();

		ajaxlock = true;
		page = pagename;
		post = poststring;

		if(method == "GET")
			xmlhttp.open("GET",page+".html"+post);
		else
			xmlhttp.open("POST",page+".html");

		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = ajaxResponse;
		if(method != "GET")
			xmlhttp.send(post);
		else
			xmlhttp.send("");
	}
}

function ajaxResponse()
{
	if (xmlhttp.readyState == 4)
	{
		ajaxlock = false;
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'admin_addadmin':		addAdmin_result();break;
					case 'admin_modifyadmin':	modifyAdmin_result();break;
				}
			}
			catch(e)
			{
				alert("<%=LANG['error_ajax']%>");
			}
		}
		else
		{
			alert("<%=LANG['error_ajax']%>");
		}
	}
}

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


var ipmasks = new Array();
var last_dir_id = null;

function addAdminSubmit()
{
	var username = $("username").value;
	if(username.length == 0 || username.search(/[\\\/\<\>\:\?\"\'\[\]\{\}\|\*\&\%]/i) != -1)
	{
		alert("<%=LANG['str_invalid_username']%>");
		return false;
	}
	var password = $("password").value;
	if(password.length < 8)
	{
		alert("<%=LANG['str_invalidadminpass']%>");
		return false;
	}
	else
	{
		//if(checkPasswordStrong(password) < 2)
		//{
		//	if(confirm("<%=LANG['str_adminpass_weak']%>"))
		//		return false;
		//}
	}
	password = password.replace(/\\/g,'\\\\');
	password = password.replace(/\"/g,'\\"');

	var selected_domain = "";
	if($("enable_domainadmin").checked)
	{
		var opt_selected = false;
		for(var x=0; x<$("domainlist").length; x++)
		{
			var opt = $("domainlist").options[x];
			if(opt.selected)
			{
				opt_selected = true;
				if(x == ($("domainlist").length-1) )
					selected_domain = selected_domain + opt.value;
				else
					selected_domain = selected_domain + opt.value + ",";
			}
		}

		if(opt_selected == false)
		{
			alert("<%=LANG['str_domainadmin_tip']%>");
			return false;
		}

		if($("mydirectory").value == "")
		{
			if(confirm("<%=LANG['str_no_basefolder_tip']%>") == false)
				return false;
		}
		else
		{
			if($("mydirectory").value.indexOf("]]") != -1)
			{
				alert("<%=LANG['error_invalid_dir']%>");
				return false;
			}
		}
	}

	var admin = {
	username:$("username").value,
	password: password,
	oldpassword:$("oldpassword").value,
	readonly:($("enable_readonly").checked ? 1:0),
	domainadmin:($("enable_domainadmin").checked ? 1:0),
	domainlist:selected_domain,
	mydirectory:$("mydirectory").value.replace(/\\/g,'/'),
	enable_two_factor:($("enable_two_factor").checked ? 1:0),
	two_factor_code:$("two_factor_code").value,
	ipmasks:ipmasks
	};

	var adminString = encodeURIComponent(JSON.stringify(admin));
	var modifyadmin = '<%=admin%>';
	var oldname = '<%=_GET["username"]%>';
	if(modifyadmin != "")
	{
		ajaxRequest("admin_modifyadmin","oldname="+oldname+"&admin="+adminString+"&r=" + Math.random());
	}
	else
	{
		ajaxRequest("admin_addadmin","admin="+adminString+"&r=" + Math.random());
	}
}

function addAdmin_result()
{
	var result = xmlhttp.responseText;
	if(result == "0" || result == 0)
	{
		alert("<%=LANG['str_existed_username']%>");
	}
	else
	{
		top.closewindow(1);
	}
}

function modifyAdmin_result()
{
	top.closewindow(1);
}

function adminInit()
{
	var admin = '<%=admin%>';
	if(admin != "")
	{
		try
		{
			var adminObject = JSON.parse(admin);
			$("username").value = adminObject["username"];
			$("password").value = adminObject["password"];
			$("oldpassword").value = adminObject["password"];
			$("enable_readonly").checked = adminObject["readonly"];
			$("enable_domainadmin").checked = adminObject["domainadmin"];
			$("mydirectory").value = adminObject["mydirectory"];
			$("enable_two_factor").checked = adminObject["enable_two_factor"];
			if(adminObject["two_factor_code"] != null && adminObject["two_factor_code"] != "")
				$("two_factor_code").value = adminObject["two_factor_code"];

			var strDomainlist = adminObject["domainlist"];
			var domainArray = strDomainlist.split(",");
			for(var i=0;i<domainArray.length;i++)
			{
				var tempDomain = domainArray[i];
				for(var x=0; x<$("domainlist").length; x++)
				{
					var opt = $("domainlist").options[x];
					if(opt.value == tempDomain)
						opt.selected = true;
				}
			}
			ipmasks = (adminObject["ipmasks"] != null ? adminObject["ipmasks"] : new Array());
			AddBlockIP_updateview();
		}
		catch(e)
		{
			alert("<%=LANG['str_loadadmin_fail']%>");
		}
		
	}
}




function AddBlockIP()
{
	showMessagebox("<%=LANG['str_addblockip']%>","<span style='padding:5px;'><%=LANG['str_ipmask_tip']%><span><br><br><%=LANG['str_ip']%>: <input type='text' style='width:190px' id='blockip'><br><input type='radio' name='radio' id='radio_deny' checked><%=LANG['str_denied']%> <input type='radio' name='radio' id='radio_allow'><%=LANG['str_allowed']%><br><br><br><button id='btn_submit' type='submit' onclick='return AddBlockIP_submit()'><span><em><%=LANG['button_submit']%></em></span></button>&nbsp;<button id='btn_cancel' onclick='top.closewindow();'><span><em><%=LANG['button_cancel']%></em></span></button>",null,340,190);
	top.$("blockip").focus();

	top.$("btn_submit").onclick = function(){return AddBlockIP_submit();};
	top.$("btn_cancel").onclick = function(){top.closewindow();};
}

function AddBlockIP_updateview()
{
	var htmltext = "<table id='listtable2' width='100%' border='0' cellpadding='2' cellspacing='0' style='table-layout:fixed;'>";
	for(var i=0;i<ipmasks.length;i++)
	{
		var refuse = ipmasks[i].refuse ? "<font color='red'>Deny</font>":"<font color='green'>Allow</font>";
		htmltext += "<tr class='listtr01' onmouseup='do_list_click2(this);'><td width='70%' f_id='"+i+"'>"+ipmasks[i].ip+"</td><td width='30%'>"+refuse+"</td></tr>";
	}
	htmltext += "</table>";
	clear("listview_div2");
	write("listview_div2",htmltext);
	selectedRow = null;
	lastsortcol = -1;
}

function AddBlockIP_submit()
{
	var blockip = htmldecode(top.$("blockip").value);
	if(blockip.length == 0 || blockip.search(/[\<\>\"\']/i) != -1)
	{
		alert("<%=LANG['str_invalidip']%>");
		top.$("blockip").focus();
		return;
	}
	var mask = new Object();
	mask.ip = blockip;
	mask.refuse = top.$("radio_deny").checked ? true:false;
	ipmasks.push(mask);
	mask = null;
	AddBlockIP_updateview();
	top.closewindow();
}

function do_list_click2(obj)
{
	var row_index = obj.rowIndex;
	if(selectedRow != $("listtable2").rows[row_index])
	{
		if(lastObj != null)
			lastObj.className = "listtr01";

		selectedRow = $("listtable2").rows[row_index];
		obj.className = "listtr02";
		lastObj = obj;
		try{
			lastObjIndex = parseInt(selectedRow.cells[0].innerHTML);
		}catch(e){
			lastObjIndex = -1;
		}
	}
	else
	{
		ModifyBlockIP();
	}

	return false;
}

function ModifyBlockIP()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['str_norow_tip']%>");
		return;
	}
	var f_id = parseInt(selectedRow.cells[0].getAttribute("f_id"));
	var f_ip = ipmasks[f_id].ip;
	var f_deny = ipmasks[f_id].refuse ? "checked":"";
	var f_allow = ipmasks[f_id].refuse ? "":"checked";
	showMessagebox("<%=LANG['str_modifyblockip']%>","<span style='padding:5px;'><%=LANG['str_ipmask_tip']%><span><br><input type='hidden' id='blockip_id' value='"+f_id+"'><br><%=LANG['str_ip']%>: <input type='text' style='width:190px' id='blockip' value='"+f_ip+"'><br><input type='radio' name='radio' id='radio_deny' "+f_deny+"><%=LANG['str_denied']%> <input type='radio' name='radio' id='radio_allow' "+f_allow+"><%=LANG['str_allowed']%><br><br><br><button id='btn_submit' type='submit' onclick='return ModifyBlockIP_submit()'><span><em><%=LANG['button_submit']%></em></span></button>&nbsp;<button id='btn_cancel' onclick='top.closewindow();'><span><em><%=LANG['button_cancel']%></em></span></button>",null,340,190);
	top.$("blockip").focus();

	top.$("btn_submit").onclick = function(){return ModifyBlockIP_submit();};
	top.$("btn_cancel").onclick = function(){top.closewindow();};
}

function ModifyBlockIP_submit()
{
	var f_id = parseInt(htmldecode(top.$("blockip_id").value));
	var blockip = htmldecode(top.$("blockip").value);
	if(blockip.length == 0 || blockip.search(/[\<\>\"\']/i) != -1)
	{
		alert("<%=LANG['str_invalidip']%>");
		top.$("blockip").focus();
		return;
	}
	ipmasks[f_id].ip = blockip;
	ipmasks[f_id].refuse = top.$("radio_deny").checked ? true:false;
	AddBlockIP_updateview();
	top.closewindow();
}

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

	var f_id = parseInt(selectedRow.cells[0].getAttribute("f_id"));
	ipmasks.splice(f_id,1);
	AddBlockIP_updateview();
}

function UpBlockIP()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['str_norow_tip']%>");
		return;
	}
	var f_id = parseInt(selectedRow.cells[0].getAttribute("f_id"));
	if(f_id > 0)
	{
		var temp = ipmasks[f_id-1]; 
		ipmasks[f_id-1] = ipmasks[f_id];
		ipmasks[f_id] = temp;
	}

	AddBlockIP_updateview();

	if(f_id > 0)
	{
		for(var i=0; i < ipmasks.length; i++)
		{
			var tempID = parseInt($("listtable2").rows[i].cells[0].getAttribute("f_id"));
			if(tempID == f_id-1)
			{
				$("listtable2").rows[i].className = "listtr02";
				lastObj = $("listtable2").rows[i];
				selectedRow = lastObj;
			}
		}
	}
}

function DownBlockIP()
{
	if(selectedRow == null)
	{
		alert("<%=LANG['str_norow_tip']%>");
		return;
	}
	var f_id = parseInt(selectedRow.cells[0].getAttribute("f_id"));
	if(f_id < ipmasks.length-1)
	{
		var temp = ipmasks[f_id+1]; 
		ipmasks[f_id+1] = ipmasks[f_id];
		ipmasks[f_id] = temp;
	}

	AddBlockIP_updateview();

	if(f_id < ipmasks.length-1)
	{
		for(var i=0; i < ipmasks.length; i++)
		{
			var tempID = parseInt($("listtable2").rows[i].cells[0].getAttribute("f_id"));
			if(tempID == f_id+1)
			{
				$("listtable2").rows[i].className = "listtr02";
				lastObj = $("listtable2").rows[i];
				selectedRow = lastObj;
			}
		}
	}
}


function chooseDirectory()
{
	showMessagebox("<%=LANG['str_choosedir']%>","<iframe src='admin_dir_selector.html' width=580 height=500 border=0 frameborder=0></iframe>",callback_return,580,500);
}

function callback_return(value)
{
	try
	{
		$("mydirectory").focus();
		if(value != null)
			$("mydirectory").value = value;
	}
	catch(e){}
}

function reset2FACode()
{
	$("two_factor_code").value = "";
}
</script>
</head>
<body style="background-color:#E6E6E6;">

<div id="tabDiv">
  <ul id="tags">
  	<li class="emptyTag"></li>
    <li class="normalTag"><a href="javascript:void(0)" onfocus="this.blur()" onclick="switchTag('tagContent1',this)"><%=LANG["title_general"]%></a></li>
	<li class="normalTag"><a href="javascript:void(0)" onfocus="this.blur()" onclick="switchTag('tagContent2',this)"><%=LANG["title_blockip"]%></a></li>
  </ul>
  <div id="tagContent" class="tagContent">
  	<div id="tagContent1">
		<input id="oldpassword" type="hidden">
		<table cellSpacing="0" cellPadding="0" border="0">

		<tr><td colspan="2">
		<table cellSpacing="0" cellPadding="0" border="0"><tr>
		<td><img src="images/vista_addadmin.gif">&nbsp;&nbsp;&nbsp;</td><td><%=LANG["str_addadmin_tip"]%></td>
		</tr></table>
		</td></tr>

		<tr><td><b><%=LANG["str_username"]%></b>:</td><td><input id="username" type="text" style="width:260px;" maxlength="30" autocomplete="off"></td></tr>
		<tr><td><%=LANG["str_password"]%>:</td><td><input id="password" type="password" style="width:260px;" autocomplete="new-password"><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 colspan=2>
		<input id="enable_two_factor" type="checkbox"><%=LANG["str_2fa_auth"]%><input id="two_factor_code" type="text" value="" style="width:155px;" disabled>
		<button onclick="reset2FACode();"><span style="vertical-align:middle;"><em><%=LANG["str_reset_totp_secret"]%></em></span></button>
		</td></tr>
		<tr style="display:<%if _GET["username"] == _SESSION["admin"] then print("none") end%>;"><td></td><td style="padding-top:8px;"><input id="enable_readonly" type="checkbox"><%=LANG["str_readonly_admin"]%></td></tr>
		<tr style="display:<%if _GET["username"] == _SESSION["admin"] then print("none") end%>;"><td></td><td><input id="enable_domainadmin" type="checkbox"><%=LANG["str_domain_admin"]%></td></tr>
		<tr style="display:<%if _GET["username"] == _SESSION["admin"] then print("none") end%>;"><td></td><td><select id='domainlist' name='domainlist' multiple='true' style='width:230px;height:70px;' disabled>
		<% 
			for _,domain in pairs(c_GetDomainList()) do
				print("<option value='"..domain.."'>"..specialhtml_encode(urldecode(domain)).."</option>")
			end 
		%>
		</select></td></tr>
		<tr style="display:<%if _GET["username"] == _SESSION["admin"] then print("none") end%>;"><td colspan="2" style="padding-top:10px;"><%=LANG["str_basefolder_tip"]%></td></tr>
		<tr style="display:<%if _GET["username"] == _SESSION["admin"] then print("none") end%>;"><td><%=LANG["str_basefolder"]%>:</td><td><input id="mydirectory" type="text" style="width:230px;" maxlength="256" disabled>
		<button id="choosedir" type="submit" onclick="chooseDirectory();" disabled><span><em><%=LANG["button_choose"]%></em></span></button>
		</td></tr>
		</table>
	</div>
	<div id="tagContent2">
		<table id="listhead2" width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;">

		<tr><td>
		<table cellSpacing="0" cellPadding="0" border="0"><tr>
		<td><img src="images/vista_network.gif">&nbsp;&nbsp;&nbsp;</td><td><%=LANG["str_adminip_tip"]%></td>
		</tr></table>
		</td></tr>

		<tr>
		<td>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #919B9C;">
			<tr>
			<td class="listhead" width="70%" onmouseover="className='listhead2';" onmouseout="className='listhead';"><%=LANG["title_ip"]%></td>
			<td class="listhead" width="30%" onmouseover="className='listhead2';" onmouseout="className='listhead';"><%=LANG["title_allowdeny"]%></td>
			</tr>
			<tr>
			<td colspan="2">
			<span id="listview_div2" style="float:left; height:260px; width:100%; background-color:#FFF; overflow:auto; overflow-x:hidden;">
			<table id="listtable2" width="100%" border="0" cellpadding="2" cellspacing="0" style="table-layout:fixed;"></table>
			</span>
			</td></tr>
		</table>
		</td></tr>

		<tr>
		<td>
		<button onclick="AddBlockIP();"><span><em><%=LANG["button_addblockip"]%></em></span></button><button onclick="ModifyBlockIP();"><span><em><%=LANG["button_modify"]%></em></span></button><button onclick="DeleteBlockIP();"><span><em><%=LANG["button_delete"]%></em></span></button><button onclick="UpBlockIP();"><span><em><%=LANG["button_up"]%></em></span></button><button onclick="DownBlockIP();"><span><em><%=LANG["button_down"]%></em></span></button>
		</td>
		</tr>
		</table>


	</div>
  </div>	
</div>

<div style="padding:3px;text-align:right;margin-top:5px;margin-right:10px;">
<button type='submit' onclick='addAdminSubmit();'><span><em><%=LANG["button_submit"]%></em></span></button>&nbsp;
<button onclick='top.closewindow();'><span><em><%=LANG["button_cancel"]%></em></span></button>
</div>

<script type="text/javascript">

$("tagContent1").style.display="block";
$("tags").getElementsByTagName("li")[1].className="selectedTag";
if(!isFirefox)
	$("username").focus();

$("password").onclick = function()
{
	if($("password").value == $("oldpassword").value)
	{
		$("password").value = "";
	}
}

$("password").onkeyup = inputPassword;
$("password").onafterpaste = inputPassword;
function inputPassword()
{
	var nPassStrong = checkPasswordStrong($("password").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";
	}
}

adminInit();


$("enable_domainadmin").onclick = function()
{
	$("domainlist").disabled = ($("enable_domainadmin").checked ? false : true);
	$("choosedir").disabled = ($("enable_domainadmin").checked ? false : true);
	$("mydirectory").disabled = ($("enable_domainadmin").checked ? false : true);
}

if($("enable_domainadmin").checked)
{
	$("domainlist").disabled = ($("enable_domainadmin").checked ? false : true);
	$("choosedir").disabled = ($("enable_domainadmin").checked ? false : true);
	$("mydirectory").disabled = ($("enable_domainadmin").checked ? false : true);
}


function switchTag(tagContent,obj){

	for(var i=1; i<$("tags").getElementsByTagName("li").length; i++)
	{
		$("tags").getElementsByTagName("li")[i].className="normalTag";
	}
	obj.parentNode.className="selectedTag";
	
	for(var j=0; j<$("tagContent").getElementsByTagName("div").length; j++)
	{
		$("tagContent").getElementsByTagName("div")[j].style.display="none";
	}
	$(tagContent).style.display="block";
	selectedRow = null;
	lastsortcol = -1;
	if(lastObj != null)
		lastObj.className = "listtr01";
}

</script>
</body>
</html>

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

<noscript><center><H2><%=LANG["error_nojavascript"]%></H2></center></noscript>