//
// Accordian plugin for jQuery
// Written by Eli Van Zoeren
//
(function($) {
  $.fn.accordian = function(options) {
    var opts = $.extend({}, $.fn.accordian.defaults, options);
    
    return this.each(function() {
      $this = $(this).addClass('accordian');
      $items = $(opts.itemSelector, $this);
      $titles = $items.children(opts.titleSelector);
      $panes = $items.children(opts.paneSelector).hide();
      
      $titles.click(function() {
        $title = $(this);
        $pane = $title.siblings(opts.paneSelector).slideToggle(300);
        $panes.not($pane).slideUp(300);
        $item = $title.parent();
        $items.not($item).removeClass('active');
        $item.toggleClass('active');
      });
    });
  };

  // plugin defaults
  $.fn.accordian.defaults = {
    itemSelector: 'li',
    titleSelector: 'h3',
    paneSelector: 'div'
  };
})(jQuery);

$('#faqs').accordian();
$('#anti-aging').accordian({titleSelector:'h4'});
