// JavaScript Document
function startslide(mycount){
	document.getElementById("spot1").src = '/images/spot_on.png'
	intval=window.setInterval('doStuff('+mycount+')',10);
}

function doStuff(mycount){
		window.clearInterval(intval);
		intval=window.setTimeout("swapBG(2,1,0,"+mycount+")",4000);
	}

function moveit(swapTo,swapFrom,endhere,totslides){
	var currentposition=document.getElementById("imageslider").style.marginLeft;
	currentposition=currentposition.replace("px", "");
	document.getElementById("imageslider").style.marginLeft = currentposition-25 + "px";
	window.clearInterval(moveslider);
	if (currentposition>(endhere+25)){
	moveslider=window.setTimeout("moveit("+swapTo+","+swapFrom+","+endhere+","+totslides+")",1);
	}else{
		if (currentposition==(-650*(totslides-1))+25){
			document.getElementById("imageslider").style.marginLeft = "0px";
			swapTo=1;
			swapFrom=0;
		}		
		document.getElementById("spot"+swapTo).src = '/images/spot_on.png'
		window.clearInterval(intval);
		intval=window.setTimeout("swapBG("+(swapTo+1)+","+(swapFrom+1)+",0,"+totslides+")",4000);
	}
}

function swapBG(swapTo,swapFrom,swapClicked,totslides){
	document.getElementById("spot"+swapFrom).src = '/images/spot_off.png'
	
	var endPlace=-650*(swapTo-1)
	moveslider=window.setTimeout("moveit("+swapTo+","+swapFrom+","+endPlace+","+totslides+")",1);
	
}
