/**
 *------------------------------------------------------------------------------
 * General set of functions that don't fit in any specific category
 *------------------------------------------------------------------------------
 */

/**
 *------------------------------------------------------------------------------
 * Function to test the type of the client browser
 *------------------------------------------------------------------------------
 * Arguments: none
 *------------------------------------------------------------------------------
 * Returns true if the browser is a version of MS Internet Explorer, otherwise
 * it returns false;
 *------------------------------------------------------------------------------
 */
function isIE() {
	if (navigator.userAgent.indexOf("MSIE") == -1) {
		return false;
	}
	return true;
}

/**
 *------------------------------------------------------------------------------
 * Function to assign keyboard focus to the first element that accepts it.  The
 * acceptance makes sure the element:
 *
 *   o - is not a standard HTML hidden element
 *   o - does not have its visibility style set to hidden
 *   o - is not currently disabled
 *
 * If all of the above hold, the element receives keyboard focus, otherwise the
 * next element is tested.
 *------------------------------------------------------------------------------
 * Arguments: none
 *------------------------------------------------------------------------------
 * Returns nothing; assigns focus if form exists with an element that accepts
 * keyboard focus
 *------------------------------------------------------------------------------
 */
function assignFocus() {
	if (document.forms.length != 0) {
		for (var i=0; i<document.forms[0].elements.length; i++) {
			if (document.forms[0].elements[i].type && 
				document.forms[0].elements[i].type != "hidden" && 
	            document.forms[0].elements[i].type != "radio" && 
	            document.forms[0].elements[i].type != "checkbox" && 
	            document.forms[0].elements[i].currentStyle.visibility != "hidden" &&
	            ! document.forms[0].elements[i].disabled) {
				document.forms[0].elements[i].focus();
				return;
	        }
		}
	}
}
