﻿/*
 * THIS SCRIPT WAS WRITTEN BY F.HARDENBERG 7 SEP 2009
 * ******************************************************
 * TO SERVE AS A TEMPORARY QUICK FIX FOR THE TICKERS 
 * THAT WEREN'T DISPLAYING ON THE WEBSITE.
 * FOR ANY QUERIES, PLEASE EMAIL farrelh@forwardslash.com
 * CALL ON EXT. 9336
 * ******************************************************
*/
var JP1 = '785992&1186558&17070544&3978673&1492924&44250733&27843246&116901759&12307216&7368467&4796530&4583047&8365794&10551739&1567510'.split('&');
var Inc1 = '1&0&0&1&0&0&0&1&1&1&0&1&0&0&1&0&0&0&'.split('&');
var LastUpdate = '1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&1250502000&'.split('&');
var JP = new Array();
var Inc = new Array();	
//for (i = 15 - 1; i >= 0; i--) {
//	JP[i + 1] = parseInt(JP1[i]) + parseInt(Inc1[i]) * (1250502594 - LastUpdate[i]);
//	Inc[i + 1] = Inc1[i];
//}
//for (i = 1; i <= 15; i++) {
//	JP[i] = parseInt(JP[i]);
//	Inc[i] = parseInt(Inc[i]);
//	if (Inc[i] < 0) Inc[i] = 0;
//}

//function num2dollar(num) {
//	num = num.toString().replace(/\$|\,/g, '');
//	if (isNaN(num))
//		num = "0";
//	sign = (num == (num = Math.abs(num)));
//	num = Math.floor(num * 100 + 0.50000000001);
//	cents = num % 100;
//	num = Math.floor(num / 100).toString();
//	if (cents < 10)
//		cents = "0" + cents;
//	for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
//		num = num.substring(0, num.length - (4 * i + 3)) + ',' +
//	num.substring(num.length - (4 * i + 3));
//	//return (((sign) ? '' : '-') + '$' + num + '.' + cents);
//	return (((sign) ? '' : '-') + '' + num + '.' + cents);
//	//return "$" + amount.toFixed(2);
//}

//function ScrollTotals() {
//	var itotal = 0;
//	var obj = document.getElementById("tTicker")
//	for (i = 1; i < JP.length; i++) {
//		JP[i] += Inc[i];
//		itotal += parseInt(JP[i]);
//	}
//	obj.innerHTML = num2dollar(itotal / 100);
//	window.setTimeout("ScrollTotals()", 1500);
//}

/***********************Progressive ticker***************************/
//increment the jackpot ticker
function JackpotTotals(id) {
    var itotal = 0;
    var obj = document.getElementById(id);
    if (obj != null) {
        itotal += parseFloat(obj.innerHTML.replace(/\$|\,/g, ''));
        itotal += 0.02;
        obj.innerHTML = addCommas(itotal);
        window.setTimeout("JackpotTotals('" + id + "');", 1500);
    }
}
//increment the game ticker
function ScrollProgressive(gameIndex) {
	var itotal = 0;
	var obj = document.getElementById("pTicker" + gameIndex);
	JP[gameIndex] += 0.01;
	itotal += JP[gameIndex];

	if (obj != null) {
	    //format the value
	    obj.innerHTML = addCommas(itotal);
	    window.setTimeout("ScrollProgressive(" + gameIndex + ")", 1700);
	}
}

//format the value to currency 
function addCommas(nStr) {
    nStr = Math.floor(nStr * 100 + (Math.random()* 6));
    cents = nStr % 100;
    if (cents < 10)
        cents = "0" + cents;
    x1 = Math.floor(nStr / 100).toString();
    x2 = '.' + cents;
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}

//Get all the value for ticker update
function LoadArray() {
    JP = new Array();
    for (i = 1; i <= 15; i++) {
        var obj = document.getElementById("pTicker" + i);
        JP[i] = parseFloat(obj.innerHTML);
    }
}
/*************************End Progressive ticker*****************************/
// Set players online//

function playersonline() {
    var currentvalue2 = ""
    var label2;


    var playersonline = document.getElementsByName("playersonline");
    if (playersonline.length > 0) {
        for (var i = 0; i < playersonline.length; i++) {
            label2 = playersonline[0];
            currentvalue2 = Number(label2.getAttribute("value"));
            label2.innerHTML = AddCommas(currentvalue2);
            label2.setAttribute("value", currentvalue2);
        }
    }
}



// end players online //
