// JavaScript Document
var staticZindex=5000;
var Drag=new Drag();
var cover=new Cover();
String.prototype.trim = function()
{
	return this.replace(/^\s*|\s*$/ig, "");
}

function checkForm()
{
    if(!isEmail($("email").value.trim()))
    {
        $("email").focus();
        return false;
    }
	if($("username").value.trim()=="")
    {
        alert("请填写姓名");
        $("username").focus();
        return false;
    }
	if($("subject").value.trim()=="")
    {
        alert("请填写主题");
        $("subject").focus();
        return false;
    }
	if($("content").value.trim()=="")
    {
        alert("请填写正文");
        $("content").focus();
        return false;
    }
    if($("validate").value.trim()=="")
    {
        alert("请输入验证码");
        $("validate").focus();
        return false;
    }
        if($("validate").value.trim().toLowerCase()!=getCookie("validate").toLowerCase())
    {
        alert("验证码错误");
        $("validate").focus();
        return false;
    }
explor('loading');
PostEmail();
    return false;
}


function LoadingWindow()
{
	document.writeln("<table id=\"loading\" style=\"position:absolute; display:none; border:1px solid white\" width=\"350\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">");
	document.writeln("    <tr>");
	document.writeln("      <td bgcolor=\"#DFEFF2\"><table style=\"border:1px solid #8FB7DE\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">");
	document.writeln("        <tr>");
	document.writeln("          <td bgcolor=\"#CDDCED\">&nbsp;<span class=\"font14px\"><strong>提交邮件<\/strong><\/span><\/td>");
	document.writeln("        <\/tr>");
	document.writeln("        <tr>");
	document.writeln("          <td id=\"lcontent\" align=\"center\" valign=\"middle\" bgcolor=\"#FFFFFF\"><br \/>");
	document.writeln("            <img src=\"\/makeup\/pic\/loading2.gif\" width=\"16\" height=\"16\" \/> 正在提交邮件信息,请稍候...<br \/>");
	document.writeln("              <br \/><\/td>");
	document.writeln("        <\/tr>");
	document.writeln("      <\/table><\/td>");
	document.writeln("    <\/tr>");
	document.writeln("  <\/table>");	
}

function PostEmail()
{
	new Ajax().invoke(
			"server/receive.aspx?username="+escape($("username").value.trim())+"&email="+escape($("email").value.trim())+"&subject="+escape($("subject").value.trim())+"&content="+escape($("content").value.trim())+"&validate="+$("validate").value.trim()+"&random="+Math.random(),
			"get",
			true,
			runPing
		);
	
		function runPing(response){
			var result=unescape(response);
			if(result=='Y')
			{
				$('lcontent').innerHTML='<img src="/makeup/pic/ok.gif"/><br><b>邮件已经成功提交</b><br>工作人员会对邮件进行审核，具体进程请关注邮件列表<br><br><input type="button" name="button" id="button" value=" 关闭 " onclick="RedirectUrl();" />';
			}
			else
			{
				alert('error');
				covercolose('loading');
			}
		}
}

function RedirectUrl()
{
	//关闭信息框
	covercolose("loading");
	window.location="list.shtml";
}