//var jsonData;
var curIndex = 0;
var newIndex = 0;
/***************************************************************************
function to load infobar xml file
***************************************************************************/
$.ajax( {

url :"xml/gen/infobar/infobar.xml",
type :'GET',
dataType :'xml',
timeout :10000,
error : function() {
$("#weatherContainer").html("<img class='centered' src='images/stubs/rgr_stub_weather_e.gif' width='' height='' alt='Résultats en cours.' />");
},
success : function(dataXml) {

var jsonData = $.xml2json(dataXml).infobar;
loadinfobar(jsonData, newIndex);
setInterval(function(){
if (curIndex == jsonData.length-1) {
newIndex = 0;
} else {
newIndex++;
}
loadinfobar(jsonData, newIndex);
curIndex=newIndex;
}, 5000);
}
});
function loadinfobar(jsonData, index) {
$('#weatherContent .xml_date').html(jsonData[index].date);
$('#weatherContent .xml_cheval').html('<a href="chevaux-de-course-en-parts.php?cheval='+jsonData[index].identifiant+'" >'+jsonData[index].cheval+'</a>');
$('#weatherContent .xml_icon img').attr('src','images/nav/'+jsonData[index].image+'.gif');

var lieu = jsonData[index].lieu;
lieu = lieu.replace(" - Réunion PMU", "");
lieu = lieu.replace(" -Réunion PMU", "");
lieu = lieu.replace("- Réunion PMU", "");
lieu = lieu.replace("-Réunion PMU", "");

lieu = lieu.replace(" - Réunion Pmu", "");
lieu = lieu.replace(" -Réunion Pmu", "");
lieu = lieu.replace("- Réunion Pmu", "");
lieu = lieu.replace("-Réunion Pmu", "");




$('#weatherContent .xml_lieu').html(lieu);
$('.gainsContent .white').html('GAINS');
$('.gainsContent .xml_gains').html(jsonData[index].gains);
}
