////////////////////////////
// http://adipalaz.awardspace.com/
///////////////////////////
(function($) {
$.fn.expandAll = function(options) {
var defaults = {
  expTxt : '[Expand All]', cllpsTxt : '[Collapse All]',
  cllps : 'div.collapsible', exp : 'h3.expand, h4.expand',
  container : '#' + this.attr("id") + ' ', ref : 'h3',
  showMethod : 'show', hideMethod : 'hide', speed : ''};
var o = $.extend({}, defaults, options);   
return this.each(function() {
  $(o.container + o.ref + ':first').before('<p id="switch"><a href="#expand-all/collapse-all">' + o.expTxt + '</a></p>');     
  $(this).find('#switch a').click(function() {
  var $cllps = $(this).closest(o.container).find(o.cllps),
      $exp = $(this).closest(o.container).find(o.exp);
  if ($(this).text() == o.expTxt) {$(this).text(o.cllpsTxt); $exp.addClass('open'); $cllps[o.showMethod](o.speed);}
  else {$(this).text(o.expTxt); $exp.removeClass('open'); $cllps[o.hideMethod](o.speed);};
});});};
// * --- Jonas Raoni Soares Silva - http://jsfromhell.com/string/capitalize [rev. #2]
String.prototype.capitalize = function(){
return this.replace(/\S+/g, function(a){
  return a.charAt(0).toUpperCase() + a.slice(1).toLowerCase();
});};
// * -----
})(jQuery);
///////////
$(function() {
var expand = $('#main h3.expand, #main h4.expand'),
    $destination = $(expand).next('div.collapsible').attr("id"),
    $title = 'Expand/Collapse&nbsp;' + $destination.capitalize();
$('#main').expandAll();
$(expand).wrapInner('<a style="display:block" href=#' + $destination + ' title=' + $title + ' />')
.next('div.collapsible').hide(); 
$(expand).click(function() {$(this).toggleClass('open').next('div.collapsible').toggle(); return false;});});
