// extend jQuery with an accordion ui
jQuery.fn.ciplAccordion = function(){
	var accordionDL = this;
	$('dt', accordionDL)
		.click(function() {
			if ($(this).hasClass('selected')) return;
			
			$('dt.selected', accordionDL)
				.removeClass('selected')
				.next('dd').slideUp('fast');
			$(this)
				.addClass('selected')
				.next('dd').slideDown('fast');
		})
		.each(function() {
			if (!$(this).hasClass('selected')) $(this).next('dd').hide();
		});
};

// default site setup
$(function(){
	// set up hover on the submenu's root, this the (non-IE) CSS '#header ul li:hover li'
	$('#header ul li:has(ul)')
		.hover(
			function(){	$(this).addClass('over'); },
			function(){ $(this).removeClass('over'); }
		);
	// disable all submenu root links
	// leaving them live ATM
	/*
	$('#header ul li:has(ul) a:first').click(function(){		
		return false;
	});
	*/
	// add an icon to all non-image external links, and target='_blank'
	// NOTE using the 'external' class to add the icon is screwy on IE when the link has a (soft only?) line break,
	// may have to append an img tag instead
	$('a[href^="http://"]')
		.attr('target', '_blank')
		.not(':has(img)').addClass('external');
});



