jQuery(document).ready(function() {

	// global functions

	// hides the answers initially
	jQuery('.answer').hide();

	// hides the close buttons initially
	jQuery('.hide').hide();


	// more global functions

	jQuery('.show').click(function() {

	  jQuery('#faq > li').each(function() {
			jQuery(this).children('.answer').slideUp('slow');
			jQuery(this).children('.hide').fadeOut('slow');
			jQuery(this).children('.show').fadeIn('slow');
			jQuery(this).children('h2').css({'color': '#000'});
		});
		if (jQuery(this).css('display') != "none") {
			jQuery(this).parent().children('.answer').slideDown('slow');
			jQuery(this).parent().children('.show').fadeOut('slow');
			jQuery(this).parent().children('.hide').fadeIn('slow');
			jQuery(this).parent().children('h2').css({'color': '#8ac100'});
		} else {
			jQuery(this).parent().children('.answer').slideUp('slow');
			jQuery(this).parent().children('.hide').fadeOut('slow');
			jQuery(this).parent().children('.show').fadeIn('slow');
			jQuery(this).parent().children('h2').css({'color': '#000'});
		}

    /*
		// hides the open answer
		jQuery('.answer').slideUp('slow');

		// fades out the close button
		jQuery('.hide').fadeOut('slow');

		// fades in the answer button
		jQuery('.show').fadeIn('slow');

		// resets the question text color
		jQuery('h2').css({'color': '#000'});
		*/

		return false;
	});


	jQuery('.hide').click(function() {
		jQuery(this).parent().children('.answer').slideUp('slow');
		jQuery(this).parent().children('.hide').fadeOut('slow');
		jQuery(this).parent().children('.show').fadeIn('slow');
		jQuery(this).parent().children('h2').css({'color': '#000'});
		return false;
	});

});
