
var thisWeek = Class.create();
thisWeek.prototype = {

	initialize: function() {
		
		var th = this;
		
		var list = $$('.this_week').first().select('div.day');
		var list_arr = new Array();

		th.day_list = list;
		th.day_offset = 0;
		
		if( list.size() > 0 ) {
			var timer = new PeriodicalExecuter(function(pe){
				th.next_day(th);
			}, 5);
		}
		
	},
	
	next_day: function(th) {
	
		var current_offset = th.day_offset;
		var next_offset = current_offset + 1;
		
		if( next_offset == th.day_list.length ) next_offset = 0;
		
		current_div = th.day_list[current_offset];
		next_div = th.day_list[next_offset];
		
		new Effect.Fade(current_div,{ duration: 0.5, from: 1, to: 0 });
		
		new Effect.Fade(next_div,{ 
			duration: 0.6, 
			from: 0, 
			to: 1,
			afterFinish: function() {
				next_div.removeClassName('hide');
				next_div.setStyle({ 'display': '' });
			}	
		});
		
		th.day_offset = next_offset;
		
	}
};

function initThisWeek() { var this_week = new thisWeek(); }
document.observe('dom:loaded',initThisWeek);

