<?php
	$nbaff=5; // 5 images pour chaque page
	$dossier_images='./diaporamas/galion/SourceGalion/thumbnails/';
	
   echo '<!DOCTYPE html>
   <html lang="fr">
  <head>
    <meta charset="utf-8">
    <title>open-eLab</title>
    
    <link rel="stylesheet" media="screen" href="/css/214.css">    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="François Régnier">
    <meta name="description" content="Participatory Workshop in Guadeloupe">
    <meta name="robots" content="all">
    ';

       error_reporting(E_ALL);
       if(isset($_GET['stop']) && $_GET['stop']=='yes'){
       $_SESSION=array();
       }

       session_start();
       
       if (isset($_GET['select']))
       {
       $select = $_GET['select'];
       $xsel = '*'.$select.'*';
       $_SESSION['diaporama']= '';
       }
       else
       {
       $select = '';
       $xsel = '*';
       }
       $diapo=glob($dossier_images.$xsel.'.JPG');
       usort($diapo, 'strnatcmp');       
       $xnb=count($diapo);

       if(empty($_SESSION['diaporama']))
       {
       $_SESSION['diaporama']=$diapo;
         $nb=$xnb;
       }
       else
       {
         $nb=count($_SESSION['diaporama']);
         if (xnb <> $nb)
         {
           $nb=$xnb;
           $img=0;
           $_SESSION['diaporama']=$diapo;
         }
       }
       if(isset($_GET['image']) && ctype_digit($_GET['image']))
       {
         $img=$_GET['image'];
         if ($img > $nb or $img > $xnb)
         {
           $img=0;
         }
       }      
       else
       {
         $img=0;
       }

   echo '
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
   <script src="/web_prez/js/url2.js"></script>
   
   <script>   
   $(document).ready(function () {
		var vv = <?php echo $img + $nbaff ; ?> ;
		var newUrl = "?image=" + vv ;
		setTimeout(function(){
    		                window.location.href = newUrl;
    		}, 5000);

		
    });
   </script>
   
    <!--[if lt IE 9]>
	<script src="script/html5shiv.js"></script>
	<![endif]-->
  </head>
  
  <!--
      Merci Dave et Zen Garden
      http://www.csszengarden.com/zengarden.xml
    -->

  <body id="css-zen-garden">
    <div>';
	      echo '<table style="border:none;">';
		echo '<tr><td>';
		    if($img>=$nbaff && $img<=$nb){
			       echo '<a href="diapo_galion.php?image=',$img-$nbaff,'"><img align="left" src="/web_prez/images/left.png" width="30px" alt="prec"></a>';
			       }
			       else
			       {
			       echo '&nbsp;';
			       }
			       echo '</td>
  			       <td colspan="3" style="text-align:center;">
			           <a href="diapo_galion.php?stop=yes"><img src="/web_prez/images/reset.png" width="30px" alt="reset"></a>
			       </td>				   ';
			       echo '<td style="width:100px;">';

  if($img<$nb-1 && $img>=0){
    echo '<a href="diapo_galion.php?image=',$img+$nbaff,'"><img src="/web_prez/images/right.png" width="30px" align="right" alt="next"></a>';
    }
    else
    {
    echo '&nbsp;';
    }
    echo '<tr>

</tr>';
       echo '<tr>';
       for ($i=$img;$i<$img+$nbaff;$i++)
       {
			 
			  echo '     	<td style="width:250px;text-align:center;">';

	$naname = explode ('/', $_SESSION['diaporama'][$i]);	
	echo '   <br /><br />';
	echo '   <a href="'.$dossier_images.'../',$naname[count($naname)-1],'" target="_blank"><img src="',$_SESSION['diaporama'][$i],'" alt="" /></a>';
	echo ' </td>';
	}
	echo '
       </tr>
       
       <tr>
	<td style="width:100px;">
</td></tr></table>

    </div>
  </body>
</html>
';
