function popup(SrcNo,PhotosID,AlbumID) {
    // Précharger l'image
    height = screen.height - 130;
    if (height > 600) height = 600;
    width = 4 * height / 3;
    winheight = height + 80;
    winwidth = width+10;
    if (window.name == "frmPhotos"){
        opener = window.opener;
    }else{
        opener = window;
    }
    
    // Vérifier si on est au bout de la catégorie
    // Photos précédente
    if (PhotosID == opener.photosArray[AlbumID].length-1){
        if (AlbumID == opener.photosArray.length-1){
            next = false;
        }else{
            next = "'"+opener.photosArray[AlbumID+1][0]+"',0,"+(AlbumID+1);
        }
    }else{
        next = "'"+opener.photosArray[AlbumID][PhotosID+1]+"',"+(PhotosID+1)+","+(AlbumID);
    }
    // Photos suivante
    if (PhotosID == 0){
        if (AlbumID == 0){
            back = false;
        }else{
            last = opener.photosArray[AlbumID-1].length-1;
            back = "'"+opener.photosArray[AlbumID-1][last]+"',"+last+","+(AlbumID-1);
        }
    }else{
        back = "'"+opener.photosArray[AlbumID][PhotosID-1]+"',"+(PhotosID-1)+","+(AlbumID);
    }
    
    // Réajuster les dimenssion si la photo est verticale
    if (opener.document.images["image"+SrcNo].width < opener.document.images["image"+SrcNo].height){
        width = 3 * height / 4;
    }
    
    // Afficher l'image
    var win = window.open('','frmPhotos','"width='+winwidth+',height='+winheight+',status=no"');
    win.resizeTo(winwidth,winheight);
	var strFenetre = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\n'+
		'<html lang="fr">\n\t<head>\n\t\t<title>Domaine Lacombe</title>\n'+
		'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n'+
		'<style type="text/css"><!--\n'+
		'body { margin:0px; background: #blue;}\nimg { border:0px;}\n--></style>\n'+
        '<link rel="StyleSheet" type="text/css" href="styles.css">\n'+
        '<style type="text/css">\n'+
        '    <!--\n'+
        '    a {color: #999999; text-decoration: underline}\n'+
        '    a:hover {color: #006666; text-decoration: underline}\n'+
        '    a:active {}\n'+
        '    a:visited {}\n'+
        '    -->\n'+
        '</style>\n'+
		'<script src="functions.js"></script>\n</head>\n';

	strFenetre +='<body>\n'+
        '<table border="0" width="100%" height="100%" cellspacing="0" cellpadding="0"><tr>'+
        '<td bgcolor="#EEEEEE" align="center" valign="top" colspan="3" height="'+height+'"><img src="photos/'+SrcNo+'.jpg" width="'+width+'" height="'+height+'"></td>\n'+
        '</tr><tr>'+
        '<td align="left" valign="center" width="33%"><font class="texte">';
    if (back) {
        strFenetre +='&nbsp;<a href="javascript:popup('+back+');">&lt;&lt; Image precedente</a>';
    }
    strFenetre +='</font></td width="34%">'+
        '<td align="center" valign="center"><font class="texte"><a href="javascript:window.close()" title="Cliquer pour fermer la fenêtre">Fermer</a></td></font>'+
        '<td align="right" valign="center" width="33%"><font class="texte">';
    if (next) {
        strFenetre +='<a href="javascript:popup('+next+');">Image suivante &gt;&gt;</a>&nbsp;';
    }
    strFenetre +='</font></td></tr></table>';
	strFenetre +='\n\t</body>\n</html>';
    
    // Afficher le popup
	win.document.open();
	win.document.write(strFenetre);
	win.document.close();
	win.focus();
}

function thumbs(indice){
    // Afficher les thumbnails des photos
    for (i=0;i<photosArray[indice].length;i++){
        // Changer de ligne apres 4 images
        if (!((i)%4)) document.write("</tr><tr>");
        
        // Afficher l'image (thumb)
    	texte = '<td align="center" valign="middle" width="130" height="100">';
    	texte += '<a href="javascript:popup(\''+photosArray[indice][i]+'\','+i+','+indice+')"><img src="photos/th'+photosArray[indice][i]+'.jpg" border="0" name="image'+photosArray[indice][i]+'">\n';
       	texte += '</td>';
        document.write(texte);
    }
}
