<?php 
// SlideShow Display (via Digital Camera Image Data) - RJM Programming - http://www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)
if (isset($_GET['least'])) {  
  $homeimage = "siteimage.jpg";
  if (isset($_GET['homeimage'])) $homeimage = $_GET['homeimage'];
  $homeurl = "http://www.rjmprogramming.com.au/";
  if (isset($_GET['homeurl'])) $homeurl = $_GET['homeurl'];
  $dsc = "DSC";
  if (isset($_GET['dsc'])) $homeimage = $_GET['dsc'];
  $imagesdir = "/images";
  if (isset($_GET['imagesdir'])) $homeimage = $_GET['imagesdir'];
  $titleblurb = " - RJM Programming - http://www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)";
  if (isset($_GET['titleblurb'])) $homeimage = $_GET['titleblurb'];

  echo "<html> " . "\n";
  echo "<head> " . "\n";
  echo "<title>" . $_GET['title'] . $titleblurb . "</title> " . "\n";
  echo "<style>\n#myBody {\n";
  if (isset($_GET['background-color'])) {
    echo " background-color: " . str_replace(";","",$_GET['background-color']) . ";\n";
  } else {
    echo " background-color: pink;\n";
  }
  echo "};\n#myDiv {\n";
  if (isset($_GET['width'])) echo " width: " . str_replace(";","",$_GET['width']) . ";\n";
  if (isset($_GET['height'])) echo " height: " . str_replace(";","",$_GET['height']) . ";\n";
  echo "};\n#myTable {\n};\n#huhA {\n};\n#prevA {\n};\n#myPic {\n};\n#nextA {\n};\n#goA {\n";
  if (isset($_GET['noopw'])) echo " display: none;\n";
  echo "};\n</style>\n";
  echo "<script type='text/javascript'> " . "\n";
  echo "//<![CDATA[" . "\n";
  echo "var image_index = 0;" . "\n";
  echo "var ijij = 0;" . "\n";
  $comma = "";
  $cprefix = "000";
  $ext = "jpg";
  $ourunderscore = "_";
  if (isset($_GET['underscore'])) $ourunderscore = $_GET['underscore'];
  $oursubdir = "";
  if (isset($_GET['home'])) { 
    $oursubdir = "/" . $_GET['home'];
  } else if (isset($_GET['different'])) {
    $oursubdir = "/" . $_GET['different'];
  }
  if (strlen($oursubdir) == 1) $oursubdir = "";
  if (isset($_GET['ext'])) $ext = $_GET['ext'];
  if ($_GET['least'] > 9) $cprefix = "00";
  if ($_GET['least'] > 99) $cprefix = "0";
  if ($_GET['least'] > 999) $cprefix = "";
  echo "var mypictures = new Array(" . "\n";
  for ($ijij=$_GET['least']; $ijij<=$_GET['most']; $ijij++) {
    echo $comma . '"' . $homeurl . $_GET['subdir'] . $imagesdir . $oursubdir . '/' . $dsc . $ourunderscore . $cprefix . (($ijij+1*0)) . '.' . $ext . '"' . "\n";
    if ($ijij == 9) $cprefix = "00";
    if ($ijij == 99) $cprefix = "0";
    if ($ijij == 999) $cprefix = "";
    $comma = ",";
  }
  if (isset($_GET['different']) && isset($_GET['home'])) {
    $oursubdir = "/" . $_GET['different'];
    $ext = "JPG";
    if (strlen($oursubdir) == 1) $oursubdir = "";
    for ($ijij=$_GET['least']; $ijij<=$_GET['most']; $ijij++) {
      echo $comma . '"' . $homeurl . $_GET['subdir'] . $imagesdir . $oursubdir . '/' . $dsc . $ourunderscore . $cprefix . (($ijij+1*0)) . '.' . $ext . '"' . "\n";
      if ($ijij == 9) $cprefix = "00";
      if ($ijij == 99) $cprefix = "0";
      if ($ijij == 999) $cprefix = "";
      $comma = ",";
    }
  }
  echo ");" . "\n";
  echo "var thispicture = eval(mypictures.length - 1);" . "\n";
  
  echo 'function initA() {' . "\n";
  echo 'document.getElementById("prevA").onclick = prevDo;' . "\n";
  echo 'document.getElementById("nextA").onclick = nextDo;' . "\n";
  echo '}' . "\n";
} //else {
  //echo "<html> " . "\n";
  //echo "<head> " . "\n";
  //echo "<title>Welcome, Street Art Lovers! - RJM Programming - http://www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)</title> " . "\n";
  //echo "<script type='text/javascript'> " . "\n";
  //echo "//<![CDATA[" . "\n";
  //echo "var mypictures = new Array(); " . "\n";

  //echo 'function initA() {' . "\n";
  //echo 'document.getElementById("prevA").onclick = prevDo;' . "\n";
  //echo 'document.getElementById("nextA").onclick = nextDo;' . "\n";
  //echo '}' . "\n";
//}
?>

function prevDo() {
  if (thispicture == 0) {
    thispicture = mypictures.length;
  }
  thispicture--;
  document.getElementById("myPic").src = mypictures[thispicture];
  return false;
}

function nextDo() {
  thispicture++;
  if (thispicture == mypictures.length) {
    thispicture = 0;
  }
  document.getElementById("myPic").src = mypictures[thispicture];
  return false;
}

function huhDo() {
  thispicture = Math.floor(Math.random()*mypictures.length + 0)
  document.getElementById("myPic").src = mypictures[thispicture];
  return false;
}

function biggerDo() {
  window.open(document.getElementById("myPic").src, '_blank');
}


//]]>
</script>
</head>
<body onload="initA();" id="myBody">
  <div id="myDiv" align="center">
  <table id="myTable"><tr>
  <td><a href="#" id="huhA" title="Random image" onclick="huhDo();">??</a></td>
  <td><a href="#" id="prevA" title="Previous image" onclick="prevDo();">&lt;&lt;</a></td><td>
<?php
  echo '<img onclick="biggerDo();" title="' . $_GET['hovertext'] . ' Click for bigger view on separate tab or window." src="' . $homeurl . $_GET['subdir'] . '/' . $homeimage . '" width="500" id="myPic" alt="' . $_GET['subject'] . ' Slideshow" />' . "\n";
  echo '</td><td><a href="#" id="nextA" title="Next image" onclick="nextDo();">&gt;&gt;</a></td>' . "\n";
  echo '<td><a target=_blank href="' . $homeurl . $_GET['subdir'] . '/" title="One Image Page Website" id="goA">++</a></td>' . "\n";
?>
  </tr></table>
  </div>
</body>
</html>

