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

function StatApercu(t) {
  if ($('#cboxLoadedContent').css('display') == "block") {
      // insérer quelquepart le titre de l'album ??
    titre = $('#cboxPhoto').attr('src');
    txt = $('#cboxTitle').text();
    if (txt != "" && txt != titre) titre += " : "+txt;
    if (!est_admin) try { _gaq.push(['_trackEvent', 'Aperçu ouvert '+t+' secondes et plus', titre]);   } catch(err) {}
    if (t == 5) apercu_to = setTimeout('StatApercu(30);',25000);
  }
}
var titre_current = "Photo";
var titre_album = "";
var apercu_to = null;
function initColorBox(ta,ti,os){
    openstate = false;
    t="thumbs";
    if (ta !== undefined) {
        titre_album = ta;
        if (os !== undefined) openstate=os;
        else openstate = true;        
        if (ti == 'apercu') {
            titre_current = "Aperçu";
            t = ti;
            $('a[rel="'+t+'"]').each(function(){if ($(this).attr('title') == null || $(this).attr('title') == "") $(this).attr('title',$(this).text());});
        } else {
            t = t+ti;
            $('a[rel="'+t+'"]').each(function(){$(this).attr('title',$(this).attr('href'));});
        }
    }

    $('a[rel="'+t+'"]').colorbox({
          open : openstate,
          transition: 'fade',
          speed: 350,
          onLoad: function() {
             $('#cboxContentDescription').hide();
             clearTimeout(apercu_to);
          },
          onCleanup: function() {
             $('#cboxContentDescription').hide();
             clearTimeout(apercu_to);
          },
          onComplete: function() {
             if (d = ZEN('d'+$(this).attr('id')))
                $('#cboxContentDescription').html(d.innerHTML).slideDown({duration: 'fast', easing: 'swing', queue:false});
             apercu_to = setTimeout('StatApercu(5);',5000);
             // 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>  -  '+titre_current+' {current} de {total}'
     });
//       slideshow:true, slideshowSpeed:4500, slideshowAuto:false, slideshowStart:' (Démarrer diaporama) ', slideshowStop:' (Arrêter diaporama) ',
     if (!ZEN('cboxContentDescription'))
        $('#cboxLoadedContent').after('<div id="cboxContentDescription"></div>');
     $('#cboxContentDescription').hide();
}

var album_actif = "";
var cache_albums = new Array();
function AlbLoaded(idalbum) {
         initColorBox();
         if (est_admin) CorrigeOA();
         $("#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;*/
  }
}

