
addListenner(window, "load", installGalleryLightbox, true);

/**
 * Place l'ouverture du popup de l'image sur le clic
 */
function installGalleryLightbox()
{
    var linklist = document.getElementsByTagName('a');
    for (var i = 0; i < linklist.length; i++) {
        if (linklist[i].className && linklist[i].className.indexOf('gallery-lightbox') >= 0) {
            linklist[i].onclick = function() { openGalleryLightbox(this); return false; };
        }
    }

} // end function "installImagePopup"


function openGalleryLightbox(link)
{
    var oData          = {};
    oData['xhrAction'] = 'lireGallerie';
    oData['type']      = 'image';
    oData['st']        = 0;
    
    /*if (link.className.indexOf('gallery-all') >= 0) {
        oData['globale'] = 1;
    }*/
    showIndicator();
    XHR_post(document.location.href, oData, showGalleryLighBox);
    
    return false;
} // end function "openGalleryLightbox()"




function buildGalleryHeader(oData)
{
    // entête : menu, infos hotel, logo
    var headerBox = document.createElement('div');
    headerBox.className = 'galerieHotelHeader';
    var logoSrc = false; //'img/slideflow/transparent.gif';
    /*if (oData['hotel'] && oData['hotel']['logo']) {
        logoSrc = oData['upload-dir'] + oData['hotel']['logo'][0]['zoom_src'];
        
    } else if (oData['fichiers'] && oData['fichiers'][0]) {
        var hotelId = oData['fichiers'][0]['hotel_id'];
        if (oData['hotel'][hotelId] && oData['hotel'][hotelId]['logo'][0]) {
            logoSrc = oData['upload-dir'] + oData['hotel'][hotelId]['logo'][0]['zoom_src'];
        }
    }*/

    
    var codeHtml = '';
    
    
    codeHtml += '<div class="partieGauche">';
    codeHtml += '    <a href="http://www.facebook.com/media/albums/?id=173273884430" target="_blank"><img src="http://www.lilibricole.com/img/galerieLogoLili.gif" alt="lilibricole" /></a>';
    codeHtml += '    <h2 class="cocon">';
    codeHtml += '        <strong>';
    codeHtml += '            <span class="rose">les galeries photo de nos lili</span>';
    codeHtml += '<span class="pourpre">bricoleuses</span>';
    codeHtml += '        </strong>';
    codeHtml += '    </h2>';
    codeHtml += '</div>';
    codeHtml += '<div class="partieDroite">';
    codeHtml += '    <a href="#" id="galerieHotelLienFermer">';
    var langueCourante = document.getElementById('langueCourante');
    if (langueCourante && langueCourante.innerHTML && langueCourante.innerHTML != 'FR') {
        codeHtml += '         Close';
    } else {
        codeHtml += '         Fermer';
    }
    codeHtml += '    </a>';
    
    codeHtml +=     '<div class="logoFb">';
    codeHtml +=         '<a href="http://www.facebook.com/media/albums/?id=173273884430" target="_blank" class="picto"><img src="http://www.lilibricole.com/img/galerieLogoFb.gif" alt="lilibricole" /></a>';
    codeHtml +=         '<a href="http://www.facebook.com/media/albums/?id=173273884430" target="_blank" class="text">retrouvez les photos sur notre facebook</a>';
    codeHtml +=     '</div>';
    codeHtml += '</div>';
    
    
    
    
    /*codeHtml += '<div class="galerieHotelMenu">';
    codeHtml += '    <a href="#" id="galerieHotelLienFermer">';
    var langueCourante = document.getElementById('langueCourante');
    if (langueCourante && langueCourante.innerHTML && langueCourante.innerHTML != 'FR') {
        codeHtml += '         Close';
    } else {
        codeHtml += '         Fermer';
    }
    codeHtml += '    </a>';
    
    codeHtml += '</div>';*/
    /*codeHtml += '<div class="galerieHotelLogo';
    if (logoSrc === false) {
    	codeHtml += ' cacher';
    }
    codeHtml += '">';
    codeHtml += '    <img src="' + logoSrc + '" alt="" id="galerieHotelLogo" />';
    codeHtml += '</div>';*/
    
    headerBox.innerHTML = codeHtml;
    
    return headerBox;
} // fin de buildGalleryHeader()





function buildGalleryFooter(oData, footerNode)
{
    var langueCourante = document.getElementById('langueCourante');
    var codeHtml = '';
    footerNode.innerHTML = '';
    
    
    if (oData['albums']) {
        //alert('albums trouvé');
        var albumId;
        for (var i in oData['albums']) {
            /*codeHtml += '<a href="#">';
            codeHtml += '    ' + oData['albums'][i]['name'];
            codeHtml += '</a>';*/
            
            link = document.createElement('a');
            link.href = '#';
            link.appendChild(document.createTextNode(oData['albums'][i]['name']));
            link.albumId = oData['albums'][i]['aid'];
            link.onclick = function() {
                
                
                showIndicator();
                //alert('changement d\'album: ' + this.albumId); 
                var oData          = {};
                oData['xhrAction'] = 'lireGallerie';
                oData['type']      = 'image';
                oData['st']        = 0;
                oData['album']     = this.albumId;
                XHR_post(document.location.href, oData, refreshGalleryLighBox);
                
                return false; 
            };
            
            
            
            //link.onmouseover = ocea_afficherGalleryLBImg;
            footerNode.appendChild(link);
        }
    }
    
    /*codeHtml += '    <a href="#" class="actif" id="galerieHotelLienPhotos">';
    if (langueCourante && langueCourante.innerHTML && langueCourante.innerHTML != 'FR') {
        codeHtml += 'photo gallery';
    } else {
        codeHtml += 'Galerie photo';
    }
    codeHtml += '</a>';
    
    if (oData['totalVideos'] > 0) {
        codeHtml += '    <a href="#" id="galerieHotelLienVideos">';
        if (langueCourante && langueCourante.innerHTML && langueCourante.innerHTML != 'FR') {
            codeHtml += 'video gallery';
        } else {
            codeHtml += 'Galerie vidéo';
        }
        codeHtml += '</a>';
    }*/
    
    return codeHtml;
} // fin de buildGalleryFooter()





function addGalleryThumb(oData, miniList)
{
    var count = 0;
    for (var i in oData['fichiers']) {
        link = document.createElement('a');
        link.id = 'fichier-' + oData['fichiers'][i]['pid'];
        //link.title = oData['fichiers'][i]['caption'];
        link.legende = '';
        var hotelId = 0;
        var logoSrc = ''; //http://www.lilibricole.com/img/slideflow/transparent.gif';
        var legende = oData['fichiers'][i]['img-alt'];
        link.legende = legende;
        
        link.description = '';
        if (oData['fichiers'][i]['caption'] && oData['fichiers'][i]['caption'].length > 2) {
      	    link.description = oData['fichiers'][i]['caption'];
        }
        
        img = document.createElement('img');
        link.href = oData['fichiers'][i]['src_big'];
        img.src = oData['fichiers'][i]['src_small'];
        link.onclick = function() { return false; };
        link.onmouseover = ocea_afficherGalleryLBImg;
        
        if (legende && legende.length > 2) {
            img.alt = legende;
            link.title = legende;
        }
        
        img.width = parseInt(oData['fichiers'][i]['src_small_width']);
        img.height = parseInt(oData['fichiers'][i]['src_small_height']);

        link.appendChild(img);
        miniList.appendChild(link);
        
        count++;
        if (count == 4) {
            count = 0;
            link = document.createElement('div');
            link.className = 'lineBreaker';
            miniList.appendChild(link);
        }
    }
    
    var link = document.getElementById('galerieHotelPagePrecedente');
    var link2 = document.getElementById('galerieHotelPageSuivante');
    
    if (oData['total'] > 20) {
        removeClass(link, 'cacher');
        removeClass(link2, 'cacher');
        
    } else {
        addClass(link, 'cacher');
        addClass(link2, 'cacher');
    }
    
} // fin de addGalleryThumb()




function buildGalleryZoomPlace(zoomBox, oData, fileSrc)
{
    zoomBox.innerHTML = '';
    
    // première image
    img = document.createElement('img');
    if (oData) {
        img.src = oData['fichiers'][0]['src_big'];
    } else if (fileSrc) {
        img.src = fileSrc;
    }
    img.id = 'galerieHotelZoomLB';
    if (oData['fichiers'][0]['img-alt']) {
        img.alt = oData['fichiers'][0]['img-alt'];
    }
    zoomBox.appendChild(img);
    
    
    // deuxième image pour l'effet de transition
    img = document.createElement('img');
    if (oData) {
        img.src = oData['fichiers'][0]['src_big'];
    } else if (fileSrc) {
        img.src = fileSrc;
    }
    img.id = 'galerieHotelZoomLB2';
    if (oData['fichiers'][0]['img-alt']) {
        img.alt = oData['fichiers'][0]['img-alt'];
    }
    zoomBox.appendChild(img);
    
    

    
    var legende = '';
    var logoSrc = ''; //'http://www.lilibricole.com/img/slideflow/transparent.gif';
    if (oData) {
        if (oData['fichiers'][0]['caption']) {
            legende = oData['fichiers'][0]['caption'];
        }
        /*if (oData['fichiers'][0]['hotel_id']) {
            hotelId = oData['fichiers'][0]['hotel_id'];
            if (oData['hotel'][hotelId]) {
                legende += '<br /><a href="hotel-accueil.php?hotel=' + hotelId + '">';
                legende += oData['hotel'][hotelId]['HO_nom'];
                legende += '</a>';
                
                if (oData['hotel'][hotelId]['logo'] && oData['hotel'][hotelId]['logo'][0]['zoom_src']) {
                	logoSrc = oData['upload-dir'] + oData['hotel'][hotelId]['logo'][0]['zoom_src'];
                }
            }
        }*/
    }
        
    
    
    // bloc légende
    var legendeBox = document.createElement('div');
    legendeBox.className = 'galerieLegendeBox';
    legendeBox.id = 'galerieLegendeBox';
    /*if (oData && legende && legende.length > 2) {
        legendeBox.innerHTML = legende;
        
    } else {*/
        legendeBox.className += ' cacher';
    //}
    zoomBox.appendChild(legendeBox);
    
    
    /*var blocLogo = document.getElementById('galerieHotelLogo');
    if (blocLogo) {
	    if (logoSrc) {
	        blocLogo.src = logoSrc;
	        addClass(blocLogo.parentNode, 'cacher');
	        
	    } else {
	    	blocLogo.src = 'http://www.lilibricole.com/img/slideflow/transparent.gif';
	        addClass(blocLogo.parentNode, 'cacher');
	    }
    }*/
    
} // fin de buildGalleryZoomPlace()






function buildGalleryMedias(oData)
{
    // zone contenu les vignettes, les flêches de navigation et le zoom
    var medias = document.createElement('div');
    medias.className = 'container galerieHotelMedias';
    
    link = document.createElement('a');
    link.href = '#';
    link.id = 'galerieHotelPagePrecedente';
    link.title = 'page précédente';
    link.onclick = goPrevGalleryPage;
    if (oData['total'] <= 20) {
        link.className = 'cacher';
    }
    medias.appendChild(link);
    
    
    var miniList = document.createElement('div');
    miniList.className = 'container galerieHotelVignettes';
    miniList.id = 'galerieHotelVignettes';
    addGalleryThumb(oData, miniList);
    
    miniList.firstChild.className += ' actif';
    medias.appendChild(miniList);
    
    

    var zoomBox = document.createElement('div');
    zoomBox.className = 'galerieHotelZoom';
    zoomBox.id = 'galerieHotelZoomPlace';
    buildGalleryZoomPlace(zoomBox, oData);
    
    
    
    medias.appendChild(zoomBox);
    
    link = document.createElement('a');
    link.href = '#';
    link.id = 'galerieHotelPageSuivante';
    link.title = 'page suivante';
    link.onclick = goNextGalleryPage;
    if (oData['total'] <= 20) {
        link.className = 'cacher';
    }
    medias.appendChild(link);
    
    return medias;
} // fin de buildGalleryMedias()



function removeIndicator()
{
    var node = document.getElementById('indicatorBg');
    node.parentNode.removeChild(node);
    node = document.getElementById('indicatorBox');
    node.parentNode.removeChild(node);
}



function showIndicator()
{
     var whole = document.getElementById('page');
     if (!whole) {
         whole = document.getElementById('corps-page');
         if (!whole) {
             return false;
         }
     }

     // fond noir transparent
     var bg = document.createElement('div');
     bg.id = 'indicatorBg';
     bg.style.position = 'absolute';
     bg.style.top = 0;
     bg.style.left = 0;
     bg.style.width = '100%';
     bg.style.height = '1000px';
     bg.style.background = '#000';
     bg.style.padding = 0;
     bg.style.margin = 0;
     bg.style.zIndex = 900;
     bg.style.filter = 'alpha(opacity=80)';
     bg.style.opacity = .8;
    
    
     // Boîte "conteneur"
     var lightBox = document.createElement('div');
     lightBox.id = 'indicatorBox';
     lightBox.style.position = 'absolute';
     lightBox.style.overflow = 'visible';
     lightBox.style.float = 'left';
     lightBox.style.top = '50%';
     lightBox.style.left = '50%';
     lightBox.style.width = '50px';
     lightBox.style.height = '50px';
     lightBox.style.background = '#fff';
     lightBox.style.padding = '10px';
     lightBox.style.margin = 0;
     lightBox.style.padding = '16px';
     lightBox.style.zIndex = 900;
     lightBox.style.textAlign = 'center';
     lightBox.className = 'spg_lightBox';
     
     // bigrotation2.gif

     var img = document.createElement('img');
     img.src = 'http://www.lilibricole.com/img/bigrotation2.gif';
     lightBox.appendChild(img);
     
     
     if (bg && whole.clientHeight) {
         bg.style.height = whole.clientHeight + 'px';
     }   

     if (lightBox) {
         var x = 0, y = 0;
         var scrolloffset = getScrollOffset();
         var win = getWindowSize();
         x = (win.x - lightBox.clientWidth) / 2;
         if (win.y > (y + lightBox.clientHeight)) {
             y += (win.y - lightBox.clientHeight) / 2;
         }
         if (scrolloffset.y) {
            y += scrolloffset.y;
         }
         //alert('scrolloffset.y = ' + scrolloffset.y + ', win.y = ' + win.y + ', y = ' + y);
         
         lightBox.style.top = y + 'px';
         lightBox.style.left = x + 'px';
     }
     
     
     
     var body = document.getElementsByTagName('body');
     if (body[0]) {
         body[0].appendChild(bg);
         body[0].appendChild(lightBox);
     }
     
}



function buildGalleryLighBox(oData)
{
    if (!oData || !oData['data']) {
        return false;
    }
    oData = oData['data'];

    var img, link;
    var mainBox = document.createElement('div');
    mainBox.className = 'container galerieHotelLightBox';
    mainBox.id = 'galerieHotelLightBox';
    
    mainBox.start = 0;
    mainBox.totalPerPage = 10;
    mainBox.total = oData['total'];
    mainBox.pageNb = Math.ceil(mainBox.total/mainBox.totalPerPage);
    mainBox.actif = false;
    mainBox.mode = 'photos';
    
    mainBox.global = 1;
    if (oData['fichiers']) {
        mainBox.global = 0;
    }
    
        
    
    
    // entêtes
    mainBox.appendChild(buildGalleryHeader(oData));
    
    // vignettes et grande photo
    mainBox.appendChild(buildGalleryMedias(oData));
    
    
    infoType = document.createElement('div');
    infoType.id = 'galerieHotelDescription';
    infoType.className = 'galerieHotelDescription';
    if (oData['fichiers'][0]['caption'] && oData['fichiers'][0]['caption'].length > 2) {
        infoType.innerHTML = oData['fichiers'][0]['caption'];
    }
    mainBox.appendChild(infoType);
    
    
    var infoType = document.createElement('div');
    infoType.className = 'galerieHotelFooter';
    //infoType.innerHTML = 
    buildGalleryFooter(oData, infoType);
    mainBox.appendChild(infoType);
    
    return mainBox;
} // fin de buildGalleryLighBox()





function showGalleryLighBox(oData)
{
    var mainBox = buildGalleryLighBox(oData); // , height: '530px'
    var options = {content: mainBox, width: '915px', closeId: 'galerieHotelLienFermer'};
    var lightBox = createLightBoxHtml('spg_lightBoxBackground',
                                      'spg_lightBox',
                                      options);

    var link = document.getElementById('galerieHotelLienPhotos');
    if (link) {
        link.onclick = switchToPhotos;
    }

    var link = document.getElementById('galerieHotelLienVideos');
    if (link) {
        link.onclick = switchToVideos;
    }
    
    // Centre la boîte et agrandi le fond noir à la hauteur de la page
    adaptLightboxPosAndSize(lightBox, -100);

    removeIndicator();
    
} // fin de showGalleryLighBox()




function switchToPhotos()
{
    var mainBox = document.getElementById('galerieHotelLightBox');
    mainBox.start = 0;
    mainBox.mode = 'photos';
    
    var link = document.getElementById('galerieHotelLienVideos');
    addClass(this, 'actif');
    if (link) {
        removeClass(link, 'actif');
    }
    
    var oData          = {};
    oData['xhrAction'] = 'lireGallerie';
    oData['type']      = 'image';
    oData['st']        = mainBox.start;
    /*if (mainBox.global) {
        oData['globale'] = 1;
    }*/
    XHR_post(document.location.href, oData, refreshGalleryLighBox);
    
    return false;
}


function switchToVideos()
{
    var mainBox = document.getElementById('galerieHotelLightBox');
    mainBox.start = 0;
    mainBox.mode = 'videos';
    
    var link = document.getElementById('galerieHotelLienPhotos');
    addClass(this, 'actif');
    if (link) {
        removeClass(link, 'actif');
    }
    
    var oData          = {};
    oData['xhrAction'] = 'lireGallerie';
    oData['type']      = 'video';
    oData['st']        = mainBox.start;
    /*if (mainBox.global) {
        oData['globale'] = 1;
    }*/
    XHR_post(document.location.href, oData, refreshGalleryLighBox);

    return false;
}





function refreshGalleryLighBox(oData)
{
    if (!oData || !oData['data']) {
        return false;
    }
    oData = oData['data'];
    var miniList = document.getElementById('galerieHotelVignettes');
    while (miniList.firstChild) {
        miniList.removeChild(miniList.firstChild);
    }
    
    addGalleryThumb(oData, miniList);
    
    if (miniList.firstChild) {
        if (miniList.firstChild.onmouseover) {
            miniList.firstChild.onmouseover();
        } else if (miniList.firstChild.onclick) {
            miniList.firstChild.onclick();
        } 
    }
    

    var lightBox = document.getElementById('spg_lightBox');
    adaptLightboxPosAndSize(lightBox);
    
    removeIndicator();
    
    return false;
} // fin de refreshGalleryLighBox()




function goPrevGalleryPage()
{
    var mainBox = document.getElementById('galerieHotelLightBox');
    
    if (mainBox.start <= 0) {
        mainBox.start = (mainBox.pageNb - 1) * mainBox.totalPerPage;
    } else {
        mainBox.start -= mainBox.totalPerPage;
    }

    var oData          = {};
    oData['xhrAction'] = 'lireGallerie';
    oData['type']      = 'image';
    if (mainBox.mode == 'videos') {
        oData['type'] = 'video';
    }
    /*if (mainBox.global) {
        oData['globale'] = 1;
    }*/
    oData['st']        = mainBox.start;
    XHR_post(document.location.href, oData, refreshGalleryLighBox);
    return false;
} // fin de goPrevGalleryPage()




function goNextGalleryPage()
{
    var mainBox = document.getElementById('galerieHotelLightBox');
    if ((mainBox.start + mainBox.totalPerPage) > mainBox.total) {
        mainBox.start = 0;
        
    } else {
        mainBox.start += mainBox.totalPerPage;
    }

    var oData          = {};
    oData['xhrAction'] = 'lireGallerie';
    oData['type']      = 'image';
    if (mainBox.mode == 'videos') {
        oData['type'] = 'video';
    }
    /*if (mainBox.global) {
        oData['globale'] = 1;
    }*/
    oData['st']        = mainBox.start;
    XHR_post(document.location.href, oData, refreshGalleryLighBox);
    return false;
} // fin de goNextGalleryPage()



function ocea_afficherGalleryVideo()
{
    var blocNouv = document.getElementById('galerieHotelLightBox');
    var extension = this.href.split('.').pop();
    var image = this.getElementsByTagName('img');
    
    var zoomPlace = document.getElementById('galerieHotelZoomPlace');
    if (!zoomPlace) {
        return false;
    }
    
    var codeVideo = '';
    var flashVar = 'file=' + this.href;
    if (image[0] && image[0].src) {
        flashVar += '&image=' + image[0].src;
    }
    var width = 559;
    var height = 300;
    var playerSrc = 'flash/mediaplayer.swf';
    
    codeVideo += '<div class="objetVideo">';
    codeVideo += '<object id="player-5646498djdfdsf654" classid="clsid:D27CDB6E-AE6D-11cf-96B8-5646498djdfdsf654"';
    codeVideo += '        name="player" width="' + width + '" height="' + height + '">';
    codeVideo += '    <param name="movie" value="' + playerSrc + '" />';
    codeVideo += '    <param name="allowfullscreen" value="true" />';
    codeVideo += '    <param name="allowscriptaccess" value="always" />';
    codeVideo += '    <param name="flashvars" value="' + flashVar + '" />';
    codeVideo += '    <param name="WMODE" value="Transparent" />';
    codeVideo += '    <embed';
    codeVideo += '        type="application/x-shockwave-flash"';
    codeVideo += '        id="player-5646498djdfdsf654"';
    codeVideo += '        name="player2-5646498djdfdsf654"';
    codeVideo += '        src="' + playerSrc + '"';
    codeVideo += '        quality="high"';
    codeVideo += '        bgcolor="#ffffff"';
    codeVideo += '        width="' + width + '"';
    codeVideo += '        height="' + height + '"';
    codeVideo += '        allowscriptaccess="always"';
    codeVideo += '        allowfullscreen="true"';
    codeVideo += '        WMODE="Transparent"';
    codeVideo += '        flashvars="' + flashVar + '" />';
    codeVideo += '</object>';
    codeVideo += '</div>';

    
    blocNouv.legende = false;
    if (this.legendeFichier && this.legendeFichier.length > 4) {
        //blocNouv.legende = this.legende;
        codeVideo += '<div class="galerieHotelDescription descriptionVideo" id="galerieHotelDescription">';
        codeVideo += this.legendeFichier;
        codeVideo += '</div>';
    }
    /*if (this.legende && this.legende.length > 4) {
        //blocNouv.legende = this.legende;
        codeVideo += '<div class="galerieLegendeBox" id="galerieLegendeBox">';
        codeVideo += this.legende;
        codeVideo += '</div>';
    }*/
    /*blocNouv.logoSrc = 'img/slideflow/transparent.gif';
    if (this.logoSrc && this.logoSrc.length > 2) {
        blocNouv.logoSrc = this.logoSrc;
    }*/

    
    blocNouv.description = false;
    /*if (this.description && this.description.length > 2) {
        //blocNouv.description = this.description;
        codeVideo += '<div class="galerieHotelDescription" id="galerieHotelDescription">';
        codeVideo += this.description;
        codeVideo += '</div>';
    }*/
    
    ocea_refreshTexts();
    
    if (!blocNouv.indexActif) {
        var miniList = document.getElementById('galerieHotelVignettes');
        blocNouv.indexActif = miniList.firstChild.id;
    }
    if (blocNouv.indexActif) {
        var actif = document.getElementById(blocNouv.indexActif);
        removeClass(actif, 'actif');
    }
    
    addClass(this, 'actif');
    blocNouv.indexActif = this.id;
        
    zoomPlace.innerHTML = codeVideo;
    
    return false;
} // fin de ocea_afficherGalleryVideo()



function ocea_afficherGalleryLBImg()
{
    var blocNouv = document.getElementById('galerieHotelLightBox');
    if (blocNouv.showTimer) {
    	clearTimeout(blocNouv.showTimer);
    }
    var that = this;
    blocNouv.showTimer = setTimeout(ocea_attendreGalleryLBImg, 400);
    
    
    
    
	
	function ocea_attendreGalleryLBImg()
	{
	    var blocNouv = document.getElementById('galerieHotelLightBox');
	    
	    blocNouv.legende = false;
	    /*if (that.legende && that.legende.length > 4) {
	        blocNouv.legende = that.legende;
	    }*/
	    
	    /*blocNouv.logoSrc = 'img/slideflow/transparent.gif';
	    if (that.logoSrc && that.logoSrc.length > 2) {
	        blocNouv.logoSrc = that.logoSrc;
	    }*/
	
	    blocNouv.description = false;
	    if (that.description && that.description.length > 2) {
	        blocNouv.description = that.description;
	    }
	    
	    if (!blocNouv.indexActif) {
	        var miniList = document.getElementById('galerieHotelVignettes');
	        blocNouv.indexActif = miniList.firstChild.id;
	    }
	    if (blocNouv.indexActif) {
	        var actif = document.getElementById(blocNouv.indexActif);
	        removeClass(actif, 'actif');
	    }
	    addClass(that, 'actif');
	    blocNouv.indexActif = that.id;
	    
	
	    if (that.href) {
	        blocNouv.preloadImg = new Image();
	        blocNouv.preloadImg.onload = ocea_changerGalleryLBImg;
	        blocNouv.preloadImg.src = that.href;
            blocNouv.preloadImg.legende = that.legende;
	        
            /*var img = document.getElementById('galerieHotelZoomLB');
            var img2 = document.getElementById('galerieHotelZoomLB2');
            img.alt = that.legende;
            img2.alt = that.legende;*/
	    }
	    return false;
	} // fin de ocea_attendreGalleryLBImg()

    /*blocNouv.legende = false;
    if (this.legende && this.legende.length > 4) {
        blocNouv.legende = this.legende;
    }
    
    blocNouv.logoSrc = 'img/slideflow/transparent.gif';
    if (this.logoSrc && this.logoSrc.length > 2) {
        blocNouv.logoSrc = this.logoSrc;
    }

    blocNouv.description = false;
    if (this.description && this.description.length > 2) {
        blocNouv.description = this.description;
    }
    
    if (!blocNouv.indexActif) {
        var miniList = document.getElementById('galerieHotelVignettes');
        blocNouv.indexActif = miniList.firstChild.id;
    }
    if (blocNouv.indexActif) {
        var actif = document.getElementById(blocNouv.indexActif);
        removeClass(actif, 'actif');
    }
    addClass(this, 'actif');
    blocNouv.indexActif = this.id;
    

    if (this.href) {
        blocNouv.preloadImg = new Image();
        blocNouv.preloadImg.onload = ocea_changerGalleryLBImg;
        blocNouv.preloadImg.src = this.href;
    }
    return false;*/
} // fin de ocea_afficherGalleryLBImg()











function ocea_changerGalleryLBImg()
{
    var blocNouv = document.getElementById('galerieHotelLightBox');

    if (blocNouv.preloadImg && !blocNouv.preloadImg.complete) {
        setTimeout('ocea_changerGalleryLBImg()', 50);
        return false;
    }

    var img = document.getElementById('galerieHotelZoomLB');
    var img2 = document.getElementById('galerieHotelZoomLB2');
    
    if (!img && !img2) {
        // reconstruit la zone "zoom"
        var zoomPlace = document.getElementById('galerieHotelZoomPlace');
        buildGalleryZoomPlace(zoomPlace, false, blocNouv.preloadImg.src);
        img = document.getElementById('galerieHotelZoomLB');
        img2 = document.getElementById('galerieHotelZoomLB2');
    }
    
    
    if (!img2) {
        //alert('l\'image nécessaire à la transition n\'a pas été trouvée');
        return false;
    }
    
    img2.src = img.src;
    img2.alt = blocNouv.preloadImg.legende;
    img2.style.visibility = 'visible';
    if (blocNouv.preloadImg.src && img && img.src) {
        img.src = blocNouv.preloadImg.src;
        img.alt = blocNouv.preloadImg.legende;
    }

    ocea_refreshTexts();

    img2.style.opacity = 1;
    img2.style.filter  = 'alpha(opacity=100)';
    blocNouv.fadeInterval = setInterval('ocea_disapearGalleryLBImg()', 70);
    
    img.onmouseover = function() {
	    var blocNouv = document.getElementById('galerieHotelLightBox');
	    if (blocNouv.showTimer) {
	    	clearTimeout(blocNouv.showTimer);
	    }
	    return false;
    };
    img2.onmouseover = img.onmouseover;
    /*var lightBox = document.getElementById('spg_lightBox');
    adaptLightboxPosAndSize(lightBox);*/

} // fin de ocea_changerGalleryLBImg()





function ocea_refreshTexts()
{
	var blocNouv = document.getElementById('galerieHotelLightBox');
    var blocLegende = document.getElementById('galerieLegendeBox');
    if (blocLegende) {
	    if (blocNouv.legende) {
	        blocLegende.innerHTML = blocNouv.legende;
	        removeClass(blocLegende, 'cacher');
	
	    } else {
	        blocLegende.innerHTML = '';
	        addClass(blocLegende, 'cacher');
	    }
    }
    
    /*var blocLogo = document.getElementById('galerieHotelLogo');
    if (blocLogo && blocNouv.logoSrc && blocNouv.logoSrc.length > 2) {
        blocLogo.src = blocNouv.logoSrc;
        removeClass(blocLogo.parentNode, 'cacher');
        
    } else {
    	blocLogo.src = 'http://www.lilibricole.com/img/slideflow/transparent.gif';
        addClass(blocLogo.parentNode, 'cacher');
    }*/

    var infoType = document.getElementById('galerieHotelDescription');
    if (infoType) {
	    if (blocNouv.description !== false) {
	        infoType.innerHTML = blocNouv.description;
	        removeClass(infoType, 'cacher');
	        
	    } else {
	    	infoType.innerHTML = '';
	        addClass(infoType, 'cacher');
	    }
    }
    
} // fin de ocea_refreshTexts()







/**
 * disapearImg
 */
 function ocea_disapearGalleryLBImg()
 {
     var blocNouv = document.getElementById('galerieHotelLightBox');
     var img2 = document.getElementById('galerieHotelZoomLB2');


     if (!img2) {
         //alert('l\'image nécessaire à la transition n\'a pas été trouvée (2)');
         return false;
     }
     
     
     img2.style.opacity -= .2;
     img2.style.filter   = 'alpha(opacity=' + (img2.style.opacity * 100) + ')';

     if (img2.style.opacity <= 0) {
         img2.style.opacity = 1;
         img2.style.filter  = 'alpha(opacity=100)';
         clearInterval(blocNouv.fadeInterval);

         img2.style.visibility = 'hidden';
     }
     
 } // end of "ocea_disapearImg()"






