/*=========================================================================================================================
| Highlight FORM FUNCTIONS
|
| Author:    Jeremy Caney, Ignia LLC (Jeremy@ignia.com)
| Client     Ignia, LLC
| Project    Ignia.com
|
| Purpose :  Highlights an input element dynamically when user has focus.
|
>=========================================================================================================================
| Usage   : Place OnActivate="Highlight(event)" within the form tag and include this file.
>=========================================================================================================================
| Revisions  Date        Author          Comments
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|            03.17.03    Jeremy Caney    Borrowed original code concepts from DynamicDrive.com.
|            MM.DD.YY    FName LName     Description
\------------------------------------------------------------------------------------------------------------------------*/

/*=========================================================================================================================
| DECLARE PUBLIC VARIABLES
>==========================================================================================================================
| Declare any public/global variables prior to page initiation
\------------------------------------------------------------------------------------------------------------------------*/
  var cssHighlight    = "FormHighlight" ;  // class name for the input Highlight
  var cssOld          = '';
  var eventObj;
  var isNS6           = document.getElementById && !document.all;
  var targetElements  = /INPUT|TEXTAREA|OPTION/;  //Select boxes will cause problems as this will force them shut when changing the class

/*=========================================================================================================================
| FUNCTION: CHECK ELEMENT
>==========================================================================================================================
| Checks whether the element clicked is a form element.
\------------------------------------------------------------------------------------------------------------------------*/
  function checkElement(paramElement) {
    if (targetElements.test(paramElement.tagName.toUpperCase())) {
      if (isNS6 && eventObj.nodeType == 3) {
        eventObj = eventObj.parentNode.parentNode;
        }
      return true;
      }
    return false;
    }

/*=========================================================================================================================
| FUNCTION: CHANGE CLASSNAME
>==========================================================================================================================
| Changes a class name to a new temporary name; stores the old name as "oldClassName".  If no classname is provided, the
| old one is restored.
\------------------------------------------------------------------------------------------------------------------------*/
//ChangeClassName: Changes the class associated with a specific object
  function ChangeClassNamex(paramObject, paramClassName) {
    if (paramObject != null) {
      if (paramClassName != null) {
        if (paramObject.oldClassName == undefined) {
          paramObject.oldClassName = paramObject.className;
          }
        paramObject.className = paramClassName;
        }
      else {
        if (paramObject.oldClassName !== undefined) {
          paramObject.className = paramObject.oldClassName;
          }
        else {
          paramObject.className = "";
          }
        }
      }
    }

/*=========================================================================================================================
| FUNCTION: Highlight ELEMENT
>==========================================================================================================================
| HighlightS A FORM ELEMENT.
\------------------------------------------------------------------------------------------------------------------------*/
  function Highlight(e) {
    eventObj = isNS6? e.target : event.srcElement;
    if (cssOld != '') {
      ChangeClassNamex(cssOld, null);
      }
    if (checkElement(eventObj)) {
      ChangeClassNamex(eventObj, cssHighlight);
      cssOld = eventObj;
      }
    }
