var Folder = new Class({
	
	initialize : function(element)
	{
		this.speed = 300;
		this.element = element;
		this.height = element.getStyle("height");
	},
	hidden : function()
	{
		this.element.setStyle("overflow", "hidden");
	},
	visible : function()
	{
		this.element.setStyle("overflow", "visible");
	},
	fold : function()
	{
		this.hidden();
		this.element.set("morph",{duration:this.speed});
		this.element.morph({"height":"0px"});
	},
	unFold : function()
	{
		this.element.set("morph", {onComplete:this.visible.bind(this), duration:this.speed});
		this.element.morph({"height":this.height});
	},
	show : function()
	{
		this.visible();
		this.element.setStyle("height",this.height);
	},
	hide : function()
	{
		this.hidden();
		this.element.setStyle("height","0px");
	}
});

Element.implement({
	fold : function()
	{
		this.makeFolder();
		this.folder.fold()
	},
	unFold : function()
	{
		this.makeFolder();
		this.folder.unFold();
	},
	hidden : function()
	{
		this.makeFolder();
		this.folder.hide();
	},
	visible : function()
	{
		this.makeFolder();
		this.folder.show();
	},
	makeFolder : function()
	{
		if(this.folder)
			return true;
		this.folder = new Folder(this);
	}
});