
function HttpAjax() { 
    var self = this;    
    this.createXMLHttpRequest = function() {
	    try { 
		    return new ActiveXObject("Msxml2.XMLHTTP"); 
	    } 
	    catch (e) {
	    }
	    try { 
		    return new ActiveXObject("Microsoft.XMLHTTP"); 
	    } 
	    catch (e) {
	    }
	    try {
		    return new XMLHttpRequest(); 
	    } 
	    catch(e) {
	    }
	    return null;
    }
    this.toString = function() {
        return "BoDao.Web.HttpAjax";
    }
    
    this.create = function(url, callbackHandler, onErrorHandler) {
        var xmlReq = this.createXMLHttpRequest();
        if (xmlReq != null) {        
		    xmlReq.open("GET", url, true);
		    xmlReq.onreadystatechange = function() {
                switch(xmlReq.readyState)
                {
                    case 0: 
                        break;
                    case 1: 
                        break;
                    case 2: 
                        break;
                    case 3: 
                        break;
                    case 4: 
                        callbackHandler(xmlReq);
                        break;
                    default:
                        onErrorHandler();
                        break;
                    }
                }
		    xmlReq.send(null);
		    return xmlReq;
        }
        else {
			throw "System does not support Ajax.";
        }
    }
    this.setVisible = function(controlId, visible) {
        if (document.getElementById(controlId) != null)
            document.getElementById(controlId).style.visibility = (visible ? "visible" : "hidden");
    }
	this.setDisplay = function(controlId, displayMode) {
        if (document.getElementById(controlId) != null)
            document.getElementById(controlId).style.display = displayMode;
	}
    this.updateContent = function (url, controlId) {
      var processingIcon;
      var _controlContent=document.getElementById(controlId);
      if( _controlContent!=null){
         _controlContent.innerHTML="<img src=\"../../IMS_Img/Index/Loading.gif\"/>";
      }		
        var xmlReq = this.createXMLHttpRequest();
        
        if (xmlReq != null) {
		    xmlReq.open("GET", url, true);
		    xmlReq.onreadystatechange = function() {
                switch(xmlReq.readyState)
                {
                    case 0: 
                        break;
                    case 1: 
                        break;
                    case 2: 
                        break;
                    case 3: 
                        break;
                    case 4: 
                        updateContent_callback(xmlReq, controlId);
                        break;
                    default:
                        updateContent_onError(controlId);
                        break;
                    }
                }
		    xmlReq.send(null);
        }
        else {
           
        }
    }   
 
    function updateContent_callback(rValue, controlId) {
      var rsp = rValue.responseText;
      var _control=document.getElementById(controlId);
      if(_control!=null)
          _control.innerHTML=rsp;  
    }   
    function updateContent_onError(controlId) {
        if (document.getElementById(controlId) != null)
            document.getElementById(controlId).innerHTML = "·þÎñÆ÷³ö´í£¬ÇëÉÔºòÔÙÊÔ£¡.";    
    }
}

function GetDailyArcticle(classID,dateformat,ControlID){ 
     var _ajax_=new HttpAjax();    
     _xmlReq_ = _ajax_.updateContent("/AjaxRequest/GetArtcileList.ashx?ChannelID="+classID+"&date="+dateformat+"&num="+Math.random(),ControlID); 
}

function CheckLogin(username,password,ControlID){ 
     var _ajax_=new HttpAjax();    
     _xmlReq_ = _ajax_.updateContent("/Controls/CheckLogin.aspx?username="+username+"&password="+password+"&num="+Math.random(),ControlID); 
}