Event.observe( window, 'load', function()
{
	if ( $( 'gas_usage' ) )
	{
		Event.observe( 'gas_usage', 'change', function( event )
		{
			Event.element( event ).previous( 'p' ).update( $( 'gas_usage' ).options[$( 'gas_usage' ).selectedIndex].text );
		});
	};
	
	if ( $( 'gas_link' ) )
	{
		Event.observe( 'gas_link', 'click', function( event )
		{
			window.location.href = baseUrl + $('gas_usage').previous( 'p' ).value;
		});
	}
	
	if ( $( 'link_to' ) && $( 'usage' ) && $( 'post_to' ) )
	{
		Event.observe( 'usage', 'change', function( event )
		{
			if ( $( 'usage' ).value === 'less_than_100k' )
			{
				$( 'link_to' ).hide();
				$( 'post_to' ).show();
			}
			else {
				Event.element( event ).previous( 'p' ).update( $( 'usage' ).options[$( 'usage' ).selectedIndex].text );
			}
		} );
	};

	if( $( 'year_select' ) ) {
		Event.observe('year', 'change', function() {
			$('year_select').submit();		
		});	
	};
	
	var links = $$( 'a.contact_person' );
	if ( links )
	{
		links.each( function( e )
		{	
			Event.observe( e, 'click', function( event )
			{links.each( function( e )
					{	e.show();	} );
				Event.stop( event );
				var person = e.innerHTML.stripTags().strip();
				$$( 'div.contact_person' ).each( function( cp )
				{	e.hide();
					cp.hide();
					if( cp.down( 1 ).innerHTML.stripTags().strip().startsWith( person ) ) {
						cp.show();
					}
				} );
			} );
		} );
	};
	
} );