var UPmessage = "enabled";
var DOWNmessage = "enabled";
var cycleStart = 0;
function nextIMG(inputMessage) {
  $('readout2').update("nextIMG:" + inputMessage) ;
  //$('read').update(cycleStart) ;
  if (UPmessage == "enabled") {
     DOWNmessage = "enabled";
     new Effect.Fade('slideshowPane', {duration: 0.5,afterFinish: swapImgUP });  
  }
}

 
function prevIMG(inputMessage) {
 $('readout2').update("prevIMG:" + inputMessage) ;
  //$('read').update(cycleStart) ;
   if (DOWNmessage == "enabled") {
     UPmessage = "enabled";
     new Effect.Fade('slideshowPane', {duration: 0.5,afterFinish: swapImgDown });  
  }
}  

function swapImgUP()  {
  $('previousButton').src= previousButtonSrc;
  $('nextButton').src= nextButtonSrc;
  if (cycleStart  > (allimages.imgs.length)) {cycleStart--}
    $('slideshowIMG').src= allimages.imgs[cycleStart+1];
    $('slideshowIMG').alt= alldescriptions.descs[cycleStart+1];
    $('imgTitle').update(alldescriptions.descs[cycleStart+1]);
    Effect.Appear('slideshowPane', {duration:.3});
    cycleStart = cycleStart+1;
    if (cycleStart  == (allimages.imgs.length-1)) {
      UPmessage = "disabled";
      $('readout2').update("swapUP:" + UPmessage) ;
      $('nextButton').src= disablednextButtonSrc;
    } else {
 UPmessage = "enabled";
 
  }
  $('readout').update("+"+cycleStart) ;
 
}
function swapImgDown()  {
  $('previousButton').src= previousButtonSrc;
  $('nextButton').src= nextButtonSrc;
  $('readout2').update("swapdown") ;
         
         if (cycleStart  == 0) {cycleStart++}
          $('slideshowIMG').src= allimages.imgs[cycleStart-1];
          $('slideshowIMG').alt= alldescriptions.descs[cycleStart-1];
          $('imgTitle').update(alldescriptions.descs[cycleStart-1]);
          Effect.Appear('slideshowPane', {duration:.3});
         
          cycleStart = cycleStart-1;
          if (cycleStart  == 0) {
           
           DOWNmessage = "disabled";
           $('readout2').update("swapDown:" + DOWNmessage) ;
           $('previousButton').src= disabledpreviousButtonSrc;
          } else {
         DOWNmessage = "enabled";
         $('previousButton').src= previousButtonSrc;
          }
          $('readout').update("-"+cycleStart) ;
   
}
 