  function XML_Load(url, method, req_params, ret_method, uparams) {
	this.XMLo=null;
    this.url = url;
    this.method = method;
    this.ret_method=ret_method; //XML or TEXT
    this.uparams = uparams;
    this.req_params=req_params;

     if (window.XMLHttpRequest) {  
         try { this.XMLo = new XMLHttpRequest(); }
         catch (e) { this.XMLo=null; }
     } else if (window.ActiveXObject) {    
                try { this.XMLo = new ActiveXObject("Microsoft.XMLHTTP"); }
                catch (e) { this.XMLo=null; }
            } else this.XMLo=null;

    if (this.XMLo!=null) { 
       //Wait while XML object initialized
       while (this.XMLo.readyState != 4 && this.XMLo.readyState != 0) {}
    }
   }

   XML_Load.prototype.IsReady=function() {   
    if (this.XMLo==null) return false;
    return true;
   }

   XML_Load.prototype.Load=function() {   
    if (this.method == "POST") {
        this.XMLo.open("POST", this.url, true);
        this.XMLo.setRequestHeader("Content-Type",
        "application/x-www-form-urlencoded; charset=UTF-8");
    } else if (this.method == "GET") {
               this.XMLo.open("GET", this.url+'?'+this.req_params, true);
           }

    var eobj=this;

    this.XMLo.onreadystatechange = function () {
     var eclass=eobj;
     var eXMLo=eclass.XMLo;

     if (eXMLo.readyState == 4) {
         if (eXMLo.status == 200) {
//     alert(eXMLo.responseText); //For Debugging only
             eclass.OnReady("",eclass.uparams,((eclass.ret_method=="XML") ? eXMLo.responseXML.documentElement : eXMLo.responseText));
			 delete eXMLo;
             delete eclass;
         } else {
//     alert(eXMLo.responseText); //For Debugging only
                 eclass.OnReady("There was a problem retrieving the XML data:\n" + eXMLo.statusText,eclass.uparams,((eclass.ret_method=="XML") ? eXMLo.responseXML.documentElement : eXMLo.responseText));
                 delete eXMLo;
                 delete eclass;
         }
     }
    }

    if (this.method == 'POST') this.XMLo.send(this.req_params);
        else if (this.method == 'GET') this.XMLo.send(null);

   }


  // Когда нужно задержать выполнение скрипта до получения ответа от сервера
   XML_Load.prototype.Load_=function() {   
    if (this.method == "POST") {
        this.XMLo.open("POST", this.url, false);
        this.XMLo.setRequestHeader("Content-Type",
        "application/x-www-form-urlencoded; charset=UTF-8");
    } else if (this.method == "GET") {
               this.XMLo.open("GET", this.url+'?'+this.req_params, true);
           }

    var eobj=this;

    this.XMLo.onreadystatechange = function () {
     var eclass=eobj;
     var eXMLo=eclass.XMLo;

     if (eXMLo.readyState == 4) {
         if (eXMLo.status == 200) {
 //         alert(eXMLo.responseText); //For Debugging only
             eclass.OnReady("",eclass.uparams,((eclass.ret_method=="XML") ? eXMLo.responseXML.documentElement : eXMLo.responseText));
			 delete eXMLo;
             delete eclass;
         } else {
//                 alert(eXMLo.responseText); //For Debugging only
                 eclass.OnReady("There was a problem retrieving the XML data:\n" + eXMLo.statusText,eclass.uparams,((eclass.ret_method=="XML") ? eXMLo.responseXML.documentElement : eXMLo.responseText));
                 delete eXMLo;
                 delete eclass;
         }
     }
    }

    if (this.method == 'POST') this.XMLo.send(this.req_params);
        else if (this.method == 'GET') this.XMLo.send(null);

   }









   function XML_FindSubRootSection(XML_RootO,sec_TagName) {
    if (!XML_RootO) return null;
    var xml_co=XML_RootO.firstChild;
    while (xml_co) {
     if (xml_co.tagName==sec_TagName) return xml_co;
     xml_co=xml_co.nextSibling;
    }
    return null;
   }



function CrEl(parent,tagName,param,style) {
 //parent - parent of element, can be NULL
 //param  - "border=1; cellspacing=3; class=my"
 //style  - "border: solid 1px #000000; backgroundColor: #FF0000;"
 tagName=tagName.toLowerCase();
 var el;
 if (tagName=="text") el=document.createTextNode(param);
     else {
           el=document.createElement(tagName);
           var i,j,attr,l;

           //Add Attributes
           if (param && param!="") {
               i=0;j=0;l=param.length;
               while (i<l) {              
                      j=param.indexOf("=",i);
                      key=param.substring(i,j).toLowerCase();
                      i=j+1;
                      j=param.indexOf(";",i);
                      val=param.substring(i,j);
                      i=j+1;
                      i++; //skip next space              

                      attr=document.createAttribute(key);
                      attr.value=val;
                      el.setAttributeNode(attr);
               }
           }

           //Add Style
           if (style && style!="") {
               i=0;j=0;l=style.length;
               while (i<l) {              
                      j=style.indexOf(":",i);
                      key=style.substring(i,j).toLowerCase();
                      i=j+1;
                      j=style.indexOf(";",i);
                      val=style.substring(i,j);
                      i=j+1;
                      i++; //skip next space       
                      eval("el.style."+key+"="+val);
               }
           }

          }
 if (parent!=null) parent.appendChild(el);
 return el;
}



   //User defined function
   XML_Load.prototype.OnReady=function(uparams,ldata) {   
 
   }

// Example of call:
// var xl=new XML_Load("http://somthing.com","GET",null,"someparameters");
// if (xl.IsReady()) {
//     xl.OnReady=function(uparams,ldata) {
//      alert(uparams); //display "someparameters"
//      alert(ladata);  //display page from somthing.com
//     }
//     xl.Load();
// }


