// // File Name: calendar.js // // Changes History: //--------------------------------------------------------------- // Author: Alexander Sokolov // Supervisor: Tsuri Bar-Haim // Date: March 29 2005 // Change Description: // Added support for opening multiple calendars // on the same page (#255364-032205). // // All [m]ultiple [c]alendars functions begin with "mc_" prefix. // It is recommended to use these mc_xxx() functions for further development // instead of previous functions, both in single- and multi-calendar pages. // Previous functions are left for backward compatibility reasons only // and should be treated as deprecated. // // The mc_xxx() functions set is completely stand-along // and does not use any function or global variable from the previous set. // // The only function a JSP needs to interface with is // mc_openCalendar(dateId, calId) // Arguments: // dateId – string ID of the text control where the picked date is to be displayed; // calId – string ID of the div element where the calendar will be drawn. // Remarks: // There is no longer need for any well-known IDs. // Any number of calendars can be displayed simultaneously on the same page. // // TODOs: // 1. Localization support (?) // 2. Customizable date format (?) // 3. Customizable L&F (.css (?)) (?) // 4. Today's day highlighting + special handling for navigating to a month // with fewer days than current (?) // 5. Complete reusability (wrap into a custom tag (?)) (?) //--------------------------------------------------------------- // Author: Alexander Sokolov // Supervisor: Tsuri Bar-Haim // Date: April 05 2005 // Change Description: // Fixed incorrect behavior of single-instance calendar // when initial date of month is greater than maximal // possible date of the next month, e.g. the following dates // affected: // Jan 31, March 31, May 31, Aug 31, Oct 31 (#255748-040205) //--------------------------------------------------------------- // Author: Alexander Sokolov // Supervisor: Tsuri Bar-Haim // Date: April 06 2005 // Change Description: // Added mc_openCalendarOnForm(dateId, calId, formId) function. // Function can be used in case if several forms with duplicated // element IDs are presented on the same page. //--------------------------------------------------------------- // Author: Alexander Sokolov // Supervisor: Maya Sadan // Date: January 16 2006 // Change Description: // Case ID 262758-120605. // Added explicit "line-height:normal" style to tables markup. //--------------------------------------------------------------- // // @ Copyright Amdocs Israel. // This document contains proprietary and confidential // information, and shall not be reproduced, transferred, or // disclosed to others, without the prior written consent of // Amdocs. // //------------------------------------------------------------------------------------------------------ var months = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); var current; var profile; var imgPath; var currentSelection; var ie = false; var ns4 = false; var ns6 = false; var sender = 0; // Macromedia script function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i'; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; //str = str + ''; //str = str + ''; //str = str + ''; str = str + ''; str = str + '
' + months[currentMonth] + '' + currentYear + '   ' + months[currentMonth] + ' ' + currentYear + '   
'; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; str = str + ''; var nextDay = 1; current.setDate(nextDay); var jumper = current.getDay(); jumper-=1; if (jumper<0){ jumper=6; } var counter = jumper; str = str + ''; for (i = 0; i < jumper; i++){ str = str + ''; } while (counter < 7){ if (counter == 5 || counter == 6){ //str = str + ''; str = str + ''; } else{ str = str + ''; } nextDay++; current.setDate(nextDay); counter++; } str = str + ''; counter = 0; var isBuilding = true; while (isBuilding){ str = str + ''; while (counter < 7){ if (current.getMonth() != nextMonth.getMonth()){ if (counter == 5 || counter == 6){ //str = str + ''; str = str + ''; } else{ str = str + ''; } nextDay++; current.setDate(nextDay); counter++; } else{ if (counter!=0) { for (t = counter; t < 7; t++){ str = str + ''; } } isBuilding = false; break; } } str = str + ''; counter = 0; } str = str + '
MTWTFSS
 ' + current.getDate() + '' + current.getDate() + '' + current.getDate() + '
' + current.getDate() + '' + current.getDate() + '' + current.getDate() + ' 
'; str = str + ''; str = str + ''; str = str + ''; str = str + 'Close'; str = str + ''; str = str + ''; current.setDate(currentDate); current.setMonth(currentMonth); current.setYear(currentYear); return str; } ///////////////////////////////////////// // Multiple calendars support functions function mc_openCalendar(dateId, calId) { mc_openCalendarOnForm(dateId, calId, null); } function mc_openCalendarOnForm(dateId, calId, formId) { var str = mc_findDateElement(dateId, formId).value; var DATE_FMT = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/\d{4}$/; var date = new Date(); if (DATE_FMT.test(str)) { // TODO: Special handling for navigating to a month // with fewer days than current: date.setDate(1); date.setFullYear(str.substr(6, 4)); date.setMonth(str.substr(3, 2)) date.setMonth(date.getMonth() - 1); } mc_fillCalendar(date, dateId, calId, formId); mc_showCalendar(calId, formId); } function mc_setDate(day, month, year, dateId, calId, formId) { if (day < 10) day = "0" + day; month = month + 1; if (month < 10) month = "0" + month; mc_findDateElement(dateId, formId).value = day + "/" + month + "/" + year; mc_hideCalendar(calId, formId); } function mc_hideCalendar(calId, formId) { mc_findCalendarElement(calId, formId).style.visibility = "hidden"; } function mc_showCalendar(calId, formId) { mc_findCalendarElement(calId, formId).style.visibility = "visible"; } function mc_nextMonth(month, year, dateId, calId, formId) { var date = new Date(); // TODO: Special handling for navigating to a month // with fewer days than current: date.setDate(1); date.setFullYear(year); date.setMonth(month + 1); mc_fillCalendar(date, dateId, calId, formId); } function mc_prevMonth(month, year, dateId, calId, formId) { var date = new Date(); // TODO: Special handling for navigating to a month // with fewer days than current: date.setDate(1); date.setFullYear(year); date.setMonth(month - 1); mc_fillCalendar(date, dateId, calId, formId); } function mc_nextYear(month, year, dateId, calId, formId) { var date = new Date(); // TODO: Special handling for navigating to a month // with fewer days than current: date.setDate(1); date.setFullYear(year + 1); date.setMonth(month); mc_fillCalendar(date, dateId, calId, formId); } function mc_prevYear(month, year, dateId, calId, formId) { var date = new Date(); // TODO: Special handling for navigating to a month // with fewer days than current: date.setDate(1); date.setFullYear(year - 1); date.setMonth(month); mc_fillCalendar(date, dateId, calId, formId); } function mc_fillCalendar(date, dateId, calId, formId) { var MONTHS = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); var strForm; if (null == formId) strForm = "null"; else strForm = "'" + formId + "'"; var month = date.getMonth(); var year = date.getFullYear(); var dateNextMonth = new Date(); dateNextMonth.setDate(1); dateNextMonth.setFullYear(year); dateNextMonth.setMonth(month + 1); var str = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + MONTHS[month] + '' + year + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; var nextDay = 1; date.setDate(nextDay); var jumper = date.getDay(); jumper-=1; if (jumper<0){ jumper=6; } var counter = jumper; for (i = 0; i < jumper; i++) { str = str + ''; } while (counter < 7) { if (counter == 5 || counter == 6) { str = str + ''; } else { str = str + ''; } nextDay++; date.setDate(nextDay); counter++; } str = str + ''; counter = 0; var isBuilding = true; while (isBuilding) { str = str + ''; while (counter < 7) { if (date.getMonth() != dateNextMonth.getMonth()) { if (counter == 5 || counter == 6) { str = str + ''; } else { str = str + ''; } nextDay++; date.setDate(nextDay); counter++; } else { if (counter != 0) { for (t = counter; t < 7; t++) { str = str + ''; } } isBuilding = false; break; } } str = str + ''; counter = 0; } str = str + '
MTWTFSS
 ' + '' + '' + nextDay + '' + '' + '' + '' + '' + nextDay + '' + '' + '
' + '' + '' + nextDay + '' + '' + '' + '' + '' + nextDay + '' + '' + ' 
' + '
Close
' ; mc_findCalendarElement(calId, formId).innerHTML = str; } function mc_findDateElement(dateId, formId) { var obj = null; if (null == formId) obj = document.getElementById(dateId); else obj = document.forms[formId].elements[dateId]; return obj; } function mc_findCalendarElement(calId, formId) { // Obtain div via form - form.all[] works fine in IE; // TODO: find solution for Netscape. return document.getElementById(calId); }