arrPhotos = new Array()
arrCaptions = new Array()
arrBigW = new Array() // for blowup
arrBigH = new Array()
arrThW = new Array()  // for thumbnails
arrThH = new Array()
arrPhIndex = new Array()

var intScrollerWidth;
var intSpacerWidth=20;
var intScrollerHeight
var strScrollerBgColor=''
var intPauseBetweenImages=3000 // milliseconds
var boolFirstPass
var intCurPic

//--------------------------------------------------
//---- IE-specific
//----
function writeIEdiv() {
document.writeln('<span id="main" style="position:relative;width:'+intScrollerWidth+';height:'+intScrollerHeight+';overflow:hidden;background-color:'+strScrollerBgColor+'">')
document.writeln('<div style="position:absolute;width:'+intScrollerWidth+';height:'+intScrollerHeight+';clip:rect(0 '+intScrollerWidth+' '+intScrollerHeight+' 0);left:0;top:0">')
document.writeln('<div id="first" style="position:absolute;width:'+intScrollerWidth+';left:1;top:0;">')
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</span>')
}

function moveIE(pic) {
  if (boolFirstPass)
    boolFirstPass=false
  else {
    intCurPic=fnLegalNum(pic+1)
    first.innerHTML=arrPhotos[intCurPic]
    document.rotator.description.value=arrCaptions[intCurPic]
  }
  tim1 = setTimeout("moveIE(intCurPic)",intPauseBetweenImages)
}

function setupIEScroll(pic) {
  intCurPic=fnLegalNum(pic)
  first.innerHTML=arrPhotos[intCurPic]
  document.rotator.description.value=arrCaptions[intCurPic]
}

//--------------------------------------------------
//---- NN-specific
//----
function writeNNlayers() {
document.writeln('<ilayer id="main" width='+intScrollerWidth+'; height='+intScrollerHeight+'; bgColor="'+strScrollerBgColor+'"; visibility=hide>')
document.writeln('<layer id="first" left=1 top=0 width='+intScrollerWidth+'; visibility=hide>')
document.write(arrPhotos[1])
document.writeln('</layer>')
document.writeln('</ilayer>')
}

function moveNN(pic){
  if (boolFirstPass)
    boolFirstPass=false
  else {
    intCurPic=fnLegalNum(pic+1)
    document.main.document.first.document.write(arrPhotos[intCurPic])
    document.main.document.first.document.close()
    document.rotator.description.value=arrCaptions[intCurPic]
  }
    tim1 = setTimeout("moveNN(intCurPic)",intPauseBetweenImages)
}

function setupNNScroll(pic) {
  intCurPic=fnLegalNum(pic)
  document.main.document.first.document.write(arrPhotos[intCurPic])
  document.main.document.first.document.close()
  document.rotator.description.value=arrCaptions[intCurPic]
  document.main.visibility='show'
  document.main.document.first.visibility='show'
}

//--------------------------------------------------
//---- common
//----
function startScroll(pic) {
  intCurPic=fnLegalNum(pic)
  boolFirstPass = true
  setupScroll(intCurPic)
  if (strBrowserType=="IE")
    moveIE(intCurPic)
  else
    moveNN(intCurPic)
}

function setupScroll(pic) {
  if (strBrowserType=="IE")
    setupIEScroll(pic)
  else
    setupNNScroll(pic)
}

function doStartOverButton() {
clearAllTimeouts()
doClick(strBnSrcStem, "fwd", true)
startScroll(1)
}

function doBackButton() {
clearAllTimeouts()
setupScroll(intCurPic-1)
doClick(strBnSrcStem, "pause", true)
}

function doAutoButton() {
clearAllTimeouts()
eval("document.pause.src='"+strBnSrcStem+"pause_o.gif'")
startScroll(intCurPic+1)
}

function doPauseButton() {
clearAllTimeouts()
}

function doZoomButton() {
clearAllTimeouts()
doClick(strBnSrcStem, "pause", true)
doBlowUp(intCurPic)
}

function clearAllTimeouts() {
clearTimeout(tim1)
}

function fnLegalNum(curPic) {
var maxx=arrPhotos.length-1
return ((curPic-1+maxx)%maxx)+1
}

function doBlowUp(picNum) {
  return enlarge(fnAddZeros(arrPhIndex[picNum]),jsPhotoPath,event,"center",arrBigW[picNum],arrBigH[picNum],arrCaptions[picNum]);
}

function fnAddZeros(numstring) { // increases length of <numstring> to 3 by adding leading zeros
numstring=""+numstring
if (numstring.length==1)
  numstring = "00" + numstring
else
  if (numstring.length==2)
    numstring = "0" + numstring
return numstring
}

function fnSpaceToPlus(phrase) { // replaces all spaces with +
return phrase.replace(/\s/g,"+")
}


