function linkOver(control,text,color) {
   control.style.color = color;

   window.status = text;
}

function linkOut(control,color) {
   control.style.color = color;

   window.status = '';
}

function trMouseOver(control, newstyle)
{
   control.orgclassName = control.className;
   control.className = newstyle;
}

function trMouseOut(control)
{
   control.className = control.orgclassName;
}

function winStatus(newText)
{
   window.status = newText;
}

function isValidTime(timeStr) {
// -- Checks if time is in HH:MM:SS AM/PM format.
// -- The seconds and AM/PM are optional.

   var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
   var matchArray = timeStr.match(timePat);
   
   if (timeStr == "")
      return true;

   if (matchArray == null)
   {
//      alert("Time is not in a valid format.");
      return false;
   }
   
   hour = matchArray[1];
   minute = matchArray[2];
   second = matchArray[4];
   ampm = matchArray[6];

   if (second=="") 
      second = null;
      
   if (ampm=="")
      ampm = null;

   if (hour < 0  || hour > 23)
   {
      alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
      return false;
   }
   
   if (hour <= 12 && ampm == null)
   {
      if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time"))
      {
         alert("You must specify AM or PM.");
         return false;
      }
   }
   
   if  (hour > 12 && ampm != null)
   {
      alert("You can't specify AM or PM for military time.");
      return false;
   }
   
   if (minute<0 || minute > 59)
   {
      alert ("Minute must be between 0 and 59.");
      return false;
   }
   
   if (second != null && (second < 0 || second > 59))
   {
      alert ("Second must be between 0 and 59.");
      return false;
   }
   
   return true;
}

function isValidDate(dateStr) {
// Date validation function courtesty of 
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY   NULL

   var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
   var matchArray = dateStr.match(datePat); // is the format ok?
   
   if (dateStr == "")
      return true;
      
   if (matchArray == null)
   {
//    alert(dateStr + " Date is not in a valid format.")
      return false;
   }
   
   month = matchArray[1]; // parse date into variables
   day = matchArray[3];
   year = matchArray[4];
   
   if (month < 1 || month > 12) 
   { // check month range
//    alert("Month must be between 1 and 12.");
      return false;
   }
   
   if (day < 1 || day > 31) 
   {
//    alert("Day must be between 1 and 31.");
      return false;
   }
   
   if ((month==4 || month==6 || month==9 || month==11) && day==31) 
   {
//    alert("Month "+month+" doesn't have 31 days!")
      return false;
   }
   
   if (month == 2) 
   { // check for february 29th
      var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
      
      if (day>29 || (day==29 && !isleap)) 
      {
//       alert("February " + year + " doesn't have " + day + " days!");
         return false;
      }
   }

      
   return true;
}

function clientTime() {
   var now = new Date();
   var current = '';
   var suffix = 'AM';

   if (now.getHours() > 12) {
      current = now.getHours() - 12 + ':';
      suffix = 'PM';
   } else if (now.getHours() == 0) {
      current = '12:';
      suffix = 'AM';
   } else {
      current = now.getHours() + ':';
      suffix = 'AM';
   }

   if (now.getMinutes() < 10) {
      current += '0' + now.getMinutes() + ' ' + suffix;
   } else {
      current += now.getMinutes() + ' ' + suffix;
   }

   return current;
}

function clientDate() {
   var now = new Date();
   var current = '';

   current = (now.getMonth() + 1) + '/' + now.getDate() + '/' + now.getFullYear();

   return current;
}


//validation sequence for entry forms

function requireInput(control, fieldname) {
   if (control.value == '') {
      alert(fieldname + ' Required');
      return false;
   }

   return true;
}

function radioValue(control) {
   for (i = 0; i < control.length; i++) {
      if (control[i].checked) {
         return control[i].value;
      }
   }
}


function Minimize(){

   window.innerWidth = 100;
   window.innerHeight = 100;
   window.screenX = screen.width;
   window.screenY = screen.height;
   alwaysLowered = true;
}

function Maximize(){

   window.innerWidth = screen.width;
   window.innerHeight = screen.height;
   window.screenX = 0;
   window.screenY = 0;
   alwaysLowered = false;
}
