var cases = ['a', 'b', 'c'];

var fxs = new Array();
fxs['btn_1'] = new Fx.Tween('btn_1', {property: 'opacity', duration: 'short'});
fxs['btn_2'] = new Fx.Tween('btn_2', {property: 'opacity', duration: 'short'});
fxs['btn_3'] = new Fx.Tween('btn_3', {property: 'opacity', duration: 'short'});
fxs['btn_4'] = new Fx.Tween('btn_4', {property: 'opacity', duration: 'short'});
fxs['btn_5'] = new Fx.Tween('btn_5', {property: 'opacity', duration: 'short'});
fxs['btn_6'] = new Fx.Tween('btn_6', {property: 'opacity', duration: 'short'});
fxs['btn_7'] = new Fx.Tween('btn_7', {property: 'opacity', duration: 'short'});
fxs['btn_8'] = new Fx.Tween('btn_8', {property: 'opacity', duration: 'short'});
fxs['btn_9'] = new Fx.Tween('btn_9', {property: 'opacity', duration: 'short'});

function mouseoverevent(el) {
	if(typeof fxs[this.id].lastletter != 'undefined') {
		var next_letter =  fxs[this.id].lastletter;
		while(next_letter == fxs[this.id].lastletter)
			next_letter = cases[Math.round(Math.random()*2)];
	}
	else 
		var next_letter = cases[Math.round(Math.random()*2)];
	fxs[this.id].lastletter = next_letter;
	fxs[this.id].start(1, 0);
	$('o_'+this.id+'_'+next_letter).setStyle('opacity', '1');
}

function mouseoutevent(el) {
	fxs[this.id].cancel();
	this.setStyle('opacity', '1');
	$$('div[id^=o_'+this.id+']').setStyle('opacity', '0');
}

$$('div[id^=btn_]').each(function(el) {
	el.addEvent('mouseover', mouseoverevent.bind(el));
	el.addEvent('mouseout', mouseoutevent.bind(el));
});

