var setFocus = function()
{

  var searchTags = new Array('input', 'select', 'textarea', 'a');

  var focusElement = getFocusElementFromPage();
  
  if (focusElement != "") 
  {
    focusElement.focus();
  }
  
 
  function getFocusElementFromPage()
  {
    var returnValue = "";
    
    for (var i = 0; i < searchTags.length && returnValue == ""; i++)
    {
      returnValue = findFocusElementFromCollection(document.getElementsByTagName(searchTags[i]));
    }
  
    return returnValue;
  }


  function findFocusElementFromCollection(collection)
  {
    var returnValue = "";
    
    for (var i = 0; i < collection.length; i++) 
    {
      if (collection[i].className && collection[i].className.match('focus')) 
      {
        returnValue = collection[i];
        break;
      }
    }
    
    return returnValue;
  }
  
}


addEvent(window, 'load', setFocus);
