// JavaScript Document
// JavaScript 1.5
// @FHH
// version 0.3.1( stable)

function eAJAX(){
    this.xmlHttp=crtXH();
    this.crtSend=crtSend;
    this.handler=eHandler;
	this.isFailure=false;
}

function crtXH(){

    var xmlHttp;
    try{
        xmlHttp = new XMLHttpRequest();
    }catch(e){
        var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
										"MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
        for(var i=0;i<XmlHttpVersions.length && !xmlHttp;i++){
            try{
                xmlHttp=new ActiveXObject(XmlHttpVersions[i]);
            }catch(e){}
        }
    }
    if(!xmlHttp){
        this.isFailure=true;
    }else return xmlHttp;

}

function crtSend(type,file,param,async){
    if(this.xmlHttp && type){
        try{
            
            if(type=="GET"){
                this.xmlHttp.open(type,file+param,async);
                this.xmlHttp.onreadystatechange=this.handler;
                this.xmlHttp.send(null);
            }else if(type=="POST"){
                this.xmlHttp.open(type,file,async);
                this.xmlHttp.onreadystatechange=this.handler;
				this.xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                this.xmlHttp.send(param);
            }else {alert('Неврно выбран тип запроса');}
        }catch(error){
            alert('Невозмжно связаться с сервером:'+error.toString())
       }
    }
}
eAJAX.prototype.arrHeadrs=new Array();
eAJAX.prototype.setHeadersArray=function(_arrMyHeaders){}
eAJAX.prototype.check=function(){ return this.isFailure; }

function eHandler(){ return false; }