﻿/*
   Before the user interacts with the page, do housekeeping.
   
   RME
   20070724
*/

// If this is a search results page, set the the cursor focus where appropriate.
function setFocusInSearchResultsPage()
{
	var sLASTNAME = 'lastName';
	var sKEYWORD = 'Keyword';
	
	var el = document.getElementById(sLASTNAME);
	
	if (el)
	{
		el.focus();
	}
	else
	{
		el = document.getElementById(sKEYWORD);
		if (el)
			el.focus();
	}
}
// If this is a search results page, set the the cursor focus where appropriate. [OBSOLETE]
function setFocusInSearchResultsPage2()
{
	var sLAWYERS = '/LAWYERS/DEFAULT.ASPX';
	var sLAWYERSRESULTS = 'LAWYERSEARCH.ASPX';
	var sLAWYERSFOCUS = 'lastName';
	var sNEWS = '/NEWS/PAGES/DEFAULT.ASPX';
	var sNEWSRESULTS = 'NEWSSEARCH.ASPX';
	var sNEWSFOCUS = 'Keyword';
	var sSITE = 'ENTIRESITESEARCH.ASPX';
	var sSITEFOCUS = sNEWSFOCUS;
	
	var sUCPath = window.location.pathname.toUpperCase();
	
	if ((sUCPath.lastIndexOf(sLAWYERS) > -1) || (sUCPath.lastIndexOf(sLAWYERSRESULTS) > -1))
	{
		document.getElementById(sLAWYERSFOCUS).focus();
	}
	else if ((sUCPath.lastIndexOf(sNEWS) > -1) || (sUCPath.lastIndexOf(sNEWSRESULTS) > -1))
	{
		document.getElementById(sNEWSFOCUS).focus();
	}
	else if (sUCPath.lastIndexOf(sSITE) > -1)
	{
		document.getElementById(sSITEFOCUS).focus();
	}
}

function doHousekeeping()
{
	setFocusInSearchResultsPage();
}