function autoRun () {
	var t;
	var thumb = $('#thumbnails a');
	var next = $(thumb[1]);
	
	function getTimeout () {
		if ( !t ) {
			t = setTimeout( function () { next.trigger('click'); }, 1500);
		}
	}
	
	function onEndTransition (o) {
		if(o) {
			next = o.parent().next().length === 0 ? $(thumb[0]) : o.parent().next().find('a');
		}
		getTimeout();
	}
	

	function onClick ( o ) {
		clearTimeout(t);
		t = 0;
	}

	$('#diaporama').simpleGalery(
							{ 
								transitionEndCallback : onEndTransition, 
								onClickEventCallback : onClick, 
								returnFalseCallback : getTimeout
							}
						);
	
	t = setTimeout( function () { next.trigger('click'); }, 1500);
	
}

$(function() {
	if( $('#diaporama').length ) {
		autoRun();
	}
  
});


	
	
