$(document).ready(function() {

	// Edit the following to change the date we count down to...
	var expiry = parseInt(Date.parse("February 14, 2012")/1000);
	var message = 'Happy Valentines Day!';
	$('#eventname').html('Valentines Day'); // Replace with the name of the event.
	
	// DO NOT EDIT BELOW THIS LINE
	
	$('#countdown').show(0);
	var countdown = function() {
		var now = new Date();
		var current = parseInt(now.getTime()/1000);
		var diff_seconds = expiry - current;
		if (diff_seconds > 0) {
			var weeks = Math.floor(diff_seconds / 604800)
				days  = Math.floor(diff_seconds % 604800 / 86400),
				hours = Math.floor(diff_seconds % 604800 % 86400 / 3600),
				mins  = Math.floor(diff_seconds % 604800 % 86400 % 3600 / 60);
				
			if (Math.floor(diff_seconds / 86400) <=28) {
				$('#weeknum,#weektext').hide();
				$('#daynum,#daytext,#hournum,#hourtext,#minnum,#mintext').width(55);
				days = Math.floor(diff_seconds / 86400);
			} else {
				$('#weeknum').html(weeks);
			}
			$('#daynum').html(days);
			$('#hournum').html(hours);
			$('#minnum').html(mins);
		}
		else if (current < parseInt(expiry + 86400)) {$('#countdown').html(message);return;}
		else {$('#countdown').hide();return;}
	}
	setInterval(countdown, 10000);
	countdown();
});
