/*
  Scrub the Search
*/
  function checkSearch(anId) {
    ok = false;
    term = document.getElementById(anId);
    if (term != null && term.value.length > 0) {
      var stuff = new RegExp("[^a-zA-Z0-9_ .*~-]","g");
      term.value = term.value.replace(stuff,"");
      term.value = term.value + "*";
      ok = true;
    }
    return ok;
  }


/*
  Get Id

  Parameters: anId

  Returns the DOM object associated to the Id passed into the function.
*/
  function getById(aString) {
    return document.getElementById(aString);
  }


/*
  Get Names

  Parameters: names

  Returns the DOM objects associated to a partial match of the name string
  passed into the function.
*/
  function getByNames(aString) {
    return document.getElementsByName(aString);
  }

/*
  ----------------------------------------------------------------------------
    Check for Valid Email

    checks for a period and the at symbol

    anId is the ID of the input field

    return true if passed, false if failed

    Ex: <form action="#" onsubmit="return checkEmail('emailA')">
          <input name="emailA" id="emailA" type="text">
  ----------------------------------------------------------------------------
*/

function checkEmail(anId) {
  var e = document.getElementById(anId);
  var ok = false;
  if (e != null) {
    if (e.value.indexOf(".") != -1 && e.value.indexOf("@") != -1) {
      ok =  true;
    }
  }
  return ok;
}

/*
  Top Menu
*/
function doHover(anInt, active) {  
  var l = document.getElementById("leftPart"+anInt);
  var c = document.getElementById("centerPart"+anInt);
  var r = document.getElementById("rightPart"+anInt);
  var a = "H";
  if (l != null && c != null && r != null) {
    l.className = "topLeft"+a;
    c.className = "topCenter"+a;
    r.className = "topRight"+a;
  }
}

function endHover(anInt, active) {
  var l = document.getElementById("leftPart"+anInt);
  var c = document.getElementById("centerPart"+anInt);
  var r = document.getElementById("rightPart"+anInt);
  var a = "";
  if (active != null && active.length > 0) {
    a = active;
  }  
  if (l != null && c != null && r != null) {
    l.className = "topLeft"+a;
    c.className = "topCenter"+a;
    r.className = "topRight"+a;
  }
}
