/* THIS GOES IN THE TOP OF THE FILE
<?php
$handle=opendir('./'); // Current Directory - change as appropriate
$mypics=array();
while ($file = readdir($handle)) {
  //check file type for images
  $the_type = strrchr($file, ".");
  $is_picture = eregi("jpg|gif|bmp|png",$the_type);  //adjust for other image types
  if ($file != "." and $file != ".." and $is_picture) { 
    $mypics[] = $file;
   } 
 }
closedir($handle);
sort($mypics);
?>*/
/* THIS GOES INSIDE A <SCRIPT> TAG PRIOR TO LOADING THIS FILE
<?php
//pic for starting point
$firstpic = $mypics[0];
//loop to write array for Javascript, except last element
echo("var imagearray = new Array('");
for ($i=0; $i+1 < count($mypics); $i++) { echo($mypics[$i] . "', '"); }
//write last element with different string
echo($mypics[$i] . "');\n");
?>*/
/* THIS GOES IN THE BODY WHERE THE SLIDE SHOW IS TO APPEAR
<table cellpadding="0" cellspacing="0">
<tr><td align="center"><img src="<?=$firstpic?>" alt="" name="rotate" id="rotate" /></td></tr>
</table>
 */
<!--
maximum = imagearray.length;

var rotation = (maximum - 1);  // initialize
var mydelay = 3000; // milliseconds between slides
var pause = 0; // pause flag

function chgImage() {
	if (document.images) { document.images.rotate.src = 'images/do/' + imagearray[rotation]; }
	else { document.all.rotate.src = 'images/do/' + imagearray[rotation]; }
}	

function nextImage() {
	pause = 1;
	rotation++;
	if (rotation == maximum) {rotation = 0;}
	chgImage();
}

function priorImage() {
	pause = 1;
	if (rotation == 0) {rotation = maximum;}
	rotation--;
	chgImage();
}
function rotate(){
	if (pause == 1);
	else {
	  rotation++;
	  if (rotation == maximum) rotation = 0; 
	  chgImage();
		mytimer = setTimeout("rotate()", mydelay);
	}
}

function pausePlay() {
	if (pause == 1) {
		pause = 0;
		rotate();
	}
	else pause = 1;
}

function showInit() {
	rotation++;
	if (rotation == maximum) {rotation = 0;}
	if (pause == 1);
	else {mytimer = setTimeout("rotate()", mydelay);}
}
addLoadEvent(showInit);
//-->
