
var AutoHidables = new Class({
		
		//Implements: Options,
		
		initialize: function(/* options */)
		{
			//this.setOptions(options);
			
			this._hshHidables = new Hash();
			
			this.initHidables();
		},
		
		initHidables: function()
		{
			var allHidables = $$('*[class=autoHidable]');
			allHidables.each(function(elm){
				var id = elm.id;
				this._hshHidables.include(id,
				{
					'element':elm,
					'height':elm.offsetHeight,
					'width':elm.offsetWidth
				});
				
				elm.addClass('hidable');
				elm.set('morph', {duration: 350, transition: 'quad:out'});
			}.bind(this));
		},
		
		toggle: function(caller, strId)
		{
			//tmp
			if(caller != null)
			$(caller).set('morph', {duration: 350, transition: 'quad:out'});
			
			var hidable = this._hshHidables.get(strId);
			
			switch(hidable.element.hasClass('visible')) {
	
			default:
			case false:
				hidable.element.setOpacity(0);
				
				hidable.element.morph({'height':hidable.height,'opacity':1});
				hidable.element.addClass('visible');
				
				$('refColon').setText(':');
				
				if(caller != null)
				$(caller).morph({'height':0,'opacity':0});
				break;
				
			case true:
				hidable.element.morph({'height':0,'opacity':0});
				hidable.element.removeClass('visible');
				$('refColon').setText(' (click to view)');
				if(caller != null)
				$(caller).morph({'height':15,'opacity':1});
				break;
				
			}
		}

});
