var i = 0;
var time = 5000;//Time tra una news e l'altra
var page = "public/filericette.txt";//File delle news formato  news uno | news due | etc
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	var receiveReq=false; //Clear our fetching variable
	try {
			receiveReq = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
	} catch (e) {
			try {
					receiveReq = new ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
		} catch (e) {
			receiveReq = false;
					}
	}
	if (!receiveReq && typeof XMLHttpRequest!='undefined') {
		   receiveReq = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
	}
	return receiveReq;
}			
//Get our browser specific XmlHttpRequest object.
var receiveReq = getXmlHttpRequestObject();		
//Initiate the asyncronous request.
function getRicette() {
	//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
	if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
		//Setup the connection as a GET call to your page
		//True explicity sets the request to asyncronous (default).
		receiveReq.open('GET', page , true);
		//Set the function that will be called when the XmlHttpRequest objects state changes.
		receiveReq.onreadystatechange = handlegetNews; 
		//Make the actual request.
		receiveReq.send(null);
	}			
}
//Called every time our XmlHttpRequest objects state changes.
function handlegetNews() {
	//Check to see if the XmlHttpRequests state is finished.
	if (receiveReq.readyState == 4) {
		//Set the contents of our span element to the result of the asyncronous call.
		var content = receiveReq.responseText;
		var arraycontent = content.split('|');
		if(i==arraycontent.length) {
			i=0;
		}
		document.getElementById('notizie').innerHTML = arraycontent[i];
		setTimeout('handlegetNews()',time);
		i++;
	}
}
