var thumb_opacity=0.35;
for(i=2; i< max_photo_plus_1; i++){
	new Element.setOpacity('thumb-' + i, thumb_opacity);
}

var current_image_id='img-1';
var current_count=1;
var first_done=false;
var rotate_on=true;
var rotate_id=false;

function over_thumb(count){
	rotate_on=false;
	darken_thumb(current_count)
	higlight_thumb(count);
}

function higlight_thumb(count){
	current_count=count;
	setTimeout('show_image(' + count + ')', 500);
	new Effect.Appear('thumb-' + count, {from: thumb_opacity, to: 1.0, duration: 0.50});
}

function show_image(count){
	if(count==current_count){
		if(current_image_id!='img-' + count) {
			new Effect.Fade(current_image_id, {duration: 0.50});
			new Effect.Appear('img-' + count, {duration: 1.50});
		}
		current_image_id='img-' + count;
	}
}

function out_thumb(count){
	rotate_on=true;
	setTimeout('rotate(\'' + get_rotate_id() + '\')', 3000);
}

function darken_thumb(count){
	new Effect.Fade('thumb-' + count, {from: 1.0, to: thumb_opacity, duration: 0.50});
}

function rotate(test_id){
	if(rotate_on && test_id==rotate_id){
		if(current_count== max_photo_plus_1 -1){
			this_count=1;
		}else{
			this_count=current_count+1
		}
		darken_thumb(current_count)
		higlight_thumb(this_count);
		setTimeout('rotate(\'' + test_id + '\')', 4000);
	}
}

function get_rotate_id(){
	rotate_id=new Date;
	rotate_id=rotate_id.getTime();
	return rotate_id;
}

setTimeout('rotate(\'' + get_rotate_id() + '\')', 3000);
