var z7webcamWidth = 0;
var z7webcamActive = 1;
var z7webcamNext = 0;

function z7webcamStart() {

	if(z7webcamCount > 0) {
		// get the width
		z7webcamWidth = jq('#webcam-container-all').width();
	
		/*
		// inverse animation
		z7webcamWidth = -1 * z7webcamWidth;
		*/
		
		setTimeout("z7webcamChange()", z7webcamTimeout);
	}
}


function z7webcamChange() {

	// get next element's number
	z7webcamNext = z7webcamActive+1;
	if(z7webcamNext > z7webcamCount) {
		z7webcamNext = 1;
	}

	// do the action
	z7webcamAction();

	// repeat the stuff with new values
	z7webcamActive = z7webcamNext;

	setTimeout("z7webcamChange()", z7webcamTimeout);
}


function z7webcamAction() {

	// start position for next element
	jq('#webcam-container-item-'+z7webcamNext).css('left', z7webcamWidth+'px');
	jq('#webcam-container-item-'+z7webcamNext).css('display', 'block');
	
	// animate the current and the next element
	jq('#webcam-container-item-'+z7webcamNext).animate( { left:"0px" }, { queue:false, duration:z7webcamDuration } );
	jq('#webcam-container-item-'+z7webcamActive).animate( { left: (z7webcamWidth*-1)+"px" }, { queue:false, duration:z7webcamDuration } );
	
	//	alert($('webcam-container-item-'+z7webcamNext).css());
}

/*
 * add some stuff to document's onload event
 */
if (window.addEventListener) {
	window.addEventListener('load', function() { z7webcamStart(); }, true);
}
else if(window.attachEvent) {
	window.attachEvent('onload', function() { z7webcamStart(); });
}