var Expander = new Class({
	options: {
		compressedHeight: 20,
		paddingExpanded: 20,
		compressOthersOnExpand: true,
		moreString: "&#9660; READ BIO",
		lessString: "&#9650; CLOSE"
	},
	
	Implements: [ Options ],
	
	initialize: function(options) {
		this.setOptions(options);
		
		this.click = this.click.bind(this);
		$$(".expandable .controls").addEvent("click", this.click);
	},
	
	click: function(e) {
		console.log("click")
		var control = e.target;
		var target = e.target.getParent();
		if (target.getStyle("height").toInt() == this.options.compressedHeight) {
			console.log(target.getElement(".content"))
			target.setStyles({
				"height" : target.getElement(".content").getSize().y,
				"padding-bottom" : this.options.paddingExpanded
			});
		
			target.getElement(".controls").set("html", this.options.lessString);
			
			if (this.options.compressOthersOnExpand == true) {
				var expandables = $$(".expandable");
				for (var i = 0; i < expandables.length; i++) {
					if (expandables[i] != target && expandables[i].getStyle("padding-bottom").toInt() != 0) {
						expandables[i].setStyles({
							"height" : this.options.compressedHeight,
							"padding-bottom" : 0
						});
						expandables[i].getElement(".controls").set("html", this.options.moreString);
					}
				}
				
			
			}
		} else {
			target.setStyles({
				"height" : this.options.compressedHeight,
				"padding-bottom" : 0
			});
		
			target.getElement(".controls").set("html", this.options.moreString);
			
		}
		
		
	}
	
});
