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;
  }
  
}

/* SETS BACKGROUND FOR EPLUS LOGIN WIDGET PASSWORD INPUT */

function setPassBg(){
	
  if(document.getElementById('login')){
  	var loginBox = document.getElementById('login');
  	
    if(!document.getElementById('login').value){
  	  loginBox.className = 'background';
    }
  
    loginBox.onfocus = function(){
  	  this.className = 'nobg'
    }
    loginBox.onblur = function(){
  	  if(this.value == "" || this.value == " "){
  			this.className = 'background';
  	 	}
    }
  }
}

addEvent(window, 'load', setFocus);
addEvent(window, 'load', setPassBg);