///////////////////////////////////////////// // Control: Dialog Box functionality ///////////////////////////////////////////// qcodo.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); qcodo.monthNamesAbbreviated = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); qcodo.dayNames = new Array("Su","Mo","Tu","We","Th","Fr","Sa"); qcodo.registerCalendar = function(mixControl, strDtxControlId) { // Initialize the Event Handler qcodo.handleEvent(); // Get Control/Wrapper var objControl; if (!(objControl = qcodo.getControl(mixControl))) return; var objWrapper = objControl.wrapper; // Get Linked DateTimeTextbox objControl.dateTimeTextBox = qcodo.getControl(strDtxControlId); // Get CalendarPane and Hide it objControl.calendarPane = document.getElementById(objControl.id + "_cal"); objControl.calendarPane.style.display = "none"; objControl.showCalendar = function() { var strPositionArray = this.wrapper.getAbsolutePosition(); this.calendarPane.style.left = strPositionArray.x + "px"; this.calendarPane.style.top = strPositionArray.y + "px"; this.calendarPane.style.position = "absolute"; this.calendarPane.style.zIndex = 10; this.calendarPane.style.display = "block"; this.drawCalendar(0, 0); }; objControl.setDate = function(intYear, intMonth, intDay) { this.dateTimeTextBox.value = qcodo.monthNamesAbbreviated[intMonth] + " " + intDay + " " + intYear; this.hideCalendar(); }; objControl.setToToday = function() { var dttToday = new Date(); this.setDate(dttToday.getFullYear(), dttToday.getMonth(), dttToday.getDate()) }; objControl.drawCalendar = function(intYear, intMonth) { // Get the "selected" date and the "current" date var dttSelected; if (this.dateTimeTextBox.value) dttSelected = new Date(this.dateTimeTextBox.value); var dttToday = new Date(); // Get the month to view var dttMonthToView; // If viewing a specific month/year, use it if (intYear) dttMonthToView = new Date(intYear, intMonth, 1); // If no "selected date" use "today" else if (!dttSelected || dttSelected == "Invalid Date") dttMonthToView = new Date(); // Otherwise, use the "selected date" else dttMonthToView = new Date(dttSelected); dttMonthToView.setDate(1); var intViewMonth = dttMonthToView.getMonth(); var intViewYear = dttMonthToView.getFullYear(); // Render the month to view var strCalendar = ''; for (var intDay = 0; intDay < qcodo.dayNames.length; ++intDay) strCalendar += ""; strCalendar += ""; for (var intDaysBack = dttMonthToView.getDay(); intDaysBack > 0; intDaysBack--) dttMonthToView.setDate(dttMonthToView.getDate() - 1); for (var intWeek = 0; intWeek < 6; intWeek++) { strCalendar += ''; for (var intDay = 0; intDay < 7; intDay++) { var strStyle = (intWeek == 5) ? "lastRow " : ""; if ((dttMonthToView.getDate() == dttToday.getDate()) && (dttMonthToView.getMonth() == dttToday.getMonth()) && (dttMonthToView.getFullYear() == dttToday.getFullYear())) strStyle += 'today '; if (dttSelected && (dttMonthToView.getDate() == dttSelected.getDate()) && (dttMonthToView.getMonth() == dttSelected.getMonth()) && (dttMonthToView.getFullYear() == dttSelected.getFullYear())) strStyle += 'selected '; if (dttMonthToView.getMonth() != intViewMonth) strStyle += 'nonMonth'; if (strStyle) strStyle = ' class="' + strStyle + '"'; strCalendar += '' + dttMonthToView.getDate() + ''; dttMonthToView.setDate(dttMonthToView.getDate() + 1); }; strCalendar += ''; }; strCalendar += '
" + qcodo.dayNames[intDay] + "
'; var intViewPreviousMonth = intViewMonth - 1; var intViewPreviousYear = intViewYear; if (intViewPreviousMonth == -1) { intViewPreviousMonth = 11; intViewPreviousYear--; }; var strPreviousMonth = intViewPreviousYear + ',' + intViewPreviousMonth; var intViewNextMonth = intViewMonth + 1; var intViewNextYear = intViewYear; if (intViewNextMonth == 12) { intViewNextMonth = 0; intViewNextYear++; }; var strNextMonth = intViewNextYear + ',' + intViewNextMonth; var strPreviousYear = (intViewYear - 1) + ',' + intViewMonth; var strNextYear = (intViewYear + 1) + ',' + intViewMonth; var strNavigator = ''; var strOptions = '
'; strOptions += '"Today"     '; strOptions += 'Cancel
'; this.calendarPane.innerHTML = strNavigator + strCalendar + strOptions; }; objControl.hideCalendar = function() { this.calendarPane.style.display = 'none'; }; objControl.onclick = objControl.showCalendar; }; ////////////////// // Qcodo Shortcuts ////////////////// qc.regCAL = qcodo.registerCalendar;