var OneDay = 1000*60*60*24;
function subtractDates (firstDate,secondDate){ return Math.ceil((new Date(firstDate).getTime()
-new Date(secondDate).getTime())/(OneDay));
}
function addDays (dateToAdd,amountInDays){ return new Date(dateToAdd.valueOf() + this.OneDay * amountInDays);
}
function daysInMonth (year,month){ var m = [31,28,31,30,31,30,31,31,30,31,30,31];
if (month != 2)
return m[month - 1];
if (year%4 != 0)
return m[1];
if (year%100 == 0 && year%400 != 0)
return m[1]
return m[1] + 1;
}
function isDate(dateStr){ var ok;
try{ var d = Date.parse(dateStr);
return true;
}catch(x){ return false;
}
}