var totalwidth; //sätts från php i html-fil
var obj,visiblewidth,currentPx,thetime;
var animdirection=-1; //- left, + right
var animspeed=1; // 1 slowest

function startAnim() {
	if (document.getElementById) {
		if (!obj) {
			obj=document.getElementById("animate");
			obj.style.left="0px";
			obj.style.width=totalwidth+"px";
		}
		if (!visiblewidth) visiblewidth=940;//parseInt(document.getElementById("picani").style.width);
		leftstoppos=totalwidth-visiblewidth;
		leftstoppos=-leftstoppos;
		rightstoppos=0;
		//window.status=currentPx;
		if (currentPx <= leftstoppos) {
			// changedirection!
			animdirection=1;
		} else if (currentPx >= rightstoppos) {
			// changedirection!
			animdirection=-1;
		} 
		currentPx=(parseInt(obj.style.left)+animdirection*animspeed);
		obj.style.left=currentPx+"px";
		thetime=setTimeout("startAnim()",50);
	}
}
function pausAnim() {
	if (document.getElementById)
		clearTimeout(thetime);
}