var urlInfos="/lib/ajax/liveinfojs.xml.php";
var dataInfos = null ;  // donnée envoyée via ajax

//Instantiation et initialisation de l'objet AJAX gérant un objet XMLHTTpRequest
var reqInfos = new AJAX();
reqInfos.setCallbackFunction(DispLiveInfo); // Fonction de Callback = DispLiveInfo()

function GetLiveInfo()
{
        //document.getElementById( 'RadioData' ).innerHTML = "<img src=\"/imagescsl/ajax-loader.gif\" border=0><br><br>";
        reqInfos.getFile(urlInfos,dataInfos);
}

	//var djBanner; var PdjBanner;
	//var djName; var PdjName;
	//var djCountry; var PdjCountry;
	//var djSessionName; var PdjSessionName;
	//var djSessionGenre; var PdjSessionGenre;
	//var currentTitle; var PcurrentTitle;
	var RadioMode; var PRadioMode;
	var CurrentListeners; var PCurrentListeners;
	var MaxListeners; var PMaxListeners;
	var DisplayTitleUpdate; var PDisplayTitleUpdate;
	//var DJAlert; var PDJAlert;

function DispLiveInfo(doc) // Fonction de Callback: reçoit la réponse en paramètre.
{
	//PdjBanner = djBanner;
	//PdjName = djName;
	//PdjCountry = djCountry;
	//PdjSessionName = djSessionName;
	//PdjSessionGenre = djSessionGenre;
	//PcurrentTitle = currentTitle;
	PRadioMode = RadioMode;
	//PCurrentListeners = CurrentListeners;
	//PMaxListeners = MaxListeners;
	PDisplayTitleUpdate = DisplayTitleUpdate;
	//PDJAlert = DJAlert;
	
	var XmlData;
	
	
	/*
	djBanner = doc.getElementsByTagName("data")[0].getElementsByTagName("djBanner")[0].firstChild.nodeValue;
	
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("djName")[0].firstChild;
	if (XmlData) {
		djName = XmlData.nodeValue;
	}
	else {
		djName = "-";
	}
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("djCountry")[0].firstChild;
	if (XmlData) {
		djCountry = XmlData.nodeValue;
	}
	else {
		djCountry = "-";
	}
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("djSessionName")[0].firstChild;
	if (XmlData) {
		djSessionName = XmlData.nodeValue;
	}
	else {
		djSessionName = "-";
	}
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("djSessionGenre")[0].firstChild;
	if (XmlData) {
		djSessionGenre = XmlData.nodeValue;
	}
	else {
		djSessionGenre = "-";
	}
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("currentTitle")[0].firstChild;
	if (XmlData) {
		currentTitle = XmlData.nodeValue;
	}
	else {
		currentTitle = "-";
	}
	*/
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("RadioMode")[0].firstChild;
	if (XmlData) {
		RadioMode = XmlData.nodeValue;
	}
	else {
		RadioMode = "-";
	}
	/*
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("CurrentListeners")[0].firstChild;
	if (XmlData) {
		CurrentListeners = XmlData.nodeValue;
	}
	else {
		CurrentListeners = "-";
	}
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("MaxListeners")[0].firstChild;
	if (XmlData) {
		MaxListeners = XmlData.nodeValue;
	}
	else {
		MaxListeners = "-";
	}
	*/
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("DisplayTitleUpdate")[0].firstChild;
	if (XmlData) {
		DisplayTitleUpdate = XmlData.nodeValue;
	}
	else {
		DisplayTitleUpdate = "-";
	}
	/*
	XmlData=doc.getElementsByTagName("data")[0].getElementsByTagName("DJAlert")[0].firstChild;
	if (XmlData) {
		DJAlert = XmlData.nodeValue;
	}
	else {
		DJAlert = "-";
	}
	*/
	/*
	var nbActivedBlock = 0;
	var percent = 0;
	var InfoListeners = '';
	if (MaxListeners != 0 && MaxListeners != "-") {
		nbActivedBlock = Math.round((CurrentListeners * 25) / MaxListeners);
		percent = Math.round((CurrentListeners * 100) / MaxListeners);
		
		for(i=0; i<25; i++) {
			if (i < nbActivedBlock) {
				InfoListeners+='<img src="/imagescsl/bp_on.png" align="absmiddle" />';
			} else {
				InfoListeners+='<img src="/imagescsl/bp_off.png" align="absmiddle" />';
			}
		}
	}
	*/
	
	// Mise a jour de l'html
	InfoData = '<div id="divResult"><center>';;
	InfoData+= '<table style="border-collapse: collapse;">';
	/*
	if (djName!='-')
	{
		InfoData+= '<tr>';
		InfoData+= '<td><img src="/imagescsl/font.php?fontsize=25&fontcolor=FFFFFF&text=';
		InfoData+= djName;
		InfoData+= '" /></td>';
		InfoData+= '</tr>';
	}
	if (djSessionName!='-')
	{
		InfoData+= '<tr>';
		InfoData+= '<td><img src="/imagescsl/font.php?fontsize=15&fontcolor=FFFFFF&text=-=[ ';
		InfoData+= djSessionName;
		InfoData+= ' ]=-" /></td>';
		InfoData+= '</tr>';
	}
	if (djSessionGenre!='-')
	{
		InfoData+= '<tr>';
		InfoData+= '<td><img src="/imagescsl/font.php?fontsize=15&fontcolor=FFFFFF&text= :: ';
		InfoData+= djSessionGenre;
		InfoData+= ' :: " /></td>';
		InfoData+= '</tr>';
	}
	InfoData+= '</table><br/>';
	InfoData+= '<div id="djBanner"><img src="/';
	InfoData+= djBanner;
	InfoData+= '" width="600" height="220" style="border: 1px solid black;" /></div><br/>';
	InfoData+= '<div>';
	if (currentTitle!='-')
	{
		InfoData+= '<table style="margin-left: 20px; border-collapse: collapse;">';
		InfoData+= '<tr>';
		InfoData+= '<td>';
		InfoData+= '<td><img src="/imagescsl/font.php?fontsize=15&fontcolor=FFFFFF&text=&gt;&gt;&gt; ';
		InfoData+= currentTitle;
		InfoData+= ' &lt;&lt;&lt;" /></td>';
		InfoData+= '</td>';
		InfoData+= '</tr>';
		InfoData+= '</table>';
	}
	*/
	if (DisplayTitleUpdate=="YES")
	{
		InfoData+='<form method="post">';
    InfoData+='Stream title: <input type="text" name="updatetitle" size=20">';
    InfoData+='<input type="submit" value="Update">';
    InfoData+='</form>';
		InfoData+='<br>';
	}
	/*
	if (DJAlert=="forgottoconnect")
	{
		InfoData+='<hr>';
		InfoData+='<font color="#00FF00">It\'s your time to mix, but <b><u>you\'re not connected to shoutcast</u></b>. Please connect to shoutcast first.</font>';
		InfoData+='<hr>';
		InfoData+='<br>';
	}
	if (DJAlert=="muststopplaylist")
	{
		InfoData+='<hr>';
		InfoData+='<font color="#00FF00">It\'s your time to mix. You\'re successfully connected to shoutcast but <b><u>your live is not played yet</u></b>. You have to <a href="/member/shoutcast/stopplaylist.php">stop the playlist</a> when you\'re ready.</font>';
		InfoData+='<hr>';
		InfoData+='<br>';
	}
	*/
	InfoData+= '</div>';
	InfoData+= '<br/>';
	/*
	if (MaxListeners != 0 && MaxListeners != "-")
	{
		InfoData+= InfoListeners;
		InfoData+= '<br>';
		InfoData+= '<img src="/imagescsl/font.php?fontsize=10&fontcolor=FFFFFF&text=';
		InfoData+= CurrentListeners+' listeners ('+percent+'%)';
		InfoData+= '" />';
		InfoData+= '<br>';
	}
	*/
	InfoData+= '</center></div>';
	
	/*
	if (PdjBanner != djBanner ||
		PdjName != djName ||
		PdjCountry != djCountry ||
		PdjSessionName != djSessionName ||
		PdjSessionGenre != djSessionGenre ||
		PcurrentTitle != currentTitle ||
		PRadioMode != RadioMode ||
		PCurrentListeners != CurrentListeners ||
		PMaxListeners != MaxListeners ||
		PDisplayTitleUpdate != DisplayTitleUpdate ||
		PDJAlert != DJAlert)
		*/
	if (PRadioMode != RadioMode ||
		PDisplayTitleUpdate != DisplayTitleUpdate)
	{
	
		document.getElementById( 'RadioData' ).innerHTML = InfoData;
	}
}
