日期:2013-08-24  浏览次数:20900 次

calendar.css:
.cal {
background-color: #ffffff;
}

.head {
color: #bb0000;
font-family: Arial;
font-weight: bold;
text-align: left;
}

.days {
color: #0000bb;
font-family: Arial;
font-weight: bold;
text-align: right;
}

.grey {
color: #ffffff;
font-family: Arial;
font-size: small;
text-align: right;
}

.links {
color: #ff0000;
font-family: Arial;
font-size: small;
text-align: right;
}

.today {
color: #ffffff;
background-color: #ff0000;
font-family: Arial;
font-size: small;
text-align: right;
}

calendar.js:
'January','February','March',
'April','May','June','July',
'August','September','October',
'November','December'
);

var daysOfMonth = new Array(
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
);

var daysOfMonthLY = new Array(
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
);

var dow = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat',
'Sun','Mon','Tue','Wed','Thu','Fri');

var size = 'width="50" height="30"';
var border = 'border="1"';

function isLeapYear(num) {
if (((num % 4 == 0) && (num % 100 != 0)) || (num % 400 == 0))
return true;
return false;
}

function CalendarSelect(Month,Year, offset) {
if (offset == null) offset = 0;

if (window.changeMonth) { }
else {
alert('A changeMonth() function has not been defined');
return '';
}

if (window.changeYear) { }
else {
alert('A changeYear() function has not been defined');
return '';
}

if (window.changeDay) { }
else {
alert('A changeDay() function has not been defined');
return '';
}

var output = '';

output += '<form name="Cal">';
output += CalendarHead(Month,Year,true);
output += CalendarMonth(Month,Year,offset);
output += '</form>';

return output;
}

function CalendarHead(Month,Year,Select) {
var output = '';

output +=
'<table cellspacing="0" class="cal">' +
'<tr><td align="left" width="100%" class="head">' +
moy[Month-1] + ' ' + Year +
'</td>';

if (Select) {

output += '<td width="50%" align="right">' +
'<select name="Month" onChange="CalMonth()">';

for (var month=1; month<=12; month++) {
output += '<option value="' + month + '"';
if (month == Month) output += ' selected';
output += '>' + moy[month-1] + '</option>';
}

output += '</select>' +
'<select name="Year" onChange="CalYear();">';

for (var year=1900; year<=2100; year++) {
output += '<option value="' + year + '"';
if (year == Year) output += ' selected';
output += '>' + year + '</option>';
}

output += '</select>';
}

output += '</td></tr></table>';

return output;
}

function CalendarMonth(M,Y,offset) {
M--;
if (offset == null) offset = 0;

firstDay = new Date(Y,M,1);
startDay = firstDay.getDay();

if (startDay < offset) startDay += 7;

var days = daysOfMonth;
if (isLeapYear(Y)) days = daysOfMonthLY;

var output = '';

output +=
'<table ' + border + ' cellpadding="0" class="cal"><tr>';

for (var i=0