/*
 * Dichotomy Actions
 * last revision 2007 01 11
 *
 * Originally developed for the Intense Minimalism blog.
 * Distributed with a CreativeCommons license (by-nc-sa 2.5).
 * Copyright (C) 2006-2007 by Davide 'Folletto' Casali.
 */

/****************************************************************************************************
 * GROWTO: Grow the selected element(s) to the height of the passed element.
 * It also reset any internal visible <il> (the sub-element passed in param should be
 * one item from a list).
 * 
 * @param		element ID selector (jQuery)
 */
jQuery.fn.growTo = function(content) {
	return this.each(function() {
		if (this.slidedOpen == content) {
			// ****** Close Tab
			jQuery(this).animate({ height: 0 }, "fast", function() {
				jQuery(this).css("height", 0);
				jQuery(this).children("li:visible").css("display", "none");
				this.slidedOpen = null; // Nothing open
			});
		} else {
			// ****** Open/Switch Tab
			jQuery(this).children("li:visible").css("display", "none");
			var size = jQuery(content).css("display", "block").get(0).offsetHeight;
		
			jQuery(this).animate({ height: size }, "fast");
			this.slidedOpen = content; // Opened one
		}
	})
}