var BagCount = {
    ratePerSecond: 39,
    currentCount: 0,
    tickTime: 0,
    
    tick: function() {
		var randomnumber = Math.floor(Math.random()*(BagCount.ratePerSecond/(1000/BagCount.tickTime)/2));
		if (Math.random() > 0.5) randomnumber = randomnumber*-1
		var increase = (BagCount.ratePerSecond/(1000/BagCount.tickTime))+randomnumber;
        BagCount.currentCount += increase;
        document.getElementById('bagCount').innerHTML = BagCount.addCommas(Math.round(BagCount.currentCount));
        window.setTimeout('BagCount.tick()', BagCount.tickTime);
    },
    start: function() {
        BagCount.currentCount = parseInt(document.getElementById('bagCount').innerHTML, 10)
        if (BagCount.isIE()) {
            BagCount.tickTime = 1000;
        } else {
            BagCount.tickTime = 250;
        }
        BagCount.tick();
    },
    isIE: function() {
        return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
    },
	addCommas: function(nStr){
		x1 = nStr+'';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1;
	}
}

function printSpecial()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n<title>';

if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("title");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '</title>\n</HEAD>\n<BODY>\n';

var printReadyElem = document.getElementById("printReady");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}

html += '\n</BODY>\n</HTML>';

var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("The print ready feature is only available if you are using an updated browser. Please update your browswer.");
}
}