// Preload Images
Image1 = new Image(119,302)
Image1.src = "../../gif/submenu.gif"
Image2 = new Image(119,302)
Image2.src = "../../gif/submenu1.gif"
Image3 = new Image(119,302)
Image3.src = "../../gif/submenu2.gif" 
Image4 = new Image(119,302)
Image4.src = "../../gif/submenu3.gif"
Image5 = new Image(119,302)
Image5.src = "../../gif/submenu4.gif"
Image6 = new Image(119,302)
Image6.src = "../../gif/submenu5.gif"
Image7 = new Image(119,302)
Image7.src = "../../gif/submenu6.gif" 
Image8 = new Image(119,302)
Image8.src = "../../gif/submenu7.gif"
Image9 = new Image(119,302)
Image9.src = "../../gif/submenu8.gif"
// End --->

// Add Rollover to Image Map
function original() {document.menu.src = Image1.src; return true;} 
function zoomout2() {document.menu.src = Image2.src; return true;}
function zoomout3() {document.menu.src = Image3.src; return true;}
function zoomout4() {document.menu.src = Image4.src; return true;} 
function zoomout5() {document.menu.src = Image5.src; return true;} 
function zoomout6() {document.menu.src = Image6.src; return true;}
function zoomout7() {document.menu.src = Image7.src; return true;}
function zoomout8() {document.menu.src = Image8.src; return true;} 
function zoomout9() {document.menu.src = Image9.src; return true;} 
// End --->

<!--- Open Pop Up
window.name="main";
leftPos = 0
if (screen){leftPos = screen.width-600}
var newWindow

// function describes open new window; oc = open close
function oNewWin(ocParam)
{
  if (!newWindow || newWindow.closed)
  {
    newWindow = window.open("" + ocParam, "newWin","noresize,scrollbars,nomenubar,height=495,width=420,left="+leftPos+",top=300")
    if (!newWindow.opener)
      {newWindow.opener = window}
  }
  // window's already open, bring it to the front
  else 
  {
    newWindow.location = "" + ocParam
    newWindow.focus()
  }   
}

function popup(mylink, windowname)
{
  if (! window.focus)
    return true;
  var href;
  if (typeof(mylink) == 'string')
    href=mylink;
  else
    href=mylink.href;
  window.open(href, windowname, 'width=500,height=440,scrollbars=no');
  return false;
}
  
//FUNCTION - Ask user for number of rows
function ask_rows()
{	  
  rows = prompt("Enter the number of rows:", "");
  while(rows == null || rows == "")
  {
	break; ("You must enter the number of rows.");
	rows = prompt("Enter the number of rows:", ""); 
  }			  
  return rows;
}

//FUNCTION - Ask user for number of columns
function ask_cols()
{
  cols = prompt("Enter the number of columns", "");
  while(cols == null || cols == "")
  {
	alert ("You must enter the number columns.");
	cols = prompt("Enter the number of columns:", "");
  } 	
  return cols;
}

//FUNCTION - Make a legal move  
function moveto(square)
{
  where=square.id;
  
  //Board Dimensions
  if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
  {
    score++;
    document.getElementById("scorey").innerHTML=score;
	
    document.getElementById(oldwhere).innerHTML=" ";
	document.getElementById(where).innerHTML="<img src=http://www.elogiq.com/online/knights/images/logo9.gif width=44 height=44>";
	document.getElementById(where).bgColor="#000000";

	oldwhere=where;
	squares[square.name]=true; 		 
  }				
  var total=((rows1*cols1))
  for (var i=0; i<total; i++) 
    if (squares[i]!=true) 
      var stuffed=true   
	if (stuffed!=true) 	  
    {
	  window.alert("You win in " + score + " moves!");
	  var answer = confirm("Play again?")
	  if (answer){window.location.href=window.location.href;}
    }		 
}

//FUNCTION - Make a legal move  
function moveto789(square)
{
  where=square.id;
  
  //Board Dimensions
  if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
  {
    score++;

    document.getElementById("scorey").innerHTML=score;
    document.getElementById(oldwhere).innerHTML=" ";
	document.getElementById(where).innerHTML="<img src=http://www.elogiq.com/online/knights/images/logo7.gif width=34 height=34>";
	document.getElementById(where).bgColor="#000000";
	oldwhere=where;
	squares[square.name]=true; 		 
  }				
  var total=((rows1*cols1))
  for (var i=0; i<total; i++) 
    if (squares[i]!=true) 
      var stuffed=true   
	if (stuffed!=true) 	  
    {
	  window.alert("You win in " + score + " moves!");
	  var answer = confirm("Play again?")
	  if (answer){window.location.href=window.location.href;}
    }		 
}
		
//FUNCTION - Make a legal move (10x10)
function moveto10(square)
{
  if (checkedArray[square.id] == false)
  {
    tempWhere=oldwhere;
    where=parseInt(square.id);
  
    //Board Dimensions
    if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
    {
      document.board.back.disabled=false;
      codeArray[score] = square.text;
	  codeString+=" " + codeArray[score];	
	  score++;
	
      numvar = parseInt(square.name);
	  whereArray[score] = numvar + 1;
      whereString+="-" + (whereArray[score]);

      document.getElementById("scorey").innerHTML=score;
	  document.getElementById("codey").innerHTML=codeString;
	  document.getElementById("wherey").innerHTML=whereString;
	
      document.getElementById(oldwhere).innerHTML=" ";
	  document.getElementById(where).innerHTML="<img src=http://www.elogiq.com/online/knights/images/logo10.gif width=24 height=24>";
	  document.getElementById(where).bgColor="#000000";
	
	  oldwhere=where;
	  squares[square.name]=true;
	  checkedArray[square.id] = true; 		 
    } 				
    var total=((rows1*cols1))
    for (var i=0; i<total; i++) 
      if (squares[i]!=true) 
        var stuffed=true   
	  if (stuffed!=true && oldwhere==203 && score==99) 	  
      {	
	    document.board.back.disabled=true;
	    window.alert("CONGRATULATIONS!  You have revealed the hidden text!");
	    window.alert("Please click Submit Answer to receive your free puzzle!");
	    document.board.emailUs.disabled=false;
      }
	  else if (stuffed!=true) 	  
      {
	    window.alert("Please try again to reveal the hidden text.");
      }
    }
    else
      return false;			 
}

//FUNCTION - Called when user pushes "Move Back"
function goBack()
{ 
  if(where != 252)
  {
    codeString = "1 ";
    whereString = "91";   			
    for(var i=0; i<score-1; i++)
    {
      codeString += (codeArray[i]) + " ";
      whereString += "-" + (whereArray[i+1]);
    }
    document.getElementById(oldwhere).innerHTML=" ";
    document.getElementById(oldwhere).bgColor="#99CCFF";
    document.getElementById(tempWhere).innerHTML="<img src=http://www.elogiq.com/online/knights/images/logo10.gif width=24 height=24>";
    document.getElementById(tempWhere).bgColor="#000000";

	squares[oldwhere] = false;	
	checkedArray[oldwhere] = false;
    score--;
    where=tempWhere;
    oldwhere=tempWhere;
	
    document.getElementById("scorey").innerHTML=score;
    document.getElementById("codey").innerHTML=codeString;
    document.getElementById("wherey").innerHTML=whereString;
  }	 
  document.board.back.disabled=true;
  return true;
}


//FUNCTION - Make a legal move  
function moveto11(square)
{
  where=square.id;
  
  if (square.text != "?")
    codeString+=" " + square.text;
  
  //Board Dimensions
  if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
  {
    score++;
	whereString+="-" + square.name;

    document.getElementById("scorey").innerHTML=score;
	document.getElementById("codey").innerHTML=codeString;
	document.getElementById("wherey").innerHTML=whereString;
	
    document.getElementById(oldwhere).innerHTML=" ";
	document.getElementById(where).innerHTML="<img src=http://www.elogiq.com/online/knights/images/logo10.gif width=24 height=24>";
	document.getElementById(where).bgColor="#000000";
	oldwhere=where;
	squares[square.name]=true; 		 
  }				
  var total=((rows1*cols1))
  for (var i=0; i<total; i++) 
    if (squares[i]!=true) 
      var stuffed=true   
	if (stuffed!=true && oldwhere==203 && score==99) 	  
    {
	  window.alert("CONGRATULATIONS!  You have revealed the hidden text!");
	  window.alert("Please email the hidden text and move sequence to tlee@elogiq.com to receive your prize!");
    }
	else if (stuffed!=true) 	  
    {
	  window.alert("Please try again to reveal the hidden text.");
    }	
}

//FUNCTION - Make a legal move (10x10)
function moveto12(square)
{
  where=square.id;
  document.write('<center>' + where + '</center>');
  
  if (square.text != "?")
    codeString+=" " + square.text;
  //document.write('<center>' + codeString + '</center>'); 
  
  //Board Dimensions
  if ((oldwhere==where-26 || oldwhere==where-30 || oldwhere==where-55 || oldwhere==where-57 || oldwhere-26==where || oldwhere-30==where || oldwhere-55==where || oldwhere-57==where))
  {
    score++;
	whereString+="-" + square.name;
	//document.write('<center>' + whereString + '</center>');

    document.getElementById("scorey").innerHTML=score;
	document.getElementById("codey").innerHTML=codeString;
	document.getElementById("wherey").innerHTML=whereString;
	
    document.getElementById(oldwhere).innerHTML=" ";
	document.getElementById(where).innerHTML="<img src=http://www.elogiq.com/online/knights/images/logo10.gif width=24 height=24>";
	document.getElementById(where).bgColor="#000000";
	oldwhere=where;
	squares[square.name]=true; 		 
  }				
  var total=((rows1*cols1))
  for (var i=0; i<total; i++) 
    if (squares[i]!=true) 
      var stuffed=true   
	if (stuffed!=true && oldwhere==203 && score==99) 	  
    { 
	  document.board.back.disabled=true; 
	  window.alert("CONGRATULATIONS!  You have revealed the hidden text!");
	  window.alert("Please email the hidden text and move sequence to tlee@elogiq.com to receive your prize!");
    }
	else if (stuffed!=true) 	  
    {
	  window.alert("Please try again to reveal the hidden text.");
    }			 
}

//FUNCTION - Called when user pushes "Play Again" first button
function restart()
{ 
  var restartAnswer = confirm("Play a new game?")
  if (restartAnswer)
    window.location.href=window.location.href;
  else
    return false;        
  return true;
}

//FUNCTION - Called when user pushes "New Board" second button
function newBoard()
{
  var newBoardAnswer = confirm("Choose another board size?")
  if (newBoardAnswer)
    window.location.href="http://www.elogiq.com/online/knights/";
  else
    return false;        
  return true;
}

//FUNCTION - Brings up Submit Page
function submitPage()
{ 
  window.location.href="http://www.elogiq.com/online/knights/submit.html";
}

//FUNCTION - Brings up Email Client
function playAgain()
{
  var newBoardAnswer = confirm("Play Again?")
  if (newBoardAnswer)
    window.location.href="http://www.elogiq.com/online/knights/";
  else
    return false;        
  return true;
}

//FUNCTION - Show Code  
function reveal(square)
{												
  where=square.id;			 
  //if (squares[where])
    //return true;
  //document.getElementById(where).innerHTML="code here";
}

//FUNCTION - Hide Code  
function hide(square)
{
  where=square.id;
  //document.getElementById(where).innerHTML=" ";
}

//FUNCTION - Set Code
function setCode(squarenum)
{
  if (squarenum == 90)
    code = "1";
  else if (squarenum == 82)
    code = ".";
  else if (squarenum == 94)
	code = "I";	
  else if (squarenum == 73)
    code = "n";
  else if (squarenum == 54)
	code = "&nbsp;";	
  else if (squarenum == 62)
    code = "t";
  else if (squarenum == 50)
	code = "h";	
  else if (squarenum == 71)
    code = "e";
  else if (squarenum == 92)
	code = "&nbsp;";
  else if (squarenum == 84)
    code = "b";
  else if (squarenum == 63)
	code = "e";	
  else if (squarenum == 51)
    code = "g";
  else if (squarenum == 70)
	code = "i";	
  else if (squarenum == 91)
    code = "n";
  else if (squarenum == 83)
	code = "n";	
  else if (squarenum == 64)
    code = "i";
  else if (squarenum == 52)
	code = "n";	
  else if (squarenum == 60)
    code = "g";
  else if (squarenum == 81)
	code = "&nbsp;";
  else if (squarenum == 93)
    code = "G";
  else if (squarenum == 74)
	code = "o";	
  else if (squarenum == 53)
    code = "d";
  else if (squarenum == 72)
	code = "&nbsp;";
  else if (squarenum == 80)
    code = "c";
  else if (squarenum == 61)
	code = "r";	
  else if (squarenum == 40)
    code = "e";
  else if (squarenum == 21)
	code = "a";	
  else if (squarenum == 0)
    code = "t";
  else if (squarenum == 12)
	code = "e";
  else if (squarenum == 4)
    code = "d";
  else if (squarenum == 23)
	code = "&nbsp;";	
  else if (squarenum == 44)
    code = "t";
  else if (squarenum == 32)
	code = "h";
  else if (squarenum == 20)
    code = "e";
  else if (squarenum == 1)
	code = "&nbsp;";	
  else if (squarenum == 13)
    code = "h";
  else if (squarenum == 34)
	code = "e";	
  else if (squarenum == 42)
    code = "a";
  else if (squarenum == 30)
	code = "v";
  else if (squarenum == 11)
    code = "e";
  else if (squarenum == 3)
	code = "n";	
  else if (squarenum == 24)
    code = "s";
  else if (squarenum == 43)
	code = "&nbsp;";
  else if (squarenum == 31)
    code = "a";
  else if (squarenum == 10)
	code = "n";	
  else if (squarenum == 2)
    code = "d";
  else if (squarenum == 14)
	code = "&nbsp;";	
  else if (squarenum == 22)
    code = "t";
  else if (squarenum == 41)
	code = "h";
  else if (squarenum == 33)
    code = "e";
  else if (squarenum == 45)
	code = "&nbsp;";	
  else if (squarenum == 26)
    code = "e";
  else if (squarenum == 5)
	code = "a";		  
  else if (squarenum == 17)
    code = "r";
  else if (squarenum == 9)
	code = "t";	
  else if (squarenum == 28)
    code = "h";
  else if (squarenum == 49)
	code = ".";	
  else if (squarenum == 37)
    code = "&nbsp;";
  else if (squarenum == 25)
	code = "2 ";
  else if (squarenum == 6)
    code = ".";
  else if (squarenum == 18)
	code = "A";	
  else if (squarenum == 39)
    code = "n";
  else if (squarenum == 47)
	code = "d";	
  else if (squarenum == 35)
    code = "&nbsp;";
  else if (squarenum == 16)
	code = "t";	
  else if (squarenum == 8)
    code = "h";	
  else if (squarenum == 29)
	code = "e";	
  else if (squarenum == 48)
    code = "&nbsp;";
  else if (squarenum == 36)
	code = "e";
  else if (squarenum == 15)
    code = "a";
  else if (squarenum == 7)
	code = "r";	
  else if (squarenum == 19)
    code = "t";
  else if (squarenum == 27)
	code = "h";
  else if (squarenum == 46)
    code = "&nbsp;";
  else if (squarenum == 38)
	code = "w";	
  else if (squarenum == 59)
    code = "a";
  else if (squarenum == 78)
	code = "s";	
  else if (squarenum == 99)
    code = "&nbsp;";
  else if (squarenum == 87)
	code = "w";
  else if (squarenum == 95)
    code = "i";
  else if (squarenum == 76)
	code = "t";	
  else if (squarenum == 55)
    code = "h";
  else if (squarenum == 67)
	code = "o";
  else if (squarenum == 79)
    code = "u";
  else if (squarenum == 98)
	code = "t";	
  else if (squarenum == 86)
    code = "&nbsp;";
  else if (squarenum == 65)
	code = "f";	
  else if (squarenum == 57)
    code = "o";
  else if (squarenum == 69)
	code = "r";
  else if (squarenum == 88)
    code = "m";
  else if (squarenum == 96)
	code = "&nbsp;";	
  else if (squarenum == 75)
    code = "a";
  else if (squarenum == 56)
	code = "n";
  else if (squarenum == 68)
    code = "d";
  else if (squarenum == 89)
	code = "&nbsp;";	
  else if (squarenum == 97)
    code = "v";
  else if (squarenum == 85)
	code = "o";	
  else if (squarenum == 66)
    code = "i";
  else if (squarenum == 58)
	code = "d";
  else if (squarenum == 77)
    code = ";";
  else
	code = "?";	
  return code;
    
  //1 In the beginning God created the heavens and the earth.
  //2 And the earth was without form and void;
}

//FUNCTION - Sets code for CodeString
function setCodeString()
{
  if (startName == 90)
    codeString = "1";
  else if (startName == 82)
    codeString = ".";
  else if (startName == 94)
	codeString = "I";	
  else if (startName == 73)
    codeString = "n";
  else if (startName == 54)
	codeString = "&nbsp;";	
  else if (startName == 62)
    codeString = "t";
  else if (startName == 50)
	codeString = "h";	
  else if (startName == 71)
    codeString = "e";
  else if (startName == 92)
	codeString = "&nbsp;";
  else if (startName == 84)
    codeString = "b";
  else if (startName == 63)
	codeString = "e";	
  else if (startName == 51)
    codeString = "g";
  else if (startName == 70)
	codeString = "i";	
  else if (startName == 91)
    codeString = "n";
  else if (startName == 83)
	codeString = "n";	
  else if (startName == 64)
    codeString = "i";
  else if (startName == 52)
	codeString = "n";	
  else if (startName == 60)
    codeString = "g";
  else if (startName == 81)
	codeString = "&nbsp;";
  else if (startName == 93)
    codeString = "G";
  else if (startName == 74)
	codeString = "o";	
  else if (startName == 53)
    codeString = "d";
  else if (startName == 72)
	codeString = "&nbsp;";
  else if (startName == 80)
    codeString = "c";
  else if (startName == 61)
	codeString = "r";	
  else if (startName == 40)
    codeString = "e";
  else if (startName == 21)
	codeString = "a";	
  else if (startName == 0)
    codeString = "t";
  else if (startName == 12)
	codeString = "e";
  else if (startName == 4)
    codeString = "d";
  else if (startName == 23)
	codeString = "&nbsp;";	
  else if (startName == 44)
    codeString = "t";
  else if (startName == 32)
	codeString = "h";
  else if (startName == 20)
    codeString = "e";
  else if (startName == 1)
	codeString = "&nbsp;";	
  else if (startName == 13)
    codeString = "h";
  else if (startName == 34)
	codeString = "e";	
  else if (startName == 42)
    codeString = "a";
  else if (startName == 30)
	codeString = "v";
  else if (startName == 11)
    codeString = "e";
  else if (startName == 3)
	codeString = "n";	
  else if (startName == 24)
    codeString = "s";
  else if (startName == 43)
	codeString = "&nbsp;";
  else if (startName == 31)
    codeString = "a";
  else if (startName == 10)
	codeString = "n";	
  else if (startName == 2)
    codeString = "d";
  else if (startName == 14)
	codeString = "&nbsp;";	
  else if (startName == 22)
    codeString = "t";
  else if (startName == 41)
	codeString = "h";
  else if (startName == 33)
    codeString = "e";
  else if (startName == 45)
	codeString = "&nbsp;";	
  else if (startName == 26)
    codeString = "e";
  else if (startName == 5)
	codeString = "a";		  
  else if (startName == 17)
    codeString = "r";
  else if (startName == 9)
	codeString = "t";	
  else if (startName == 28)
    codeString = "h";
  else if (startName == 49)
	codeString = ".";	
  else if (startName == 37)
    codeString = "&nbsp;";
  else if (startName == 25)
	codeString = "2 ";
  else if (startName == 6)
    codeString = ".";
  else if (startName == 18)
	codeString = "A";	
  else if (startName == 39)
    codeString = "n";
  else if (startName == 47)
	codeString = "d";	
  else if (startName == 35)
    codeString = "&nbsp;";
  else if (startName == 16)
	codeString = "t";	
  else if (startName == 8)
    codeString = "h";	
  else if (startName == 29)
	codeString = "e";	
  else if (startName == 48)
    codeString = "&nbsp;";
  else if (startName == 36)
	codeString = "e";
  else if (startName == 15)
    codeString = "a";
  else if (startName == 7)
	codeString = "r";	
  else if (startName == 19)
    codeString = "t";
  else if (startName == 27)
	codeString = "h";
  else if (startName == 46)
    codeString = "&nbsp;";
  else if (startName == 38)
	codeString = "w";	
  else if (startName == 59)
    codeString = "a";
  else if (startName == 78)
	codeString = "s";	
  else if (startName == 99)
    codeString = "&nbsp;";
  else if (startName == 87)
	codeString = "w";
  else if (startName == 95)
    codeString = "i";
  else if (startName == 76)
	codeString = "t";	
  else if (startName == 55)
    codeString = "h";
  else if (startName == 67)
	codeString = "o";
  else if (startName == 79)
    codeString = "u";
  else if (startName == 98)
	codeString = "t";	
  else if (startName == 86)
    codeString = "&nbsp;";
  else if (startName == 65)
	codeString = "f";	
  else if (startName == 57)
    codeString = "o";
  else if (startName == 69)
	codeString = "r";
  else if (startName == 88)
    codeString = "m";
  else if (startName == 96)
	codeString = "&nbsp;";	
  else if (startName == 75)
    codeString = "a";
  else if (startName == 56)
	codeString = "n";
  else if (startName == 68)
    codeString = "d";
  else if (startName == 89)
	codeString = "&nbsp;";	
  else if (startName == 97)
    codeString = "v";
  else if (startName == 85)
	codeString = "o";	
  else if (startName == 66)
    codeString = "i";
  else if (startName == 58)
	codeString = "d";
  else if (startName == 77)
    codeString = ";";
  else
	codeString = "?";	
  return codeString;  
  
  //1 In the beginning God created the heavens and the earth.
  //2 And the earth was without form and void;	  
}
//90-82-94-73-54-62-50-71-92-84-63-51-70-91-83-64-52-60-81-93-74-53-72-80-61-40-21-0-12-4-23-44-32-20-1-13-34-42-30-11-3-24-43-31-10-2-14-22-41-33-45-26-5-17-9-28-49-37-25-6-18-39-47-35-16-8-29-48-36-15-7-19-27-46-38-59-78-99-87-95-76-55-67-79-98-86-65-57-69-88-96-75-56-68-89-97-85-66-58-77
//90-71-50-31-10-2-14-6-18-39-58-79-98-86-94-82-70-51-30-11-3-15-7-19-38-59-78-99-87-95-83-91-72-80-61-40-21-0-12-4-16-8-29-48-69-88-96-84-92-73-81-60-41-20-1-13-5-17-9-28-49-68-89-97-85-93-74-62-43-22-34-26-47-66-54-75-67-46-27-35-23-42-63-55-76-57-36-24-32-53-65-77-56-37-45-64-52-44-25-33

