JavaScript date pagination