/**
 * @author berrym
 */
window.addEvent('domready', function() {
	allFade();
	raiseButton(0);
	$$('.swb').addEvent('mouseenter', function() {
		var buttonIndex = this.get('name');
		$clear(running);
		raiseButton(buttonIndex);
	});
	var slideCount = 1;
	var slideAnimate = function() {
		raiseButton(slideCount);
		slideCount++;
		if(slideCount == 6) {
			slideCount = 0;
		}
	}
	var running = slideAnimate.periodical(7000);
});

var allFade = function() {
	$$('.timed').setStyle('opacity', 0);
};

var raiseButton = function(e) {
	var allButtons = $$('.swb');
	$each(allButtons, function(button, index){
		if(index!=e){
			$('swb'+index).getElement("img").tween('margin-bottom', 0);
			$('slide'+index).tween('opacity', 0);
		} else {
			$('swb'+index).getElement("img").tween('margin-bottom', 15);
			$('slide'+index).tween('opacity', 1);
		};
	});
};

