function validateForm (form) {

    // reset errors
    $A(form.elements).each(function (input) {
        input.removeClassName('validate-error');
    });
    $('validation-errors').childElements().invoke('hide');
    $$('.validate-error-notice').invoke('hide');


    // check all required elements
    form.select('.validate-required').each(function (input) {
        if (input.tagName == 'SELECT') {
            if (input.selectedIndex == 0) {
                input.addClassName('validate-error');
                $(input.id + '-validate-error-notice').show();
                $('validate-error-required').show();
            }
        } else {
            if (! $F(input)) {
                input.addClassName('validate-error');
                $(input.id + '-validate-error-notice').show();
                $('validate-error-required').show();
            }
        }
    });

    // check all email fields
    form.select('.validate-email').each(function (input) {
        if (! $F(input).match(/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/)) {
            input.addClassName('validate-error');
            $(input.id + '-validate-error-notice').show();
            $('validate-error-email').show();
        }
    });

    //check all phone number fields
    form.select('.validate-phone').each(function (input) {
        if (! $F(input).match(/^\d{3}-\d{3}-\d{4}$/)) {
            input.addClassName('validate-error');
            $(input.id + '-validate-error-notice').show();
            $('validate-error-phone').show();
        }
    });


    if ($$('.validate-error').size() > 0) {
        $$('.validate-error').first().focus();
        return false;
    }

    return true;
}

function updateDateTime ( )
{
   var currentTime = new Date ( );
  
   var currentDay = currentTime.getDay ( );
   var currentDate = currentTime.getDate ( );
   var currentMon = currentTime.getMonth ( );
   var currentYr = currentTime.getFullYear ( );
   var currentHours = currentTime.getHours ( );
   var currentMinutes = currentTime.getMinutes ( );
   var currentSeconds = currentTime.getSeconds ( );

   // Pad the minutes and seconds with leading zeros, if required
   currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
   currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
 
   // Choose either "AM" or "PM" as appropriate
   var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

   // Convert the hours component to 12-hour format if needed
   currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

   // Convert an hours component of "0" to "12"
   currentHours = ( currentHours == 0 ) ? 12 : currentHours;

   // Give textual names
   switch (currentDay) {
      case 0: currentDay = "Sunday"; break;
      case 1: currentDay = "Monday"; break;
      case 2: currentDay = "Tuesday"; break;
      case 3: currentDay = "Wednesday"; break;
      case 4: currentDay = "Thursday"; break;
      case 5: currentDay = "Friday"; break;
      case 6: currentDay = "Saturday"; break;
   } ;
   switch (currentMon) {
      case 0:  currentMon = "January"; break;
      case 1:  currentMon = "February"; break;
      case 2:  currentMon = "March"; break;
      case 3:  currentMon = "April"; break;
      case 4:  currentMon = "May"; break;
      case 5:  currentMon = "June"; break;
      case 6:  currentMon = "July"; break;
      case 7:  currentMon = "August"; break;
      case 8:  currentMon = "September"; break;
      case 9:  currentMon = "October"; break;
      case 10: currentMon = "November"; break;
      case 11: currentMon = "December"; break;
   } ;

   // Compose the string for display
   var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
   var currentDateString = currentDay + ", " + currentMon + " " + currentDate + ", " + currentYr

   if (! $('date-time')) return;
   // Update the time display
   document.getElementById("date").firstChild.nodeValue = currentDateString;
   document.getElementById("time").firstChild.nodeValue = currentTimeString;
}
setInterval("updateDateTime()", 1000);


