myPix = new Array("images/ganz01.jpg","images/ganz02.jpg","images/ganz03.jpg","images/ganz04.jpg","images/ganz05.jpg","images/ganz06.jpg","images/ganz07.jpg","images/ganz08.jpg","images/ganz09.jpg","images/ganz10.jpg","images/ganz11.jpg","images/ganz12.jpg","images/ganz13.jpg","images/ganz14.jpg","images/ganz15.jpg","images/ganz16.jpg","images/ganz17.jpg","images/ganz18.jpg","images/ganz19.jpg","images/ganz20.jpg")
imgCt = myPix.length
randomNum = Math.floor ((Math.random() * imgCt))
randomNum2 = Math.floor ((Math.random() * imgCt))
while (randomNum2 == randomNum)
{
   randomNum2 = Math.floor ((Math.random() * imgCt))
}
randomNum3 = Math.floor ((Math.random() * imgCt))
while ((randomNum3 == randomNum2) || (randomNum3 == randomNum))
{
   randomNum3 = Math.floor ((Math.random() * imgCt))
}
randomNum4 = Math.floor ((Math.random() * imgCt))
while ((randomNum4 == randomNum3) || (randomNum4 == randomNum2) || (randomNum4 == randomNum))
{
   randomNum4 = Math.floor ((Math.random() * imgCt))
}

function startGanz()
{
   alert("You have started the ganzfeld test. Press the End Percieving button whenever you are ready.")
}

function stopGanz()
{
   if (document.images)
   {
      document.ganz1.src = myPix[randomNum]
      document.ganz2.src = myPix[randomNum2]
      document.ganz3.src = myPix[randomNum3]
      document.ganz4.src = myPix[randomNum4]
   }
}

function displayTarget(guess)
{
   possTargets = new Array(randomNum,randomNum2,randomNum3,randomNum4)
   count = possTargets.length
   randomTar = Math.floor ((Math.random() * count))
   index = possTargets[randomTar]
   if (document.images)
   {
      document.myPicture.src = myPix[index]
   }
   message = "Sorry, but that was an incorrect guess."
   if (guess == randomTar)
   {
      message = "You guessed correctly!"
   }
   setTimeout("results(message)",1*1000)
}

function results(message)
{
   if (confirm(message + " Would you like to play again?"))
   {
      window.location="onlineganzfeld.html"
   }
}
