// JScript 文件
// JScript 文件
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 "MallZ.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=\"Images/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 = "Data unavailable. Please try again.";    
    }
}
function GetProductMessage(ProductID,ControlID){ 
     var _ajax_=new HttpAjax();    
	 _xmlReq_ = _ajax_.updateContent("../WebService/ShopService.ashx?Action=GetProductMessage&ProductID="+ProductID+"&Rnd="+Math.random(),ControlID); 
}
var _orderLastPush="";
var _contentArray=new Array(3);
var _activeIndex=0;

_contentArray[0]=_contentArray[1]=_contentArray[2]="";
function GetShopOrder(action,orderFormID,ControlID)
{
  
    var _Currentindex=0;
    switch(action)
    {
       case "bank":
         _Currentindex=0;        
         break;
       case "deliver":
         _Currentindex=2;        
         break;
       case "invoice":
         _Currentindex=1;       
         break;
    }   
    var _orderContent=document.getElementById(ControlID).innerHTML;
    if(_orderContent!="")
    {
       if( _contentArray[_activeIndex]=="")
           _contentArray[_activeIndex]=_orderContent;      
       if(_contentArray[_Currentindex]!="")
       {          
         document.getElementById(ControlID).innerHTML=_contentArray[_Currentindex];
         return;
       } 
    }
 
    if(_orderLastPush=="")
      _orderLastPush=action;
    else
    {
       if(_orderLastPush==action)
         return;
       else
         _orderLastPush=action;
    }
    var _ajax_=new HttpAjax(); 
    _xmlReq_ = _ajax_.updateContent("../WebService/ShopService.ashx?Action=ShowOrderItem&type="+action+"&OrderFormID="+orderFormID+"&Rnd="+Math.random(),ControlID);
    switch(action)
    {
       case "deliver":       
         _activeIndex=2;
         break;
       case "invoice":        
         _activeIndex=1;
         break;
    }
}
function setButtonActive(_flag)
{
   
   var ulObj=document.getElementById("M1");  
   for(var i=0;i<ulObj.childNodes.length;i++)
     ulObj.childNodes[i].className="";
    ulObj.childNodes[_flag].className="active";  

}

