// init(): loads initialization functions (i.e. preload images or popups)
// to be deprecated by the addLoadEvent funciton
function init( ) {
	// load selected indexes for navigation mentu
	document.menu.officials.selectedIndex = 0;
	document.menu.agencies.selectedIndex = 0;
}
// loadURL(url): redirects current window to new url
// should no longer be used; instead use html meta tag or redirect on server side
function loadURL(url) {
	// navigate to url
	window.location=url;
}
// Simon Willison's unobtrusive onLoad function [http://simonwillison.net/2004/May/26/addLoadEvent/]
function addLoadEvent( func ) {
	var oldOnLoad = window.onload;
	if( typeof window.onload != "function" ) {
		window.onload = func;
	} else {
		window.onload = function( ) {
			if( oldOnLoad ) { oldOnLoad( ); }
			func( );
		}
	}
}
// Roshambo's cross-browser implementation of addEventListener [http://snipplr.com/view/561/add-event-listener/]
function addListener( htmlElement, eventType, func ) {
	var returnValue = false;
	if( window.addEventListener ) {
		htmlElement.addEventListener( eventType, func, false );
		returnValue = true;
	} else if( window.attachEvent ) {
		htmlElement.attachEvent( "on" + eventType, func );
		returnValue = true;
	}
	return returnValue;
}
// Peter-Paul Koch's cross-browser implementation of event targets [http://www.quirksmode.org/js/events_properties.html]
function findTarget( e ) {
	var targetNode = null;
	if( e.target ) targetNode = e.target;
	else if( e.srcElement ) targetNode = e.srcElement;
	if( targetNode.nodeType == 3 ) targetNode = targetNode.parentNode;
	return targetNode;
}
// Brian Arthmire's unobtrusive targetBlank to open links in a new window [blarthmi@franklincountyohio.gov]
// usage: <a class="externalLink" ...
function targetBlank( ) {
	var i, anchors = document.getElementsByTagName( "a" ), returnValue = false;
	if( anchors ) {
		// iterate through every anchor element
		for( i = 0 ; i < anchors.length ; i++ ) {
			// if anchor element is marked as an externalLink...
			if( anchors[ i ].className == "externalLink" && anchors[ i ].getAttribute( "href" ) ) {
				// ...then add the targetBlank
				returnValue = true;
				anchors[ i ].target = "_blank";
			}
		}
	}
	return returnValue;
}
// Brian Arthmire's unobtrusive autoFormSubmit to submit forms onChange [blarthmi@franklincountyohio.gov]
// usage: <select class="autoSubmit" name= ...
function autoFormSubmit( ) {
	var i, nodes = document.getElementsByTagName( "select" ), returnValue = false;
	if( nodes ) {
		// iterate through every select element
		for( i = 0 ; i < nodes.length ; i++ ) {
			// if select element is marked as an autoSubmit...
			if( nodes[ i ].className == "autoSubmit" ) {
				returnValue = true;
				// ...then add the submit form onChange event
				addListener( nodes[ i ], "change", function( e ) {
					var obj = findTarget( e );
					// move up the dom tree until we find the form to submit
					while( obj != null && obj.nodeName != "FORM" ) { obj = obj.parentNode; }
					if( obj ) { obj.submit( ); }
				} );
			}
		}
	}
	return returnValue;
}