function dayofyear(d) {   // d is a Date object
	var yn = d.getFullYear();
	var mn = d.getMonth();
	var dn = d.getDate();
	var d1 = new Date(yn,0,1,12,0,0); // noon on Jan. 1
	var d2 = new Date(yn,mn,dn,12,0,0); // noon on input date
	var ddiff = Math.round((d2-d1)/864e5);
	return ddiff+1;
}

$(document).ready(function() {
	// detect leap year, if so
	now = new Date
	theYear=now.getYear()
	var isLeap = new Date(theYear,1,29).getDate() == 29;	
	if (isLeap) {
		$('#cal').css('backgroundImage', 'url(assets/img/calendar-strip-leap.jpg)');
	}
	
	day = dayofyear(new Date());
	
	var pos = Math.round(((day - 1) * -37.23) + 335);
	$("#cal").css("backgroundPosition", pos + "px 0");
	
});
