// collapseable jQuery interaction layer
$(document).ready(function(){

	// Set default menu states	
	expanded = $('li.expanded > h2');
	expanded.css('cursor', 'pointer');
	jQuery.each(expanded, function(){
		$(this).text('- ' + $(this).text());
	});
	collapsed = $('li.collapsed > h2');
	collapsed.css('cursor', 'pointer').next('ul').css('display', 'none');
	jQuery.each(collapsed, function(){
		$(this).text('+ ' + $(this).text());
	});
	
	// Switch menu states when the menu headers are clicked
	$('li.toggleable > h2').click(function(){
		menu_header = $(this);
		menu_header.next('ul').slideToggle('normal');
		if (menu_header.text().substring(0, 2) == '+ ')
			menu_header.text('- ' + menu_header.text().substring(2));
		else if (menu_header.text().substring(0, 2) == '- ')
			menu_header.text('+ ' + menu_header.text().substring(2));
	});

});
/*** 
    Simple jQuery Slideshow Script
***/

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
