function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}

$(function() {
	$.ajax({
		type: "GET",
		//url: "ticker_en.xml",
	  url: "http://www.primocanaledica33.it/admin/news.xml",
		dataType: "xml",
		success: function(xmlData)
		{
			xmlDataSet = xmlData;
			browseXML();
		},
		    error: function(){
        alert('Errore nel caricamento del file XML');
    }
	});
	
	$("#tickercontainer").hover(function(){ 
	  keep = true;
	},function(){ 
	  keep = false;
	});
});

var msg=new Array();
var entryLength = 0;
var z=0;
var keep = false;
function browseXML()
{
	entryLength=$("item",xmlDataSet).length;
	for(var i=0; i<entryLength; i++){			
		strToAppend="<p>" + $("item/pubDate",xmlDataSet)[i].childNodes[0].nodeValue + '<a target="_blank" href="' + $("item/link",xmlDataSet)[i].childNodes[0].nodeValue + '">' + stripslashes($("item/title",xmlDataSet)[i].childNodes[0].nodeValue) + '<\/a><\/p>';
		msg[msg.length++]=strToAppend;					
	}
}

function Visualizza(){
	if(z==entryLength){
		z=0;
	}
	$("#tickercontainer #mask").empty();	
	$("#tickercontainer #mask").append(msg[z]);
	z++;
	$("#tickercontainer #mask p").animate({opacity: 'show' }, 1500, "easeout", function(){ $(this).animate({opacity: 1.0 }, 2500, "easeout", function(){$(this).animate({opacity: 'hide' }, 3500, "easeout", function(){Visualizza()})})});
}



$(window).bind("load", function() {
	setTimeout("Visualizza()",1000);
});