﻿
//======================================================
//　　　　　　　　　     \\\|///                      
//　　　　　　　　　   \\　- -　//                   
//　   www.donetbbs.com  ( @ @ ) www.csharpbbs.com                    
//┏━━━━━━━━━oOOo-(_)-oOOo━━━┓          
//┃　　　　　　　　　　　　　　　　 　　┃
//┃　　　　　　　东 网 原 创 　　　　　 ┃
//┃　　　　美人草作品，请保留此信息！ 　┃
//┃　　　** csharpbbs@hotmail.com **    ┃
//┃　　　** donetbbs@hotmail.com **　   ┃
//┃　　　**   www.dituapi.com    **　   ┃
//┃　　　**    QICQ 351310701    **　   ┃
//┃　　　　　　　　　　　　　Dooo　     ┃
//┗━━━━━━━━━ oooD━-(　 )━━━┛
//　　　　　　　　　　 (  )　  ) /
//　　　　　　　　　　　\ (　 (_/
//　　　　　　　　　　　 \_)
//===========上海东网技术服务有限公司=============


Namespace.register("Dongwin.Ajax");
Dongwin.Ajax={

        Index:0,
        Objects:'',
        ResponseText:'',
        CallFunction:'',
        CallBack: function(callBack) {    
        if(typeof callBack!="object"){callBack={};}
            this.callBack = {
            oncomplate:callBack.oncomplate||function(){}
            }
        },
        Post:function(action,path,send,callBack)
        {            
            
            var ac="Dongwin."+path+action;
            
            if (this.Index==0)
            {
                this.Objects=new Array();
                this.ResponseText=new Array();
                this.CallFunction=new Array();
            }
                if (!Dongwin.IE)
                {
                    Dongwin.Ajax.Objects[ac]= new XMLHttpRequest();
                }
                else
                {
                    Dongwin.Ajax.Objects[ac]=new ActiveXObject("Microsoft.XMLHTTP");
                }
                this.Index +=1;
                if (this.Index>=10)
                {
                    this.Index=0;
                }
            send="Action="+action+send;
            
            path=Dongwin.Path+"/Utility/"+path+".aspx";            
            Dongwin.Ajax.Objects[ac].open("POST",''+path+'?',true);
            Dongwin.Ajax.Objects[ac].setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
            Dongwin.Ajax.Objects[ac].send(send);
            Dongwin.Ajax.CallFunction[ac]=callBack; 
            Dongwin.Ajax.Objects[ac].onreadystatechange = function(){Dongwin.Ajax.Status(ac,path);}  
        },
        Status:function(action,path)
        {
            if (null!=Dongwin.Ajax.Objects[action])
            {
                if (Dongwin.Ajax.Objects[action].readyState==4)
                {
                    
                        if (Dongwin.Ajax.Objects[action].status==200)
                        {
                            Dongwin.Ajax.CallBack(Dongwin.Ajax.CallFunction); 
                            Dongwin.Ajax.ResponseText[action]=unescape(Dongwin.Ajax.Objects[action].responseText);
                            if(typeof Dongwin.Ajax.CallFunction[action]!="undefined")
                            {
                                Dongwin.Ajax.CallFunction[action].oncomplate(); 
                            }
                            var json=eval(Dongwin.Ajax.ResponseText[action]);                
                            if (json[0].PostBack!='')
                            {
                            //json[0].PostBack
                             //eval("(" + json[0].PostBack + ")");
                               // alert('"+json[0].PostBack"+');
                               eval(json[0].PostBack);
                            }
                            Dongwin.Load.Hidden();
                            Dongwin.Ajax.ResponseText[action]='';
                            //Dongwin.Ajax.Objects[action].responseText='';
                        }
                        else if (Dongwin.Ajax.Objects[action].status==500)
                        {
                            document.write(Dongwin.Ajax.Objects[action].responseText);
                        }
                        else // (Dongwin.Ajax.Objects[action].status==450 || Dongwin.Ajax.Objects[action].status==12030)
                        {
                            Dongwin.Load.Hidden();
                            //path=Dongwin.Path+"/Utility/"+path+".aspx";    
                            alert(new Dongwin.Language.Ajax().Error.replace("{Path}",path));
                        }
                }   
                
          }    
         
        }
        
    ,
    Path:'Ajax'
    ,
    Action:0
    ,
    Array:new Array()
    ,
    Attribute:function()
    {
        this.title='';
        this.name='';
        this.id='';
        this.type='';
    }
}
