/*********************************************** Fool-Proof Date Input Script with DHTML Calendar by Jason Moon - calendar@moonscript.com ************************************************/ // Customizable variables var DefaultDateFormat = 'DD/MM/YYYY'; // If no date format is supplied, this will be used instead var HideWait = 3; // Number of seconds before the calendar will disappear var Y2kPivotPoint = 76; // 2-digit years before this point will be created in the 21st century var UnselectedMonthText = ''; // Text to display in the 1st month list item when the date isn't required var FontSize = 12; // In pixels var FontFamily = 'Tahoma'; var CellWidth = 25; var CellHeight = 20; var ImageURL = 'http://images.moonscript.com/icons/calendarIcon.jpg'; var NextURL = 'http://images.moonscript.com/icons/calendarNext.gif'; var PrevURL = 'http://images.moonscript.com/icons/calendarPrev.gif'; var CalBGColor = '#FBF7E8'; // var CalBGColor = '#FF0000'; var CalBoxBGColor = '#F2EACD'; // var TopRowBGColor = '#F2EACD'; var TopRowBGColor = '#E4CFB2'; var DayBGColor = '#294f96'; // Global variables var ZCounter = 100; var TodayToFirstDateOffset = 1; var FirstToSecondDateOffset = 1; var Today = new Date(); Today.setHours(0); Today.setMinutes(0); Today.setSeconds(0); Today.setMilliseconds(0); var Yesterday = new Date(); Yesterday.setTime(Today.getTime()-86400000); var FirstDate = new Date(); FirstDate.setTime(Today.getTime()+(TodayToFirstDateOffset*86400000)); var SecondDate = new Date(); SecondDate.setTime(FirstDate.getTime()+(FirstToSecondDateOffset*86400000)); var WeekDays = new Array('Mo','Di','Mi','Do','Fr','Sa','So'); var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var MonthNames = new Array('01','02','03','04','05','06','07','08','09','10','11','12'); // Write out the stylesheet definition for the calendar with (document) { writeln(''); } function compareDatesAafterB(dateA, dateB) { dateA.setHours(0); dateA.setMinutes(0); dateA.setSeconds(0); dateA.setMilliseconds(0); dateB.setHours(0); dateB.setMinutes(0); dateB.setSeconds(0); dateB.setMilliseconds(0); if(dateA.getTime() > dateB.getTime()) return true; else return false; } function checkDateInput(form) { var tempFrom = new Date(von_tag_Object.picked.yearPad, von_tag_Object.picked.monthIndex, von_tag_Object.picked.dayPad); var tempTo = new Date(bis_tag_Object.picked.yearPad, bis_tag_Object.picked.monthIndex, bis_tag_Object.picked.dayPad); var alertMessage; if(compareDatesAafterB(tempTo,tempFrom)) if(compareDatesAafterB(tempFrom,Yesterday)) return true; else alertMessage = 'Das von Ihnen eingestellte Anreisedatum liegt in der Vergangenheit. Bitte korrigieren Sie ihre Eingabe.'; else alertMessage = 'Das von Ihnen eingestellte Abreisedatum muss mindestens einen Tag auf das Anreisedatum folgen. Bitte korrigieren Sie ihre Eingabe.'; alert(alertMessage); return false; } // Only allows certain keys to be used in the date field function YearDigitsOnly(e) { var KeyCode = (e.keyCode) ? e.keyCode : e.which; return ((KeyCode == 8) // backspace || (KeyCode == 9) // tab || (KeyCode == 37) // left arrow || (KeyCode == 39) // right arrow || (KeyCode == 46) // delete || ((KeyCode > 47) && (KeyCode < 58)) // 0 - 9 ); } // Gets the absolute pixel position of the supplied element function GetTagPixels(StartTag, Direction) { var PixelAmt = (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop; while ((StartTag.tagName != 'BODY') && (StartTag.tagName != 'HTML')) { StartTag = StartTag.offsetParent; PixelAmt += (Direction == 'LEFT') ? StartTag.offsetLeft : StartTag.offsetTop; } return PixelAmt; } // Is the specified select-list behind the calendar? function BehindCal(SelectList, CalLeftX, CalRightX, CalTopY, CalBottomY, ListTopY) { var ListLeftX = GetTagPixels(SelectList, 'LEFT'); var ListRightX = ListLeftX + SelectList.offsetWidth; var ListBottomY = ListTopY + SelectList.offsetHeight; return (((ListTopY < CalBottomY) && (ListBottomY > CalTopY)) && ((ListLeftX < CalRightX) && (ListRightX > CalLeftX))); } // For IE, hides any select-lists that are behind the calendar function FixSelectLists(Over) { if (navigator.appName == 'Microsoft Internet Explorer') { var CalDiv = this.getCalendar(); var CalLeftX = CalDiv.offsetLeft; var CalRightX = CalLeftX + CalDiv.offsetWidth; var CalTopY = CalDiv.offsetTop; var CalBottomY = CalTopY + (CellHeight * 9); var FoundCalInput = false; formLoop : for (var j=this.formNumber;j