
function update_countdown() {
	var target_date = NEXT_RACE_DATE;
	var rem = SYC_get_remaining(target_date);
	rem = SYC_format_remaining(rem);
	/* We now hold an array with [d,h,m,s] formatted strings */
	showstr = rem[0].toString() + "d " + rem[1] + "h " + rem[2] + "m " + rem[3] + "s";
	$(".nextrace").html(showstr);
}

$(document).ready(function(){
	
	/* Add active attribute for left col menu */
	$("#subnav li").mouseover(function() {
		$(this).addClass("active");
	})
	$("#subnav li").mouseout(function() {
		$(this).removeClass("active");
	})
	
	/* Add active attribute for main nav */
	$("#nav li").mouseover(function() {
		$(this).addClass("active");
	})
	$("#nav li").mouseout(function() {
		$(this).removeClass("active");
	})
	
	/* Activate the counter */
	if (NEXT_RACE_DATE == null) {
		$(".nextrace").html("Announced soon");
	} else {
		update_countdown();
		setInterval(update_countdown, 1000);
	}
});
