port from http://jquery-jcal.googlecode.com/svn/trunk/