<!-- Begin
var point = "start";
var startcell = "";
var endcell = "";
var rows = 17;
var cols = 17;
var count = 0;
var cellvalues = new Array("B","E","D","G","E","S","E","D","A","L","B","A","L","L","E","T","E","H","Y","A","D","T","S","E","T","T","A","K","S","L","L","I","K","S","A","C","E","L","K","I","S","U","M","E","D","I","A","N","O","N","L","L","A","A","A","H","N","O","I","T","I","T","E","P","M","O","C","E","T","M","T","O","I","I","B","U","N","N","Y","H","O","P","S","S","Z","B","E","P","L","C","C","S","I","T","S","P","I","N","R","M","T","E","R","L","P","D","L","O","G","T","P","O","U","Z","E","J","U","R","R","O","S","I","S","A","L","C","H","O","W","Q","V","U","L","E","O","O","N","P","O","T","C","V","A","L","X","E","O","M","H","T","P","K","N","Z","I","D","I","E","E","Z","D","Y","C","P","S","T","U","I","I","T","E","N","R","L","S","L","T","A","E","S","P","I","R","A","L","N","A","L","E","A","P","P","D","L","T","H","M","L","L","C","S","F","G","R","B","L","W","S","E","T","A","K","S","G","I","V","P","K","L","U","I","U","P","K","R","V","K","W","N","M","K","B","E","C","I","W","A","O","O","I","C","E","S","H","O","W","C","Z","U","R","D","D","L","R","C","D","R","A","W","R","O","F","A","X","E","L","E","S","I","R","D","V","A","T","B","O","O","T","S","X","M","G","C","I","S","U","M","S","A");
var hiddenwords = "|SALCHOW|LOOP|TOEPICK|JUMPS|NICOL|GLITTER|DANCE|WALTZ|LEV|SITSPIN|CAMELSPIN|SKATER|COACH|ICESHOW|GUARDS|BLADES|MEDIA|STROKING|COMPETITION|GOLD|SPLIT|SILVER|BRONZE|CLUB|SKATECOVERS|HOP|SKILLS|SKATES|EDGES|ICE|LUTZ|BOOTS|MUSIC|DOUBLE|BALLET|TRIPLE|TESTDAY|GLIDE|BUNNYHOP|AXEL|MEDAL|FLIP|SPIRAL|FORWARD|BACKWARD|ONTARIO|LACES|";

function selectcell(cell) {
if (point == "start") {
    document.getElementById(cell).style.backgroundColor = "#ff0000";
    startcell = cell;
    point = "end";
  }
  else {
    document.getElementById(cell).style.backgroundColor = "#ff0000";
    endcell = cell;
    point = "start";
    if (startcell == endcell)
        document.getElementById(startcell).style.backgroundColor = "";
      else docheck();
}
}

function docheck() {
word = "";
startcellvars = startcell.substring(4);
var startxy = new Array();
startxy = startcellvars.split('_');
startx = startxy[0] * 1;starty = startxy[1] * 1;
endcellvars = endcell.substring(4);
endxy = endcellvars.split('_');
endx = endxy[0] * 1;endy = endxy[1] * 1;

if (startx == endx || starty == endy || (startx - endx == starty - endy) || (endx - startx == starty - endy)) {
    if (startx != endx) wordlength = startx - endx; else wordlength = starty - endy;if (wordlength < 0) wordlength = wordlength * -1;wordlength++;
    xval = startx;yval = starty;
    for (letter=0;letter<wordlength;letter++) {
      currcell = "cell" + xval + "_" + yval;
      lettervar = (xval - 1) * 17 + yval - 1;
      word+= cellvalues[lettervar];
        if (endx > startx) xval++;if (startx > endx) xval--;
        if (endy > starty) yval++;if (starty > endy) yval--;
    }

    if (hiddenwords.indexOf("|" + word + "|") > -1) {
        xval = startx;yval = starty;
        for (letter=0;letter<wordlength;letter++) {
          currcell = "cell" + xval + "_" + yval;
          document.getElementById(currcell).style.backgroundColor = "";
          document.getElementById(currcell).style.backgroundImage = "url('circle.gif')";
            if (endx > startx) xval++;if (startx > endx) xval--;
            if (endy > starty) yval++;if (starty > endy) yval--;
        }
        document.foundlistform.foundlist.value += word + "\n";
      }
      else {
        document.getElementById(startcell).style.backgroundColor = "";
        document.getElementById(endcell).style.backgroundColor = "";
        alert(word + " is not a word in our list.\nTry again.");
    }
  }
  else {
    document.getElementById(startcell).style.backgroundColor = "";
    document.getElementById(endcell).style.backgroundColor = "";
    alert("Your start and end points are not in a straight line.\nTry again.");
}
}
// End -->

