function showElement(forward){
	ticks=0;
	subElements[currentIndex].hide();
	if(forward){
		currentIndex+=1;
		if(currentIndex>(subElements.length-1)){
			currentIndex=0;
		}
	}else{
		currentIndex-=1;
		if(currentIndex<0){
			currentIndex=subElements.length-1;
		}
	}
	subElements[currentIndex].show();
}
function showNext(){
	showElement(true);
}

function pause(){
	if(stop==false){
		$('stopImg').toggle();
		$('goImg').toggle();
		stop=true;
	}else{
		$('stopImg').toggle();
		$('goImg').toggle();
		stop=false;
		run();
	}
}
function run(){
	new PeriodicalExecuter(function(pe) {
		if(!stop){
			ticks++;
			$('progress').style.width=""+ticks+"%";
			if(ticks>99){
				showNext();
			}
		}else{
			pe.stop()
		}
	}, 0.1);
}
