$(document).ready(function() {
	$('#navigation ul:has(a#current)').prev().addClass('open');
	
	$('#navigation h3:not(.open)').next().hide();
	
	$('#navigation li:has(h3>a#current)').css('background','url(img/arrow_current.jpg) 10px center no-repeat');
	$('#navigation li:has(>a#current)').css('background','url(img/arrow_current.jpg) 25px center no-repeat');

	$('#navigation h3>a').parents('li').each(function() {
		var $bgImage = $(this).css('background-image');
		$(this).hover(function() {
			$(this).css('background', '#084DB1 url(img/arrow_hover.jpg) 10px center no-repeat');
		}, function() {
			if ($bgImage == 'none') {
				$(this).css('background', '#0073BC');
			} else {
				$(this).css('background', '#0073BC url(img/arrow_current.jpg) 10px center no-repeat');
			}
		});
	});

	$('#navigation li:has(ul)').not(':has(h3.open)').hover(function() {
		$(this).css('background', '#084DB1 url(img/arrow_open.jpg) 10px 10px no-repeat');
	}, function() {
		$(this).css('background', '#0073BC');
	});

	$('#navigation li:has(h3.open)').hover(function() {
		$(this).css('background', '#084DB1 url(img/arrow_open.jpg) 10px 10px no-repeat');
		$('#navigation ul>li:has(a#current)').css('background', '#084DB1 url(img/arrow_hover.jpg) 25px center no-repeat');
	}, function() {
		$(this).css('background', '#0073BC');
		$('#navigation ul>li:has(a#current)').css('background', '#0073BC url(img/arrow_current.jpg) 25px center no-repeat');
	});

	$('#navigation ul>li').each(function() {
		$(this).hover(function() {
			$(this).css('background', 'url(img/arrow_hover.jpg) 25px center no-repeat');
		}, function() {
			$(this).css('background', 'none');
		});
	});

	$('#navigation h3').css('cursor','pointer').click(function() {
		$('#navigation h3.open').removeClass('open').next().hide();
		$(this).addClass('open').next().show();
	});
});

