﻿var u,r,i,c,t2,m,f,w,a,t=new Date();
var cType=false;
t.setYear(2000);
function a()
{
    if(parseInt((new Date()-t)/1000)<30)
    {
        alert("请稍后再做评论");
        return false;
    }
    ShowCode();
    r=$("rcode").value;
    if(r.length!=6){alert("请填写验证码");$("rcode").focus();return false;}
    u=$("username").value;
    if(u.length<2){alert("请正确填写用户名");$("username").focus();return false;}
    i=$("info").value;
    if(i.length<50){alert("详细信息不得少于50个字");$("info").focus();return false;}
    return true;
}
function b()
{
    if(parseInt((new Date()-t)/1000)<30)
    {
        alert("请稍后再留言");
        return false;
    }
    ShowCode();
    r=$("rcode").value;
    if(r.length!=6){alert("请填写验证码");$("rcode").focus();return false;}
    c=$("comname").value;
    if(c.length<2){alert("请正确填写公司名");$("comname").focus();return false;}
    u=$("username").value;
    if(u.length<2){alert("请正确填写姓名");$("username").focus();return false;}
    t2=$("tel").value;
    if(t2.length<8){alert("请正确填写电话");$("tel").focus();return false;}
    i=$("info").value;
    if(i.length<20){alert("留言信息不得少于20个字");$("info").focus();return false;}
    
    m=$("mail").value;
    f=$("fax").value;
    w=$("web").value;
    a=$("add").value;
    cType=true;
    return true;
}
function b2()
{
    $("frmPost").reset();
}
function $(o)
{
    return document.getElementById(o);
}
function ShowRCode()
{
    $("MyCode").src="http://www.5jjdw.com/RCode.aspx?f=" + Math.random() ;
    $("rcode").value="";
    $("rcode").focus();
    return false;
}
function ShowCode()
{
    if($("ForCode").style.display!="")
    {
        $("ForCode").style.display="";
        ShowRCode();
    }
}
function DateDiff(sDate1, sDate2){
    //var aDate, oDate1, oDate2, iDays;
    //aDate = sDate1.split("-")
    //oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
    //aDate = sDate2.split("-")
    //oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
    var iDays = parseInt((sDate1 - sDate2) / 1000 / 60 / 60 /24)
    return iDays
}


    var working=false;
    var handleSuccessc = function(oc){
	    if(oc.responseText !== undefined){
		    var comments = oc.responseText;
		    if(comments!=""){
	            if(!cType)
	            {
		            switch(comments.substring(0,1))
		            {
		                case "0":
		        	        alert("发送成功,请等待该企业/公司与你联系.");
		        	        t=new Date();
		                    $("rcode").value="";
		                    $("info").value="";
		                    break;
		                case "1":
		        	        alert("请正确输入用户名");
		                    break;
		                case "2":
		        	        alert("请正确输入详细信息");
		                    break;
		                case "3":
		                    alert("评论ID不正确!");
		                    break;
		                case "4":
		                    alert("验证码不正确!");
		                    $("rcode").value="";
		                    break;
		                default:
		                    alert("应聘失败!")
		                    break;
		             }
		        }
                 else
                 {
                 
		            switch(comments.substring(0,1))
		            {
                        case "0":
    	                    alert("留言成功.");
    	                    t=new Date();
                            $("rcode").value="";
                            $("info").value="";
                            $("ForCode").style.display="none"
                            break;
                        case "1":
    	                    alert("请正确输入姓名或公司名");
                            break;
                        case "2":
    	                    alert("请正确输入详细信息");
                            break;
                        case "3":
                            alert("留言ID不正确!");
                            break;
                        case "4":
                            alert("验证码不正确!");
                            $("rcode").value="";
                            break;
                        default:
                            alert("留言失败!")
                            break;
                     }
                 }
		    }
	    working=false;
	    }
    }

    var handleFailurec = function(oc){
	    if(oc.responseText !== undefined){
		    working=false;
		    alert("发送请求时出错");
	    }
    }

    var callbackc =
    {
      success:handleSuccessc,
      failure:handleFailurec,
      argument: { '':'' }
    };
    
    function post(id)
    {
        if(a())
        {
            //if(working){alert("正在请求中，稍后再试!");return false;}
	    //    var param=Math.random();
            //var sUrlc="http://www.5jjdw.com/common/yingpin.aspx";
            //var postdata="action=post&rndid="+param+"&u="+encodeURIComponent(u)+"&i="+encodeURIComponent(i)+"&id="+id+"&r="+r;
            //working=true;
            //var requestc = YAHOO.util.Connect.asyncRequest("POST", sUrlc, callbackc,postdata);
            //ShowRCode();
            return ture;
        }
        return false;
    }
    
    function liuyan(id)
    {
        if(b())
        {
            //if(working){alert("正在请求中，稍后再试!");return false;}
	    //var param=Math.random();
            //var sUrlc="http://www.5jjdw.com/common/liuyan.aspx";
            //var postdata="action=post&rndid="+param+"&u="+encodeURIComponent(u)+"&i="+encodeURIComponent(i)+"&c="+encodeURIComponent(c)+"&t="+encodeURIComponent(t2)+"&m="+encodeURIComponent(m)+"&f="+encodeURIComponent(f)+"&w="+encodeURIComponent(w)+"&a="+encodeURIComponent(a)+"&id="+id+"&r="+r;
            //working=true;
            //var requestc = YAHOO.util.Connect.asyncRequest("POST", sUrlc, callbackc,postdata);
            //ShowRCode();
	//t=new Date();
            return ture;
        }
        return false;
    }

function closeliuyan(){
	var narrowmen = document.getElementById("closediv");
	var narrowbox = document.getElementById("liuyanmain");
	var closebt = document.getElementById("closebt");
	if (narrowbox.style.display == "block"){
		narrowbox.style.display = "none";
		closebt.src="http://www.5jjdw.com/template/qy/default/images/open.gif";
		}
		else{
		narrowbox.style.display = "block";
		closebt.src="http://www.5jjdw.com/template/qy/default/images/close.gif";
		}
	}
	function extbkboxove(str){document.getElementById("liuyandiv").style.display = "none";}
