
var moreButton = new Class({
								
	initialize: function(e) 
	{
		this.vo = eval("(" + e.id + ")");
		this.e = e;
		this.h = $(this.vo.moreDiv).getSize().y +10;
		
		this.doOpen = {'height':[this.h]};
		this.doClose = {'height':['0']};
		
		this.t = new Fx.Morph($(this.vo.moreDiv),{duration:'normal', transition:'cubic:out', onComplete: function() { this.afterMorph();}.bind(this) });
		
		$(this.vo.moreDiv).setStyle('overflow','hidden');
		
		if(this.vo.state=='opened')
		{
			$(this.vo.moreDiv).setStyle('height',this.h);	
		}else{
			
			$(this.vo.moreDiv).setStyle('display','none');
			$(this.vo.moreDiv).setStyle('height','0');
		}
		
		if(!this.vo.more){this.vo.more = this.e.innerHTML;} 
		if(!this.vo.less){this.vo.less = this.e.innerHTML;} 
		
		this.setEvents(e);
		
	},
	
	setEvents: function(e)
	{
		this.e.addEvents
		({
			'mouseover': this.doMouseover.bind(this),
			'mouseout': this.doMouseout.bind(this),
			'click': this.doClick.bind(this)
		});
		
		e.onclick = function()
		{
			return false;
		};	
		
		e.onmouseover = function()
		{
			return false;
		};
		
		e.onmouseout = function()
		{
			return false;
		};
	},
	
	doClick: function()
	{
		if(this.vo.state=='opened')
		{
			this.t.start(this.doClose);
		}else{
			$(this.vo.moreDiv).setStyle('display','block');
			this.t.start(this.doOpen);
		}
		this.e.blur();
	},
	
	doMouseover: function()
	{
		this.e.style.cursor = 'pointer';
	},
	
	doMouseout: function()
	{
		this.e.style.cursor = 'default';
	},
	afterMorph: function(t)
	{
		if(this.vo.state=='opened')
		{
			this.e.innerHTML = this.vo.more;
			$(this.vo.moreDiv).setStyle('display','none');

			this.vo.state = 'closed';	
		}else{
			this.e.innerHTML = this.vo.less;
			this.vo.state = 'opened';	
		}
	}
	
});
	
function initMoreButton(where)
{
	$$('#' + where +' .moreButton').each(function(e){;new moreButton(e);});
}

