<!-- StereoViewPort version 1.0  -->
<!-- Copyright (c) 2001 Monte J. Ramstad  --> 
var ie4 = (document.all);
currentL = 0;
speedfactor = 1;
rightloaded = false;
leftloaded = false;
loaded = false;
playbut = "Start";
if (ie4) {
     document.stereoform = new Object  
     document.stereoform.delay = new Object          
}
//timedelay = document.stereoform.delay.value;
timedelay = 1000*speedfactor*4;
function newdelay() {
  speedfactor = document.stereoform.speed[document.stereoform.speed.selectedIndex].value;
  timedelay = document.stereoform.delay.value*1000*speedfactor;
}
function next() {
  if (++currentL >= document.stereoform.clip.length ) currentL = 0;
  document.stereoform.clip.selectedIndex = currentL;
  pressed();
}
function previous() {
  if (--currentL < 0) currentL = document.stereoform.clip.length-1;
  document.stereoform.clip.selectedIndex = currentL;
  pressed();
}
function first() {
  currentL = 0;
  document.stereoform.clip.selectedIndex = currentL;
  pressed();
}
function last() {
  currentL = document.stereoform.clip.length-1;
  document.stereoform.clip.selectedIndex = currentL;
  pressed();
}
function StartPlay(text) {
  timedelay = document.stereoform.delay.value*1000*speedfactor;
  document.stereoform.startbutton.value = (text == "Stop") ? "Start" : "Stop";
  playbut = document.stereoform.startbutton.value;
  playclip();
}
function iscross(text) {
  document.stereoform.format.value = (text == "Cross") ? "Parallel" : "Cross";
  pressed();
}
function pressed() {
  //if (document.stereoform.startbutton.value != "Stop" ) {
  if (playbut != "Stop" ) {
    newimage();
  }
}

function newindex() {
  currentL = document.stereoform.clip.selectedIndex;
  pressed();
}
function playclip() {
 // if (document.stereoform.startbutton.value == "Stop") {
  if (playbut == "Stop") {
    if (++currentL >= document.stereoform.clip.length ) currentL = 0;
    document.stereoform.clip.selectedIndex = currentL;
    newimage();
  }
}
function loadcheckR() {
  rightloaded = true;
  loadcheck();
}
function loadcheckL() {
  leftloaded = true;
  loadcheck();
}
function loadcheck() {
  if ( ( (rightloaded) && (leftloaded)) ) {
    if (currentL != document.stereoform.clip.selectedIndex) {
      newindex();
    }
    else {
    if (playbut == "Stop" ) {
      window.setTimeout("playclip()", timedelay);
      rightloaded = false;
      leftloaded = false;
    }
    }
  }
}
function newimage() {
  currentL = document.stereoform.clip.selectedIndex;
  curValue = document.stereoform.clip[currentL].value;
  atcomma = document.stereoform.clip[currentL].value.indexOf(",",1);
  if (atcomma == -1) {
    currentR = (currentL == document.stereoform.clip.length-1) ? 0 : currentL+1;
    curImageL = document.stereoform.clip[currentL].value;
    curImageR = document.stereoform.clip[currentR].value;
  }
  else {
    curImageL = curValue.substring(0,atcomma);
    curImageR = curValue.substring(atcomma+1,curValue.length)
  }
  if (loaded) {
    if (document.stereoform.format.value.indexOf("P",0) >= 0 ) { 
      document.images.showL.src = curImageL;
      document.images.showR.src = curImageR;
    }
    else {
      document.images.showR.src = curImageL;
      document.images.showL.src = curImageR;
    }
  }
}
function howto() {
  leftpos = 120;
  toppos = 90;
  if (screen) {
    leftpos = (screen.width-400)/2;
    toppos = (screen.height-300)/2;
  }
  var helpwin = window.open('http://www.pokescope.com/howto.html','newWin','alwaysRaised=1,dependent=1,left='+leftpos+',top='+toppos+',resizable=1,scrollbars=1,width=400,height=300');

  return false;
}
function options() {
  newdelay();
  loaded = true;
  if ( currentL != document.stereoform.clip.selectedIndex)
    newimage();
}

