﻿function CommentQueryString()
{
    var UserMan = "" ; if (document.getElementById("txtCommentUserMan")!=null)  UserMan = document.getElementById('txtCommentUserMan').value;
    var UserMail = "" ; if (document.getElementById("txtCommentUserMail")!=null)  UserMail = document.getElementById('txtCommentUserMail').value;

    var CommType = "" ; if (document.getElementById("txtCommentType")!=null)  CommType = document.getElementById('txtCommentType').value;  
    var CommTitle = "" ; if (document.getElementById("txtCommentTitle")!=null)  CommTitle = document.getElementById('txtCommentTitle').value;  
    var CommContent = "" ; if (document.getElementById("txtCommentContent")!=null)  CommContent = document.getElementById('txtCommentContent').value;  

    if (UserMan=="" && document.getElementById("txtCommentUserMan")!=null)
    {
        document.getElementById('txtCommentUserMan').focus();
        alert("请输入姓名!");
        return "false" ;
    }

    if (UserMail=="" && document.getElementById("txtCommentUserMail")!=null)
    {
        document.getElementById('txtCommentUserMail').focus();
        alert("请输入邮箱!");
        return "false" ;
    }
    
    if (CommType=="" )
    {
        document.getElementById('txtCommentType').focus();
        alert("请输入留言的类型!");
        return "false" ;
    }
    
    if (CommTitle==""  )
    {
        document.getElementById('txtCommentTitle').focus();
        alert("请输入留言的标题!");
        return "false" ;
    }
    
    if (CommContent==""  )
    {
        document.getElementById('txtCommentContent').focus();
        alert("请输入留言的内容!");
        return "false" ;
    }
    
    if (document.getElementById("txtCommentCheckCode")!=null)
    {
        var CheckCode = document.getElementById("txtCommentCheckCode").value; 
        if (GetCookie("CheckCode")!= CheckCode.toUpperCase(CheckCode) )
        {
            document.getElementById('txtCheckCode').focus();
            alert("你输入的验证码不对!"); 
            return "false" ;
        }
    }
            
    var queryString = 'IsJoinMember=0';
    queryString += '&CommAuthorID=0';
    queryString += '&CommAuthor='+UserMan;
    queryString += '&CommCompany=';
    
    queryString += '&CommEmail=';
    queryString += '&CommTel=';
    queryString += '&CommFax=';
    queryString += '&CommMobile=';
    queryString += '&CommMSN=';
    queryString += '&CommQQ=';
    
    queryString += '&CommLogID='+SiteLogID;
    queryString += '&CommType='+CommType;
    queryString += '&CommTitle='+CommTitle;
    queryString += '&CommContent='+CommContent;

            
    return queryString;
}

function InsertComment()
{
    createXmlhttp();
    var url = urlLocation+"InsertComment";
    var data = CommentQueryString();
   
    if (data != "false")
    {
        xmlhttp.open("POST",url,true);
        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
        xmlhttp.setRequestHeader ("Content-Length",data.length);         
        xmlhttp.send(data);      
        xmlhttp.onreadystatechange = work_InsertComment;  
    }
}

function work_InsertComment()
{
    if(xmlhttp.readyState == 4)
    {
        if(xmlhttp.status == 200)
        {
            alert("你的留言成功!");
        }
    }
}