/*
======================================================================
Funzione: ContentRetriever
Descrizione: Classe 
======================================================================
*/
function ContentRetriever(dataRetrieverUrl){
	this.jsonData = "";
	this.dataRetrieverUrl = dataRetrieverUrl;
	this.ajaxObj = createHttpRequest();
	this.observerArray = [];	
}

ContentRetriever.prototype.attach = function(observerObject){
	this.observerArray.push(observerObject);
};

ContentRetriever.prototype.getContent = function(){
	if (this.ajaxObj){
		var instance = this;
		this.ajaxObj.open('GET', this.dataRetrieverUrl , true);		
		this.ajaxObj.onreadystatechange = function(){instance.callbackFunction();};
		this.ajaxObj.send(null);
	}
};

ContentRetriever.prototype.callbackFunction = function(){
	if (this.ajaxObj.readyState == 4 && this.ajaxObj.status==200){ 
		if(this.ajaxObj.responseText && this.ajaxObj.responseText.length > 0){
			this.jsonData = eval("(" + this.ajaxObj.responseText + ")");
		}
		this.notify();
	}
};

ContentRetriever.prototype.notify = function(){
	for(var i = 0; i < this.observerArray.length; i++){
		this.observerArray[i].update(this.jsonData);
	}
};


