Handling dates in Javascript

A few tips.

Comparing Dates In Javascript / Actionscript

If you have two date objects, you need to compare their values returned by their valueOf or getTime methods:
date1.valueOf() > new Date().valueOf()

If you are only after the difference in days, a quickt way of doing it is:
Math.floor( ( date1 - date2 ) / 86400000 );

Working With Weeks In Javascript / Actionscript

To find the start of the week:
//Mon=1, Tue=2,.., Sun=7
var start = 1;
date1.setDate( date1.getDate() - ( date1.getDay() + 7 - start ) % 7 )