
/* The year for the copyright */
function countDown (month, day, year){
    var date = new Date();
    date.setFullYear(year, month-1, day);

    var today = new Date();

    // The diff to the date, but we really only care about days, not milliseconds
    var days = (date.getTime() - today.getTime())/(86400*1000);
    if (days > 0) {
	// upcoming event
	var i = days/30;
	if (days < 2) {
	    return ("Tomorrow");
	} else if (days < 7) {
	    return ("In "+ days + " days");
	} else if (days < 50) {
	    var i = Math.round(days/7);
	    if (i<1.5) {
		return ("Next week");
	    } else {
		return ("In about "+ Math.round(i) + " weeks");
	    }
	} else {
	    var i = days/30;
	    return ("In "+ Math.round(i) + " months");
	} 
    } else {
    	// past event
	days = Math.abs(days);
	if (days < 2) {
	    return ("Yesterday");
	} else if (days < 7) {
	    return (days + " days ago");
	} else if (days < 50) {
	    var i = days/7;
	    if (i<1.5) {
		return ("Last week.");
	    } else {
		return (Math.floor(i) + " weeks ago");
	    }
	} else {
	    var i = days/30;
	    if (i<18) {
		return (Math.round(i) + " months ago");
	    } else if (i<30){
		i /= 12;
		return ("About " + Math.round(i) + " years ago");
	    } else {
		i /= 12;
		return (Math.round(i) + " years ago");
	    }
	} 
    }
}

function daysUntil (month, day, year){
    var date = new Date();
    date.setFullYear(year, month-1, day);
    var today = new Date();

    // The diff to the date, but we really only care about days, not milliseconds
    var days = (date.getTime() - today.getTime())/(86400*1000);
    return (Math.floor(days));
}


