//window globals
   var backgnd="whitesmoke"

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


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

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) {
     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">' +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
/*   openNewWindowB(topic) */
   setTimeout("slideShow()", 100)
}

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

function updateDelay(xdelayObj)
{
   delay = Math.pow(2,xdelayObj.selectedIndex)*1000
/*
   if (xdelayObj.selectedIndex > 4){
      manualDelay = true
      delay = 100000
      } */
   return
}

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

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

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

function openNewWindowB(topic) {
   openWindowB()
   writeContentsB(topic)
}

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

   var backgnd2 = "red"
function writeContentsB(topic) {
     bstr ='<HTML><HEAD><TITLE>' + topic + '</TITLE>'
     bstr +='</HEAD>'
     bstr +='<BODY bgcolor='+backgnd2+'>'
     bstr +='<TABLE ALIGN="CENTER" width="720" BORDER="0"><TR><TD ALIGN="CENTER">'
     bstr +='</TD><TD align="center" width="120">'
     bstr +='</TD></TR></TABLE>'    
     bstr +='</BODY></HTML>'
     WindowB.document.write(bstr)
}

