//////////////////////////////////////////////
//  copyright    WILLIAM   RUSSEIL   2009   //
//    pour Boutiques de Gestion en Ligne    //
// reproduction interdite sans autorisation //
//               infos@wmc.fr               //
//////////////////////////////////////////////

var inc = 0;
var leftPosition = 0;
var nextInterval;
var rewindInterval;
var leftDiv;
var rightDiv;
var leftDivWidth = '<style>#leftContainer {width: '+(nbPhotos+1)*696+'px;}</style>'
document.write(leftDivWidth);
var rightDivWidth = '<style>#rightContainer {width: '+nbPhotos*300+'px;}</style>'
document.write(rightDivWidth);

if(!document.getElementById) document.getElementById=function (id) {
	return eval("document.all."+id);
}

function change() {
	inc++;
	if (inc >= nbPhotos) {
		inc = 0;
		setTimeout(replay, 1000);
	}
	rightDiv.style.marginLeft = (-200*inc) +"px";
	setTimeout(animate, 1000);
}

function next()
{
	if (leftPosition <= -696*inc) {
		leftPosition = -696*inc;
		clearInterval(nextInterval);
		waiter();
	} else {
		leftPosition -= 24;
		leftDiv.style.marginLeft = leftPosition + "px";
	}
}

function rewind() {
	var leftPos = parseInt(leftDiv.style.marginLeft);
	if (leftPos <= -696*nbPhotos) {
		clearInterval(rewindInterval);
		leftDiv.style.marginLeft = 0 + "px";
	} else {
		leftPos -= 24;
		leftDiv.style.marginLeft = leftPos + "px";
	}
}

function waiter() {
	leftDiv = document.getElementById("leftContainer");
	rightDiv = document.getElementById("rightContainer");
	setTimeout(change, 3000);
}

function animate() {
	nextInterval = setInterval(next, vitesse);
}

function replay() {
    rewindInterval = setInterval(rewind, vitesse);
}



