/* Javascript for Bioss website */

/*-----------------------------------------------------------------------------------------------------
 * $
 * Returns the element specified by the passed ID
 *-----------------------------------------------------------------------------------------------------*/

function $(id) {
	return document.getElementById(id);
	}

/*-----------------------------------------------------------------------------------------------------
 * $S
 * Returns the styles of the element specified by the passed ID
 *-----------------------------------------------------------------------------------------------------*/

function $S(id) {
	return document.getElementById(id).style;
	}
	
var TIMER_INTERVAL = 30000;

var isSelfAnimating = true;
var timer = setInterval(nextChartPosition, TIMER_INTERVAL);
var currentAnimationPosition = 0;

function moveChartTo(theChart, theHorizontalPosition, numberOfButtons) {
	if (theChart != undefined && theChart != "") {
		var chartDiv = $(theChart);
		if (chartDiv != undefined) {
			chartDiv.style.backgroundPosition = - theHorizontalPosition * 350 + "px 0px";
			for (var i = 0; i < numberOfButtons; i++) {
				if (i != theHorizontalPosition) {
					$(theChart + "-button-" + i).className = "work-people-value-button";
					}
				else {
					$(theChart + "-button-" + i).className = "work-people-value-button button-selected";
					}
				}
			}
		}
	}
	
function nextChartPosition() {
	if (isSelfAnimating) {
		currentAnimationPosition = (currentAnimationPosition + 1) % 7;
		
		moveChartTo("work-people-value-chart", currentAnimationPosition, 7);
		}
	else {
		clearInterval(timer);
		}
	}

