
/*******************************************************************************************
 * Component:  focus.js - Script used to set focus to the first field on every form.
 *
 * Modification History:
 *
 * Date       Task# Who    Description
 * ---------- ----- ------ -----------------------------------------------------------------
 * 16-09-2004	  103 dafra0 Created.
 *******************************************************************************************/

// Get the second form object.
function SetFocusToFirstTextbox() {
  var txt = GetFirstTextBox();
  if (txt) {
    try { 
      txt.focus();
    } catch(e) {
      // Do nothing.
    }
  }
}

function GetFirstTextBox() {
  // find first input[type=text] in second form
  forms = document.getElementsByTagName('form');
  if (forms.length > 1) {
	  inputs = forms[1].getElementsByTagName('input');
	  i = 0;
	  while (inputs[i]) {
	    if (inputs[i].getAttribute('type') == 'text' || inputs[i].getAttribute('type') == 'password') {
	      return inputs[i];
	    }
	    i++;
	  }
	}
	return;
}

