function Calendar()
{
} // Calendar
Calendar._allowPast = false;
Calendar._autoHideDate = true;
Calendar._cmdName = null;
Calendar._dateControl = null;
Calendar._day = null;
Calendar._firstMonth = 0;
Calendar._firstYear = 0;
Calendar._lastMonth = 0;
Calendar._lastYear = 0;
Calendar._month = null;
Calendar._year = null;
Calendar.hideDateFields = function()
{
if ((!Calendar._autoHideDate) ||
(!Calendar._dateControl))
{
return;
} // if
var temp = new Array(
'Day',
'Hour',
'Meridian',
'Minute',
'Month',
'Second',
'Year');
for (var i in temp)
{
var elem = document.getElementById(Calendar._dateControl + temp[i]);
if (elem)
{
elem.style.visibility = 'hidden';
} // if
} // for
} // hideDateFields
Calendar.loadPopupCalGrid = function(year,
month,
day,
dateControl,
autoHideDate,
cmdName,
allowPast,
firstYear,
firstMonth,
lastYear,
lastMonth)
{
if ((dateControl != null) && (dateControl != undefined))
{
Calendar._dateControl = dateControl;
} // if
else
{
dateControl = Calendar._dateControl;
} // else
if ((autoHideDate != null) && (autoHideDate != undefined))
{
Calendar._autoHideDate = autoHideDate;
} // if
else
{
autoHideDate = Calendar._autoHideDate;
} // else
Calendar.hideDateFields();
document.getElementById('popupCalClose').style.display = 'none';
document.getElementById('popupCalLoad').style.display = 'inline';
if ((year != null) && (year != undefined))
{
Calendar._year = year;
} // if
else if ((Calendar._year == null) && (dateControl != null))
{
year = document.getElementById(dateControl + 'Year').value;
Calendar._year = year;
} // else if
else
{
year = Calendar._year;
} // else
if ((month != null) && (month != undefined))
{
Calendar._month = month;
} // if
else if ((Calendar._month == null) && (dateControl != null))
{
month = document.getElementById(dateControl + 'Month').value;
Calendar._month = month;
} // else if
else
{
month = Calendar._month;
} // else
if ((day != null) && (day != undefined))
{
Calendar._day = day;
} // if
else if ((Calendar._day == null) && (dateControl != null))
{
day = document.getElementById(dateControl + 'Day').value;
Calendar._day = day;
} // else if
else
{
day = Calendar._day;
} // else
if ((cmdName != null) && (cmdName != undefined))
{
Calendar._cmdName = cmdName;
} // if
else
{
cmdName = Calendar._cmdName;
} // else
if ((allowPast != null) && (allowPast != undefined))
{
Calendar._allowPast = allowPast;
} // if
if ((firstYear != null) && (firstYear != undefined))
{
Calendar._firstYear = firstYear;
} // if
if ((firstMonth != null) && (firstMonth != undefined))
{
Calendar._firstMonth = firstMonth;
} // if
if ((lastYear != null) && (lastYear != undefined))
{
Calendar._lastYear = lastYear;
} // if
if ((lastMonth != null) && (lastMonth != undefined))
{
Calendar._lastMonth = lastMonth;
} // if
if (cmdName)
{
var data = {
'year'         : year,
'month'        : month,
'day'          : day,
'dateControl'  : dateControl
};
Core.ajaxSendCommand(cmdName,
{ 'month' : month, 'year' : year },
Calendar._popupCalLoadCallback,
data);
} // if
else
{
Calendar._finishCalPopupLoad(year,
month,
day,
dateControl)
} // else
} // loadPopupCalGrid
Calendar.loadNextPopupCalGrid = function()
{
if (Calendar._nextOk())
{
Calendar._month++;
if (Calendar._month > 12)
{
Calendar._year++;
Calendar._month = 1;
} // if
} // if
Calendar.loadPopupCalGrid();
} // nextPopupCalGrid
Calendar.loadPrevPopupCalGrid = function()
{
if (Calendar._prevOk())
{
Calendar._month--;
if (Calendar._month < 1)
{
Calendar._year--;
Calendar._month = 12;
} // if
} // if
Calendar.loadPopupCalGrid();
} // prevPopupCalGrid
Calendar.showDateFields = function()
{
if ((!Calendar._autoHideDate) ||
(!Calendar._dateControl))
{
return;
} // if
var temp = new Array(
'Day',
'Hour',
'Meridian',
'Minute',
'Month',
'Second',
'Year');
for (var i in temp)
{
var elem = document.getElementById(Calendar._dateControl + temp[i]);
if (elem)
{
elem.style.visibility = '';
} // if
} // for
} // showDateFields
Calendar._changeDateControl = function(day)
{
var elem = document.getElementById(Calendar._dateControl + 'Year');
if (elem)
{
elem.value = Calendar._year;
} // if
elem = document.getElementById(Calendar._dateControl + 'Month');
if (elem)
{
elem.value = Calendar._month;
if (parseInt(Calendar._month) < 10)
{
elem.value = '0' + Calendar._month;
} // if
} // if
elem = document.getElementById(Calendar._dateControl + 'Day');
if (elem)
{
elem.value = day;
if (parseInt(day) < 10)
{
elem.value = '0' + day;
} // if
} // if
} // _changeDateControl
Calendar._finishCalPopupLoad = function(year,
month,
day,
dateControl,
days)
{
if (Calendar._prevOk())
{
document.getElementById('popupCalPrev').style.display = 'inline';
} // if
else
{
document.getElementById('popupCalPrev').style.display = 'none';
} // else
if (Calendar._nextOk())
{
document.getElementById('popupCalNext').style.display = 'inline';
} // if
else
{
document.getElementById('popupCalNext').style.display = 'none';
} // else
var dt;
if (dateControl)
{
var curYear = document.getElementById(dateControl + 'Year').value;
var curMonth = document.getElementById(dateControl + 'Month').value;
var curDay = document.getElementById(dateControl + 'Day').value;
} // if
else
{
dt = new Date();
var curYear = dt.getFullYear();
var curMonth = dt.getMonth() + 1;
var curDay = dt.getDate();
} // else
dt = new Date(year,
month - 1,
1,
12,
0,
0,
0);
var elem = document.getElementById('popupCalTitle');
Utils.removeChildren(elem);
elem.appendChild(document.createTextNode(Utils.getMonthString(dt.getMonth() + 1) + ' ' + dt.getFullYear()));
var d = 1;
var start = dt.getDay();
var end = Utils.getDaysInMonth(year,
month);
var monthInPast = ((year < curYear) || ((month < curMonth) && (year == curYear)));
var show5 = false;
var show6 = false;
for (var j = 0; j < 42; j++)
{
elem = document.getElementById('popupCalCell' + j);
elem.className = '';
Utils.removeChildren(elem);
if ((j < start) ||
(d > end))
{
elem.appendChild(document.createTextNode('\u00A0'));
} // if
else
{
if (j > 27)
{
show5 = true;
} // if
if (j > 34)
{
show6 = true;
} // if
var action = '';
if ((!monthInPast) && (month == curMonth) && (d == curDay))
{
elem.className = 'cellCurrent';
} // if
if ((!Calendar._allowPast) &&
((monthInPast) || ((month == curMonth) && (year == curYear) && (d < curDay))))
{
elem.className = 'cellPast';
} // if
else if ((days) &&
(days[d]))
{
if (days[d]['action'])
{
action = days[d]['action'] + ';';
} // if
if (parseInt(days[d]['updateDate']))
{
action += 'Calendar._changeDateControl(' + d + ');';
} // if
if (parseInt(days[d]['close']))
{
action += "Calendar.showDateFields();Popup.hide('popupCal');";
} // if
if (action)
{
elem.className = 'cellAvail';
} // if
if (days[d]['class'])
{
elem.className = days[d]['class'];
} // if
} // if
else if (dateControl)
{
action = "Calendar._changeDateControl(" + d + ");Calendar.showDateFields();Popup.hide('popupCal');";
} // else if
if (action)
{
var a = document.createElement('a');
a.setAttribute('href',
'javascript:' + action + 'void(0);');
a.setAttribute('onfocus',
'this.blur();');
elem.appendChild(a);
a.appendChild(document.createTextNode(d));
} // if
else
{
elem.appendChild(document.createTextNode(d));
} // else
d++;
} // else
} // for
if (show5)
{
document.getElementById('popupCalGridRow5').style.display = '';
} // if
else
{
document.getElementById('popupCalGridRow5').style.display = 'none';
} // else
if (show6)
{
document.getElementById('popupCalGridRow6').style.display = '';
} // if
else
{
document.getElementById('popupCalGridRow6').style.display = 'none';
} // else
document.getElementById('popupCalLoad').style.display = 'none';
document.getElementById('popupCalClose').style.display = 'inline';
} // _finishCalPopupLoad
Calendar._nextOk = function()
{
return ((!Calendar._lastMonth) || (!Calendar._lastYear) || (Calendar._year < Calendar._lastYear) || ((Calendar._month < Calendar._lastMonth) && (Calendar._year == Calendar._lastYear)));
} // _nextOk
Calendar._popupCalLoadCallback = function(obj,
data,
status,
reason)
{
if ((obj) &&
(data))
{
Calendar._finishCalPopupLoad(data.year,
data.month,
data.day,
data.dateControl,
obj.days)
} // if
} // _popupCalLoadCallback
Calendar._prevOk = function()
{
return ((Calendar._allowPast) || (!Calendar._firstMonth) || (!Calendar._firstYear) || (Calendar._year > Calendar._firstYear) || ((Calendar._month > Calendar._firstMonth) && (Calendar._year == Calendar._firstYear)));
} // _prevOk
