$(function(){
	$('img.hover').each(function(){
		var img = new Image();
		var src = $(this).attr('src');
		var name = src.substring(0, src.lastIndexOf('.'));
		var ext = src.substring(src.lastIndexOf('.'));
		var hover = name+'-hover'+ext;
		img.src = hover;
		$(this).data('org', src);
		$(this).data('hover', hover);
	});
	
	$('img.hover').hover(
		function(){ $(this).attr('src', $(this).data('hover') ); },
		function(){ $(this).attr('src', $(this).data('org') ); }
	);
	
	$('#navigation > li').each(function(){
		if (window.XMLHttpRequest) // only IE6 doesn't have this object
		{
			var text = $(this).find('a:first').text();
			var span = $('<span/>');
	
			span.text(text);
			$(this).prepend(span);
		}

		var corner = 85 - ($(this).width() / 2);
		$(this).find('ul.flyout:first').css('margin-left', -corner);
	});
	
	$('#navigation li').hover(
		function(){ $(this).find('ul.flyout:first').show(); },
		function(){ $(this).find('ul.flyout:first').hide(); }
	);
	
	$('#submenu.home img.hover').mouseover(function(){
		var index = $(this).parent().index();
		$('#flash-image div.flash-header').hide();
		$('#flash-image div.flash-header:eq('+index+')').show();
	});
	
	/*$('#submenu.home img.hover').mouseout(function(){
		$('#flash-image div.flash-header').hide();
		$('#flash-image div.flash-header:eq(6)').show();
	});*/

});
