
function createCounters() {
    for (var aClock in counterArray) {
        //console.log("clear: "+counterArray[aClock]);
        counterArray[aClock].stop();
    };
    counterArray.length = 0;
    
    // get game clock
    var clockDuration = document.getElementById("gameClock").innerHTML;
    var clock = new Counter("gameClock", clockDuration);
    counterArray.push(clock);
    
    updateCounters();
}

function setBonusForTeam(action, bonus, teamOneOrTwo) {
	var paramString = "action=";
	paramString += action;
	paramString += "+tag="+bonus;

	var bonusButton1 = (teamOneOrTwo==1 ? document.getElementById("homeBonus1") : document.getElementById("visitorBonus1") );
	var bonusButton2 = (teamOneOrTwo==1 ? document.getElementById("homeBonus2") : document.getElementById("visitorBonus2") );
	
	$.ajax({
		   type: "POST",
		   url: "/html/scoreBoard",
		   data: paramString,
		   cache: false,
		   success: function(bonuses) {
			   if (bonuses == 0) {
					$(bonusButton1).removeClass("active")
					$(bonusButton2).removeClass("active")
			   } else if (bonuses == 1) {
					$(bonusButton1).addClass("active")
					$(bonusButton2).removeClass("active")
			   } else if (bonuses == 2) {
					$(bonusButton1).addClass("active")
					$(bonusButton2).addClass("active")
			   }
		   }
	});
}
