﻿
CommentType();

//加载留言类别
function CommentType()
{    
   
    dealActcmt("/pager/CommentType.aspx"+"?"+Math.random());   
    
    if(document.getElementById("tag_commentpost")!= null)
    {
        
        document.getElementById("tag_commentpost").style.cursor="pointer";
        document.getElementById("tag_commentpost").onclick = function()
        {
            
//            if(document.getElementById("tag_pltype").options[document.getElementById("tag_pltype").selectedIndex].value == "请选择")
//            {
//                alert("请输入留言类别");
//                document.getElementById("tag_pltype").focus();
//                return false;                                
//            }
            if (document.getElementById("tag_pltype").selectedIndex == 0) {
                alert("请输入留言类别");
                document.getElementById("tag_pltype").focus();
                return false;  
            } 
            else if(document.getElementById("username").value == "")
            {
                alert("请输入联系人");
                document.getElementById("username").focus();
                return false;
            }
            else if(document.getElementById("addr").value == "")
            {
                alert("请输入联系方式");
                document.getElementById("addr").focus();
                return false;
            }
            else if(document.getElementById("title").value == "")
            {
                alert("请输入标题");
                document.getElementById("title").focus();
                return false;
            }
            else if(document.getElementById("content").value == "")
            {
                alert("请输入内容");
                document.getElementById("content").focus();
                return false;
            }
            else
            {
                document.theform.submit();                        
            }
        }
     }   
    
}
//AJAX 获取远程数据
var xmlHttpcmt;
function createXMLHttpRequestcmt()
{ //创建一个xmlHttpRequest对象
    
    try{ xmlHttpcmt = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e)
    {
        try{ xmlHttpcmt = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch(e){ xmlHttpcmt = null; }    
    }
    if( !xmlHttpcmt && (typeof XMLHttpRequest != "undefined") )
        xmlHttpcmt = new XMLHttpRequest();   
    
}

function dealActcmt(url)
{   
    createXMLHttpRequestcmt();
    xmlHttpcmt.onreadystatechange = handleStateChangecmt; //请求状态改变事件触发handleStateChanges功能
    xmlHttpcmt.open("GET",url); //采用get方法提交数据
    xmlHttpcmt.send(null);       
}

function handleStateChangecmt()
{
    if(xmlHttpcmt.readyState == 4)
    {   //表示请求状态 4为完成
        if(xmlHttpcmt.status == 200)
        {
            var returnResult = xmlHttpcmt.responseText;            
            //标题             
            for(var i=0;i< returnResult.split('|').length;i++)
            {                
                if(document.getElementById("tag_pltype")!= null)
                {
                    if(returnResult.split('|')[i]!="")
                    document.getElementById("tag_pltype").options.add(new Option(returnResult.split('|')[i].split(',')[1],returnResult.split('|')[i].split(',')[0]));
                }
            }
            
                                   
        }
    }            
    
}