<!--

var WEEKDAYS =
  new Array(
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
)

var MONTHS =
  new Array(
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
)

function SuperDate(init_date) {
  this.date = new Date();
  if(init_date) this.date.setTime(init_date.getTime());
}


/////// New Methods ///////

/*

%MM  - The month name (January)
%mon - The month abbreviation (Jan). Not case sensitive.
%mm  - The padded month number (01)
%m   - The unpadded month number (1)

%WW  - The day name (Monday)
%www - The day abbreviation (Mon)
%ww  - The day abbreviation (Mo)

%dd  - The padded day number (05)
%d   - The unpadded day number (5)

%yyyy- The full year number (2001). Will display years 0 - 99 as 1900 - 1999
%yy  - The abbreviated year number (01)

%HH  - The padded hour number (07) in military time. Use %hh for standard
%H   - The unpadded hour number (7) in military time. Use %h for standard

%p   - AM or PM as appropriate. Not case sensitive.

%nn  - The padded minute number (08)
%n   - The unpadded minute number (8)

%ss  - The padded seconds number (09)
%s   - The unpadded seconds number (9)

*/

function SuperDate_format(mask) {
  mask = mask.replace(/%MM/g, MONTHS[this.getMonth()])
  mask = mask.replace(/%mon/gi, MONTHS[this.getMonth()].substr(0, 3))
  mask = mask.replace(/%mm/g, fill(this.getMonth() + 1, 2))
  mask = mask.replace(/%m/g, this.getMonth() + 1)
  mask = mask.replace(/%WW/g, WEEKDAYS[this.getDay()])
  mask = mask.replace(/%ww/g, WEEKDAYS[this.getDay()].substr(0, 2))
  mask = mask.replace(/%www/g, WEEKDAYS[this.getDay()].substr(0, 3))
  mask = mask.replace(/%dd/g, fill(this.getDate(), 2))
  mask = mask.replace(/%d/g, this.getDate())
  mask = mask.replace(/%yyyy/g, this.getYear())
  var yString = "" + this.getYear()
  mask = mask.replace(/%yy/g, yString.substr(yString.length - 2), 2)
  mask = mask.replace(/%HH/g, fill(this.getHours() == 0 ? 0 : this.getHours(), 2))
  mask = mask.replace(/%H/g, this.getHours() == 0 ? 0 : this.getHours())
  mask = mask.replace(/%hh/g, fill(this.getHours() > 12 ? this.getHours() - 12 : this.getHours() == 0 ? 12 : this.getHours(), 2))
  mask = mask.replace(/%h/g, this.getHours() > 12 ? this.getHours() - 12 : this.getHours() == 0 ? 12 : this.getHours())
  mask = mask.replace(/%p/gi, this.getHours() >= 12 ? "PM" : "AM")
  mask = mask.replace(/%nn/g, fill(this.getMinutes(), 2))
  mask = mask.replace(/%n/g, this.getMinutes())
  mask = mask.replace(/%ss/g, fill(this.getSeconds(), 2))
  mask = mask.replace(/%s/g, this.getSeconds())

  return mask
}
SuperDate.prototype.format = SuperDate_format

//shiftDate
function SuperDate_shiftDate(n) { this.date.setDate(this.getDate() + (1 * n)) }
SuperDate.prototype.shiftDate = SuperDate_shiftDate;
 
//shiftHours
function SuperDate_shiftHours(n) { this.date.setHours(this.getHours() + (1 * n)) }
SuperDate.prototype.shiftHours = SuperDate_shiftHours;
 
//shiftMinutes
function SuperDate_shiftMinutes(n) { this.date.setMinutes(this.getMinutes() + (1 * n)) }
SuperDate.prototype.shiftMinutes = SuperDate_shiftMinutes;
 
//shiftMonth
function SuperDate_shiftMonth(n) { this.date.setMonth(this.getMonth() + (1 * n)) }
SuperDate.prototype.shiftMonth = SuperDate_shiftMonth;
 
//shiftSeconds
function SuperDate_shiftSeconds(n) { this.date.setSeconds(this.getSeconds() + (1 * n)) }
SuperDate.prototype.shiftSeconds = SuperDate_shiftSeconds;
 
//shiftTime
function SuperDate_shiftTime(n) { this.date.setTime(this.getTime() + (1 * n)) }
SuperDate.prototype.shiftTime = SuperDate_shiftTime;

//shiftYear
function SuperDate_shiftYear(n) { this.date.setYear(this.getYear() + (1 * n)) }
SuperDate.prototype.shiftYear = SuperDate_shiftYear;

//daysInMonth
function SuperDate_daysInMonth() {
  var month = this.getMonth();
  if(month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11)
    return 31;
  if(month == 3 || month == 5 || month == 8 || month == 10)
    return 30;
  if(this.isLeapYear())
    return 29;
  return 28;
}
SuperDate.prototype.daysInMonth = SuperDate_daysInMonth;

//firstOfMonth
function SuperDate_firstOfMonth() { return new SuperDate(new Date (this.getYear(), this.getMonth(), 1)) }
SuperDate.prototype.firstOfMonth = SuperDate_firstOfMonth;

//isLeapYear()
function SuperDate_isLeapYear () {
  var year = this.getYear();
  return !(year % 4) && (year % 100 || !(year % 400)) ? true : false;
}
SuperDate.prototype.isLeapYear = SuperDate_isLeapYear;

//calendarMonth
function SuperDate_calendarMonth() {
  var daysInMonth  = this.daysInMonth();
  var firstOfMonth = this.firstOfMonth();
  var startDate    = firstOfMonth.getDay();

  var calendar = new Array();
  var week = new Array();

  for(var i = 0, d = 0, w = 0; ; i++) {
    if(!(i % 7)) {
      if(i)
        calendar.push(week);
      if(d >= daysInMonth)
        break;
      week = new Array();
    }

    if(i < startDate && !d) d = -1;

    week.push(d < daysInMonth ? ++d : 0);
  }

  return calendar;
}
SuperDate.prototype.calendarMonth = SuperDate_calendarMonth;




/////// Modified Methods ///////

//getYear
function SuperDate_getYear() {
  var y = this.date.getYear()
  if(document.all) {
    return (y >= 0 && y <= 99 ? 1900 + y : y)
  }
  else {
    return 1900 + y
  }
}
SuperDate.prototype.getYear = SuperDate_getYear;
 



/////// Original Methods ///////

//getDate
function SuperDate_getDate() { return this.date.getDate(); }
SuperDate.prototype.getDate = SuperDate_getDate;
 
//getDay
function SuperDate_getDay() { return this.date.getDay(); }
SuperDate.prototype.getDay = SuperDate_getDay;
 
//getHours
function SuperDate_getHours() { return this.date.getHours(); }
SuperDate.prototype.getHours = SuperDate_getHours;
 
//getMinutes
function SuperDate_getMinutes() { return this.date.getMinutes(); }
SuperDate.prototype.getMinutes = SuperDate_getMinutes;
 
//getMonth
function SuperDate_getMonth() { return this.date.getMonth(); }
SuperDate.prototype.getMonth = SuperDate_getMonth;
 
//getSeconds
function SuperDate_getSeconds() { return this.date.getSeconds(); }
SuperDate.prototype.getSeconds = SuperDate_getSeconds;
 
//getTime
function SuperDate_getTime() { return this.date.getTime(); }
SuperDate.prototype.getTime = SuperDate_getTime;
 
//getTimezoneOffset
function SuperDate_getTimezoneOffset() { return this.date.getTimezoneOffset(); }
SuperDate.prototype.getTimezoneOffset = SuperDate_getTimezoneOffset;
 
//parse
function SuperDate_parse() { return this.date.parse(); }
SuperDate.prototype.parse = SuperDate_parse;
 
//setDate
function SuperDate_setDate(d) { this.date.setDate(d); }
SuperDate.prototype.setDate = SuperDate_setDate;
 
//setHours
function SuperDate_setHours(h) { this.date.setHours(h); }
SuperDate.prototype.setHours = SuperDate_setHours;
 
//setMinutes
function SuperDate_setMinutes(m) { this.date.setMinutes(m); }
SuperDate.prototype.setMinutes = SuperDate_setMinutes;
 
//setMonth
function SuperDate_setMonth(m) { this.date.setMonth(m); }
SuperDate.prototype.setMonth = SuperDate_setMonth;
 
//setSeconds
function SuperDate_setSeconds(s) { this.date.setSeconds(s); }
SuperDate.prototype.setSeconds = SuperDate_setSeconds;
 
//setTime
function SuperDate_setTime(t) { this.date.setTime(t); }
SuperDate.prototype.setTime = SuperDate_setTime;
 
//setYear
function SuperDate_setYear(y) { this.date.setYear(y); }
SuperDate.prototype.setYear = SuperDate_setYear;
 
//toGMTString
function SuperDate_toGMTString() { return this.date.toGMTString(); }
SuperDate.prototype.toGMTString = SuperDate_toGMTString;
 
//toLocaleString
function SuperDate_toLocaleString(year, month, day, hrs, min, sec) { return this.date.toLocaleString(year, month, day, hrs, min, sec); }
SuperDate.prototype.toLocaleString = SuperDate_toLocaleString;

//UTC
function SuperDate_UTC(d) { return this.date.UTC(); }
SuperDate.prototype.UTC = SuperDate_UTC;



/////// Other Functions //////////

function fill(n, d) {
  var digits = 0
  var temp = n
  while(temp > 0) {
    temp = Math.floor(temp / 10)
    digits++
  }
  if(n == 0) digits = 1

  while(digits != d) {
    n = "0" + n
    digits++
  }

  return n
}

//-->