/* Takes in the id number of the slide to load */
/* and makes it the active slide */
var slide_duration = 10000; //in ms

var current = 's1' //Start off with a default current value of 1
var firstTimePlaying = 0 //use this to set pause as the start button

function goToSlide(id) {
	resetSlides();
	slidelink = document.getElementById(id)
	slidelink.className = 'active'
	slidenum = parseInt(id.substr(1),10)
	// setShadows(slidenum)
	changeImage(slidenum)
	current = id;
	}
	
function viewSlide(id) {
	goToSlide(id)
	pause()
	}

function pause() {
	//set the control class to play
	control = document.getElementById('playpausebutton')
	control.className = 'play'
	}
	
function prev() {
	//find out what current is
	//if current is 1, then next slide is 8
	//else +1 to current 
	if (current == 's1') {
		goToSlide('s8') }
	else { 
		slidenum = parseInt(current.substr(1),10)
		goToSlide('s'+(slidenum-1))
		}
	}
	
function next() {
	if (current == 's8') { goToSlide('s1'); }
	else {
		slidenum = parseInt(current.substr(1),10)
		goToSlide('s'+(slidenum+1))
		}
	}
	
function toggleRotate() {
	//check if button is set to play or pause
	//if set to pause, start slideshow
	//if set to play, stop slideshow
	//toggle button class
	control = document.getElementById('playpausebutton')
	if (firstTimePlaying == 0) {
		rotate()
		firstTimePlaying++
		}
	else {
		control.className = (control.className == 'play' ? 'pause' : 'play' );
		rotate();
		}
	}

function rotate() {
	if (document.getElementById('playpausebutton').className == 'pause') {
		next();
		setTimeout("rotate()",slide_duration);
		}
	}
	

function resetSlides() {
	var images = 8
	for (i = 1; i<=8; i++) {
		slidelink = document.getElementById('s'+i)
		slidelink.className = ''
		}
	}

function changeImage(id) {
//	alert("image number is "+'home_'+image_number);
	image = document.getElementById('slide_image');
	image.src = '/ui/oef_news/slide_'+id+'.jpg';
	}
