function r_on(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/" + i + "_over.gif"; 
    }
  }
}

function r_off(i) {
  if (document.images) { 
    if (document[i].src.indexOf("down") < 0) {
      document[i].src = "images/" + i + ".gif"; 
    }
  }
}

function writeDate() {
  var today = new Date();
  var year = today.getFullYear();
  document.write(year);
}

function leaveSite(site) {
  if (confirm('You are now leaving this web site.\nIf you do not wish to leave this site, click Cancel. Click OK to leave.') == 1) {
    window.open(site, 'Untitled','toolbar=yes,width=750,height=500,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes')
  }
}

function popUp(page) {
  popup_window = window.open(page,'popup','location,menubar,resizable,scrollbars,status,toolbar,width=500,height=300');
}

function convertSpaces(str) {
  var out = "", flag = 0;
  for (i = 0; i < str.length; i++) {
    if (str.charAt(i) != "_") {
      out += str.charAt(i);
      flag = 0;
    } else {
      if (flag == 0) {
        out += " ";
        flag = 1;
      }
    }
  }
  return out;
}

function checkrequired(which) {
  var pass=true;
  if (document.images) {
    for (i=0; i < which.length; i++) {
      var tempobj=which.elements[i];
      if (tempobj.name.substring(0,9)=="required_") {
        if (((tempobj.type=="text"||tempobj.type=="textarea")&&
          tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
          tempobj.selectedIndex==0)) {
          pass=false;
          break;
        }
      }
    }
  }
  if (!pass) {
    shortFieldName = tempobj.name.substring(9,tempobj.name.length).toUpperCase();
    alert("The "+convertSpaces(shortFieldName)+" field is required. Please enter the "+convertSpaces(shortFieldName.toLowerCase())+" and try again.");
    return false;
  } else {
    return true;
  }
}
