
var currentdiapo =-1;
var rundiapo=0;
function gTimer() {
    if (rundiapo === 1) {
        nextdiapo();
        setTimeout("gTimer()",5000);
    }
}

function startdiapo() {
    if (rundiapo === 1) {
        rundiapo=0;
        jQuery("#startd").show();
        jQuery("#stopd").hide();
    }
    else {
        rundiapo=1;
        gTimer();
        jQuery("#startd").hide();
        jQuery("#stopd").show();
    }
}
function nextdiapo() {
    var i = currentdiapo +1;
    if (i === nb_diapo) {
        i=0;
    }
    affichediapo(i);
}
function firstdiapo() {
    affichediapo(0);
}
function lastdiapo() {
    affichediapo(nb_diapo - 1);
}
function prevdiapo() {
    var i = currentdiapo - 1;
    if (i === -1) {
        i= nb_diapo - 1;
    }
    affichediapo(i);
}
function affichediapo(i) {
    if (i===0) {
        jQuery('#diapo_first').hide();
        jQuery('#diapo_prev').hide();
    } else{
        jQuery('#diapo_first').show();
        jQuery('#diapo_prev').show();
    }
    if (i=== nb_diapo - 1) {
        jQuery('#diapo_last').hide();
        jQuery('#diapo_next').hide();
    } else{
        jQuery('#diapo_last').show();
        jQuery('#diapo_next').show();
    }
    jQuery('#leg_'+currentdiapo).hide();
    jQuery('#leg_'+i).show();
    jQuery('#diapo_'+currentdiapo).hide();
    jQuery('#diapo_'+i).fadeIn("slow");
    currentdiapo = i;
}
