var calendarVisible = false;
var today;
var yearBegin;
var yearEnd;
var monthsText;
var daysText;
var headerText;
var headerColor;
var backgroundColor;
var previousImgSrc;
var nextImgSrc;
var transparencyImgSrc;
var slcExtDate;
var slcExtMonth;
var slcExtYear;
document.write("");
function _OnLoanItem_WAR_elmu_getAbsoluteLeft(obj) {
var i = 0;
while (obj != null) {
i += obj.offsetLeft;
obj = obj.offsetParent;
}
return i;
}
function _OnLoanItem_WAR_elmu_getAbsoluteTop(obj) {
var i = 0;
while (obj != null) {
i += obj.offsetTop;
obj = obj.offsetParent;
}
return i;
}
function _OnLoanItem_WAR_elmu_getSelectValue(select) {
return select.options[select.selectedIndex].value;
}
function _OnLoanItem_WAR_elmu_setSelectValue(select, value) {
for (var i = 0; i < select.length; i++) {
if (select.options[i].value == value) {
select.options[i].selected = true;
return true;
}
}
return false;
}
function _OnLoanItem_WAR_elmu_drawCalendar(month, year) {
if (month == -1) {
if (year == -1) {
month = today.getMonth() + 1;
} else {
month = 1;
}
}
if (year == -1) {
year = today.getFullYear();
}
if ((month == 1) && (year == yearBegin)) {
document.images["previous"].style.cursor = "default";
var width = document.images["previous"].width;
var height = document.images["previous"].height;
document.images["previous"].src = transparencyImgSrc;
document.images["previous"].width = width;
document.images["previous"].height = height;
document.images["next"].style.cursor = "hand";
document.images["next"].src = nextImgSrc;
} else if ((month == 12) && (year == yearEnd)) {
document.images["previous"].style.cursor = "hand";
document.images["previous"].src = previousImgSrc;
document.images["next"].style.cursor = "default";
var width = document.images["next"].width;
var height = document.images["next"].height;
document.images["next"].src = transparencyImgSrc;
document.images["next"].width = width;
document.images["next"].height = height;
} else {
document.images["previous"].style.cursor = "hand";
document.images["previous"].src = previousImgSrc;
document.images["next"].style.cursor = "hand";
document.images["next"].src = nextImgSrc;
}
_OnLoanItem_WAR_elmu_setSelectValue(document.frmCalendar.slcCalendarMonth, month);
_OnLoanItem_WAR_elmu_setSelectValue(document.frmCalendar.slcCalendarYear, year);
var spnInnerCalendar = document.getElementById('spnInnerCalendar');
spnInnerCalendar.innerHTML = _OnLoanItem_WAR_elmu_paintCalendar(month, year);
}
function _OnLoanItem_WAR_elmu_hideCalendar() {
var spnOuterCalendar = document.getElementById('spnOuterCalendar');
spnOuterCalendar.style.visibility = "hidden";
calendarVisible = false;
}
function _OnLoanItem_WAR_elmu_paintCalendar(month, year) {
var lastDate = 28;
while ((new Date(year, month - 1, lastDate + 1)).getMonth() == month - 1) {
lastDate++;
}
var firstDay = (new Date(year, month - 1, 1)).getDay();
var begin = false;
if (firstDay == 0) {
begin = true;
}
var date = 1;
var html = "";
html += "
";
html += " ";
html += " | ";
html += " | ";
html += " ";
html += " ";
for (var i = 0; i < 7; i++) {
html += " " + days[i] + " | ";
}
html += "
";
for (var j = 0; j < 6; j ++) {
html+=" ";
for (var k = 0; k < 7; k ++) {
if (begin) {
var matchedToday = (date == today.getDate() && month == today.getMonth() + 1 && year == today.getFullYear());
var matchedSelected = (date == _OnLoanItem_WAR_elmu_getSelectValue(slcExtDate) && month == _OnLoanItem_WAR_elmu_getSelectValue(slcExtMonth) && year == _OnLoanItem_WAR_elmu_getSelectValue(slcExtYear));
html += "";
html += "";
html += "" + (matchedSelected ? "" : "") + date + (matchedSelected ? "" : "") + "";
html += "";
html += " | ";
date++;
if (date > lastDate) {
begin = false;
}
} else {
html += " | ";
if (date < lastDate && k + 1 == firstDay) {
begin = true;
}
}
}
html+="
";
}
html += "
";
html += " ";
html += " | ";
html += "
";
html += "
";
return html;
}
function _OnLoanItem_WAR_elmu_showCalendar(left, top, date, year1, year2, months, days, header, hdcolor, bgcolor, previous, next, transparency, dateSelect, monthSelect, yearSelect) {
if (calendarVisible) {
_OnLoanItem_WAR_elmu_hideCalendar();
} else {
today = date;
yearBegin = year1;
yearEnd = year2;
monthsText = months;
daysText = days;
headerText = header;
headerColor = hdcolor;
backgroundColor = bgcolor
previousImgSrc = previous;
nextImgSrc = next;
transparencyImgSrc = transparency;
slcExtDate = dateSelect;
slcExtMonth = monthSelect;
slcExtYear = yearSelect;
var html = "";
html += "";
var spnOuterCalendar = document.getElementById('spnOuterCalendar');
spnOuterCalendar.innerHTML = html;
_OnLoanItem_WAR_elmu_drawCalendar(_OnLoanItem_WAR_elmu_getSelectValue(slcExtMonth), _OnLoanItem_WAR_elmu_getSelectValue(slcExtYear));
spnOuterCalendar.style.left = left + 10 + 'px';
spnOuterCalendar.style.top = top + 'px';
spnOuterCalendar.style.visibility = "visible";
calendarVisible = true;
}
}
function _OnLoanItem_WAR_elmu_updateCalendar(i) {
var year = parseInt(_OnLoanItem_WAR_elmu_getSelectValue(document.frmCalendar.slcCalendarYear));
var month = parseInt(_OnLoanItem_WAR_elmu_getSelectValue(document.frmCalendar.slcCalendarMonth)) + i;
if (month == 0) {
month = 12;
year--;
} else if (month == 13) {
month = 1;
year++;
}
if ((year >= yearBegin) && (year <= yearEnd)) {
_OnLoanItem_WAR_elmu_drawCalendar(month, year);
}
}
function _OnLoanItem_WAR_elmu_updateExtSelect(date, month, year) {
_OnLoanItem_WAR_elmu_setSelectValue(slcExtDate, date);
_OnLoanItem_WAR_elmu_setSelectValue(slcExtMonth, month);
_OnLoanItem_WAR_elmu_setSelectValue(slcExtYear, year);
_OnLoanItem_WAR_elmu_hideCalendar();
return false;
}