
function createCounters() {
	var clock;
	// clear clocks
    for (var aClock in counterArray) {
        counterArray[aClock].stop();
    };
    counterArray.length = 0;
    // get game clock duration
    var clockDuration = document.getElementById("gameClock").innerHTML;
	
	var soccerClock = document.getElementById("hiddenClockType").value;
	
	if (soccerClock==1) { // if this is a time elapsed clock then
		var endClockTime = document.getElementById("clockEnd").value;
		clock = new SoccerCounter("gameClock", clockDuration, endClockTime);
	} else { // regualr countdown clock
		clock = new Counter("gameClock", clockDuration);
	}
	counterArray.push(clock);
	updateCounters();
}


function setExtraTime() {
    var me = $(this);
    var paramString = "action=setExtraTime";
    paramString += "+tag="+document.getElementById("extraTime").value;

    var clockContents = document.getElementById("gameClockForm");
    
    // post the string, asking the server for the preview string using these token fields
    $.ajax({
           type: "POST",
           url: "/html/scoreBoard",
           data: paramString,
           cache: false,
           success: function(html) {
           clockContents.innerHTML = html;
           createCounters();
           }
           });
    
}
