<%
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>Copy User</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<%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:12px/20px Verdana, Geneva, Arial, Helvetica, sans-serif;}
<%end%>
img {border:0px;}

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


</style>
<script language="javascript" src="include/common.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()
{
	if (xmlhttp.readyState == 4)
	{
		ajaxlock = false;
		if (xmlhttp.status == 200)
		{
			try
			{
				switch(page)
				{
					case 'admin_copyuser':	copyuser_result();break;
				}
			}
			catch(e)
			{
				alert("<%=LANG['error_ajax']%>");
			}
		}
		else
		{
			alert("<%=LANG['error_ajax']%>");
		}
	}
}


function copyUser()
{
	var domain = htmldecode($("domain").value);
	var username = htmldecode(trim($("username").value));
	var newname = htmldecode(trim($("newname").value));

	if(newname.length == 0 || newname.search(/[\\\/\<\>\:\?\"\|\*\&\%]/i) != -1)
	{
		alert("<%=LANG['str_invalid_username']%>");
		$("newname").focus();
		return false;
	}

	ajaxRequest("admin_copyuser","domain="+domain+"&username="+username+"&newname="+newname);
}

function copyuser_result()
{
	var result = trim(xmlhttp.responseText);
	if(result == "-1" || result == -1 || result == "")
	{
		alert("<%=LANG['str_copyuser_fail']%>");
		top.closewindow();
	}
	else if(result == "-2" || result == -2)
	{
		alert("<%=LANG['str_existed_username']%>");
	}
	else if(result == "-3" || result == -3)
	{
		alert("<%=LANG['str_existed_aduser']%>");
	}
	else
	{
		var newname = htmldecode($("newname").value);
		top.closewindow(newname);
	}
}

</script>
<html>
<body style="background-color:#E6E6E6;" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br><br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<input id="domain" type="hidden" value="<%=_GET["domain"]%>">
<input id="username" type="hidden" value="<%=_GET["username"]%>">
<tr><td align="center">
<%=LANG["str_new_username"]%>:<input id="newname" type="text" style="width:150px; margin:2px;">
</td></tr>
<tr><td height="60">&nbsp;</td></tr>
<tr><td align="center">
<button type='submit' onclick='copyUser();'><span><em><%=LANG["button_submit"]%></em></span></button>&nbsp;
<button onclick='top.closewindow();'><span><em><%=LANG["button_cancel"]%></em></span></button>
</td></tr>
</table>
</body>
</html>
<script>
$("newname").focus();
</script>

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