$(function() {

		// Fancybox up the sidebar images
	$("#content-supp a:has(img)").attr('rel', 'gallery').fancybox({
		titleShow: false
	});
	
/**
 * Modules
**/
	if ($("body").hasClass('module')) {
	
			// Attach the toggle to the Feature title(s)
		$("#features dt")
			.toggle(
				function(e) {
					e.preventDefault();
					$(this).removeClass('expanded').addClass('collapsed');
					$(this).next('dd').slideUp('slow');
				},
				function(e) {
					e.preventDefault();
					$(this).removeClass('collapsed').addClass('expanded');
					$(this).next('dd').slideDown('slow');
				}
			)
			.click();
			
			// Attach large picture fancybox to the medium sized picture
		$("#screenshots #med-img-box a:has(img)").attr('rel', 'gallery').fancybox({
			titleShow: false
		});
		
			// Attach picture toggler to thumbnails to switch medium sized pictures
		$("#screenshots #thumbnails a:has(img)")
			.bind("click", function(e) {
				var imgUrl = $(this).attr("href");
				
					// Find the matching image
				var mediumImg = $('#screenshots #med-img-box a[href="'+ imgUrl +'"]');
					
					// Show it only if it isn't currently active
				if (mediumImg.length) {
					$('#screenshots #med-img-box a:visible').fadeOut('fast');
					mediumImg.fadeIn("fast");
				}
				
				e.preventDefault();
			});
		$("#screenshots #med-img-box a:has(img)")
			.not(":first").hide();
	};
});
