// JavaScript Document
function y2k(number)    { return (number < 1000) ? number + 1900 : number; }
var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
var thisField;

function padout(number) { return (number < 10) ? '0' + number : number; }
function restart() {
    document.data.date.value = '' + padout(month - 0 + 1) + '/' + padout(day) + '/' + year;
    mywindow.close();
}
function newWindow() {
    mywindow=open('cal.htm','myname','resizable=no,width=350,height=270');
    mywindow.location.href = 'cal.aspx';
    if (mywindow.opener == null) mywindow.opener = self;
}
function Calendar(Month,Year) {
    var output = '';    
    output += '<FORM NAME="Cal"><TABLE BORDER=0><TR><TD ALIGN=LEFT WIDTH=100%>';
    output += '<FONT COLOR="#8F1736" FACE="Arial" SIZE=+1>' + names[Month] + ' ' + Year + '<\/FONT><\/TD><TD WIDTH=50% ALIGN=RIGHT>';
    output += '<SELECT NAME="Month" onChange="changeMonth();">';
    for (month=0; month<12; month++) {
        if (month == Month) output += '<OPTION VALUE="' + month + '" SELECTED>' + names[month] + '<\/OPTION>';
        else                output += '<OPTION VALUE="' + month + '">'          + names[month] + '<\/OPTION>';
    }
    output += '<\/SELECT><SELECT NAME="Year" onChange="changeYear();">';
    for (year=2005; year<2007; year++) {
        if (year == Year) output += '<OPTION VALUE="' + year + '" SELECTED>' + year + '<\/OPTION>';
        else              output += '<OPTION VALUE="' + year + '">'          + year + '<\/OPTION>';
    }
    output += '<\/SELECT><\/TD><\/TR><TR><TD ALIGN=CENTER COLSPAN=2>';
    firstDay = new Date(Year,Month,1);
    startDay = firstDay.getDay();
    if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
         days[1] = 29; 
    else
         days[1] = 28;
    output += '<TABLE CALLSPACING=0 CELLPADDING=0 BORDER=1 BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#C0C0C0"><TR>';
    for (i=0; i<7; i++)
        output += '<TD WIDTH=50 ALIGN=CENTER VALIGN=MIDDLE><FONT SIZE=-1 COLOR="#8F1736" FACE="ARIAL"><B>' + dow[i] +'<\/B><\/FONT><\/TD>';
    output += '<\/TR><TR ALIGN=CENTER VALIGN=MIDDLE>';
    var column = 0;
    var lastMonth = Month - 1;
    if (lastMonth == -1) lastMonth = 11;
    for (i=0; i<getDay(); i++, column++)
        output += '<TD WIDTH=50 HEIGHT=30><FONT SIZE=-1 COLOR="#808080" FACE="ARIAL">' + (days[lastMonth]-startDay+i+1) + '<\/FONT><\/TD>';
    for (i=1; i<=days[Month]; i++, column++) {
        output += '<TD WIDTH=50 HEIGHT=30>' + '<A HREF="javascript:changeDay(' + i + ')" style:"color:#8F1736;"><FONT SIZE=-1 FACE="ARIAL" COLOR="#8F1736">' + i + '<\/FONT><\/A>' +'<\/TD>';
        if (column == 6) {
            output += '<\/TR><TR ALIGN=CENTER VALIGN=MIDDLE>';
            column = -1;
        }
    }
    if (column > 0) {
        for (i=1; column<7; i++, column++)
            output +=  '<TD WIDTH=50 HEIGHT=30><FONT SIZE=-1 COLOR="#808080" FACE="ARIAL">' + i + '<\/FONT><\/TD>';
    }
    output += '<\/TR><\/TABLE><\/FORM><\/TD><\/TR><\/TABLE>';
    return output;
}
function changeDay(day) {
    opener.day = day + '';
    opener.restart();
    self.close;
}
function changeMonth() {
    opener.month = document.Cal.Month.options[document.Cal.Month.selectedIndex].value + '';
    location.href = 'cal.htm';
}
function changeYear() {
    opener.year = document.Cal.Year.options[document.Cal.Year.selectedIndex].value + '';
    location.href = "cal.htm";
}
function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}
var names     = new makeArray0('January','February','March','April','May','June','July','August','September','October','November','December');
var days      = new makeArray0(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var dow       = new makeArray0('Sun','Mon','Tue','Wed','Thu','Fri','Sat');