﻿function checkValidDate(fieldName) {
   var errorCode = 0;
   dateField = fieldName.value;

   if (dateField.length != 10)
      errorCode = 1;

   day      = dateField.substring(0, 2);
   point1   = dateField.substring(2, 3);
   month    = dateField.substring(3, 5);
   point2   = dateField.substring(5, 6);
   year     = dateField.substring(6, 10);

   if (isNaN(day))
      errorCode = 1;
   if (isNaN(month))
      errorCode = 1;
   if (isNaN(year))
      errorCode = 1;
   if ((day < 1) || (day > 31))
      errorCode = 2;
   if (point1 != '.')
      errorCode = 3;
   if ((month < 1) || (month > 12))
      errorCode = 4;
   if (point2 != '.')
      errorCode = 5;
   if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
      if (day == 31)
         errorCode = 7
   }

   if (month == 2) {
      var g = parseInt(year/4);
      if (isNaN(g))
         errorCode=8;
      if (day > 29)
         errorCode = 9;
      if ((day == 29) && ((year/4) != parseInt(year/4)))
         errorCode=10;
   }

   if (errorCode > 0) {
      return false;
   } else {
      return true;
   }
}


function GoToPage(hiddenName, hiddenValue, bookMark) {
   hiddenName.value = hiddenValue;
   if(bookMark.length > 0)
      document.itemform.action = document.itemform.action+"#"+bookMark;
   document.itemform.submit();
   return true;
}

/* Menu Related */
startList = function() {
   if (document.all && document.getElementById) {
      initHovers("nav", "over");
   }
}

function initHovers(listName, cName) {
   navRoot = document.getElementById(listName);
   
   for (i = 0; i < navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      
      if (node.nodeName == "LI") {
         node.onmouseover = function() { this.className = cName; }
         node.onmouseout = function() { this.className = this.className.replace(cName, ""); }
      }
   }
}
