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