function addLoadEvent(fn) {
	if (typeof window.addEventListener != "undefined") {
		window.addEventListener("load", fn, false);
	}
	else if (typeof document.addEventListener != "undefined") {
		document.addEventListener("load", fn, false);
	}
	else if (typeof window.attachEvent != "undefined") {
		window.attachEvent("onload", fn);
	}
	else if (typeof window.onload == "function") {
		var fnOld = window.onload;
		window.onload = function() {
			fnOld();
			fn();
		};
	}
	else {
		window.onload = fn;
	}
}
var countdownInterval;
function startCountdown() {
	countdownInterval = setInterval(getTimeLeft,1000);
}
function getTimeLeft() {
	var countdown = document.getElementById('countdown');
	if(!countdown){return;}
	var now = new Date();
	var eventTime = new Date();
	eventTime.setFullYear(2008);
	eventTime.setMonth(5);
	eventTime.setDate(12);
	eventTime.setHours(0);
	eventTime.setMinutes(0);
	eventTime.setSeconds(0);
	eventTime.setMilliseconds(0);
	var span = eventTime.getTime() - now.getTime();
	var scratch = Math.floor(span/1000);
	var seconds = scratch % 60;
	seconds = seconds + " ";
	if(seconds.length == 2) { seconds = "0" + seconds; }
	scratch = Math.floor((scratch-seconds)/60);
	var minutes = scratch % 60;
	minutes = minutes + " ";
	if(minutes.length == 2) { minutes = "0" + minutes; }
	scratch = Math.floor((scratch-minutes)/60);
	var hours = scratch % 24;
	hours = hours + " ";
	if(hours.length == 2) { hours = "0" + hours; }
	scratch = Math.floor((scratch-minutes)/24);
	var days = scratch + (isLeapYear(2008) ? 1 : 0);
	var d = days > 0 ? "<strong>" + days + "</strong> day" + (days > 1 ? "s " : " ") : "";
	var h = hours > 0 ? "<strong>" + hours + "</strong> hour" + (hours > 1 ? "s " : " ") : "";
	var m = minutes > 0 ? "<strong>" + minutes + "</strong> minute" + (minutes > 1 ? "s " : " ") : "";
	var s = seconds > 0 ? "<strong>" + seconds + "</strong> second" + (seconds > 1 ? "s " : " ") : "";
	countdown.innerHTML = d + h + m + s + "<strong>until 2008 Bonnaroo Music & Arts Festival</strong>";
}
function isLeapYear(yr) {
	return new Date(yr,2-1,29).getDate()==29;
}
addLoadEvent(startCountdown);
