// JavaScript Document

$(document).ready(function() { 
	// Apply the 'closed' class to all li elements in collapse lists
	$('.collapseList > li').addClass('closed');
	
	// If a 'highlight' is present open it, else open the first item in the list
	if ($('.collapseList > li.highlight').length > 0) {
		$('.collapseList > li.highlight').removeClass('closed').addClass('open');
	} else {
		$('.collapseList > li:first-child').removeClass('closed').addClass('open');
	}
	
	// Apply the inline function to the 'header' element of each
	$('.collapseList li .header').click(function() {
		// If this item is already open, close it
		if($(this).parent().hasClass('open')) {
			$(this).siblings('.content').slideUp('slow' ,function() {
				$(this).parent().removeClass('open').addClass('closed');
			});
		// If not, close all other open items and open this one
		} else {
			$(this).parent().siblings('.open').children('.content').slideUp('slow' ,function() {
				$(this).parent().removeClass('open').addClass('closed');
			});
			$(this).siblings('.content').slideDown('slow' ,function() {
				$(this).parent().removeClass('closed').addClass('open');
			});
		}		 
	});
	
});
