var comxmlHttp;
function createCompXMLHttpRequest() {
  if (window.ActiveXObject) {
     comxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      
  }
  else if (window.XMLHttpRequest) {
      comxmlHttp = new XMLHttpRequest();                
  }
 
  if (!comxmlHttp) {  // 异常，创建对象实例失败
   window.alert("不能创建XMLHttpRequest对象实例.");
	
	return false;
  }
  return comxmlHttp;
}

function categorythemecompliant(catename)
 {
  
  var categoryname=catename;
  var reasonValue="";
  var checkCount=0;
  var reason = document.getElementsByName("complaintreason");
  var otherreason= document.getElementById("reason").value;
  for(i=0;i<reason.length;i++){
     if(reason[i].checked){
       reasonValue+="<li>"+reason[i].value+"</li>";
       checkCount++;
     }
  }
  if(checkCount==0&&otherreason==""){
     alert("请选择或填写投诉理由!");
     return false;
  }
  if(otherreason!="")
   reasonValue+="<li>"+otherreason+"</li>";
  closeCompliant();
  comxmlHttp=createCompXMLHttpRequest();
  var para="catename="+categoryname+"&reason="+reasonValue;
  var url = "/themecomplaint.do";
  comxmlHttp.open("POST", url, true);
  comxmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
  comxmlHttp.onreadystatechange =categorythemecompliantCallback;
  comxmlHttp.send(para);  

 }

function categorythemecompliantCallback()
 {
  if (comxmlHttp.readyState == 4)
  {
    if (comxmlHttp.status==200) 
    {
          var flag = comxmlHttp.responseXML.getElementsByTagName("flag")[0].firstChild.data;
          var info = comxmlHttp.responseXML.getElementsByTagName("msg")[0].firstChild.data;
        
            if(flag=="true"){
              //window.alert("投诉成功!请等待处理");
              document.getElementById("compla").style.display="block";
            }else 
            {
              window.alert(info);
            }
          
    }else {
        window.alert("操作失败，系统繁忙请稍后！");
    }
  }
 }
 function showComplaint(){
    var obj = document.getElementById("complaints");
    obj.style.display="block";
 }
 function closeCompliant(){
    var obj = document.getElementById("complaints");
    obj.style.display="none";
 }
 function colseCompliantConfirm(){
     var obj = document.getElementById("compla");
     obj.style.display="none";
 }