/*
 * J. Cavalheiro
 * 2008-2009
 * 
 */

function _AJAX(ref,url,after_load_code) {					

	this.ref=ref;
	this.url=url;
	this.after_load_code=after_load_code;	
	this.xmlHttp;	
	this.init();		
	
}

_AJAX.prototype.init = function() {   		     					
		if (window.XMLHttpRequest) {			
		  // IE7, Mozilla
		  this.xmlHttp = new XMLHttpRequest();
		}
		else
		{
		  if (window.ActiveXObject) {
		     // IE5.x e IE6.
		     this.xmlHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0');
		  }
		}				
   	}
	
_AJAX.prototype.sendAJAXRequest = function() {		
	var self=this;	
	var result;
		
 	this.xmlHttp.onreadystatechange=function() {		
			if (self.xmlHttp.readyState==4) {																				
				self.AJAXdisplay();
			}
		}
 	this.xmlHttp.open("GET",this.url,true); 	
 	this.xmlHttp.send(null);  	
}	

	
_AJAX.prototype.AJAXdisplay = function () {			
		var ref=this.ref;
		var after_load_code=this.after_load_code;
		var result=this.xmlHttp.responseText;		 

		if (ref) {
			el=document.getElementById(ref);		
			el.innerHTML=result;
		}

		
		if (after_load_code) {					
			eval(after_load_code);				 																										
		}							
}	
	
function AJAXGetPage(ref,url,after_load_code) {							
		var ajax=new _AJAX(ref,url,after_load_code);									
		ajax.sendAJAXRequest();		
}
		







