// JavaScript Document
// NHN JavaScript code - we will use the prefix NHN to avoid confusion

// Generic empty load/unload function that we will call from all pages
// If needed for some purpose on a particular page, redefine there
function NHNload() {
}
function NHNunload() {
}
function NHNemlink(key,coded,display) {
// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/
// Modified by A. Feldt, University of Oklahoma to be a function to
// ease multiple address use on a single page and to allow an optional link name
// A special case has been added:  if the optional link name is the text
// "obscured" then we display the link as visually obscured.
  var shift=coded.length;
  var link="";
  var ltr;
  var displayed="";
  for (i=0; i<coded.length; i++) {
    if (key.indexOf(coded.charAt(i))==-1) {
      ltr = coded.charAt(i);
      if (display == "obscured") {
        if (ltr == ".") {
          displayed += '<b>dot</b> ';
        } else if (ltr == "@") {
          displayed += '<b>at</b> ';
        } else {
          displayed += (ltr) + ' ';
        }
      }
      link += (ltr);
    }
    else {
      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length;
      link += (key.charAt(ltr));
      if (display == "obscured") {
        displayed += (key.charAt(ltr)) + ' ';
      }
    }
  }
  if (display == "obscured") {
    display = displayed.substr(0,displayed.length-1); // remove final space
  }
  if (display) {
    document.write("<a href='mailto:"+link+"'>"+display+"</a>");
  } else {
    document.write("<a href='mailto:"+link+"'>"+link+"</a>");
  }
}
