y = 0;
z = 0;
speed = 2;

function addCommas(strValue)
{
  var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})');

    //check for match to search criteria
    while(objRegExp.test(strValue)) {
       //replace original string with first group match,
       //a comma, then second group match
       strValue = strValue.replace(objRegExp, '$1,$2');
    }
  return strValue;
}

function removeCommas(strValue)
{ 
  var objRegExp = /,/g; //search for commas globally

  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}

function increment1() {
	if (z == 0) {
		value = document.prog_jackpot.amount.value.substring(0);
	} else {
		value = document.prog_jackpot.amount.value.substring(1);
		value = removeCommas(value);
	}
	minincrement = 2;
	maxincrement = 4;
	increment_value = (Math.round(Math.random()*(maxincrement-minincrement)))+minincrement;
	increment_value = ".0"+increment_value;

	updatedvalue = parseFloat(value)+parseFloat(increment_value);
	updatedvalue = "$"+updatedvalue;
	var dotPos = updatedvalue.indexOf('.');
	if (dotPos > 0) {
		updatedvalue +='00';
		updatedvalue = updatedvalue.substring(0,dotPos +=3);
	} 
	else updatedvalue = updatedvalue + '.00';
	
	document.prog_jackpot.amount.value=addCommas(updatedvalue);


	switch (speed) {
		case 0:
			mininterval = 500;
			maxinterval = 700;
			break;
		case 1:
			mininterval = 1000;
			maxinterval = 1400;
			break;
		case 2:
			mininterval = 1500;
			maxinterval = 2100;
			break;
		default:
			mininterval = 2000;
			maxinterval = 2800;
			break;
	}
	
	setTimeout("increment1("+speed+")", (Math.round(Math.random()*(maxinterval-mininterval)))+mininterval);
	z++;
}

/*function increment2() {
	if (y == 0) {
		value = document.badbeat_jackpot.badbeat_amount.value.substring(0);
	} else {
		value = document.badbeat_jackpot.badbeat_amount.value.substring(1);
	}
	value = removeCommas(value);
	minincrement = 2;
	maxincrement = 5;
	increment_value = (Math.round(Math.random()*(maxincrement-minincrement)))+minincrement;
	increment_value = ".0"+increment_value;

	updatedvalue = parseFloat(value)+parseFloat(increment_value);
	updatedvalue = "$"+updatedvalue;
	var dotPos = updatedvalue.indexOf('.');
	if (dotPos > 0) {
		updatedvalue +='00';
		updatedvalue = updatedvalue.substring(0,dotPos +=3);
	} 
	else updatedvalue = updatedvalue + '.00';
	
	document.badbeat_jackpot.badbeat_amount.value=addCommas(updatedvalue);


	switch (speed) {
		case 0:
			mininterval = 500;
			maxinterval = 700;
			break;
		case 1:
			mininterval = 1000;
			maxinterval = 1400;
			break;
		case 2:
			mininterval = 1500;
			maxinterval = 2100;
			break;
		default:
			mininterval = 2000;
			maxinterval = 2800;
			break;
	}
	
	setTimeout("increment2("+speed+")", (Math.round(Math.random()*(maxinterval-mininterval)))+mininterval);
	y++;
}*/

function increment() {
	increment1();
	/*increment2();    //  this made an error on the page */
}

window.onload = increment;

