<%
include("language.html")
if _SESSION["logined"] ~= nil then

local httpport = c_GetAdminOptionInt(ADMIN_OPTION_LISTEN_PORT_INT)
local httpsecure = c_GetAdminOptionInt(ADMIN_OPTION_SECURE_ENABLE_INT)
local httpcert = c_GetAdminOptionStr(ADMIN_OPTION_SSL_NAME_STR)
%>
<!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>Admin General 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: 520px;
	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: 290px;
	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">
var httpport = <%=httpport%>;
var httpsecure = <% if httpsecure == 1 then print("1") else print("0") end %>;

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("");
		$("waitingdiv").style.display = "";
	}
}

function ajaxResponse()
{
	ajaxlock = false;
	$("waitingdiv").style.display = "none";
	if (xmlhttp.readyState == 4)
	{
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'admin_set_admin_general':	doSubmit_result();break;
				}
			}
			catch(e)
			{
				alert("<%=LANG['error_ajax']%>");
			}
		}
		else
		{
			alert("<%=LANG['error_ajax']%>");
		}
	}
}


function doSubmit()
{
	var enable_adminlog = ($("enable_adminlog").checked ? 1:0);
	var sha256_password = ($("sha256_password").checked ? 1:0);
	var adminlog_filename = encodeURIComponent($("adminlog_filename").value);
	var adminlog_maxsize = $("adminlog_maxsize").value;
	ajaxRequest("admin_set_admin_general","enable_adminlog="+enable_adminlog+"&sha256_password="+sha256_password+"&adminlog_filename="+adminlog_filename+"&adminlog_maxsize="+adminlog_maxsize+"&r="+Math.random());
	return true;
}

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

</script>
</head>
<body style="background-color:#E6E6E6;">

<div id="waitingdiv" style="position:absolute; z-index:100; 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:20%; width:250px; height:100px;"><img src="images/loading2.gif" border="0">
<H2><b><%=LANG["title_updating"]%></b></H2></div></div>

<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_general_setting"]%></a></li>
  </ul>
  <div id="tagContent" class="tagContent">
	<div id="tagContent1">
		<table width="100%" cellSpacing="0" cellPadding="2" border="0">
		<tr><td height="30" colspan="2"><input type="checkbox" id="sha256_password" <%if c_GetAdminOptionInt(ADMIN_OPTION_ENABLE_SHA256) == 1 then print("checked") end%>><%=LANG["str_sha256_adminpass"]%></td></tr>
		<tr><td height="30" colspan="2"><input type="checkbox" id="enable_adminlog" <%if c_GetAdminOptionInt(ADMIN_OPTION_LOGFILE_ENABLE_INT) == 1 then print("checked") end%>><b><%=LANG["str_adminlog_enable"]%></b></td></tr>
		<tr><td height="30"><%=LANG["str_log_filename"]%>:</td><td><input id="adminlog_filename" type="text" style="width:240px;" disabled value="<%=c_GetAdminOptionStr(ADMIN_OPTION_LOGFILE_FILENAME_STR)%>"></td></tr>
		<tr><td height="20" colspan="2"><%=LANG["str_logwildcard_tip"]%>:</td></tr>
		<tr><td height="20" colspan="2">%Y=<%=LANG["str_year"]%>&nbsp;&nbsp;&nbsp;%M=<%=LANG["str_month"]%>&nbsp;&nbsp;&nbsp;%D=<%=LANG["str_day"]%>&nbsp;&nbsp;&nbsp;%MM=<%=LANG["str_month"]%> (01-12)&nbsp;&nbsp;&nbsp;%DD=<%=LANG["str_day"]%> (01-31)</td></tr>
		<tr><td height="60"><%=LANG["str_log_maxsize"]%>:</td><td><input id="adminlog_maxsize" type="text" style="width:120px;" disabled value="<%=c_GetAdminOptionInt(ADMIN_OPTION_LOGFILE_MAXSIZE_INT)%>">KB (0 = <%=LANG["str_nolimit"]%>)</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";


$("enable_adminlog").onclick = function()
{
	$("adminlog_filename").disabled = ($("enable_adminlog").checked ? false : true);
	$("adminlog_maxsize").disabled = ($("enable_adminlog").checked ? false : true);
	if($("enable_adminlog").checked)
		$("adminlog_filename").focus();
}

if($("enable_adminlog").checked)
{
	$("adminlog_filename").disabled = ($("enable_adminlog").checked ? false : true);
	$("adminlog_maxsize").disabled = ($("enable_adminlog").checked ? false : true);
	$("adminlog_filename").focus();
}

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

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