if (document.location == "http://ww.rai.tv/dl/raitv/" || document.location == "http://www.rai.tv/dl/raitv/home.html") {
	document.location = "http://www.rai.tv";
}

var immaginiClassifiche =new Array("/dl/raitv/img/piu_visti_Oggi.gif",
								"/dl/raitv/img/piu_visti_Set.gif",
								"/dl/raitv/img/piu_visti_Mese.gif",
								"/dl/raitv/img/piu_votati_Oggi.gif",
								"/dl/raitv/img/piu_votati_Set.gif",
								"/dl/raitv/img/piu_votati_Mese.gif");	
								
var immaginiClassifiche_d =new Array("/dl/raitv/img/piu_visti_Set_d.gif",
									 "/dl/raitv/img/piu_visti_Mese_d.gif",
									 "/dl/raitv/img/piu_votati_Oggi_d.gif",
									 "/dl/raitv/img/piu_votati_Set_d.gif",
									 "/dl/raitv/img/piu_votati_Mese_d.gif",
									 "/dl/raitv/img/piu_visti_Oggi_d.gif");
var xmlAjax = "";
var indiceClassifiche = 0;
var tools = new AjaxTools();

function readXML(ind) {
	var i = 1;
	$("#titClassifiche").attr("src", immaginiClassifiche[indiceClassifiche]);
	$("#titClassifiche_d").attr("src", immaginiClassifiche_d[indiceClassifiche]);
	$(".contentBox div").html("");
	$(xmlAjax).find('classifica').each(function(){
		if ($(this).attr('tipo_stat') == indiceClassifiche) {
			$(this).find('item').each(function(){
				var id = "#elenco"+i;
				var html = '<a href="'+$(this).find('link').text()+'" target="_top" >'+$(this).find('titolo').text()+'</a>';
				$(id).html(html+"<br>");
				i++;
			})	
		}
	});
}
//* Gianni
//*
//* Cambiato path dell'url delle classifiche
//*

function readClassifica() {
	$.ajax({
		 type: "GET",
 		 //url: "http://www.rai.tv/mpclassifiche",
		 url: "/dl/raitv/xmlstatici/mpclassifiche.xml",
		 dataType: "html",
		 success: function(html) {
			html = html.replace(/\r\n+/,'');
			xmlAjax = tools.CreateXmlDocumentFromContent(html);
			readXML(indiceClassifiche);
		 }
	}); 
}

function shiftClassificaUp() {
	if(indiceClassifiche < 5) 
		indiceClassifiche++;
	else
		indiceClassifiche = 0;
	
	readXML(indiceClassifiche);
}

function shiftClassificaDown() {
	if(indiceClassifiche!=0) 
		indiceClassifiche--;
	else
		indiceClassifiche = 5;
	
	readXML(indiceClassifiche);
}

