
window.onload = init;

function init() {
  // Get all input tags
  var els = document.getElementsByTagName('input');

  // How many input tags?
  var elCount = els.length;
  var elCurr = 0;
  var stillLooking = true;

  // Find the first text box
  while (elCurr < elCount && stillLooking) {
    // Get next input tag
    var el = els[elCurr];
    // Is it of type 'text'
    if (el.type.toLowerCase() == 'text') {
      // Set focus and stop the loop
      el.focus();
      stillLooking = false;
    }
    elCurr++;
  }
}
