;(function($) {
  // plugin definition
  jQuery.fn.faqs = function(options) {
	// build options before element iteration
	var defaults = {
	overcolor: '#f00'
  };
	
	var opts = $.extend({},defaults,options);
	// iterate and reformat each matched element
	
	return this.each(function() {
	var Obj = {'class':'faqintro', 'text': 'Click on a question to reveal its answer.'};
	$('<p/>',Obj).insertBefore($('.question:eq(0)'));
	var answers$ = $('.answer');
	answers$.css('cursor','pointer');
	var color = answers$.css('color');
	var questions$ = $('.question');
	questions$.css('cursor', 'pointer');
	answers$.hide();
	questions$.click(function() {
		var theans$ = $(this).next();
		if(theans$.is(':hidden')){
		answers$.filter(':visible').hide();
		theans$.slideDown();
		$(this).siblings('.question').css('color',color);
		$(this).css('color',opts.overcolor);
		}  else {
			theans$.slideUp().prev().css('color',color);
		}
	}); // end click
	
	answers$.click(function(){
		$('.answer').slideUp();
		$('.answer').prev().css('color',color);
		}); // end click
												
	}); // end each
}; // end plugin
// end of closure
})(jQuery);
