 $file = "photos.txt";
         $data = @file($file) or die('Could not read file!');
         $pi = $lastphoto;
         $ctr = 0;
         $getnext = 0;
         foreach ($data as $line) {
           $ctr = $ctr + 1;
           if ($ctr>1) {$pi = $imgdata[0];}
           $imgdata = explode('@&@', $line);
           $imgdata[0] = trim($imgdata[0]);
           if ($getnext) {$nextphoto=$imgdata[0]; $getnext = 0;}
           if ($photo==$imgdata[0]) {
	     $pfile=trim($imgdata[1]);
             $ptitle=trim($imgdata[4]);
             $pwidth=trim($imgdata[2]);
             $pheight=trim($imgdata[3]);
             $prevphoto = $pi;
             if ($photo==$lastphoto) {$nextphoto=$firstphoto;} else {$getnext=1;} 
         }

         echo '<center>';
	 echo '<img src="photos/'.$pfile.'.png" width="'.$pwidth.'" height="'.$pheight.'" border="0" usemap="#Map">';
         echo '<map name="Map">';

      
          //0,0, width/5, height
          //(4/5)*width, 0, width, height
      
          $c11 = 0;
          $c21 = 0;
          $c31 = $pwidth/4;
          $c41 = $pheight;
          $c12 = 0.25*$pwidth;
          $c22 = 0;
          $c32 = $pwidth;
          $c42 = $pheight;

          if ($prevphoto!=$null) {
            echo '<area shape="rect" coords="'.$c11.','.$c21.','.$c31.','.$c41.'" href="?page=photos&photo='.$prevphoto.'" alt="previous image">';
          }
          if ($nextphoto!=$null) {
             echo '<area shape="rect" coords="'.$c12.','.$c22.','.$c32.','.$c42.'" href="?page=photos&photo='.$nextphoto.'" alt="next image">';
          }
          echo '</map>';
	 echo '</center>';
