var number = 0;

window.addEvent('domready', function(){
	$('main_photo').getElements('.bigimage').each(function(i,x) {
//      console.log('Image');
		i.setStyles({'opacity':'100'});
	if(x > 0) i.addClass('photo_hidden');
	});
	$('showcase').getElements('li').each(function(i,x) {
		i.addEvent('click', function(event){
			event.stop();
			showshowcase(x);
			number = x;
		});
	});
});

window.addEvent('load', function(){
//	animation();
});

function animation() {
	var nav = $('showcase');
	if (number > nav.getElements('li').length-1) {number = 0;}
	var fx = nav.effects({duration: 1200, transition: Fx.Transitions.Quart.easeOut});
/*	fx.start().chain(
		function(){this.start(showshowcase(number));},
		function(){this.start(number = number + 1);},
		function(){this.start(animation());}
	);*/
}

function showshowcase(number) {
//console.log('called ' + number);
	activatethumbnail(number);
//	var big = 'showcase-' + number + '-big';
//	$('showcase-loader').setStyles({'display':'none'});

	$('main_photo').getElements('div').each(function(i,x) {
		if (x == number) {
			i.removeClass('photo_hidden');
			//console.log('Remove hidden from ' + x);	
		} else {
			i.addClass('photo_hidden');		
			//console.log('Add hidden to ' + x);	
		}
	});

/*	$('showcase').getElements('.bigimage').each(function(i) {
		var fx = $(i).effects({duration: 1000, transition: Fx.Transitions.Quart.easeOut});
		if (i.get('id') !== big) {
			fx.start({'opacity':'0'});
		}
		else {
			fx.start({'opacity':'1'});
		}
	});*/
}

function activatethumbnail(number) {
	$('showcase').getElements('li').each(function(i,x) {
		if (x == number) {
			i.addClass('activephoto');
		}
		else {
			i.removeClass('activephoto');
		}
	});
}
