
var request;
var queryString; 
var stPos = 333;
var stSpeed = 20;
var scrollAgain = null;
var dailyMessage;
var browser = navigator.appName;
if (browser == "Opera") {
	stSpeed = 10;
	}


//first extract the current html from the ticker

function getMessage() {
 dailyMessage = document.getElementById("tickerText").innerHTML;
 sendData();
 scroller();	
}

// then create the variables to send via ajax

function sendData() {
	var url="/poker/ipokernetworkfeed.jsp";
	httpRequest("POST",url,true);
	}
	

// note the main ajax functions sit in /include/javascript/ajax.js
// the following function waits for the response then runs the function getDocInfo and passes the xml information to it
// else it runs the scoller function which just shows the daily message
	

function handleResponse(){
	if(request.readyState == 4) {
		if(request.status == 200) {
			var doc = request.responseXML;
			var info = getDocInfo(doc);
		}
	}
}

//the following function extracts the data from the xml feed and places it into the tickerText node 

function getDocInfo(doc) {
var root = doc.documentElement;
var nds;
var onlinePlayers;
var playersInTournaments;
var activeTournaments;
var realTables;
var realPlayers;

 if (root.hasChildNodes()) {
 	nds = root.childNodes;
	for (var i = 0; i < nds.length; i++) {
			if (nds[i].nodeName == 'onlineplayers') {
				onlinePlayers = nds[i].firstChild.nodeValue;
				}
			if (nds[i].nodeName == 'playersintournaments') {
				playersInTournaments = nds[i].firstChild.nodeValue;
				}
			if (nds[i].nodeName == 'activetournaments') {
				activeTournaments = nds[i].firstChild.nodeValue;
				}
			if (nds[i].nodeName == 'realtables') {
				realTables = nds[i].firstChild.nodeValue;
				}
			if (nds[i].nodeName == 'realplayers') {
				realPlayers = nds[i].firstChild.nodeValue;
				}
		}
	} 
			mydiv = document.getElementById("tickerText");
			mydiv.innerHTML="Joueurs en ligne: <strong>" + onlinePlayers + "</strong>, Joueurs en tournois: <strong>" + playersInTournaments + "</strong>, Tournois actifs: <strong>" + activeTournaments + "</strong>, Tables payante: <strong>" + realTables + "</strong>, Joueurs de tables payantes: <strong>" + realPlayers + "</strong>, " + dailyMessage;	
					
}







function scroller() {
		st = document.getElementById('tickerText');
		st.style.left = stPos+'px';
		stLength = st.offsetWidth;
		stEnd = 0 - stLength;
		if (stPos == stEnd) {
			stPos = 333;
			}
		stPos = stPos -1;
		scrollAgain = setTimeout('scroller()',stSpeed);
}


function scrollerStop() {
		clearTimeout(scrollAgain);
}




