﻿////////////////////////////
// This script was modified by http://www.bespokesoftware.co.uk 
// The original script was found on the website below.
// http://adipalaz.awardspace.com/experiments/jquery/expand.html
// * When using this script, please keep the above url intact.
///////////////////////////

(function($) {
    $.fn.ExpandCollapse = function(options) {
        var defaults = {
             cllpsEl : 'div',
             method : 'slideToggle',
             speed : 'fast'
        };
        var o = $.extend({}, defaults, options);           
        
        var sStatus = $.cookie('expand_collapse_' + $(this).attr('id'));  
        if (sStatus != null) {   
            var iResult = sStatus.replace('%20', ' ').indexOf('collapsed');     
            if (parseInt(iResult) > -1){           
                $(this).next('div').attr('style', 'display: none'); 
                $(this).toggleClass('collapsed');
            }
         }                 
  
        $(this).click(function() {
            $(this).toggleClass('collapsed').next(o.cllpsEl)[o.method](o.speed);
            $.cookie('expand_collapse_' + $(this).attr('id'), $(this).attr('class'));
            return false;
         });       
    };
    //http://www.learningjquery.com/2008/02/simple-effects-plugins:
    $.fn.slideFadeToggle = function(speed, easing, callback) {
        return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
    };        
})(jQuery);


