function ajaxRequest() {
    //cria objeto independente do browser
    try {
	this.xmlhttp = new XMLHttpRequest();
    } catch(ee) {
	try {
	    this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
	    try {
		this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch(E) {
		this.xmlhttp = false;
	    }
	}
    }

    this.__parms = '';
    //fim construtora
	
	this.__noCache = function (uri) {
		return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)
	}

    //faz a requisicao do conteudo
    this.__request = function(type, page, parms, callback) {
	page = this.__noCache(page);
	
	if (parms == undefined) parms = null;


	if(callback == undefined) {
	    this.xmlhttp.open(type, page, false);
	    if (type=='POST' && parms) this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    this.xmlhttp.send(parms);

	    if (this.xmlhttp.responseText) return this.xmlhttp.responseText; 
	    else return this.xmlhttp.responseXML;
	}
	else {
	    this.xmlhttp.open(type, page, true);
	    if (type=='POST' && parms) this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    
	    var xmlhttp = this.xmlhttp;
	    
	    this.xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4)
		callback((xmlhttp.responseXML) ? xmlhttp.responseXML : 
			 xmlhttp.responseText);
	    }
	    this.xmlhttp.send(parms);
	}
    }//fim __request

    //string usada para guardar os parametros

    //adiciona parametros para o post
    this.addParameter = function(name, value) {
	if (this.__parms.length == 0) this.__parms += name+'='+value;
	else this.__parms += '&'+name+'='+value;
    }//fim addParameter

    //faz requisicao via GET
    this.get = function(page, callback) {
	return this.__request('GET', page, null, callback);
    } //fim GET

    //faz requisicao via POST
    this.post = function(page, callback) {
	return this.__request('POST', page, this.__parms, callback);
    }//fim POST

    this.test = function(page, callback) {
	this.xmlhttp.open('POST', page, true);
	this.xmlhttp.setRequestHeader('Content-Type', 'application/xml');

	var xmlhttp = this.xmlhttp;

	this.xmlhttp.onreadystatechange = function () {
	    if (xmlhttp.readyState == 4)
	    callback((xmlhttp.responseXML) ? xmlhttp.responseXML : 
		     xmlhttp.responseText);
	}
	this.xmlhttp.send('<?xml version="1.0"?><methodCall><methodName>ola</methodName><params><param><value><int>12</int></value></param><param><value><int>72</int></value></param><param><value><int>88</int></value></param><param><value><int>29</int></value></param></params></methodCall>');
    }

    this.xmlrpc = function(method, parms, page, callback) {
	this.xmlhttp.open('POST', page, true);
	this.xmlhttp.setRequestHeader('Content-Type', 'application/xml');

	var xmlhttp = this.xmlhttp;

	this.xmlhttp.onreadystatechange = function () {
	    if (xmlhttp.readyState == 4)
	    callback((xmlhttp.responseXML) ? xmlhttp.responseXML : 
		     xmlhttp.responseText);
	}

	var msg = '<?xml version="1.0"?><methodCall><methodName>ola</methodName><params><param><value><int>12</int></value></param><param><value><int>72</int></value></param><param><value><int>88</int></value></param><param><value><int>29</int></value></param></params></methodCall>';

	this.xmlhttp.send(msg);
    }
}

