
// Boolean for browser type
var agt=navigator.userAgent.toLowerCase();

var is_Opera = (navigator.userAgent.indexOf('Opera') != -1); 
var is_MSIE = (navigator.userAgent.indexOf('MSIE') != -1); 
var is_Moz = (navigator.userAgent.indexOf('Gecko') != -1); 
var is_nav = (navigator.userAgent.indexOf('Netscape') != -1 && navigator.userAgent.indexOf('Gecko') != -1);

// Gets an element by ID
function getElement(sSelection)
{
	var oElement;
	if( is_nav )
	{
		oElement = eval("document.ids." + sSelection);
	} else {
		oElement = document.getElementById(sSelection);
	}
	
	return oElement;
}

// Checks or uncheckes all checkboxes associated with the given field
// Does NOT change field status if the checkbox is disabled
function setCheckboxState(sFormName, sCheckboxName, bSetCheckbox)
{ 
	var theForm = window.document.forms[sFormName];
	for(i = 0; i < theForm.elements.length; i++)
	{
		if ( (theForm.elements[i].type == "checkbox") && (theForm.elements[i].name == sCheckboxName) && !(theForm.elements[i].disabled) )
		{
			theForm.elements[i].checked = bSetCheckbox;
		}
	}
}

// Sets an option in a select box by value
function setOption(oSelect, vValue)
{
	for(i = 0; i < oSelect.options.length; i++)
	{
		if(oSelect.options[i].value == vValue)
		{
			oSelect.options[i].selected = true;
			break;
		}
	}
}

// Sets a radio by value
function setRadio(oRadio, vValue)
{
	for(i = 0; i < oRadio.length; i++)
	{
		if(oRadio[i].value == vValue)
		{
			oRadio[i].checked = true;
			break;
		}
	}
}

// Sets checkbox(es) by value
function setCheckbox(oCheckbox, vValue)
{
	alert(formNavigation.MainYN.length);
	for(i = 0; i < oCheckbox.length; i++)
	{
		if(oCheckbox[i].value == vValue)
		{
			oCheckbox[i].checked = true;
		}
	}
}

// Class for name/value pairs
function Type(vValue, sName)
{
	this.vValue = vValue;
	this.sName = sName;
}

// Populates the provided select object with options
function createOptions(oSelect, arrTypes)
{
	// Clear the existing options
	oSelect.options.length = 0;
	
	// Add a new option for each type
	for(var n = 0; n < arrTypes.length; n++)
	{
		oSelect.options[n] = new Option(arrTypes[n].sName, arrTypes[n].vValue);
	}
}
