var updater;

function startAutoUpdater(qty, delay, postId, wpPath) {
	
	var params = 'action=autoupdater&postId='+postId+'&qty='+qty;

	var url = decodeURIComponent(wpPath)+'/wp-content/plugins/TheComBox_Slideshow/thecombox_sshow_func.php';
	
	updater = new Ajax.PeriodicalUpdater( 'SLIDES_WRAP', url, {
		method: 'POST',
		frequency: delay,
		decay: 1,
		parameters: params,
		onLoading: function() { 
			$('SLIDESHOW_LOADING').appear();
		},
		onSuccess:function() {
			new Effect.Opacity('SLIDES_WRAP', { from: 0.5, to: 1.0, duration: 1 });
		}
	});
}

function changePic(id, postId, wpPath) {
	updater.stop();

	var url = decodeURIComponent(wpPath)+'/wp-content/plugins/TheComBox_Slideshow/thecombox_sshow_func.php';
	
	var pictureId = id;

	var parametres = 'action=change&postId='+postId+'&picId='+pictureId;
	new Ajax.Updater( 'SLIDES_WRAP', url, {
		method: 'POST',
		parameters: parametres,
		onSuccess:function() { 
			new Effect.Opacity('SLIDES_WRAP', { from: 0.5, to: 1.0, duration: 1 });
		}
	});
}

function restartAutoUpdater() {
	updater.start();
}