// WWW: http://www.mattkruse.com/ // Browser capability sniffing var use_gebi=false, use_css=false, use_layers=false; nn6=false; nn7=false; if (document.getElementById) { use_gebi=true; } else if (document.all) { use_css=true; } else if (document.layers) { use_layers=true; } if ((navigator.vendor)) { var ver = parseFloat(navigator.vendorSub); nn6 = (ver >= 6 && ver < 7); nn7 = (ver >= 7); } // getAnchorPosition(anchorname) // This function returns an object having .x and .y properties which are the coordinates // of the named anchor, relative to the page. function getAnchorPosition(anchorname) { // This function will return an Object with x and y properties var useWindow=false; var coordinates=new Object(); var x=0,y=0; // Logic to find position if (use_gebi && document.all) { x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); } else if (use_gebi && nn6) { var o=document.getElementById(anchorname); x=o.offsetLeft; y=o.offsetTop; } else if (use_gebi && nn7) { var o=document.getElementById(anchorname); x=AnchorPosition_getPageOffsetLeft(o); y=AnchorPosition_getPageOffsetTop(o); } else if (use_gebi) { var o=document.getElementById(anchorname); x=o.offsetLeft; y=o.offsetTop; } else if (use_css) { x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); } else if (use_layers) { var found=0; for (var i=0; i= winX) { popX = popX - popWidth + (xOffset + xxOffset); } if(popY+popHeight >= winY) { popY = popY - popHeight - (yOffset*2 + yyOffset); } } } // -------------------------------------------------------------------------------- Calendar.Months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; // Non-Leap year Month days.. Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // Leap year Month days.. Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; // Code modified to capture the date value ( p_day has been included) function Calendar(p_item, p_WinCal, p_day, p_month, p_year, p_format) { if ((p_month == null) && (p_year == null)) return; if (p_WinCal == null) this.gWinCal = ggWinCal; else this.gWinCal = p_WinCal; if (p_month == null) { this.gMonthName = null; this.gMonth = null; this.gYearly = true; } else { this.gMonthName = Calendar.get_month(p_month); this.gMonth = new Number(p_month); this.gYearly = false; } // Code added to capture the date value this.gDay = p_day; this.gYear = p_year; this.gFormat = p_format; // Customize your Calendar here..... this.gTextColor = "#000000"; this.gMainTableBgColor = "#DFE4EB"; this.gHeaderBgColor = "#607C9F"; // The Year Display this.gHeaderFontColor = "#FFFFFF"; this.gHeaderFontFace = "Verdana, Arial, Helvetica, sans-serif"; this.gHeaderFontSize = "2"; this.gLinkColor="#000000"; // Display of Weekdays ( S M T W T F S ) this.gDayFontFace = "Verdana, Arial, Helvetica, sans-serif"; this.gDayFontSize = "2"; // Display of Dates ( 1 - 31 ) this.gDateFontFace = "Verdana, Arial, Helvetica, sans-serif"; this.gDateFontSize = "1"; this.gDateBgColor = "#FFFFFF"; this.gWeekendBgColor = "#EEEEEE"; this.gSelectedDateFontColor = "#FF0000"; // Images used in the Calendar this.gImgYearDcr = "/chcfweb/sbc/scripts/cal-images/year_dcr.gif"; this.gImgYearInc = "/chcfweb/sbc/scripts/cal-images/year_inc.gif"; this.gImgMonDcr = "/chcfweb/sbc/scripts/cal-images/month_dcr.gif"; this.gImgMonInc = "/chcfweb/sbc/scripts/cal-images/month_inc.gif"; this.gReturnItem = p_item; } Calendar.get_month = Calendar_get_month; Calendar.get_daysofmonth = Calendar_get_daysofmonth; Calendar.calc_month_year = Calendar_calc_month_year; Calendar.print = Calendar_print; function Calendar_get_month(monthNo) { return Calendar.Months[monthNo]; } function Calendar_get_daysofmonth(monthNo, p_year) { /* Check for leap year .. 1.Years evenly divisible by four are normally leap years, except for... 2.Years also evenly divisible by 100 are not leap years, except for... 3.Years also evenly divisible by 400 are leap years. */ if ((p_year % 4) == 0) { if ((p_year % 100) == 0 && (p_year % 400) != 0) return Calendar.DOMonth[monthNo]; return Calendar.lDOMonth[monthNo]; } else return Calendar.DOMonth[monthNo]; } function Calendar_print() { ggWinCal.print(); } function Calendar_calc_month_year(p_Month, p_Year, incr) { /* Will return an 1-D array with 1st element being the calculated month and second being the calculated year after applying the month increment/decrement as specified by 'incr' parameter. 'incr' will normally have 1/-1 to navigate thru the months. */ var ret_arr = new Array(); if (incr == -1) { // B A C K W A R D if (p_Month == 0) { ret_arr[0] = 11; ret_arr[1] = parseInt(p_Year,10) - 1; } else { ret_arr[0] = parseInt(p_Month,10) - 1; ret_arr[1] = parseInt(p_Year,10); } } else if (incr == 1) { // F O R W A R D if (p_Month == 11) { ret_arr[0] = 0; ret_arr[1] = parseInt(p_Year,10) + 1; } else { ret_arr[0] = parseInt(p_Month,10) + 1; ret_arr[1] = parseInt(p_Year,10); } } return ret_arr; } // This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists. new Calendar(); Calendar.prototype.getMonthlyCalendarCode = function() { var vCode = ""; var vHeader_Code = ""; var vData_Code = ""; // Begin Table Drawing code here.. vHeader_Code = this.cal_header(); vData_Code = this.cal_data(); vCode = vCode + vHeader_Code + vData_Code; return vCode; } Calendar.prototype.show = function() { var vCode = ""; this.gWinCal.document.open(); // Setup the page... this.wwrite(""); this.wwrite("Calendar"); this.wwrite(""); this.wwrite(""); // Show navigation buttons var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1); var prevMM = prevMMYYYY[0]; var prevYYYY = prevMMYYYY[1]; var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1); var nextMM = nextMMYYYY[0]; var nextYYYY = nextMMYYYY[1]; this.wwrite("
"); // Code modofied to capture the date value (gDay being included) this.wwrite("
"); this.wwrite("Prev Year<\/A>"); this.wwrite("Prev Month<\/A>"); this.wwriteA(this.gMonthName + " " + this.gYear); this.wwrite(""); this.wwrite("Next Month<\/A>"); this.wwrite("Next Year<\/A>
"); // Get the complete calendar code for the month.. vCode = this.getMonthlyCalendarCode(); this.wwrite(vCode); this.wwrite("
"); this.gWinCal.document.close(); } Calendar.prototype.wwrite = function(wtext) { this.gWinCal.document.writeln(wtext); } Calendar.prototype.wwriteA = function(wtext) { this.gWinCal.document.write(wtext); } Calendar.prototype.cal_header = function() { var vCode = ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + ""; vCode = vCode + "
SMTWTFS
"; return vCode; } Calendar.prototype.cal_data = function() { var vDate = new Date(); vDate.setDate(1); vDate.setMonth(this.gMonth); vDate.setFullYear(this.gYear); var vFirstDay=vDate.getDay(); var vDay=1; var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear); var vOnLastDay=0; var vCode = ""; var toHighlight = true; //if( this.gDay == p_day && this.gMonth == p_month && this.gYear == gYear ) if( (this.gDay == p_day) && (vDate.getMonth() == p_month) && (this.gYear == p_year) ) { //alert("Inside if.."); toHighlight = true; } else { //alert("Inside else"); toHighlight = false; } /* Get day for the 1st of the requested month/year.. Place as many blank cells before the 1st day of the month as necessary. */ vCode = vCode + ""; vCode = vCode + ""; for (i=0; i "; } // Write rest of the 1st week // changeFlag has been included to trigger the onChange event in the concerned screens for (j=vFirstDay; j<7; j++) { vCode = vCode + ""; vDay=vDay + 1; } vCode = vCode + ""; // Write the rest of the weeks // changeFlag has been included to trigger the onChange event in the concerned screens for (k=2; k<7; k++) { vCode = vCode + ""; for (j=0; j<7; j++) { vCode = vCode + ""; vDay=vDay + 1; if (vDay > vLastDay) { vOnLastDay = 1; break; } } if (j == 6) vCode = vCode + ""; if (vOnLastDay == 1) break; } // Fill up the rest of last week with proper blanks, so that we get proper square blocks for (m=1; m<(7-j); m++) { if (this.gYearly) vCode = vCode + ""; else vCode = vCode + ""; } vCode = vCode + "
" + "" + this.format_day(vDay, toHighlight) + "" + "
" + "" + this.format_day(vDay, toHighlight) + "" + "
  
"; return vCode; } Calendar.prototype.format_day = function(vday, toHighlight) { // Code modified to capture the date value (the date in the text field is shown highlighted) if (toHighlight == true && vday == this.gDay) return ("" + vday + ""); else return (vday); } Calendar.prototype.write_weekend_string = function(vday) { var i; // Return special formatting for the weekend day. for (i=0; i 31 || isNaN(p_month) || p_month == -1 || p_month<0 || p_month > 11 || p_year.length != 4 || isNaN(p_year) ) { p_day = gNow.getDate(); p_month = new String(gNow.getMonth()); p_year = new String(gNow.getFullYear().toString()); } } // ---------------------------------------------------------------------------- if (arguments[3] == null) p_format = "MM/DD/YYYY"; else p_format = arguments[3]; // Code added to capture the cursor position setCursorPosition(arguments[0],arguments[5],arguments[6]); // Creating Dependable Popup Window, i.e close all previously opened calendars before opening a new one. clearCalendarInstances(); // Code modified vWinCal = window.open("", "Calendar", "width="+arguments[5]+",height="+arguments[6]+",status=no,resizable=no,top="+popY+",left="+popX); vWinCal.opener = self; ggWinCal = vWinCal; Build(p_item, p_day, p_month, p_year, p_format); } // New code added to clear all calendar instances when the browser window is closed or url is changed function clearCalendarInstances() { if(ggWinCal && ggWinCal.open && !ggWinCal.closed) ggWinCal.close(); } function show_calendar_services() { /* p_month : 0-11 for Jan-Dec; 12 for All Months. p_year : 4-digit year p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...) p_item : Return Item. */ p_item = arguments[1]; // Code added to capture the date value if (arguments[2] == "" && arguments[7] == "") { p_day = gNow.getDate(); p_month = new String(gNow.getMonth()); p_year = new String(gNow.getFullYear().toString()); } else if(arguments[2] == "" && arguments[7] != ""){ var dateValue = arguments[7]; var dateArray = dateValue.split( (dateValue.indexOf("/") != -1) ? "/" : "-"); p_day = new Number(dateArray[1]); p_month = new Number(dateArray[0])-1; p_year = new String(dateArray[2]); if( isNaN(p_day) || p_day < 1 || p_day > 31 || isNaN(p_month) || p_month == -1 || p_month<0 || p_month > 11 || p_year.length != 4 || isNaN(p_year) ) { p_day = gNow.getDate(); p_month = new String(gNow.getMonth()); p_year = new String(gNow.getFullYear().toString()); } } else { var dateValue = arguments[2]; var dateArray = dateValue.split( (dateValue.indexOf("/") != -1) ? "/" : "-"); p_day = new Number(dateArray[1]); p_month = new Number(dateArray[0])-1; p_year = new String(dateArray[2]); if( isNaN(p_day) || p_day < 1 || p_day > 31 || isNaN(p_month) || p_month == -1 || p_month<0 || p_month > 11 || p_year.length != 4 || isNaN(p_year) ) { p_day = gNow.getDate(); p_month = new String(gNow.getMonth()); p_year = new String(gNow.getFullYear().toString()); } } // ---------------------------------------------------------------------------- if (arguments[3] == null) p_format = "MM/DD/YYYY"; else p_format = arguments[3]; // Code added to capture the cursor position setCursorPosition(arguments[0],arguments[5],arguments[6]); // Creating Dependable Popup Window, i.e close all previously opened calendars before opening a new one. clearCalendarInstances(); // Code modified vWinCal = window.open("", "Calendar", "width="+arguments[5]+",height="+arguments[6]+",status=no,resizable=no,top="+popY+",left="+popX); vWinCal.opener = self; ggWinCal = vWinCal; Build(p_item, p_day, p_month, p_year, p_format); } // ------ E N D ----------------------------------------------------------------------