﻿
var xmlHttp = createXMLHttpRequest();
var leibie=null;
var content;
function createXMLHttpRequest() {
   /*@cc_on @*/
   /*@if (@_jscript_version >= 5)
   var progids=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]
   for (i in progids) {
   try { return new ActiveXObject(progids[i]) }
   catch (e) {}
   }
   @end @*/
   try {
      return new XMLHttpRequest();
   }
   catch (e2) {
      return null;
   }
}

function startRequest(lb,url) {
  
//处理前---------------------------------   
    leibie=lb;
   url="/ajax/ajax.aspx?lb="+lb+"&"+url;
   var pa="&random="+Math.round(Math.random()*10000);   
  if(leibie=="addcom" ) url=url+pa;
  if(leibie=="writehome" ) url="/page/writehome.aspx";
 //-------------------------------------
   xmlHttp.open("GET", url, true);
   xmlHttp.onreadystatechange = handleStateChange;
   xmlHttp.send(null);
}
function handleStateChange() {

   if (xmlHttp.readyState == 4) {
      if (xmlHttp.status == 200) {
         content = xmlHttp.responseText;
         var tem_content = xmlHttp.responseText;
         content=content.substring(content.indexOf("<!-- info -->")+13,content.indexOf("<!-- endinfo -->"));
         content=content.replace(/^\s*/g,"").replace(/\s*$/g,"");
         
    //处理后---------------------------------
         if(leibie=="UserNameIsExist") {
         if(content=="恭喜您,用户名可用!") {
      document.getElementById("ipt_username").className="SucceedMsg";
      document.getElementById("ipt_username").innerHTML = content;
   }
   else
   {
      document.getElementById("ipt_username").className="FailedMsg";
      document.getElementById("ipt_username").innerHTML = content;
      bl=false;
   }
   }
    //-------------------------------------
   if(leibie=="qu_btime") {document.getElementById("btime").innerHTML = content;}
    //-------------------------------------
   if(leibie=="addcom"){alert(content);}
    //----END---------------------------------
         
      }
   }
}


