
//HIDE AND SHOW
function HideContent(dd) {
if(dd.length < 1) { return; }
document.getElementById(dd).style.display = "none";}
function ShowContent(dd) {
if(dd.length < 1) { return; }
document.getElementById(dd).style.display = "block";}
function ReverseContentDisplay(dd) {
if(dd.length < 1) { return; }
if(document.getElementById(dd).style.display == "none") {document.getElementById(dd).style.display = "block"; }
else {document.getElementById(dd).style.display = "none"; }}


var image_directory = "http://www.coopermarketing.com/simon/";
var ok = false; 
var pcbusy = false; 
var userturn = true;
var butdown = false;
var stage = 1;
var cnt = 1;
var pcclicks = new Array();
var userclicks = new Array();
var pos;
var tst = true;
var msg = "Click Go!";
btn1 = new Image();
btn1.src = image_directory + "resting.gif";
btn2 = new Image();
btn2.src = image_directory + "chosen.gif";
function updown(isdn) {
if (isdn) {
document.f[('pl'+pos)].src = image_directory + 'chosen.gif';
}
else {
document.f[('pl'+pos)].src= image_directory + 'resting.gif';
   }
}
function dopc() {
document.f.st.value = stage;
if (cnt <= stage) {
pcbusy = true;
userturn = false;
document.f.s.value = "The Hen's Turn";
HideContent('pickarps');
setTimeout("pos=Math.floor((Math.random()*8)+1); updown(true)",500);
setTimeout("updown(false) ; pcclicks[cnt]=pos; cnt++; dopc()",1200);
}
else {
userclicks = new Array();
cnt = 1;
document.f.s.value = "Your Turn";
pcbusy = false;
userturn = true;
document.f.b.focus();
   }
}
function testclicks() {
tst = true;
for(i = 1;cnt > i; i++) {
if (pcclicks[i] == userclicks[i]) {
tst = true && tst;
}
else {
tst = false && tst;
   }
}
if(tst) {
setTimeout("stage++ ; document.f.st.value=stage ; msg='That is correct!';ShowContent('pickarps');document.f.b.value='Continue';document.f.s.value=msg ; document.f.b.focus()",300);

if (stage==5) {setTimeout("stage=1 ; cnt=1 ; pcclicks=new Array() ; document.f.st.value=stage ; msg='You Won!';ShowContent('pickarps');document.f.b.value='START'; document.f.s.value=msg",300);}
}
else {
setTimeout("stage=1 ; cnt=1 ; pcclicks=new Array() ; document.f.st.value=stage ; msg='Oops! Play Again?';document.f.s.value=msg",300);ShowContent('pickarps');document.f.b.value='START';
}
cnt = 1;
}
function testclk(downflag, pos) {
if (userturn&&(!pcbusy)) {
if (downflag) {
document.f[('pl'+pos)].src = image_directory + 'chosen.gif';
}else{
document.f[('pl'+pos)].src = image_directory + 'resting.gif';
}
if (ok && !downflag) {
userclicks[cnt] = pos;
cnt++;
if (pcclicks.length == userclicks.length) {
testclicks();
         }
      }
   }
}



document.write('<form name="f">');
document.write('<table cellspacing=0 cellpadding=0 cols="8" width="400" border="5" bordercolor="5fd756" bordercolorlight="16b12c" bgcolor="white">');
document.write('<tr>');
document.write('<td colspan="8" bgcolor="339933">');
document.write('<img src="http://www.coopermarketing.com/simon/simon-header.jpg" width=420 height=50>');
document.write('</tr><tr>');
document.write('<td><img src="'+image_directory + 'resting.gif" name="pl1" onMousedown="testclk(true,1)" width=50 height=100 onMouseup="testclk(false,1)"></td>');
document.write('<td><img src="'+image_directory + 'resting2.gif" name="pl2" onMousedown="testclk(true,2)" width=50 height=100 onMouseup="testclk(false,2)"></td>');
document.write('<td><img src="'+image_directory + 'resting3.gif" name="pl3" onMousedown="testclk(true,3)" width=50 height=100 onMouseup="testclk(false,3)"></td>');
document.write('<td><img src="'+image_directory + 'resting3.gif" name="pl4" onMousedown="testclk(true,4)" width=50 height=100 onMouseup="testclk(false,4)"></td>');
document.write('<td><img src="'+image_directory + 'resting2.gif" name="pl5" onMousedown="testclk(true,5)" width=50 height=100 onMouseup="testclk(false,5)"></td>');
document.write('<td><img src="'+image_directory + 'resting.gif" name="pl6" onMousedown="testclk(true,6)" width=50 height=100 onMouseup="testclk(false,6)"></td>');
document.write('<td><img src="'+image_directory + 'resting2.gif" name="pl7" onMousedown="testclk(true,7)" width=50 height=100 onMouseup="testclk(false,7)"></td>');
document.write('<td><img src="'+image_directory + 'resting.gif" name="pl8" onMousedown="testclk(true,8)" width=50 height=100 onMouseup="testclk(false,8)"></td>');
document.write('</tr><tr>');
document.write('<td colspan="4" align=center bgcolor="124616">');
document.write('<font size="3" face="Arial,Helvetica" color=yellow>Level: <input type="text" size="2" value="1" name="st" readonly style="background-color: 124616; overflow: auto;border: none;font-Size = 12pt;color = yellow;font-Family=Arial,Helvetica;"></font>');
document.write('</td><td colspan="4" align=center bgcolor="124616"><input type="text"  name="s" value="Copy the Hens..." readonly style="background-color: 124616; overflow: auto;border: none;font-Size = 12pt;color = yellow;font-Family=Arial,Helvetica;">');
document.write('</td></tr><tr>');
document.write('<td align="center" colspan=8 height=50  bgcolor="339933"><div id="pickarps" style="display:block;"><input type="button" value=" START " name="b" onClick="ok=true ; if(!pcbusy) dopc()"></div></td>');
document.write('</tr></table>');
document.write('</form>');
