﻿var u,r,i,t=new Date();
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 $(o)
{
    return document.getElementById(o);
}
function ShowRCode()
{
    $("MyCode").src="/RCode.aspx?f=" + Math.random() ;
    $("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!=""){
		        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;
		        }
		    }
	    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="/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 false;
    }

    function KeyDownHandler()
    {
     // process only the Enter key
     if (event.keyCode == 13)
     {
      return so();
     }
    }

function so()
{
    var o;
    o=getob("kw");
    if(o.value.length<2)
    {
        alert("请输入关键字");o.focus();return false;
    }
    o=getob("frmIndex");
    switch(getob("type").value)
    {
        case "1":
            o.action="http://www.5jjdw.com/product/index.aspx";
            break;
        case "2":
            o.action="http://www.5jjdw.com/business/business.aspx";
            break;
        case "3":
            o.action="http://www.5jjdw.com/company/index.aspx";
            break;
        case "4":
            o.action="http://www.5jjdw.com/market/marketmore.aspx?type=4&area=0";
            break;
        case "5":
            o.action="http://www.5jjdw.com/chamber/shanghuimore.aspx?type=5&area=0";
            break;
        case "6":
            o.action="http://www.5jjdw.com/exhibition/exhibition1.aspx";
            break;
        default:
            break;
    }
    return true;
}
function getob(o)
{
    return document.getElementById(o);
}
