var activeButton;
var ajaxButton = new Class({
								
	initialize: function(e) 
	{
		this.vo = eval("(" + e.id + ")");
		this.e = e;
		this.vo.l = vo.l;
		this.setEvents(e);
		//alert(this.e.childNodes);
		this.t = new Fx.Morph(this.e.childNodes[0],{duration:'normal', transition:'cubic:out'});
		switch(this.vo.what)
		{
			case 'getItem':
				//this.e.setStyle('opacity',0.5);
				break;
		}
		
	},
	
	setGlobals: function()
	{
		vo = this.vo;
		activeButton = this;
	},
	
	doRequest: function()
	{
		switch(this.vo.what)
		{
			case 'getList':
			case 'getItem':
			case 'getRelated':
			case 'getHome':
				window.location = '#';
				sequencer();
			break;
			default:
		}		
	},
	
	afterRequest: function(t)
	{
		//messages
		switch(t.toString())
		{
			default:
				error('something went wrong on the server. this is the error:<br><br>' + t.toString());
		}
	},
	
	updateAfterRequest: function()
	{
	},
	
	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($('player'))
		{
			$('player').dispose();
		}
		this.setGlobals();
		this.doRequest();
		this.e.blur();
	},
	
	doMouseover: function()
	{
		this.e.style.cursor = 'pointer';
		switch(this.vo.what)
		{
			case 'getItem':
			case 'getRelated':
				//this.e.setStyle('opacity',0.5);
				this.t.cancel();this.t.start({'paddingTop':[10]});
			break;
		}
	},
	
	doMouseout: function()
	{
		this.e.style.cursor = 'default';
		switch(this.vo.what)
		{
			case 'getItem':
			case 'getRelated':

				//this.e.setStyle('opacity',1);
				this.t.cancel();this.t.start({'paddingTop':[0]});
			break;
		}
	}
	
});
	
function initAjaxButton(where)
{
	
	$$('#' + where +' .ajaxButton').each(function(e){;new ajaxButton(e);});
}

