//window globals
   var backgnd="ivory"

   var doneThis = 0
   var picrun = false
   var delaymax = 16000
   var delaymin = 500
   var delay = 8000
   var icdelay = 4000


function openNewWindow(topic,filename,caption,num) {
   openWindow()
   writeContents(topic,filename,caption,num)
}

function openWindow() {
   var windowFeatures = 'toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes'
   aWindow = window.open('','',windowFeatures)
}

function writeContents(topic,filename,caption,num) {
     astr ='<HTML><HEAD><TITLE>' + topic + '</TITLE>'
     astr +='</HEAD>'
     astr +='<BODY bgcolor='+backgnd+'>'
     astr +='<TABLE ALIGN="CENTER" width="725" BORDER="0"><TR><TD ALIGN="CENTER" width="605" height="520" valign="middle">'
     astr +='<IMG name="slide" SRC='+filename+'><BR>'
     astr += '<FONT color="black" FACE="ARIAL">' +num+ '.&nbsp&nbsp ' +caption +  '</font><BR>'
     astr +='</TD><TD align="center" width="120"><FORM name="picform">'
     astr +='<INPUT TYPE="button" NAME="closeslide" VALUE="Close"  onclick="self.close()">'
     astr +='</FORM>'
     astr +='</TD></TR></TABLE>'    
     astr +='</BODY></HTML>'
     aWindow.document.write(astr)
}

//----------------------------



function startSlideShow()
{
   picrun = false
   doneThis = firstpic
   setTimeout("slideShow()", 100)
}

function slideShow()
{
   picx = picImg[doneThis].src
   caption = capImg[doneThis]
   num = doneThis + 1
   if(picrun == true){aWindow.document.close();writeContents(topic,picx,caption,num)}
   else{openNewWindow(topic,picx,caption,num)}
   picrun = true
   doneThis++
   if(doneThis <= lastpic){setTimeout("slideShow()", delay)}
   return
}

function updateDelay(xdelayObj)
{
   delay = Math.pow(2,xdelayObj.selectedIndex)*1000
   return
}

function newSlide(jnx)
{
   inx = jnx-1
   picx = picImg[inx].src
   caption = capImg[inx]
   openNewWindow(topic,picx,caption,jnx)
   picrun = true
   return
}

function nextSlide()
{
   if(doneThis < lastpic) {
      doneThis++
      newSlide(doneThis)
      }
   return
}

function backSlide()
{
   if(doneThis > firstpic) {
      doneThis++
      newSlide()
      }
   return
}


