var TextSlider = Class.create();
TextSlider.prototype = {
	
	initialize: function(area_id) {
		this.area = $(area_id);
		this.content = '';
		this.cut = '';
		this.opened = false;
		this.showLimit = 1500;
		this.cutLimit = 500;
		this.openButtonTitle = ' [+]';
		this.closeButtonTitle= ' [-]';

		if (this.area.innerHTML.length > this.showLimit) {
			this.content = this.area.innerHTML;
			this.cut = this.content.truncate(this.cutLimit, '... ');
			
			var ahref = this.createButton(this.openButtonTitle);
			this.area.update(this.cut);
			this.area.insert(ahref);
			
		}
	},
	
	toggle: function() {
		if (!this.opened) {
			this.area.update(this.content);
			this.area.insert(this.createButton(this.closeButtonTitle));
			this.opened = true;
		} else {
			this.area.update(this.cut);
			this.area.insert(this.createButton(this.openButtonTitle));
			this.opened = false;
		}
		return false;
	},
	
	createButton: function(title) {
			var ahref = document.createElement('a');
			ahref.href = '#';
			ahref.onclick = this.toggle.bind(this);
			ahref.appendChild(document.createTextNode(title));
			return ahref;
	}
	
	
	
}
