// http://adipalaz.awardspace.com/experiments/jquery/expand.html
// * When using this script, please keep the above url intact.

(function($) {

$.fn.expandAll = function(options) {
var defaults = {
trigger1 : '[Expand All]',
trigger2 : '[Collapse All]',
cllps : 'div.collapse',
exp : 'span.expand',
container : '#' + this.attr("id") + ' ',
ref : 'div',
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="#">' + o.trigger1 + '</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.trigger1) {
$(this).text(o.trigger2);
$exp.addClass('open');
//$cllps[o.showMethod](o.speed);
$cllps.slideFadeToggle('slow', 'linear');
} else {
$(this).text(o.trigger1);
$exp.removeClass('open');
//$cllps[o.hideMethod](o.speed);
$cllps.slideFadeToggle('slow', 'linear');
}
return false;
});
});};

//http://www.learningjquery.com/2008/02/simple-effects-plugins:

$.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

$.fn.slideFadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};
})(jQuery);

////////////////////////////

$(function() {
$('div.collapse').hide()


$('span.expand').click(function() {
$(this).toggleClass('open')
.next('div.collapse').slideFadeToggle('medium','linear');
return false;
});
});
