// countdown.js 1.0 - a countdown script (live in ie4+, mozilla)
// This script lives at http://stufflikethat.org/projects/misc/countdown/ .
// Copyright (C) 2001 David Danziger (david@stufflikethat.org)
// This program is free software released under the terms of the
// GNU General Public License (http://www.gnu.org/copyleft/gpl.html).

function countdown() {

	var currentDate = new Date();

	//the date we are counting down to
	var endDate = new Date("May 11, 2002 00:00:00");
	
	//for minutes and seconds, we can just fake it
	var secsLeft = (60 - currentDate.getSeconds());
	var minsLeft = (60 - currentDate.getMinutes() - 1);
	
        var msLeft = endDate - currentDate;
	
	//the days left, note that we use floor because hours are accounted for
        var daysLeft = Math.floor(msLeft / 86400000);

	//this should accurately find the hours in all cases now
	var hoursLeft = (Math.floor(msLeft / 3600000)) % 24;
	
	//browser detection - live countdown only works in ie4+ and mozilla
	var agent = navigator.userAgent.toLowerCase();
	var majorVer = parseInt(navigator.appVersion);
	//opera likes to spoof ie but doesn't support the same stuff
	var ie = ((agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1));
	var ie4plus = (ie && (majorVer >= 4));
	//mozilla now supports innerHTML by popular demand
	var gecko = (agent.indexOf('gecko') != -1);
	
	if (ie4plus || gecko) {
	    var remainstring = ""+daysLeft+" days, "+hoursLeft+" hours, "+minsLeft+" mins, "+secsLeft+" secs";
	    //this will make it count down live
	    document.getElementById("remainhtml").innerHTML = remainstring;
	    window.setTimeout("countdown();", 1000);
	} else { //for browsers that don't do innerHTML
	    var remainstring = ""+daysLeft+" days, "+hoursLeft+" hours, "+minsLeft+" mins";
	    document.write(""+remainstring);
	}

}

window.onLoad=countdown();
