// Prototype for find method of Array object
Array.prototype.find = function(searchStr)
{
	var found = false;
	for (i=0; i<this.length; i++) {
		if (this[i] == searchStr) {
			found = true;
		}
	} // for
	return found;
}

/**
 * Check for existence of the addLoadEvent function;
 * Define function if not found
 * NOTE - Functions are methods of some object, in this case the window object
 */
if (!window.addLoadEvent) {
	/* Event handler to execute after page has loaded. */
	function addLoadEvent(func)
	{
		// Store existing onload event
		var oldonload = window.onload;
		// Assign function parameter to onload event if none exists
		if (typeof window.onload != 'function') {
			window.onload = func;
		// Create new function to call existing and new function
		} else {
			window.onload = function()
			{
				if (oldonload) {
					oldonload();
				}
				func();
			} // function()
		} // if/else
	} // addLoadEvent
}

// Add styling to all required input form elements
function setRequiredLabels()
{
	var css;
	// Modify text of all required labels
	elements = document.getElementsByTagName('span');
	for (var i=0; i<elements.length; i++) {
		if ((elements[i].className != null) && (elements[i].innerHTML != null)) {
			// Get all CSS classes for element
			css = elements[i].className.split(' ');
			// Update text only for elementds with a 'required' class
			if (css.find('required')) {
				elements[i].innerHTML = '*' + elements[i].innerHTML;
			}
  	}
	} // for
}

addLoadEvent(setRequiredLabels);
