// JavaScript Document

	var Num = 1;
	var Max = 0;
	var Size = 0;
	var Width = 0;
	function setDiaporama(value1,value2) {
		Max=value1;
		Size=(value1-1)*value2;
		Width=value2;
		$("#diaporama_boite_bouge").css("width", value1*value2);
	}

$(document).ready(function(){

    $.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };

});

$(function(){ 
	
	$("#diaporama_bouton_gauche").mousedown(function() {
		$("#diaporama_boite_bouge").fadeTo("fast",0);
		if ( (Num-1)==0 ) {
			$("#diaporama_boite_bouge").animate({left: -Size}, "fast");
			Num=Max;
		}else{
			$("#diaporama_boite_bouge").animate({"left": "+="+Width+"px"}, "fast");
			Num--;
		}
		$("#diaporama_boite_bouge").fadeTo("normal",1);
	});	
	$("#diaporama_bouton_droit").mousedown(function() {
		$("#diaporama_boite_bouge").fadeTo("fast",0);
		if ( (Num+1)>Max ) {
			$("#diaporama_boite_bouge").animate({"left": "0px"}, "fast");
			Num=1;
		}else{
			$("#diaporama_boite_bouge").animate({"left": "-="+Width+"px"}, "fast");
			Num++;
		}
		$("#diaporama_boite_bouge").fadeTo("normal",1);		
	});	
 
}); 
