function imageOn(imgName){
  if (document.images){
    document.images[imgName].src = "Images/button_" + imgName + "_hover.gif";
  }
}
function imageOff(imgName){
  if (document.images){
    document.images[imgName].src = "Images/button_" + imgName + ".gif";
  }
}
function butter_roomsingle(){
  document.myform.butterfield_hall_roommate.readOnly = true;
  document.myform.butterfield_hall_roommate.style.backgroundColor = "#CCCCCC";
}
function butter_roomdouble(){
  document.myform.butterfield_hall_roommate.readOnly = false;
  document.myform.butterfield_hall_roommate.style.backgroundColor = "#FFFFFF";
}
function guest_roomsingle(){
  document.myform.guest_house_roommate.readOnly = true;
  document.myform.guest_house_roommate.style.backgroundColor = "#CCCCCC";
}
function guest_roomdouble(){
  document.myform.guest_house_roommate.readOnly = false;
  document.myform.guest_house_roommate.style.backgroundColor = "#FFFFFF";
}
function CheckRequiredFields(){
  var msg = new String();

  if(isblank(document.myform.Card_Number.value)){
    msg += '\\nPlease type something in the "Credit Card Number" text field.';
  }
  if (isblank(document.myform.Card_Name.value)) {
    msg += '\\nPlease type something in the "Name on card" text field.';
  }
  if (isblank(document.myform.Card_Address1.value)) {
    msg += '\\nPlease type something in the "Address 1" text field.';
  }
  if (isblank(document.myform.Card_City.value)) {
    msg += '\\nPlease type something in the "City" text field.';
  }
  if (isblank(document.myform.Card_State.value)) {
    msg += '\\nPlease type something in the "State" text field.';
  }
  if (isblank(document.myform.Card_Country.value)) {
    msg += '\\nPlease type something in the "Country" text field.';
  }
  if (isblank(document.myform.Card_Zip.value)) {
    msg += '\\nPlease type something in the "Zip Code" text field.';
  }

  // Put field checks above this point.
    if(msg.length > 2) {
      alert('NOTE:' + msg);
      return false;
    }
  return true;
}
function isblank(s) {
  for(var i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if ((c != ' ') && (c != '\n') && (c != '')) return false;
  }
  return true;
}
function verify(f) {
  var msg;
  var empty_fields = "";
  var pattern = /proceeding_sub.html/;

  for(var i = 0; i < f.length; i++) {
    var e = f.elements[i];
    var dPattern = /^\d\//;
    if ((e.type == "text") && !e.optional) {
      if (e.type == "text" && ((e.value == null) || (e.value == "") || isblank(e.value))) {
        empty_fields += "\n            " + e.name;
        continue;
      }
      if (e.name == "arrival" || e.name == "departure"){
        if (!e.value.match(dPattern))
          empty_fields += "\n The " + e.name + " date must be in US Format (e.g. Month/Day/Year)";
      }
    }
    else if (e.type == "checkbox" && location.pathname.match(pattern)){
      if (!e.checked){
        empty_fields += "\n You must agree to the copyright by checking the box";
      }
    }
  }

  if (!empty_fields) return true;
  msg  = "____________________________________________________\n\n";
  msg += "The form was not submitted because of the following error(s).\n";
  msg += "Please correct these error(s) and re-submit.\n";
  msg += "____________________________________________________\n\n";

  msg += empty_fields;

  alert(msg);
  return false;
}
