var SYNAPSE = new Class({
	initialize: function(obj) {
		this.imageDir = './images/navigation/';
		this.options = JSON.decode(obj);
		switch(this.options.size.toString()) {
			case 'medium':
				this.options.width = 28;
				this.options.height = 28;
				this.options.fxSpeedFactor = 1.25;
				break;
			case 'big':
				this.options.width = 48;
				this.options.height = 48;
				this.options.fxSpeedFactor = 1.5;
				break;
			case 'active':
				this.options.width = 72;
				this.options.height = 72;
				this.options.fxSpeedFactor = 1.75;
				break;
			default:
				this.options.width = 22;
				this.options.height = 22;
				this.options.fxSpeedFactor = 1.0;
				break;
		}

		this.ID = 'synapse-' + this.options.name;
		this.loaded = false;

		this.synapse = new Element('img', {'id':this.ID, 'alt':this.options.title, 'title':this.options.title});
		this.synapse.setStyles({
			'cursor':'pointer',
			'opacity':0,
			'position':'absolute'
		});
		$('navigation').grab(this.synapse);
	},

	show: function() {
		var _self = this;

		this.synapse.addEvent('load', function() {
			if(!_self.loaded) {
				_self.loaded = true;
				new Fx.Morph(_self.ID.toString(), {duration:_self.options.fxSpeedFactor * 400, transition:Fx.Transitions.Bounce.easeOut}).start({
					'height':[0,_self.options.height],
					'left':[_self.options.pos.x + parseInt(_self.options.width / 2),_self.options.pos.x],
					'opacity':[0,1],
					'top':[_self.options.pos.y + parseInt(_self.options.height / 2),_self.options.pos.y],
					'width':[0,_self.options.width]
				});
			}
		});

		this.synapse.addEvent('mouseover', function() {
			if(_self.options.size != 'active') _self.synapse.src = navigation.imageDir + _self.options.size + '-synapse-on.gif'
		});

		this.synapse.addEvent('mouseout', function() {
			if(_self.options.size != 'active') _self.synapse.src = navigation.imageDir + _self.options.size + '-synapse-off.gif'
		});

		this.synapse.addEvent('click', function() {
			window.location.href = _self.options.link;
		});

		this.synapse.src = this.imageDir + this.options.size + '-synapse-off.gif';
	}
});