function SaveData()//保存数据
{
    if(!AllText()){
        return false;
    }
    var  xmlData="<action>SaveData</action>"
    var tableData = GenerateSingleRowTableXml(document,"COOPERATE","1");
    xmlData=formatXmlData(tableData,xmlData);
    result=sendXmlData(xmlData,"service/service.jsp");

    if(!checkResult(result))
    {
        var errResult = getErrorMessage(result);
        if(errResult!=null)
        {
            alert(errResult);
            if(errResult.indexOf("EMAIL")!=-1){
                document.getElementById('txt_EMAIL').select();
            }
        }
        return false;
    }
    else
    {
        var oDiv = document.createElement("DIV");
        oDiv.innerHTML = getErrorMessage(result);
        alert('信息提交成功,感谢您的支持！');
        Cls();
    }
}
function AllText()//判断数据是否正确
{
    if(trim(document.getElementById('txt_COMPANYNAME').value) == ""){
        alert('请填写 公司名称');
        document.getElementById('txt_COMPANYNAME').select();
        return false;
    }
    if(trim(document.getElementById('txt_COMPANYADDRESS').value) == ""){
        alert('请填写 公司地址');
        document.getElementById('txt_COMPANYADDRESS').select();
        return false;
    }
    if(trim(document.getElementById('txt_COMPANYMANAGER').value) == ""){
        alert('请填写 联系人');
        document.getElementById('txt_COMPANYMANAGER').select();
        return false;
    }
    var phone = trim(document.getElementById('txt_TELPHONE').value);
    if(phone == ""){
        alert('请填写 联系电话');
        document.getElementById('txt_TELPHONE').select();
        return false;
    }
    if(isNaN(phone) || phone.indexOf(".")!=-1 || phone < 0){
        alert('联系电话 格式不正确');
        document.getElementById('txt_TELPHONE').select();
        return false;
    }
    phone = trim(document.getElementById('txt_FAX').value);
    if(phone != ""){
        if(isNaN(phone) || phone.indexOf(".")!=-1 || phone < 0){
            alert('传真 格式不正确');
            document.getElementById('txt_FAX').select();
            return false;
        }
    }
    if(trim(document.getElementById('txt_COOPERATE').value) == ""){
        alert('请填写 合作意向');
        document.getElementById('txt_COOPERATE').select();
        return false;
    }
    return true;
}

function Cls()//重置
{
    document.getElementById('txt_COMPANYNAME').value = "";
    document.getElementById('txt_COMPANYADDRESS').value = "";
    document.getElementById('txt_COMPANYMANAGER').value = "";
    document.getElementById('txt_TELPHONE').value = "";
    document.getElementById('txt_FAX').value = "";
    document.getElementById('txt_EMAIL').value = "";
    document.getElementById('txt_COOPERATE').value = "";
    document.getElementById('txt_COMPANYNAME').select();
}
