$(document).ready(function(){

	var slideDuration = 150;

	if($('div.section').length > 0) {
		$('div.section div.content').each(function() {
			$(this).css("height", $(this).height()+"px").hide();
		});
		// open first?
		// $('div.section:first').addClass('open').children('div.content').show();
		$('div.section a.open').click(function(){
			var theDiv = $(this).parent('p').parent('div.section');
			if(theDiv.hasClass('open')) {
				theDiv.removeClass('open').children('div.content').slideUp(slideDuration);
			} else {
				// only one at a time?
				// $('div.section').removeClass('open').children('div.content').slideUp(slideDuration);
				theDiv.addClass('open').children('div.content').slideDown(slideDuration);
			}
			return false;
		});
	}

	if($('#gallery').length > 0) {
		$('#gallery img').hide();
		$('#gallery img:first').show();
		$('#gallery').cycle({ 
			prev:   'a.prev', 
			next:   'a.next', 
			timeout: 0,
			speed: 0,
			after: function(){
				var theId = parseInt(this.id.substr(3));
				$('div.caption').html(captions[theId-1]);
				$('span#img_no').html(theId);
			}
		});
	}

	


});