var bFound = false;

if(typeof core_disable_autofocus == "undefined")
{
  // for each form

  for (f=0; f < document.forms.length; f++)
  {
    // for each element in each form

    for(i=0; i < document.forms[f].length; i++)
    {
      // if it's not a hidden element

      if (document.forms[f][i].type != "hidden" &&  document.forms[f][i].type != "checkbox" && document.forms[f][i].type != "radio" && document.forms[f][i].type != "submit" && document.forms[f][i].type != "button" && document.forms[f][i].type != "reset")
      {
        // and it's not disabled

        if (document.forms[f][i].disabled != true)
        {
            // set the focus to it
				try {
					document.forms[f][i].focus();
					document.forms[f][i].value = document.forms[f][i].value; // place cursor behind value
            	var bFound = true;
				} catch(err) {
					
				}
        }
      }
      // if found in this element, stop looking

      if (bFound == true)
        break;
    }
    // if found in this form, stop looking

    if (bFound == true)
      break;
  }
}
