3
<title>Date Selector</title>
4
<script language="JavaScript">
9
return (number < 1000) ? number + 1900 : number;
15
function _rgb2hex(red,green,blue)
17
var html_red = red.toString(16).toUpperCase();
18
var html_green = green.toString(16).toUpperCase();
19
var html_blue = blue.toString(16).toUpperCase();
20
if (html_red.length == 1) {
21
html_red = "0" + html_red
24
if (html_green.length == 1) {
25
html_green = "0" + html_green
28
if (html_blue.length == 1) {
29
html_blue = "0" + html_blue
32
return '#' + html_red + html_green + html_blue;
38
function _hex2rgb(htmlcode)
40
var htmlcode = htmlcode.replace(/#/,'');
41
var rgb = new Array();
42
rgb["red"] = parseInt(htmlcode.substr(0,2),16);
43
rgb["green"] = parseInt(htmlcode.substr(2,2),16);
44
rgb["blue"] = parseInt(htmlcode.substr(4,2),16);
51
function getDarkColor(htmlcode)
53
var decimalcolor = _hex2rgb(htmlcode);
54
decimalcolor["red"] = Math.max(0,decimalcolor["red"]-40);
55
decimalcolor["green"] = Math.max(0,decimalcolor["green"]-40);
56
decimalcolor["blue"] = Math.max(0,decimalcolor["blue"]-40);
57
return _rgb2hex(decimalcolor["red"],decimalcolor["green"],decimalcolor["blue"]);
62
if (typeof(window.opener.calendarStartMonday) == 'undefined') {
63
var calendarStartMonday = false;
66
var calendarStartMonday = window.opener.calendarStartMonday ? true : false;
69
// get the date format
70
if (typeof(window.opener.calendarFormat) == 'undefined') {
71
var calendarFormat = 'y/m/d';
73
// we are doing on a leap of faith here that the user has 'm','d' and 'y' only in the format
75
var calendarFormat = window.opener.calendarFormat;
78
// get the calendarColors variable and setup the colors
79
if (typeof(window.opener.calendarColors) == 'undefined') {
80
alert('Please configure the colors by setting the calendarColors array!');
84
// grab the color settings
85
var calendarColors = window.opener.calendarColors;
86
// set defaults for the selected date to be a darker color
87
if (typeof(calendarColors['dateSelectedBgColor']) == 'undefined') {
88
calendarColors['dateSelectedBgColor'] = getDarkColor(calendarColors['dateBgColor']);
91
if (typeof(calendarColors['dateSelectedColor']) == 'undefined') {
92
calendarColors['dateSelectedColor'] = calendarColors['dateColor'];
95
if (typeof(window.opener.calendarMonths) == 'undefined' || window.opener.calendarMonths.length != 12) {
96
var calendarMonths = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
99
var calendarMonths = window.opener.calendarMonths;
102
if (typeof(window.opener.calendarWeekdays) == 'undefined' || window.opener.calendarWeekdays.length != 8) {
103
// we have two sundays to accomodate for calendars starting on monday
104
var calendarWeekdays = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S', 'S');
107
var calendarWeekdays = window.opener.calendarWeekdays;
110
var calendarDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
113
var right_still = "arrows_r_still.gif"
114
var right_anim = "arrows_r_anim.gif"
115
var left_still = "arrows_l_still.gif"
116
var left_anim = "arrows_l_anim.gif"
118
// get the reference to the target element and setup the date
119
var targetDateField = window.opener.calendarTarget;
120
var dateString = targetDateField.value;
122
if (dateString != '' &&
123
(typeof(window.opener.calendarUseToday) == 'undefined' || !window.opener.calendarUseToday)) {
124
// convert the user format of the date into something we use to make a javascript Date object
125
// we need to pad with placeholders to get the rigth offset
126
tmp_format = calendarFormat.replace(/m/i, 'mm').replace(/d/i, 'dd').replace(/y/i, 'yyyy');
127
tmp_yOffset = tmp_format.indexOf('y');
128
tmp_mOffset = tmp_format.indexOf('m');
129
tmp_dOffset = tmp_format.indexOf('d');
130
var today = new Date(dateString.substring(tmp_yOffset, tmp_yOffset + 4), dateString.substring(tmp_mOffset, tmp_mOffset +
131
2) - 1, dateString.substring(tmp_dOffset, tmp_dOffset + 2));
133
if ((today == "Invalid Date") || (isNaN(today))) {
134
var today = new Date();
139
var today = new Date();
142
var day = today.getDate();
143
var year = y2k(today.getYear());
144
var month = today.getMonth();
146
var currentDay = day;
147
var currentYear = year;
148
var currentMonth = month;
151
<frameset frameborder="0" framespacing="0" ROWS="100%,*">
152
<frame scrolling="no" frameborder="0" marginheight="0" marginwidth="0" name="cal" noresize src="calendar_body.html">