#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html
Cache-Control: no-cache

"
echo -n ""; 
. ../common/common.sh 
myself="/cgi-bin/Protocol/`basename $0`"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function IsChar(str)
{
        if (str == \"\")
                return false;
        for (i = 0; i < str.length; i++) {
		if (str.charCodeAt(i) >= 255)
			return false;
        }
	return true;
}
function beforeAddAgp(frm) {
	var agpname = document.getElementsByName(\"agpname\")[0];
	var agpcname = document.getElementsByName(\"agpcname\")[0];
	agpname.value = TrimAll(agpname.value);
	if (!IsChar(agpname.value)) {
		alert(\"ЭƱΪӢĸ!\");
		agpname.select();
		return false;
	}
	if (!IsName(agpname.value)) {
		alert(\"вܰ&ַ!\");
		agpname.select();
		return false;
	}
	agpcname.value = TrimAll(agpcname.value);
	if (agpcname.value == \"\") {
		alert(\",Ҫ7ַ15Ӣַ!\");
		agpcname.select();
		return false;
	}
	if (!IsName(agpcname.value)) {
		alert(\"вܰ&ַ!\");
		agpcname.select();
		return false;
	}
	return true;
}
function onCancel()
{
	window.location.href = \"/cgi-bin/Protocol/usragp_list\";
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ];  then
	errmsg=`${FLOWEYE} agp add name=${CGI_agpname} cname=${CGI_agpcname}` 
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
		afm_load_page 0 "/cgi-bin/Protocol/usragp_list?agpid=${CGI_agpname}"
		exit 0
	fi
fi

echo -n "
<body>
"; cgi_show_title "Զ->ԶЭ->Э" 
echo -n "
<br>
<form method=post onsubmit=\"return beforeAddAgp(this)\" action=\"${myself}\">
<table width=600 border=0 cellspacing=1 cellpadding=2>
<tr id=row1>
	<td width=40></td>
	<td width=80 align=left>Ӣ</td>
	<td width=* align=left>
		<input type=text name=agpname value=\"${CGI_agpname}\" style=\"width:100;height:21\"></input>
		&nbsp;(ֻӢĸַ,ȲҪ15)
	</td>
</tr>
<tr id=row1>
	<td></td>
	<td></td>
	<td>
		<input type=text name=agpcname value=\"${CGI_agpcname}\" style=\"width:100;height:21\"></input>
		&nbsp;(Ӣַ,ȲҪ7ֻ15Ӣַ)
	</td>
</tr>
</table>
<table style=\"width:600; border-bottom:1px #787882 solid; color:#0000ff\">
<tr><td align=right>&nbsp;</td></tr>
</table>
<table style=\"width:600\">
<tr>
        <td align=right>
                <input type=submit style=\"width:90\" value=\"ύ\"></input>
                <input type=button style=\"width:90\" value=\"ȡ\" onclick=\"onCancel()\"></input>
        </td>
</tr>
</table>
</form>
</body>
</html>
";