
function initRollovers( target ){
	var image_cache = new Object();
	$( '#contact-menu, #foot-menu, .ex-menu' ).find( 'img' ).each( function(){
		var imgsrc = this.src;
		var ftype = imgsrc.substring( imgsrc.lastIndexOf('.'), imgsrc.length );
		var imgsrc_on = imgsrc.replace( ftype, '_on' + ftype );
		image_cache[ this.src ] = new Image();
		image_cache[ this.src ] = imgsrc_on;
		
		$( this ).hover(
			function(){
				this.src = imgsrc_on;
			},
			function(){
				this.src = imgsrc;
			}	
		);
	} );
	$( '.rollover' ).each( function(){
		var imgsrc = this.src;
		var ftype = imgsrc.substring( imgsrc.lastIndexOf('.'), imgsrc.length );
		var imgsrc_on = imgsrc.replace( ftype, '_on' + ftype );
		image_cache[ this.src ] = new Image();
		image_cache[ this.src ] = imgsrc_on;
		
		$( this ).hover(
			function(){
				this.src = imgsrc_on;
			},
			function(){
				this.src = imgsrc;
			}	
		);
	} );
}

function initExpandMenus(){
	var image_cache = new Object();
	$( '.ex-trigger' ).each( function(){
		
		var imgsrc = $( this ).children( 'a' ).children( 'img' ).attr( 'src' );
		var ftype = imgsrc.substring( imgsrc.lastIndexOf('.'), imgsrc.length );
		var imgsrc_on = imgsrc.replace( ftype, '_on' + ftype );
		image_cache[ this.src ] = new Image();
		image_cache[ this.src ] = imgsrc_on;
		
		$( this ).children( 'a' )
			.attr( 'href', 'javascript:;' )
			.toggle(
				function(){
					$( this ).children( 'img' ).attr( 'src', imgsrc_on );
					$( this ).siblings( 'ul' ).fadeIn('fast');
				},
				function(){
					$( this ).siblings( 'ul' ).fadeOut('fast');
					$( this ).children( 'img' ).attr( 'src', imgsrc );
				}
			)
		;
	} );
}

$( document ).ready( function(){
	initExpandMenus();
	initRollovers();
} );
