var xmax=856;
var picmax=5;
var timer;
var main;
var picx; 
var picnum;
var picnxt;
var slideval;

function scroll(){
	document.getElementById("pic"+picnum).style.left=picx-xmax+"px";   
	document.getElementById("pic"+picnxt).style.left=picx+"px";

        if (picx==0) clearInterval(timer);

        if (picx<400) slideval=picx/5
        else if (slideval<60) slideval=(xmax-picx)/5;

	if (slideval<15) slideval=15;

	picx=picx-slideval;
	if (picx<0) picx=0;
}

function anim(){
	clearInterval(timer);
	picnum=picnxt;
	picnxt++;
	if (picnxt>picmax) picnxt=1;
	picx=xmax;
	slideval=1;
	obj=document.getElementById("pic"+picnxt);

// All of this should be set by style sheet but in case it didn't load
	obj.style.top=0;     
        obj.style.position="absolute"; 
	obj.style.display="block";

	timer=setInterval("scroll()",30);
}

function startAnimation(){
	picnxt=1;
	clearInterval(main);
	main=setInterval("anim()",15000);
        obj=document.getElementById("pic1");
	obj.style.left=0;     
	obj.style.top=0;     
	obj.style.display="block";
        obj.position="absolute"; 
	//anim();
}



