<!-- Original:  Brian Gosselin (bgaudiodr@aol.com) -->
<!-- Web Site:  http://www.bgaudiodr.iwarp.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

var puzzles = new Array('puzzle_one.jpg', 'puzzle_two.jpg', 'puzzle_three.jpg', 'puzzle_one.jpg');



var pics = new Array();
for (i = 0; i <= 8; i++) {
pics[i] = new Image();
pics[i].src = 'image' + i + '.gif';
}
var map=new Array(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8);
var user = new Array();
var temparray = new Array();
var clickarray = new Array(0, 0);
var ticker, sec, min, ctr, id, oktoclick, finished;
function init() {
clearTimeout(id);
for (i = 0; i <= 15 ;i++) {
user[i] = 0;
}
ticker = 0;
min = 0;
sec = 0;
ctr = 0;
oktoclick = true;keeptrying = true;
finished = 0;
scramble();
 
for (i = 0; i <= 15; i++) {
document.f[('img'+i)].src = "image0.gif";
   }
}




function init_second() {
clearTimeout(id);
for (i = 0; i <= 15 ;i++) {
user[i] = 0;
}
ctr = 0;
oktoclick = true;
keeptrying = true;
finished = 0;
scramble();
 
for (i = 0; i <= 15; i++) {
document.f[('img'+i)].src = "image0.gif";
   }
}




function scramble() {
for (z = 0; z < 3; z++) {
for (x = 0; x <= 15; x++) {
temparray[0] = Math.floor(Math.random()*16);
temparray[1] = map[temparray[0]];
temparray[2] = map[x];
map[x] = temparray[1];
map[temparray[0]] = temparray[2];
      }
   }
}
function showimage(but) {
if (oktoclick) {
oktoclick = false; 
document.f[('img'+but)].src = 'image'+map[but]+'.gif';
if (ctr == 0) {
ctr++;
clickarray[0] = but;
oktoclick = true;
} else {
clickarray[1] = but;
ctr = 0;
setTimeout('returntoold()', 600);
      }
   }
}
function the_correct_answer0()
{
	if (keeptrying)	{
			if (document.f.correct_answer0.value == "five smooth stones")
			{	alert('right!!!! --------- now for the second puzzle!');
				mytable.background=puzzles[1];init_second();
			}
	else	{	alert('try again!');mytable.background=puzzles[0];keeptrying = false;
			}	}
		else {alert('the answer is five smooth stones; here is the next puzzle');
			mytable.background=puzzles[1];init_second();	}
}


function the_correct_answer1()

{
	if (keeptrying)	{
			if ((document.f.correct_answer1.value == "am I a dog") || (document.f.correct_answer1.value == "Am I a dog") || (document.f.correct_answer1.value == "Am I a dog?"))
			{	alert('right!!!! --------- now for the third puzzle!');
				mytable.background=puzzles[2];init_second();
			}
	else	{	alert('try again!');mytable.background=puzzles[1];keeptrying = false;
			}	}
		else {alert('the answer is am I a dog; here is the next puzzle');
			mytable.background=puzzles[2];init_second();	}
}


function the_correct_answer2()
{	if (keeptrying)	{

if ((document.f.correct_answer2.value == "Israelite Camp") || (document.f.correct_answer2.value == "israelite camp") || (document.f.correct_answer2.value == "Israelite camp"))

{	alert('right!!!! ');
							}
	else	{	alert('try again!');mytable.background=puzzles[2];keeptrying = false;
			}	}
		else {alert('the answer is Israelite camp!');
				}
}




function returntoold() {

if ((clickarray[0] == clickarray[1]) && (!user[clickarray[0]])) {
document.f[('img'+clickarray[0])].src = "image0.gif";
oktoclick = true;
} else {
if (map[clickarray[0]] != map[clickarray[1]]) {
if (user[clickarray[0]] == 0) {
document.f[('img'+clickarray[0])].src = "image0.gif";
}
if (user[clickarray[1]] == 0) {
document.f[('img'+clickarray[1])].src = "image0.gif";
   }
}
if (map[clickarray[0]] == map[clickarray[1]]) {
if (user[clickarray[0]] == 0&&user[clickarray[1]] == 0) { finished++;document.f[('img'+clickarray[1])].src = "trans.gif";document.f[('img'+clickarray[0])].src = "trans.gif";
 }
user[clickarray[0]] = 1;
user[clickarray[1]] = 1;
}
 if (finished >= 8) {
  
 } else {
oktoclick = true;
      }

  }




}
//  End -->
