function Vozjax(){
    this.method = "GET";
    this.responseText;
    this.responseXML;

    this.onLoading = function() { return; };
    this.onLoaded = function() { return; };
    this.onInteractive = function() { return; };
    this.onComplete = function() { return; };
}

Vozjax.prototype.run = function ( _file ){
    var oXml = null;

    if (window.XMLHttpRequest) {
        oXml = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        oXml = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert("ˇAtención! Su navegador no incluye soporte para visualizar correctamente esta web");
    }

    var self = this;
    oXml.onreadystatechange = function() {
        switch (oXml.readyState){
            case 1:
                self.onLoading();
                break;
            case 2:
                self.onLoaded();
                break;
            case 3:
                self.onInteractive();
                break;
            case 4:
                self.responseText = oXml.responseText;
                self.responseXML = oXml.responseXML;
                self.onComplete();
                break;
        }
    }
    oXml.open (this.method, _file ,true);
    oXml.send (null);
}

/**
*
*  AJAX IFRAME METHOD (AIM)
*
**/
 
AIM = {
 
	frame : function(c) {
 
		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('DIV');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);
 
		var i = document.getElementById(n);
		if (c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
		}
		if (c && typeof(c.onError) == 'function') {
			i.onError = c.onError;
		}
 
		return n;
	},
 
	form : function(f, name) {
		f.setAttribute('target', name);
	},
 
	submit : function(f, c) {
		AIM.form(f, AIM.frame(c));
		if (c && typeof(c.onStart) == 'function') {
			return c.onStart();
		} else {
			return true;
		}
	},
 
	loaded : function(id) {
		var i = document.getElementById(id);
        if (i.contentDocument) {
			var d = i.contentDocument;
		} else if (i.contentWindow) {
			var d = i.contentWindow.document;
            var content = "<" + NODE_RESPONSE + ">" + d.body.innerHTML;
		} else {
			var d = window.frames[id].document;
            var content = d.body.innerHTML;
		}
		if (d.location.href == "about:blank") {
			return;
		}
        if (content){
            var doc = getDocument(content);
        }else{
            var doc = d;
        }
        if (doc.getElementsByTagName(NODE_RESPONSE).length > 0){
            var code = doc.getElementsByTagName(NODE_CODE)[0].firstChild.nodeValue;
            var msg = "";
            if (doc.getElementsByTagName(NODE_MESSAGE)[0].firstChild != null)
                msg = doc.getElementsByTagName(NODE_MESSAGE)[0].firstChild.nodeValue;
            if (code == RESPONSE_OK){
                if (typeof(i.onComplete) == 'function') {
                    i.onComplete(msg);
                }
            }else{
                if (typeof(i.onError) == 'function') {
                    i.onError(code, msg);
                }
            }
        }
	}
 
}
