var i=0,sum=0,inc=0.03,major,strike, million, magic, prog3, xmlHttp1=null,xmlHttp2=null,xmlHttp3=null,xmlHttp4;

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


function ticker()
{
major=Number(major); // Change value to number incase it's a string
strike=Number(strike);
million=Number(million);
magic=Number(magic);
inc=Math.floor((Math.random()*3));
inc=inc/100;
major+=inc
strike+=inc;
million+=inc;
magic+=inc;

if(element=document.getElementById('jackpot'))
	element.firstChild.nodeValue = '$'+addCommas((major+strike+million+magic).toFixed(2));

if(element=document.getElementById('sum-major'))
	element.firstChild.nodeValue = '$'+addCommas((major).toFixed(2));

if(element=document.getElementById('sum-strike'))
	element.firstChild.nodeValue = '$'+addCommas((strike).toFixed(2));

if(element=document.getElementById('sum-million'))
	element.firstChild.nodeValue = '$'+addCommas((million).toFixed(2));

if(element=document.getElementById('sum-magic'))
	element.firstChild.nodeValue = '$'+addCommas((magic).toFixed(2));


i+=1;
if (i > 3500)
	return;
setTimeout("ticker()",300);
}


function displayContent(url1,url2,url3,url4)
{
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp1=new XMLHttpRequest();
  xmlHttp2=new XMLHttpRequest();
  xmlHttp3=new XMLHttpRequest();
  xmlHttp4=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttp3=new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttp4=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
      xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
      xmlHttp3=new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttp4=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }

  xmlHttp1.onreadystatechange=process;
  xmlHttp2.onreadystatechange=process;
  xmlHttp3.onreadystatechange=process;
  xmlHttp4.onreadystatechange=process;
  
  xmlHttp1.open("GET",url1,true); // Open a URL using "get" method
  xmlHttp2.open("GET",url2,true); // Open a URL using "get" method
  xmlHttp3.open("GET",url3,true); // Open a URL using "get" method
  xmlHttp4.open("GET",url4,true); // Open a URL using "get" method
  xmlHttp1.send(null); // Don't send values to server
  xmlHttp2.send(null); // Don't send values to server
  xmlHttp3.send(null); // Don't send values to server
  xmlHttp4.send(null); // Don't send values to server
}  

function process()
{
if(xmlHttp1.readyState!=4) return;
if(xmlHttp2.readyState!=4) return;
if(xmlHttp3.readyState!=4) return;
if(xmlHttp4.readyState!=4) return;
	var req=xmlHttp1.responseText; // Get the server's response
	req=req.replace(/"/g,''); // Remove all trailing quotes
	major=req.split('jackpot:')[1].split('}')[0]; // Split the string into the value
	req=xmlHttp2.responseText; // Get the server's response
	req=req.replace(/"/g,''); // Remove all trailing quotes
	strike=req.split('jackpot:')[1].split('}')[0]; // Split the string into the value
	req=xmlHttp3.responseText; // Get the server's response
	req=req.replace(/"/g,''); // Remove all trailing quotes
	million=req.split('jackpot:')[1].split('}')[0]; // Split the string into the value
	req=xmlHttp4.responseText; // Get the server's response
	req=req.replace(/"/g,''); // Remove all trailing quotes
	magic=req.split('jackpot:')[1].split('}')[0]; // Split the string into the value
	ticker();
} // End of the anonymous function

window.onload=function()
{
	displayContent('majormoolah.php','strikegold.php','millionreels.php','moneymagic.php'); // Configuration of displayContent function.
}