//Global Variables //Define the different browser types that are supported var NS4 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==4); var NS6 = (navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)==5); var IE4 = document.all; //Calendar objects var calNS4; var calNS6; var calIE4; //Holding Variables var CALENDAR_HTML = ""; var DISPLAY_DATE = ""; var CURRENT_DATE_FIELD = ""; var HLD_DIV = ""; var BUILT = "no"; //End of Global Variables //Write out the style sheets document.write(""); //This function is used to display the calendar function showCalendar(field,date,xPos,yPos) { if (HLD_DIV != date && BUILT == "yes") { if (NS4) calNS4.visibility = 'hidden'; else if (IE4) calIE4.style.visibility = 'hidden'; else if (NS6) calNS6.style.visibility = 'hidden'; BUILT = "no"; HLD_DIV = date; } if (BUILT == "yes") { if (NS4) calNS4.visibility = 'visible'; else if (IE4) calIE4.style.visibility = 'visible'; else if (NS6) calNS6.style.visibility = 'visible'; return; } //Set the Date field to use CURRENT_DATE_FIELD = field; //Set the Display Date to null DISPLAY_DATE = ""; //Build the Calendar buildCalendar(); if (!xPos) xPos = ""; if (!yPos) yPos = ""; //Display the Calendar on the Web page if (NS4) { calNS4 = new Layer(50,this); calNS4.document.write(CALENDAR_HTML); calNS4.document.close(); if (xPos != "" || yPos != "") { this.calNS4.pageX = xPos; this.calNS4.pageY = (yPos - 95); } else { this.calNS4.pageX = document.layers[date].pageX; this.calNS4.pageY = (document.layers[date].pageY - 95); } calNS4.visibility = 'visible'; } else if (IE4) { calIE4 = document.all[date]; calIE4.innerHTML = CALENDAR_HTML; if (xPos != "" || yPos != "") { calIE4.style.posLeft = xPos; calIE4.style.posTop = yPos; } calIE4.style.visibility = 'visible'; } else if (NS6) { calNS6 = document.getElementById(date); calNS6.innerHTML = CALENDAR_HTML; if (xPos != "" || yPos != "") { calNS6.style.top = yPos; calNS6.style.left = xPos; } calNS6.style.visibility = 'visible'; } BUILT = "yes"; } //This function is used to hide the calendar function hideCalendar() { if (BUILT == "no") return; if (NS4) calNS4.visibility = 'hidden'; else if (IE4) calIE4.style.visibility = 'hidden'; else if (NS6) calNS6.style.visibility = 'hidden'; } //This function is used to change the Calendar Date function chgCalendarDate(dspDate) { //Set the Display to the new Date DISPLAY_DATE = dspDate; //Build the Calendar buildCalendar(); //Display the Calendar on the Web page if (NS4) { calNS4.document.write(CALENDAR_HTML); calNS4.document.close(); } else if (IE4) calIE4.innerHTML = CALENDAR_HTML; else if (NS6) calNS6.innerHTML = CALENDAR_HTML; } //This function is used to change the Date field to the selected calendar date function chgDate(txtDate) { var valori = new Array(); valori=txtDate.split('/'); var mese=valori[0]; if (mese<10) mese="0"+mese; var giorno=valori[1]; if (giorno<10) giorno="0"+giorno; var anno=valori[2]; var italianDate=giorno+'/'+mese+'/'+anno; //Change the Date field //document.forms[0][CURRENT_DATE_FIELD].value = txtDate; document.forms[0][CURRENT_DATE_FIELD].value = italianDate; //Hide the Calendar hideCalendar(); } //This function is used to Build the Calendar function buildCalendar() { //Define the Month Names and Month Days Array monthNames = new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"); monthDays = new Array(12); //Entry the Total Days for each Month monthDays[0] = 31; monthDays[1] = 28; monthDays[2] = 31; monthDays[3] = 30; monthDays[4] = 31; monthDays[5] = 30; monthDays[6] = 31; monthDays[7] = 31; monthDays[8] = 30; monthDays[9] = 31; monthDays[10] = 30; monthDays[11] = 31; //Determine the Date for the Calendar to Display if (DISPLAY_DATE == "") calendarDateObj = new Date(); else calendarDateObj = new Date(DISPLAY_DATE); //Obtain the Calendar Dates calendarDate = calendarDateObj.getDate(); calendarDay = calendarDateObj.getDay(); calendarMonth = calendarDateObj.getMonth(); calendarYear = calendarDateObj.getYear(); //Obtain Todays Dates currentDateObj = new Date(); currentDate = currentDateObj.getDate(); currentDay = currentDateObj.getDay(); currentMonth = currentDateObj.getMonth(); currentYear = currentDateObj.getYear(); //*** Fix - TDS 2-06-2003 *** if ((calendarMonth == currentMonth) && (calendarYear == currentYear)) { calendarDate = currentDate; calendarDay = currentDay; } if (LeapYear(calendarYear)) monthDays[1] = 29; //*** End Fix - 2-06-2003 *** //Make sure the Year is in the correct century calendarYear = calendarYear % 100; calendarYear = ((calendarYear < 50) ? (2000 + calendarYear) : (1900 + calendarYear)); //Calculate the Blank entries before the 1st of the month blankEntry = calendarDate; while (blankEntry > 7) blankEntry-= 7; blankEntry = calendarDay - blankEntry + 1; if (blankEntry < 0) blankEntry+= 7; //Calculate Next Months Date nextMonth = (calendarMonth + 2); if (nextMonth == 13) { nextMonth = 1; nextYear = (calendarYear + 1); } else nextYear = calendarYear; nextDate = nextMonth + "/1/" + nextYear; //Calculate Previous Months Date prevMonth = calendarMonth; if (prevMonth == 0) { prevMonth = 12; prevYear = (calendarYear - 1); } else prevYear = calendarYear; prevDate = prevMonth + "/1/" + prevYear; //Build the Header for the Calendar CALENDAR_HTML = "
| 3 | "; CALENDAR_HTML += "" + monthNames[calendarMonth] + " " + calendarYear + " | "; CALENDAR_HTML += "4 | "; CALENDAR_HTML += "||||
| DOM | "; CALENDAR_HTML += "LUN | "; CALENDAR_HTML += "MAR | "; CALENDAR_HTML += "MER | "; CALENDAR_HTML += "GIO | "; CALENDAR_HTML += "VEN | "; CALENDAR_HTML += "SAB | "; CALENDAR_HTML += "
| "; //Start the Day Counter dayCount = 1; //Loop through until the total days of calendar month have been reached while (dayCount <= monthDays[calendarMonth]) { //Start a new table row each time through the loop except the first time if (dayCount > 1) CALENDAR_HTML += " | ||||||
| " + tdData + " | "; //Add to the Day counter dayCount++; } //End the table row CALENDAR_HTML += "||||||
| "; CALENDAR_HTML += " | ||||||