<%
include("language.html")
if _SESSION["logined"] ~= nil then
%>
<%
if _GET["domain"] ~= nil then
	local domain = _GET["domain"]
	local translimit = c_GetTransferLimit(domain)
	translimit = json.encode_s(translimit)
%>
<!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>Transfer Limit Setting</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
a {text-decoration:none;}
a,a:visited {color:#000;background:inherit;}
html, body {height: 100%;margin:0px;padding:0px;}
<%if _COOKIE["admin_lang"] == "schinese" or _COOKIE["admin_lang"] == "tchinese" or _COOKIE["admin_lang"] == "japanese" then%>
body,td,span {font:12px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%else%>
body,td,span {font:11px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%end%>
img {border:0px;}
input,select,textarea{margin:4px;}
input,textarea{background-color:expression((this.disabled && this.disabled==true)?"#D4D0C8":"")}

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


#tabDiv {
	width: 555px;
	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: 270px;
	overflow-y:auto;
	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 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()
{
	ajaxlock = false;
	if (xmlhttp.readyState == 4)
	{
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'admin_set_translimit':	doSubmit_result();break;
				}
			}
			catch(e)
			{
				alert("<%=LANG['error_ajax']%>");
			}
		}
		else
		{
			alert("<%=LANG['error_ajax']%>");
		}
	}
}

function doInit()
{
	var translimit = '<%=translimit%>';
	if(translimit != "")
	{
		try
		{
			var limitObject = JSON.parse(translimit);
			$("enable_upload_never").checked = limitObject["enable_upload_never"];
			$("cur_upload_size_never").value = limitObject["cur_upload_size_never"];
			$("max_upload_size_never").value = limitObject["max_upload_size_never"];
			$("enable_download_never").checked = limitObject["enable_download_never"];
			$("cur_download_size_never").value = limitObject["cur_download_size_never"];
			$("max_download_size_never").value = limitObject["max_download_size_never"];

			$("enable_upload_hourly").checked = limitObject["enable_upload_hourly"];
			$("cur_upload_size_hourly").value = limitObject["cur_upload_size_hourly"];
			$("max_upload_size_hourly").value = limitObject["max_upload_size_hourly"];
			$("enable_download_hourly").checked = limitObject["enable_download_hourly"];
			$("cur_download_size_hourly").value = limitObject["cur_download_size_hourly"];
			$("max_download_size_hourly").value = limitObject["max_download_size_hourly"];

			$("enable_upload_daily").checked = limitObject["enable_upload_daily"];
			$("cur_upload_size_daily").value = limitObject["cur_upload_size_daily"];
			$("max_upload_size_daily").value = limitObject["max_upload_size_daily"];
			$("enable_download_daily").checked = limitObject["enable_download_daily"];
			$("cur_download_size_daily").value = limitObject["cur_download_size_daily"];
			$("max_download_size_daily").value = limitObject["max_download_size_daily"];

			$("enable_upload_weekly").checked = limitObject["enable_upload_weekly"];
			$("cur_upload_size_weekly").value = limitObject["cur_upload_size_weekly"];
			$("max_upload_size_weekly").value = limitObject["max_upload_size_weekly"];
			$("enable_download_weekly").checked = limitObject["enable_download_weekly"];
			$("cur_download_size_weekly").value = limitObject["cur_download_size_weekly"];
			$("max_download_size_weekly").value = limitObject["max_download_size_weekly"];

			$("enable_upload_monthly").checked = limitObject["enable_upload_monthly"];
			$("cur_upload_size_monthly").value = limitObject["cur_upload_size_monthly"];
			$("max_upload_size_monthly").value = limitObject["max_upload_size_monthly"];
			$("enable_download_monthly").checked = limitObject["enable_download_monthly"];
			$("cur_download_size_monthly").value = limitObject["cur_download_size_monthly"];
			$("max_download_size_monthly").value = limitObject["max_download_size_monthly"];
		}
		catch(e)
		{
			alert("<%=LANG['str_loadtranslimit_fail']%>");
		}
	}
}

function doSubmit()
{
	var domain = $("domain").value;
	var translimit = {
	enable_upload_never:($("enable_upload_never").checked ? true:false),
	cur_upload_size_never:$("cur_upload_size_never").value,
	max_upload_size_never:$("max_upload_size_never").value,
	enable_download_never:($("enable_download_never").checked ? true:false),
	cur_download_size_never:$("cur_download_size_never").value,
	max_download_size_never:$("max_download_size_never").value,

	enable_upload_hourly:($("enable_upload_hourly").checked ? true:false),
	cur_upload_size_hourly:$("cur_upload_size_hourly").value,
	max_upload_size_hourly:$("max_upload_size_hourly").value,
	enable_download_hourly:($("enable_download_hourly").checked ? true:false),
	cur_download_size_hourly:$("cur_download_size_hourly").value,
	max_download_size_hourly:$("max_download_size_hourly").value,

	enable_upload_daily:($("enable_upload_daily").checked ? true:false),
	cur_upload_size_daily:$("cur_upload_size_daily").value,
	max_upload_size_daily:$("max_upload_size_daily").value,
	enable_download_daily:($("enable_download_daily").checked ? true:false),
	cur_download_size_daily:$("cur_download_size_daily").value,
	max_download_size_daily:$("max_download_size_daily").value,

	enable_upload_weekly:($("enable_upload_weekly").checked ? true:false),
	cur_upload_size_weekly:$("cur_upload_size_weekly").value,
	max_upload_size_weekly:$("max_upload_size_weekly").value,
	enable_download_weekly:($("enable_download_weekly").checked ? true:false),
	cur_download_size_weekly:$("cur_download_size_weekly").value,
	max_download_size_weekly:$("max_download_size_weekly").value,

	enable_upload_monthly:($("enable_upload_monthly").checked ? true:false),
	cur_upload_size_monthly:$("cur_upload_size_monthly").value,
	max_upload_size_monthly:$("max_upload_size_monthly").value,
	enable_download_monthly:($("enable_download_monthly").checked ? true:false),
	cur_download_size_monthly:$("cur_download_size_monthly").value,
	max_download_size_monthly:$("max_download_size_monthly").value
	};

	var limitString = urlEncode(JSON.stringify(translimit));
	ajaxRequest("admin_set_translimit","domain="+domain+"&limit="+limitString);
}

function doSubmit_result()
{
	top.closewindow(1);
}
</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["str_totallimit"]%></a></li>
	<li class="normalTag"><a href="javascript:void(0)" onfocus="this.blur()" onclick="switchTag('tagContent2',this)"><%=LANG["str_limithourly"]%></a></li>
	<li class="normalTag"><a href="javascript:void(0)" onfocus="this.blur()" onclick="switchTag('tagContent3',this)"><%=LANG["str_limitdaily"]%></a></li>
	<li class="normalTag"><a href="javascript:void(0)" onfocus="this.blur()" onclick="switchTag('tagContent4',this)"><%=LANG["str_limitweekly"]%></a></li>
	<li class="normalTag"><a href="javascript:void(0)" onfocus="this.blur()" onclick="switchTag('tagContent5',this)"><%=LANG["str_limitmonthly"]%></a></li>
  </ul>
  <div id="tagContent" class="tagContent">
  	<div id="tagContent1">
		<input id="domain" type="hidden" value="<%=_GET["domain"]%>">
		<table cellSpacing="0" cellPadding="0" border="0">
		<tr><td colspan="3" height="30" style="color:#0000FF;"><%=LANG["str_totallimit_tip"]%><br><br></td></tr>
		<tr><td></td><td><b><%=LANG["str_current"]%></b></td><td><b><%=LANG["str_max"]%></b></td></tr>
		<tr><td><input id="enable_download_never" type="checkbox" onclick="checkDownloadLimit_never();"> <%=LANG["str_download"]%></td><td><input id="cur_download_size_never" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_download_size_never" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		<tr><td><input id="enable_upload_never" type="checkbox" onclick="checkUploadLimit_never();"> <%=LANG["str_upload"]%></td><td><input id="cur_upload_size_never" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_upload_size_never" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		</table>
	</div>
	<div id="tagContent2">
		<table cellSpacing="0" cellPadding="0" border="0">
		<tr><td colspan="3" height="30" style="color:#008000;"><%=LANG["str_limithourly_tip"]%><br><br></td></tr>
		<tr><td></td><td><b><%=LANG["str_current"]%></b></td><td><b><%=LANG["str_max"]%></b></td></tr>
		<tr><td><input id="enable_download_hourly" type="checkbox" onclick="checkDownloadLimit_hourly();"> <%=LANG["str_download"]%></td><td><input id="cur_download_size_hourly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_download_size_hourly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		<tr><td><input id="enable_upload_hourly" type="checkbox" onclick="checkUploadLimit_hourly();"> <%=LANG["str_upload"]%></td><td><input id="cur_upload_size_hourly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_upload_size_hourly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		</table>
	</div>
	<div id="tagContent3">
		<table cellSpacing="0" cellPadding="0" border="0">
		<tr><td colspan="3" height="30" style="color:#000000;"><%=LANG["str_limitdaily_tip"]%><br><br></td></tr>
		<tr><td></td><td><b><%=LANG["str_current"]%></b></td><td><b><%=LANG["str_max"]%></b></td></tr>
		<tr><td><input id="enable_download_daily" type="checkbox" onclick="checkDownloadLimit_daily();"> <%=LANG["str_download"]%></td><td><input id="cur_download_size_daily" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_download_size_daily" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		<tr><td><input id="enable_upload_daily" type="checkbox" onclick="checkUploadLimit_daily();"> <%=LANG["str_upload"]%></td><td><input id="cur_upload_size_daily" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_upload_size_daily" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		</table>
	</div>
	<div id="tagContent4">
		<table cellSpacing="0" cellPadding="0" border="0">
		<tr><td colspan="3" height="30" style="color:#800000;"><%=LANG["str_limitweekly_tip"]%><br><br></td></tr>
		<tr><td></td><td><b><%=LANG["str_current"]%></b></td><td><b><%=LANG["str_max"]%></b></td></tr>
		<tr><td><input id="enable_download_weekly" type="checkbox" onclick="checkDownloadLimit_weekly();"> <%=LANG["str_download"]%></td><td><input id="cur_download_size_weekly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_download_size_weekly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		<tr><td><input id="enable_upload_weekly" type="checkbox" onclick="checkUploadLimit_weekly();"> <%=LANG["str_upload"]%></td><td><input id="cur_upload_size_weekly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_upload_size_weekly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		</table>
	</div>
	<div id="tagContent5">
		<table cellSpacing="0" cellPadding="0" border="0">
		<tr><td colspan="3" height="30" style="color:#708090;"><%=LANG["str_limitmonthly_tip"]%><br><br></td></tr>
		<tr><td></td><td><b><%=LANG["str_current"]%></b></td><td><b><%=LANG["str_max"]%></b></td></tr>
		<tr><td><input id="enable_download_monthly" type="checkbox" onclick="checkDownloadLimit_monthly();"> <%=LANG["str_download"]%></td><td><input id="cur_download_size_monthly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_download_size_monthly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		<tr><td><input id="enable_upload_monthly" type="checkbox" onclick="checkUploadLimit_monthly();"> <%=LANG["str_upload"]%></td><td><input id="cur_upload_size_monthly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td><td><input id="max_upload_size_monthly" type="text" value="0" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width:100px;">MB </td></tr>
		</table>
	</div>
  </div>	
</div>

<div style="padding:3px;text-align:right;margin-right:10px;">
<button type='submit' onclick='doSubmit();'><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";
$("cur_download_size_never").focus();
doInit();

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

function checkDownloadLimit_never()
{
	if($("enable_download_never").checked)
	{
		$("cur_download_size_never").disabled = false;
		$("max_download_size_never").disabled = false;
	}
	else
	{
		$("cur_download_size_never").disabled = true;
		$("max_download_size_never").disabled = true;
	}
}

function checkUploadLimit_never()
{
	if($("enable_upload_never").checked)
	{
		$("cur_upload_size_never").disabled = false;
		$("max_upload_size_never").disabled = false;
	}
	else
	{
		$("cur_upload_size_never").disabled = true;
		$("max_upload_size_never").disabled = true;
	}
}

function checkDownloadLimit_hourly()
{
	if($("enable_download_hourly").checked)
	{
		$("cur_download_size_hourly").disabled = false;
		$("max_download_size_hourly").disabled = false;
	}
	else
	{
		$("cur_download_size_hourly").disabled = true;
		$("max_download_size_hourly").disabled = true;
	}
}

function checkUploadLimit_hourly()
{
	if($("enable_upload_hourly").checked)
	{
		$("cur_upload_size_hourly").disabled = false;
		$("max_upload_size_hourly").disabled = false;
	}
	else
	{
		$("cur_upload_size_hourly").disabled = true;
		$("max_upload_size_hourly").disabled = true;
	}
}

function checkDownloadLimit_daily()
{
	if($("enable_download_daily").checked)
	{
		$("cur_download_size_daily").disabled = false;
		$("max_download_size_daily").disabled = false;
	}
	else
	{
		$("cur_download_size_daily").disabled = true;
		$("max_download_size_daily").disabled = true;
	}
}

function checkUploadLimit_daily()
{
	if($("enable_upload_daily").checked)
	{
		$("cur_upload_size_daily").disabled = false;
		$("max_upload_size_daily").disabled = false;
	}
	else
	{
		$("cur_upload_size_daily").disabled = true;
		$("max_upload_size_daily").disabled = true;
	}
}

function checkDownloadLimit_weekly()
{
	if($("enable_download_weekly").checked)
	{
		$("cur_download_size_weekly").disabled = false;
		$("max_download_size_weekly").disabled = false;
	}
	else
	{
		$("cur_download_size_weekly").disabled = true;
		$("max_download_size_weekly").disabled = true;
	}
}

function checkUploadLimit_weekly()
{
	if($("enable_upload_weekly").checked)
	{
		$("cur_upload_size_weekly").disabled = false;
		$("max_upload_size_weekly").disabled = false;
	}
	else
	{
		$("cur_upload_size_weekly").disabled = true;
		$("max_upload_size_weekly").disabled = true;
	}
}

function checkDownloadLimit_monthly()
{
	if($("enable_download_monthly").checked)
	{
		$("cur_download_size_monthly").disabled = false;
		$("max_download_size_monthly").disabled = false;
	}
	else
	{
		$("cur_download_size_monthly").disabled = true;
		$("max_download_size_monthly").disabled = true;
	}
}

function checkUploadLimit_monthly()
{
	if($("enable_upload_monthly").checked)
	{
		$("cur_upload_size_monthly").disabled = false;
		$("max_upload_size_monthly").disabled = false;
	}
	else
	{
		$("cur_upload_size_monthly").disabled = true;
		$("max_upload_size_monthly").disabled = true;
	}
}

checkDownloadLimit_never();
checkUploadLimit_never();
checkDownloadLimit_hourly();
checkUploadLimit_hourly();
checkDownloadLimit_daily();
checkUploadLimit_daily();
checkDownloadLimit_weekly();
checkUploadLimit_weekly();
checkDownloadLimit_monthly();
checkUploadLimit_monthly();

</script>
</body>
</html>
<% end %>

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