function ajaxObject(url, oncompleteFunction) {
  
	var that=this;      
  
	this.updating = false;
  
	this.abort = function() {
		if (that.updating) {
			that.updating=false;
			that.AJAX.abort();
			that.AJAX=null;
		}
	};
  
	this.send = function(passData,postMethod) { 
		if (that.updating) { return false; }
		that.AJAX = null;                          
		if (window.XMLHttpRequest) {              
			that.AJAX=new XMLHttpRequest();              
		} else {                                  
			that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
		}                                             
    
		if (that.AJAX==null) {                             
			return false;                               
		} else {
			that.AJAX.onreadystatechange = function() {  
				switch(that.AJAX.readyState) {
				    case 0: // Uninitialized
				    	//that.onRequest(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
				        break;
				    case 1: // Loading
				    	//that.onLoading(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
				        break;
				    case 2: // Loaded
				    	that.onLoaded(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
				        break;
				    case 3: // Interactive
				    	that.onInteractive(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);
				        break;
				    case 4: // Done!
				    	that.updating=false;                
						that.onComplete(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
						that.AJAX=null;             
						break;
				    default:
				        break;
			    }
			};                                                        
			that.updating = new Date();        
      
			passData = that.serializedata(passData);
      
			if (/post/i.test(postMethod)) {
				var uri=urlCall+'?'+that.updating.getTime();
				that.AJAX.open("POST", uri, true);
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				that.AJAX.setRequestHeader("Content-Length", passData.length);
				that.AJAX.send(passData);
			} else {
				var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
				that.AJAX.open("GET", uri, true);                             
				that.AJAX.send(null);                                         
			}              
			return true;                                             
		}                                                                           
	};
	
	this.load = function(contentDiv,passData,postMethod) { 
		this.onComplete = function(response, status, xml){
			document.getElementById(contentDiv).innerHTML = response;
		};
		this.send(passData, postMethod);                                                         
	};
	
	this.loadScript = function (response){
			var script = document.createElement('script');
			script.setAttribute('type', 'text/javascript');
			script.text = response;
			var cabecera = document.getElementsByTagName('head');
			cabecera[0].appendChild(script);
			cabecera[0].removeChild(script);
	};
	
	this.serializedata = function(data){
		if(typeof(data)!='string'){
			var str = '';
			for(x in data){
				str = str + x + '=' + data[x] + '&'; 
			}
			str = str.substr(0,str.length-1);
			return str;
		}else{
			return str;
		}
	};
	
	var urlCall = url;        
	this.onRequest = function () { };
	this.onLoading = function () { };
	this.onLoaded = function () { };
	this.onInteractive = function () { };
	this.onComplete = oncompleteFunction || function () { };
}
/*
String.implement('stripScripts', function(exec){
	var scripts = '';
	var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(all, code){
		scripts += code + '\n';
		return '';
	});
	if (exec === true) Browser.exec(scripts);
	else if (typeOf(exec) == 'function') exec(scripts, text);
	return text;
});
*/
