function switchTab(tab) {
	switch(tab) {
		case 1:
			$('schedule-wednesday').show();
			$('schedule-thursday').hide();
			$('schedule-friday').hide();
			$('schedule-tabs-top').style.backgroundPosition = '0px 0px';
			$('schedule-tabs-bottom').style.backgroundPosition = '0px -129px';
			break;
		case 2:
			$('schedule-wednesday').hide();
			$('schedule-thursday').show();
			$('schedule-friday').hide();
			$('schedule-tabs-top').style.backgroundPosition = '0px -43px';
			$('schedule-tabs-bottom').style.backgroundPosition = '0px -172px';
			break;
		case 3:
			$('schedule-wednesday').hide();
			$('schedule-thursday').hide();
			$('schedule-friday').show();
			$('schedule-tabs-top').style.backgroundPosition = '0px -86px';
			$('schedule-tabs-bottom').style.backgroundPosition = '0px -215px';
			break;
	}
}

var autoSlider = {	
	items: null,
	totalItems: null,
	current: 1,
	timer: null,

	init: function(){
		autoSlider.items = $$('.digits span');
		autoSlider.totalItems = $$('.digits span').length;
	},
	next: function(){
		if(autoSlider.current == autoSlider.totalItems-1){
			autoSlider.current = 1;			
		}else{
			autoSlider.current++;
		}
		switchDigitTimer(autoSlider.items[autoSlider.current].down());
	}
};

document.observe('dom:loaded', function(){
	autoSlider.init();
	new PeriodicalExecuter(function(pe){
		autoSlider.timer = pe;
		autoSlider.next();
	},5);		
});
function switchDigitTimer(el) {
	if ( el )
	{
		var selectedDigit = $('selectedDigit');
		if ( selectedDigit.className ) {
			$(selectedDigit.className).className = selectedDigit.className;
			selectedDigit.className = el.id;
			el.className = el.className + '-current';
			setJSONValues(el.id);
		}
	}
}

function switchDigit(el) {
	if ( el )
	{
		var selectedDigit = $('selectedDigit');
		if ( selectedDigit.className ) {
			autoSlider.timer.stop();
			$(selectedDigit.className).className = selectedDigit.className;
			selectedDigit.className = el.id;
			el.className = el.className + '-current';
			setJSONValues(el.id);
		}
	}
}

function setJSONValues(id) {
	if ( id )
	{
		for (i in shortTextJSON)
		{
			var updateArr = new Array('short_text_title', 'short_text_when', 'short_text_text', 'short_text_image');
			var idArr = id.split('-');
			var targetID = parseInt(idArr[1]) - 1;
			var keyArr = new Array();
			for (k in shortTextJSON[i][targetID] ) { keyArr.push(k); }
			for (j=0; j<updateArr.length; j++) {
				if ( $(updateArr[j]).nodeName == "IMG" ) {
					$(updateArr[j]).src = shortTextJSON[i][targetID]['image'];
				} else {
					$(updateArr[j]).update(shortTextJSON[i][targetID][keyArr[j]]);
				}
			}
		}
	}
}
