/**
 * Name: Scripts.js
 * Date: March 2011
 * Description: Scripts for fooltography
 * Version: 1.0
 * Coder: Enrique Ramirez
 * Coder URI: http://enrique-ramirez.com
*/

$(document).ready(function(){

/* Initializing Carousel
-----------------------------------------------*/
	$('#slideshow').infiniteCarousel();
	
/* Automating Carousel
-----------------------------------------------*/
	/* Setting a counter to reset timer */
	var counter = 0;
	
	/* Fake a click on right arrow every 5 seconds */
	$('#slideshow').everyTime(1000,function(i) {
	
		/* If 5 seconds have passed */
		if (counter == 5) {
			/* Fake a click on the right arrow... */
			$('#slideshow .arrow-right').click();
			
			/* ... and reset the counter */
			counter=0;
		} else {
		
			/* Else, if 5 seconds have not yet passed, add 1 to the counter */
			counter++;
		}
	});
	
	/* Reseting timer when the user interacts with carousel */
	$('.arrow-left, .arrow-right, a.goto-slide').click(function () {
		counter=0;
	});
	
});
