function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

var isNN = (navigator.appName.indexOf("Netscape") != -1);
function autoTab(input, len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode;
  var filter = (isNN) ? [0, 8, 9] : [0, 8, 9, 16, 17, 18, 37, 38, 39, 40, 46];
  if (input.value.length >= len && !containsElement(filter, keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input) + 1) % input.form.length].focus();
  }
  function containsElement(arr, ele) {
    var found = false, index = 0;
    while (!found && index < arr.length)
      if (arr[index] == ele)
      found = true;
    else
      index++;
    return found;
  }
  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
      if (input.form[i] == input) index = i;
    else i++;
    return index;
  }
  return true;
} // close function autoTab

// function onlyDigits
var isIE = document.all ? true : false;
var isNS = document.layers ? true : false;
function onlyDigits(e) {
  var keyNum = true;
  if (isIE) { // Internet Explorer
    if (window.event.keyCode < 46 || window.event.keyCode == 47 || window.event.keyCode > 57) {
      window.event.keyCode = 0;
      keyNum = false;
    }
  }
  if (isNS) { // Netscape
    if (e.which < 46 || e.which == 47 || e.which > 57) {
      e.which = 0;
      keyNum = false;
    }
  }
  return (keyNum);
  if (isNS) document.captureEvents(Event.KEYPRESS);
  document.onkeypress = onlyDigits;
} // close function onlyDigits


function Tab(currentField, nextField) {
  // Determine if the current field's max length has been reached.

  if (currentField.value.length == currentField.maxLength) {
    // Retreive the next field in the tab sequence, and give it the focus.

    document.getElementById(nextField).focus();
  }
}

function isNumberKey(e) {
  var msg = e.value;
  var chr;
  for (i = 0; i < msg.length; i++) {
    chr = msg.substring(i, i + 1);
    if (chr < "0" || chr > "9") {
      msg = msg.substring(0, i);
      e.value = msg;
    }
  }
}


