function setPageFocus()
{
	if (typeof(dialogWin) == 'undefined' || !dialogWin)
	{
		// Attempt to set focus inside main content. If this fails, use entire document.
		var oContent = document.getElementById('contentDiv');
		if (oContent == null)
			oContent = document;
	
		// set focus to the element with tabIndex 1 of the current form
		// if tabIndex 1 can not have its focus set, increment tabIndex
		var oTabIndexed = oContent.getElementsByTagName('*');
		var j = 0;
		var found = false;
		var tabIndexNum = 1;
		while (j < oTabIndexed.length && !found)
		{
			if (oTabIndexed[j].tabIndex != null && oTabIndexed[j].tabIndex == tabIndexNum)
			{
				if (!oTabIndexed[j].disabled && !oTabIndexed[j].hidden && !oTabIndexed[j].invisible)
				{
					oTabIndexed[j].focus();
					found = true;
				}
				else
				{
					tabIndexNum++;
				}
			}
			j++;
		}
		
		// If there is no element with tabIndex 1, set the focus to the first 'a' element			
		// If this fails, ignore the error. 
		if (!found)
		{
			try
			{
				oContent.getElementsByTagName('a').item(0).focus();
			}
			catch (e)
			{
			}
		}
	}
}
