$(function(){
	
	over_suffix = '_o';
	down_suffix = '_d';
	navimages = new Array();
	i = 0;
	
	// preload images...
	$('#header-nav img').each(function(){
		
		regexp = new RegExp('(.*)\\.(.*)$','i');
		imgsrc = $(this).attr('src');
		
		img = new Image();
		img.src = imgsrc.replace(regexp,'$1' + over_suffix + '.$2');
		navimages.push(img);
		
		img = new Image();
		img.src = imgsrc.replace(regexp,'$1' + down_suffix + '.$2');
		navimages.push(img);
		
		i++;
	});
	
	// create rollover states for buttons
	$('#header-nav ul li')
			.hover(function(){
						
				$(this).parent().find('ul').hide(); // hide other subnavs
				$(this).find('ul').show(); // show this subnav
				
				regexp = new RegExp('(.*)\\.(.*)$','i');
				src = $(this).find('img').attr('src').replace(regexp,'$1' + over_suffix + '.$2');
				//alert(src);
				$(this).find('img:not(.active)').attr('src',src); // change button state
				
			}, function(){
				
				regexp = new RegExp('(.*)' + over_suffix + '\\.(.*)$','i');
				src = $(this).find('img').attr('src').replace(regexp,'$1.$2');
				$(this).find('img:not(.active)').attr('src',src); // change button state
				
			}
	);
});