/*
 * Expandable
 * Requires: jquery.parseclass.js
 */

(function($) {
	$.fn.extend({
		Expandable: function() {
			this.each(function() {
				var $this = $(this),
				config = {
					handle: ".handle",
					content: ".content"/*,
					showText: "Show",
					hideText: "Hide"*/
				},
				exts = $this.ParseClass();
				
				for (var key in exts) {
					config[key] = exts[key];
				}
				
				$(config.handle, $this).click(function(e) {
					if ($this.hasClass("hide")) {
						if (typeof(config.hideText) != "undefined") {
							$(config.handle, $this).html(config.hideText);
						}
						$this.addClass("show").removeClass("hide");
						$(config.content, $this).show('blind', {}, 500, function() {
							$(config.content, $this).css({display:""});
						});
					} else {
						$(config.content, $this).hide('blind', {}, 500, function() {
							if (typeof(config.showText) != "undefined") {
								$(config.handle, $this).html(config.showText);
							}
							$(config.content, $this).css({display:""});
							$this.addClass("hide").removeClass("show");
						});
					}
					e.preventDefault();
				});
			});
		}
	});
	
	$(document).ready(function() {
		$(".expandable").Expandable();
	});
})(jQuery);
