//Description: This javascript sets the focus on the page to the first TextBox,
//Checkbox, Password Box, Radio Button, or Selection box.

//12-1-2004: KAH Addition - Added a condition to check for a hidden field.
//i.e. this hidden field is used to stop from setting the focus on the page.
//e.g. Consent.ascx (SHP) does NOT want the focus brought down to the 'Agree' checkbox.
//So we added this hidden field to stop that from happening.

var form = document.forms[0];
if(form.elements.hffocusRequired == null)
{
	var fail; // if focus fails, try another text box
	for (var i = 0; i < document.forms[0].elements.length; i++)
		if (form.elements[i].type == 'text' || form.elements[i].type == 'password'
			|| form.elements[i].type == 'radio' || form.elements[i].type == 'checkbox'
			|| form.elements[i].type == 'select-one')
		{
			fail = false;
			try
			{
				document.forms[0].elements[i].focus();
			} //try
			catch(e)
			{
				fail = true;
			} //catch
			
			if (fail)
			{
				fail = false;
				try
				{
					document.forms[0].elements[i].select();
				} // try
				catch(e)
				{
					fail = true;
				} // catch
			} // if
			
			if (fail)
				fail = false;
			else
				break;
		} // if
}