
/* ---------------------------------------------------------------
 *
 *          Fonctions ALBUM PHOTOS
 *
 * -------------------------------------------------------------*/

var titre_album = "";

function initColorBox(ta,ti,os){
    openstate = false;
    t="thumbs";
    if (ta !== undefined) {
        titre_album = ta;
        if (os !== undefined) openstate=os;
        else openstate = true;
        t+=ti;
        if (ti != 'apercu')
            $('a[rel='+t+']').each(function(){$(this).attr('title',$(this).attr('href'));});
        else
            $('a[rel='+t+']').each(function(){if ($(this).attr('title') == null) $(this).attr('title',$(this).text());});
    }

    $('a[rel='+t+']').colorbox({
              open : openstate,
              transition: 'fade',
              speed: 350,
              onLoad: function() {
                 $('#cboxContentDescription').hide();
              },
              onComplete: function() {
                 if (d = ZEN('d'+$(this).attr('id')))
                    $('#cboxContentDescription').html(d.innerHTML).slideDown({duration: 'fast', easing: 'swing', queue:false});

                 // empêche la copie par simple drag, ou encore empêche de sortir de la page en draggant involontairement dans le navigateur..                 
                 //$('#cboxPhoto').mousedown(function(e){e.preventDefault();}).bind('drag',function(e){e.preventDefault();});
              },
              previous:'Précédente',
              next:'Suivante',
              close:'Fermer',
              current: '<b>'+titre_album+'</b>  -  Photo {current} de {total}'
         });
         $('#cboxLoadedContent').after('<div id="cboxContentDescription"></div>');
         $('#cboxContentDescription').hide();

/*
              opacity: 0.7, // trop pâle et on perd le texte au dessus et en dessous...
              slideshow:true,
              slideshowSpeed:4500,
              slideshowAuto:false,
              slideshowStart:' (Démarrer diaporama) ',
              slideshowStop:' (Arrêter diaporama) ',
*/

}

var album_actif = "";
var cache_albums = new Array();
function AlbLoaded(idalbum) {
         initColorBox();
         if (est_admin) {
            CorrigeOptionsAdmin();
         }
         $("#album_pres_thumbs_titre").css('visibility','visible');
         $('#album_pres_thumbs').stop(false,true).css('opacity',0.1).fadeTo({duration:'slow',queue:false},1);

         $('#album_titre_page_'+idalbum).find('img').remove();

         edition_active = false;
    }

function AfficheAlbumThumbs(idalbum) {
  if (CheckEdition()) {
    album_actif = idalbum;
    // si pas admin, mettre la string en cache, et ne pas demander deux fois...


    //$("#album_pres_thumbs, #album_pres_thumbs_titre").fadeOut('fast');
    $("#album_pres_thumbs_titre").css('visibility','hidden'); // conserve la hauteur...
    $('#album_pres_thumbs').stop(true,true).fadeOut({duration:'slow',queue:false});


    // mettre dans current le nom de la page !
    // ainsi que dans la bonne page.. :)
    titre_album = $('#album_titre_page_'+idalbum).text();
    $('#album_titre_page_'+idalbum).append('<img src="loading.gif" style="height:10px;" alt="Chargement de la page" />');
    $('#album_pres_thumbs_titre').text(titre_album);

    if (!est_admin && cache_albums[idalbum]) {
       $('#album_pres_thumbs').html(cache_albums[idalbum]);
       AlbLoaded(idalbum);
    }
    else
        $('#album_pres_thumbs')
        .load('album_pages.php?idalbum='+idalbum,
          function() {
             cache_albums[idalbum] = $('#album_pres_thumbs').html();
             AlbLoaded(idalbum);
             if (est_intra) CheckTimeup();
        });

    /*ZEN('iframe_historique').src='zen_historique.php?session=1&p='+page_active+'&alb='+idalbum;*/
  }
}

