<!--

function check_date(field, calendar, obj, anchor, format){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var separator = "/";
var year;
var month;
var day;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
    if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
       DateTemp = DateTemp + DateValue.substr(i,1);
    }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue =  '20' + DateValue.substr(4,2) + DateValue.substr(0,4); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(0,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(4,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(6,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 is entered, no error, deleting the entry */
   if ((year == 0) && (month == 0) && (day == 00)) {
      err = 0; year = ""; month = ""; day = ""; separator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + separator + day + separator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Invalid date. Please enter date in the MM/DD/YYYY format.");
/*      calendar.select(obj, anchor, format);*/
      DateField.select();
      DateField.focus();
   }
}

function check_time(field){
var Timecheckstr = "0123456789";
var TimeField = field;
var TimeValue = "";
var TimeTemp = "";
var Timeseparator = ":";
var hour;
var minute;
var Timeerr = 0;
var j;
   Timeerr = 0;
   TimeValue = TimeField.value;
/* Delete all chars except 0..9 */
   for (j = 0; j < TimeValue.length; j++) {
    if (Timecheckstr.indexOf(TimeValue.substr(j,1)) >= 0) {
       TimeTemp = TimeTemp + TimeValue.substr(j,1);
    }
   }
     TimeValue = TimeTemp;
   /* Time must be 4 digits*/
   if (TimeValue.length != 4) {
      Timeerr = 19;
   }
  /* Validation of hour */
   hour = TimeValue.substr(0,2);
   if (hour > 23) {
      Timeerr = 21;
   }
   /* Validation of minute*/
   minute = TimeValue.substr(2,2);
   if (minute > 59) {
      Timeerr = 22;
   }
   /* if 00 is entered, no error, deleting the entry */
   if ((hour == 0) && (minute == 0)) {
      Timeerr = 0; hour = ""; minute = ""; Timeseparator = "";
   }
   /* if no error, write the completed time to Input-Field (e.g. 23:59) */
   if (Timeerr == 0) {
      TimeField.value = hour + Timeseparator + minute;
   }
   /* Error-message if Timeerr != 0 */
   else {
      alert("Invalid time. Please enter 24-hour time in the HH:MM format.");
      TimeField.select();
    TimeField.focus();
   }
}

function check_words(field, maxWords) {
    if (maxWords == 0) return;
	var value = field.value;
	while (value.charAt(0) == " ") {
		value = value.substr(1);
	}
	while (value.charAt(value.length - 1) == " ") {
		value = value.substr(0, value.length - 1);
	}
	field.value = value;
	var spaceCount = 0;
	for (var i = 0; i < value.length; i++) {
		if (value.charAt(i) == " ") { spaceCount++; }
	}	
	if (spaceCount >= maxWords) {
		alert("The maximum number of words this field may contain is " + maxWords);
		field.focus();
	}
}

function check_duration(field){
var Durationcheckstr = "0123456789";
var DurationField = field;
var DurationValue = "";
var DurationTemp = "";
var Durationseparator = ":";
var Dday;
var Dhour;
var Dminute;
var Durationerr = 0;
var k;
   Durationerr = 0;
   DurationValue = DurationField.value;
/* Delete all chars except 0..9 */
   for (k = 0; k < DurationValue.length; k++) {
    if (Durationcheckstr.indexOf(DurationValue.substr(k,1)) >= 0) {
       DurationTemp = DurationTemp + DurationValue.substr(k,1);
    }
   }
     DurationValue = DurationTemp;
   /* Duration must be 6 digits*/
   if (DurationValue.length != 6) {
      Durationerr = 19;
   }
  /* Validation of day */
   Dday = DurationValue.substr(0,2);
   if (Dday > 99) {
      Durationerr = 21;
   }
  /* Validation of hour */
   Dhour = DurationValue.substr(2,2);
   if (Dhour > 23) {
      Durationerr = 21;
   }
   /* Validation of minute*/
   Dminute = DurationValue.substr(4,2);
   if (Dminute > 59) {
      Durationerr = 22;
   }
   /* if 00 is entered, no error, deleting the entry */
   if ((Dday == 0) && (Dhour == 0) && (Dminute == 0)) {
      Durationerr = 0; Dday = "00"; Dhour = "00"; Dminute = "00"; Durationseparator = ":";
   }
   /* if no error, write the completed time to Input-Field (e.g. 23:59) */
   if (Durationerr == 0) {
      DurationField.value = Dday + Durationseparator + Dhour + Durationseparator + Dminute;
   }
   /* Error-message if Durationerr != 0 */
   else {
      alert("Invalid duration.\nPlease enter the duration in the DD:HH:MM format,\nwhere DD is 99 or less, HH is 23 or less, and MM is 59 or less.");
      DurationField.select();
    DurationField.focus();
   }
}

// -->