////////////////////////////
// http://adipalaz.com/experiments/jquery/expand_collapse_different_directions.html
// * When using this script, please keep the above url intact.
///////////////////////////
(function($) {
$.fn.addTrigger = function(options) {
  var defaults = {
       trigger1 : 'Show content',
       trigger2 : 'Hide content',
       ref : '.collapse',
       container : 'div.demo'
    };
  var o = $.extend({}, defaults, options);   
  return this.each(function() {
      $('<div class="switch"><a href="#" title="expand/collapse">' + o.trigger2 + '</a></div>')
      .insertBefore(o.container + ':eq(' + $(o.container).index(this) + ') ' + o.ref);
      $(this).find('.switch a').click(function () {
        $(this).toggleClass("plus");
        ($(this).text() == o.trigger2) ? $(this).text(o.trigger1) : $(this).text(o.trigger2);
      });
  });
};
$.fn.marginLeft = function(speed, easing, callback) {
  var w = this.width() + parseInt(this.css('paddingLeft')) + parseInt(this.css('paddingRight'));
  return this.animate({marginLeft: parseInt(this.css('marginLeft')) < 0 ? 0 : -(w+1)}, speed, easing, callback); 
};
$.fn.marginRight = function(speed, easing, callback) {
  var w = this.width() + parseInt(this.css('paddingLeft')) + parseInt(this.css('paddingRight'));
  return this.animate({marginLeft: parseInt(this.css('marginLeft')) > 0 ? 0 : w+1}, speed, easing, callback); 
};
$.fn.slideLeft = function(speed, easing, callback) {
  var w = this.width() + parseInt(this.css('paddingLeft')) + parseInt(this.css('paddingRight'));
  return this.animate({left: parseInt(this.css('left')) < 0 ? 0 : -(w+1)}, speed, easing, callback); 
};
$.fn.slideRight = function(speed, easing, callback) {
  var w = this.width() + parseInt(this.css('paddingLeft')) + parseInt(this.css('paddingRight'));
  return this.animate({left: parseInt(this.css('left')) > 0 ? 0 : w+1}, speed, easing, callback); 
}; 
$.fn.partialWidth = function(speed, easing, callback) {
  var w = this.parent().width() + 1 + (parseInt(this.css('paddingLeft')) + parseInt(this.css('paddingRight')));
  return this.animate({width: parseInt(this.css('width')) > (w-75) ? (w-75) : w}, speed, easing, callback); 
};
$.fn.slideDiag = function(speed, easing, callback) {
  var w = this.width() + parseInt(this.css('paddingLeft')) + parseInt(this.css('paddingRight')),
      h = parseInt(this.css('height'));
  return this.animate({left: parseInt(this.css('left')) > 0 ? 0 : w+1, bottom: parseInt(this.css('bottom')) < 0 ? 0 : -(h+1)}, speed, easing, callback); 
}; 
//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);

////////////////////////////
$(function() {
    $('div.demo').each(function(index) {
        var $thisDemo = $('div.demo:eq(' + index + ')');
        switch (index) {
        //override some default options in demos 1, 2, 6, 8, 9, 10:

        //the rest of the demos use all the default options:
            default: $thisDemo.addTrigger();
        };
    });
       
		
		    //example 7
    $('div.demo.left .switch').click(function() {
        $(this).next().slideLeft('slow','linear');
        return false;
    });
    
    //example 8
     $('div.demo.right .switch').click(function() {
        $(this).next().slideRight('slow','linear');
        return false;
    });

});

