// JavaScript Document

currentPos = 0;
timer = "";
currentObj = "";
cycleTimer = "";


width = 723;

padding = 0;



elementsAtm = 2;



cycleSpeed = 5000;

function position(pos) {
clearTimeout(timer);
clearTimeout(cycleTimer);

if (currentObj != "") {
document.getElementById(currentObj).className = "control";

}

currentObj = pos;
document.getElementById(pos).className = "control_current";




width = width+(padding*2)

pos = pos - 1;

thestop = (pos*width);



	thestop = thestop*-1;
	currentCount = currentPos*-1;	



trans(pos, width, thestop, currentCount)





}


function trans(pos, width, thestop, current) {

speed = 50;
		document.getElementById('counter').value = (current);


if ((current) > (thestop) & (current) != (thestop)) {
	
	if ((current) != (thestop)) {
	
		current -= speed;
		if (current - speed < thestop) {
			current = thestop
		}
		document.getElementById('images').style.left = current+"px";
		
		
		currentPos = current;
		if (currentPos < 0) {
			currentPos = currentPos*-1;
		}
		
		
		timer = setTimeout ("trans("+pos+", "+width+", "+thestop+", "+current+")", 20);
	
	}

}
else if ((current) < (thestop) & (current) != (thestop))  {

	if ((current) != (thestop)) {
	
		current += speed;
		if (current + speed > thestop) {
			current = thestop
		}
		document.getElementById('images').style.left = current+"px";
		
		
		currentPos = current;
		if (currentPos < 0) {
			currentPos = currentPos*-1;
		}
		
		timer = setTimeout ("trans("+pos+", "+width+", "+thestop+", "+current+")", 20);
	
	}
}
else {
	currentPos = current;
	if (currentPos < 0) {
		currentPos = currentPos*-1;
	}
	
	cycleTimer = setTimeout ("cycle()", cycleSpeed);

}
}






function cycle() {
	temp = currentPos;

	if (temp < 0) {
		temp = currentPos*-1;
	}
	
	

	pos = (temp/width)+1;
	
	if (pos == elementsAtm) {
		pos = 0;
	}
	
	
	if (currentObj != "") {
	
	}
	currentObj = pos+1;
	
	
	
	thestop = pos;
	
	thestop = (pos*width);



	thestop = thestop*-1;
	currentCount = currentPos*-1;	

	trans(pos, width, thestop, currentCount);
	
}


function startCycle () {
	
	currentObj = 1;
	
	cycleTimer = setTimeout ("cycle()", cycleSpeed);

}

