/*
 * For each call to the move cursor function, the onKeyUp and onFocus event handlers must
 * supply the following:
 *   1. onKeyUp - moveCursor (currentField, nextField, currentFieldSize).
 *   2. onFocus - eventFlag = false.
 *
 * Note: The onFocus event handler must reference the Global "eventFlag" variable. 
 *
 * As an example, here is the code needed to move the cursor to telephone_exchange input
 * field after keying the third (last) digit of the telephone area code.  
 * 
 *  <input type = "text" name = "telephone_area_code"
 *      onkeyup = "moveCursor(this, formName.telephone_exchange, 3)"
 *      onFocus = "eventFlag = false>
 */

// Define Global variable to used by the move cursor function.
var eventFlag = true;

function moveCursor(currentField, nextField, currentFieldSize)
  {
   if (eventFlag && currentField.value.length == currentFieldSize)
      {
       // The next field gets the focus when all the characters have been keyed into the
       // current field.
       nextField.focus();

       if (nextField.type == "text")
          {
           // If the next field is text, then the next field is also selected (Tab key effect).
	   nextField.select();
          }
      }
   else
      {
       if (currentField.value.length < currentFieldSize)
	  {
	   eventFlag = true;
	  }
      }
  }


