var playspeed=5;
var this_Image = 0;
var myPlayMode = 0;
var myDirection=1;
var my_stop_flag=1;
var my_pause_flag=1;
var myTimeOut=playspeed;
var myDocs = new Array();
var max_image = 0;
var img1dest;
var img2dest;
var myTitle;
var photoDirectory = "photos";
var autoPlay=1;

function getRandomPhoto(){return (Math.round(Math.random() * (max_image - 1)))}
function OnImgLoad() {if (myPlayMode) window.setTimeout("Tick()", myTimeOut*1000);}
function Photo_Main() {
  if (document.getElementById){
       img1dest=document.getElementById("myImage");
       img2dest=document.getElementById("myDesc");
       myTitle=document.getElementById("imgTitle");
  }
  else if (document.all){
       img1dest = document.all["myImage"];  
    // img2dest=document.all["myDesc"];
      // myTitle=document.all["imgTitle"];
  }
  else if (document.layers){
         img1dest = document.layers["myImage"]; 
     //  img2dest=document.layers["myDesc"];
     //  myTitle=document.layers["imgTitle"];
  } 
  var myTimeOut=playspeed;
   img1dest.src = photoDirectory + "/" + myDocs[this_Image][0];
 // img1dest.src = myDocs[this_Image][0] + "/1.jpg";
 // img2dest.src = myDocs[this_Image][0] + "/2.jpg";
  //myTitle.innerHTML=myDocs[this_Image][1];
  if (autoPlay ==1){
  this_Image --;
  Photo_Play();
}}
function Photo_Play() {
 myPlayMode = !myPlayMode;
 myTimeOut=playspeed;
 myDirection=1;
 if (myPlayMode) {
 my_stop_flag=0;
 my_pause_flag=0;
 Photo_Next();		
 }
 else  {
 my_stop_flag=1;
 my_pause_flag=1;
}} 
function Photo_Prev() {ChangeImage(false);}
function Photo_Next() {ChangeImage(true);}
function ChangeImage(fFwd) {
 if (fFwd) {
 if (++this_Image == max_image)this_Image=0;
   img1dest.src = photoDirectory + "/" + myDocs[this_Image][0];
 // img1dest.src = myDocs[this_Image][0] + "/1.jpg";
 // img2dest.src = myDocs[this_Image][0] + "/2.jpg";
 // myTitle.innerHTML=myDocs[this_Image][1];
 }
 else {
 if (this_Image == 0)this_Image = max_image;
 this_Image--;
   img1dest.src = photoDirectory + "/" + myDocs[this_Image][0];
 // img1dest.src = myDocs[this_Image][0] + "/1.jpg";
 // img2dest.src = myDocs[this_Image][0] + "/2.jpg";
 // myTitle.innerHTML=myDocs[this_Image][1];
 }}
function Tick() {
 if (myPlayMode){
 if (myDirection)Photo_Next();
 else Photo_Prev();
}}
