var current_image;
var play_mode=0;
var oldIndex=0;
var maxloop;

function GoToImage(number){
	play_mode=0;
	maxloop=0;
	viewPic(number);
	document.getElementById('SekvensForm').value=nameSekvens;
}
function animate_fwd(){
	if(play_mode==0){return;}
	if(current_image<0){
		current_image=(antPic-1);
		setTimeout("animate_fwd()",1500);
	} else {
		viewPic(current_image);
		current_image--;
		setTimeout("animate_fwd()",300);
	}	
}
function viewPic(nr){
	if(theImages[nr].width>100){
		document.getElementById('animation').src=theImages[nr].src;
	} else {
		if (maxloop<10){
			setTimeout("viewPic("+nr+")",300);
		}
		maxloop++;
	}
	document.getElementById("areaBild"+oldIndex).style.textDecoration='none';
	document.getElementById("areaBild"+nr).style.textDecoration='underline';
	oldIndex=nr;
}
function startAnimation(){
	if(play_mode==0){
		document.getElementById('SekvensForm').value=nameStopp;
		play_mode=1;
		current_image=(antPic-1);
		animate_fwd();
	} else {GoToImage(0);}
}
function unDecorate(){
	for(var i=0;i<antPic;i++){
		document.getElementById("areaBild"+i).style.textDecoration='none';
	}
}
function bytSida(sida){
	var u=document.getElementById(sida).href;
	document.location=u;
}

//function timedRefresh() {
//	setTimeout("location.reload();",600000); //600000
//}
//timedRefresh();


