/*
* jQuery.slideToggleMinHeight - v0.1
* http://www.e-capy.com/slideToggleMinHeight
*
* minHeight: A number determining the min height. Default value 50px if any specified.
* speed: A number determining how long the animation will run. Default is 500 ms.
* easeEffect: A string indicating which easing function to use for the transition. Available transitions in http://gsgd.co.uk/sandbox/jquery/easing/
* callback: A function to call once the animation is complete. the method sends the jQuery object and action performed.
*
* Author: Marcelo Tosco - www.e-capy.com  - 10/2010.
*/
$(document).ready(function() {
	$.fn.slideToggleMinHeight = function (minHeight, speed, callback, easing) {
		var el = $(this);
		el.css("overflow", "hidden");
		var minHeight = minHeight > 0 ? minHeight : 80;
		var currHeight = el.height();
		//var speed = speed > 10 ? speed : 500;
		var speed = speed > 0 ? speed : 500;
		var easing = easing === undefined || easing == "" ? false : easing;
		var callback = $.isFunction(callback) ? callback : function() {};
		
		if (el.data("origHeight")) {
			var origHeight = el.data("origHeight");
		} else {
			el.data("origHeight", el.height())
			var origHeight = el.height();
		}
		
		if (currHeight > minHeight) {
			el.animate({ height: minHeight }, speed, easing, function() { callback($(this), "close"); });
		} else if (currHeight == minHeight) {
			el.animate({ height: origHeight }, speed, easing, function() { callback($(this), "open"); });
		}
	}
});

