<!--
function getCookie (name)
{
  var dcookie = document.cookie;
  var cname = name + "=";
  var clen = dcookie.length;
  var cbegin = 0;
  while (cbegin < clen)
  {
    var vbegin = cbegin + cname.length;
    if (dcookie.substring(cbegin, vbegin) == cname)
    {
      var vend = dcookie.indexOf (";", vbegin);
      if (vend == -1) vend = clen;
      return unescape(dcookie.substring(vbegin, vend));
    }
    cbegin = dcookie.indexOf(" ", cbegin) + 1;
    if (cbegin == 0) break;
  }
  return null;
}

function setCookie (name, value, expires)
{
  if (!expires) expires = new Date();
  document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

function delCookie (name)
{
  var expireNow = new Date();
  document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
}

var Alphabet = new initAlphaArray()
var NumOfWords = 32;
var SaveData = "";
var ImageNum = "";
var LettersSelected = "";
var RandomWord = "";
var DisplayWord = "";
var position = 0;
var word = new WordList();
var expdate = new Date();
var RandomNumber = (expdate.getSeconds())%NumOfWords;

function initAlphaArray()
{
  this.length = 26
  this[0] = "A"
  this[1] = "B"
  this[2] = "C"
  this[3] = "D"
  this[4] = "E"
  this[5] = "F"
  this[6] = "G"
  this[7] = "H"
  this[8] = "I"
  this[9] = "J"
  this[10] = "K"
  this[11] = "L"
  this[12] = "M"
  this[13] = "N"
  this[14] = "O"
  this[15] = "P"
  this[16] = "Q"
  this[17] = "R"
  this[18] = "S"
  this[19] = "T"
  this[20] = "U"
  this[21] = "V"
  this[22] = "W"
  this[23] = "X"
  this[24] = "Y"
  this[25] = "Z"
}

function WordList() 
{
    this.length = NumOfWords;
this[0] = "IDEOLOGY";
this[1] = "CONFESSION";
this[2] = "PARRHESIA";
this[3] = "CONDUCT OF CONDUCT";
this[4] = "DISCIPLINARY INSTITUTIONS";
this[5] = "HETEROTOPIA";
this[6] = "GENEALOGY";
this[7] = "GOVERNMENTALITY";
this[8] = "MEDICAL GAZE";
this[9] = "POWER/KNOWLEDGE";
this[10] = "MONARCHICAL PUNISHMENT";
this[11] = "DISCIPLINE";
this[12] = "MONITORING";
this[13] = "NORMALISATION";
this[14] = "MADNESS";
this[15] = "TIMETABLE";
this[16] = "DISCOURSE";
this[17] = "POWER";
this[18] = "DIFFERENCE";
this[19] = "EPISTEME";
this[20] = "ARCHAEOLOGY OF KNOWLEDGE";
this[21] = "PROLIFERATION OF DISCOURSES";
this[22] = "REGIME OF TRUTH";
this[23] = "DISCURSIVE FORMATION";
this[24] = "RESISTANCE";
this[25] = "PANOPTICON";
this[26] = "TECHNOLOGIES OF SELF";
this[27] = "SEXUALITIES";
this[28] = "DOCILE BODIES";
this[29] = "GREAT CONFINEMENT";
this[30] = "BIOPOLITICS";
this[31] = "REPRESSIVE HYPOTHESIS";

    
    
    }

function availableLetters(i)
{
  if (LettersSelected.charAt(i)==Alphabet[i])
    document.write('<TD ALIGN=CENTER VALIGN=CENTER WIDTH=20 HEIGHT=12>' + '<B><A HREF="javascript:LoadNextPage('+i+',\''+Alphabet[i]+'\')">'+Alphabet[i]+'</A></B></TD>');
  else
    document.write('<TD ALIGN=CENTER VALIGN=CENTER WIDTH=20 HEIGHT=12> </TD>');
}

function LoadNextPage(selected,letter)
{
  if (RandomWord.indexOf(letter) == -1)
  {
    if (ImageNum == "A") ImageNum = "B";
		else if (ImageNum =="B") ImageNum = "C";
		else if (ImageNum =="C") ImageNum = "D";
		else if (ImageNum =="D") ImageNum = "E";
		else if (ImageNum =="E") ImageNum = "F";
		else if (ImageNum =="F") ImageNum = "G";
		else if (ImageNum =="G") ImageNum = "H";
		else if (ImageNum =="H") ImageNum = "I";
		else if (ImageNum =="I") ImageNum = "J";
		else ImageNum = "A";
  }

  var j=0;
  var HoldLettersSelected = LettersSelected;
  LettersSelected = "";
  if (selected == 0)
  {
    for (j=1; j<=25; j++)
    {
      LettersSelected += HoldLettersSelected.charAt(j);
    }
    LettersSelected = "^" + LettersSelected;
  }
  else if (selected == 25)
  {
    for (j=0; j<=24; j++)
    {
      LettersSelected += HoldLettersSelected.charAt(j);
    }
    LettersSelected += "^";
  }
  else
  {
    for (j=0; j<selected; j++)
    {
      LettersSelected += HoldLettersSelected.charAt(j);
    }
    LettersSelected += "^";
    for (j=selected+1; j<=25; j++)
    {
      LettersSelected += HoldLettersSelected.charAt(j);
    }
  }
  SaveData = ImageNum + LettersSelected + RandomWord + "*";
  setCookie("_HangMan", SaveData, expdate);
  history.go(0);
}

expdate.setTime (expdate.getTime() + (1000*60*60*24*10));

if(getCookie("_HangMan") == null)
{
  ImageNum = "A";
  LettersSelected = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  RandomWord = word[RandomNumber];
  SaveData = ImageNum + LettersSelected + RandomWord + "*";
  setCookie("_HangMan", SaveData, expdate);
}

else
{
  SaveData = getCookie("_HangMan");
  ImageNum = SaveData.charAt(0);
  for (position=1; position<=26; position++)
  {
    LettersSelected += SaveData.charAt(position);
  }
  for (position=27; position<SaveData.indexOf("*"); position++)
  {
    RandomWord += SaveData.charAt(position);
  }
}

DisplayWord = "";
for (i=0; i<RandomWord.length; i++)
{
  if (RandomWord.charAt(i) == ' ')
  {
    DisplayWord += " ";
  }
  else
  {
    MatchFound = false;
    for (j=0; j<=25; j++)
    {
      if ((LettersSelected.charAt(j) == "^") && (RandomWord.charAt(i) == Alphabet[j]))
      {
        DisplayWord += RandomWord.charAt(i);
	MatchFound = true;
      }
    }
    if (!MatchFound) DisplayWord += "-";
  }
}

document.write('<TITLE>Tonys Hangman: Michel Foucault</TITLE>');
document.write('<BODY BGCOLOR="#FFFFFF"');
document.write('<CENTER><TABLE BORDER=0 BGCOLOR="#FF6666"'+' WIDTH=60% CELLSPACING=0>');
document.write('<TR><TD>');
document.write('<CENTER><FONT SIZE=6>Tonys Hangman</FONT>');
document.write('<BR><B>');
document.write('<FONT COLOR=2c448b SIZE=4>Michel Foucault</FONT>');
document.write('</B></CENTER>');
document.write('</TD></TR>');
document.write('</TABLE></CENTER><BR>');
document.write('<IMG HEIGHT=280 WIDTH=306 ALIGN=RIGHT ALT="Hangman"'+'SRC="hangman'+ImageNum+'.gif" >');
document.write('<CENTER>');

if (ImageNum == "J")
{
  document.write('<FONT COLOR=RED SIZE=4>You lose!<BR>Answer =:  "' + RandomWord + '"</FONT>');
}
else if (RandomWord == DisplayWord)
{
  document.write('<FONT COLOR=RED SIZE=8>You Win!</FONT>');
}
else
{
  document.write('<BR><FONT SIZE=4>Try to beat the rope!  You are only allowed 10 errors!</FONT>');
  document.write('<TABLE>');
  document.write('<TR>');

  for (i=0; i<13; i++) availableLetters(i);
  document.write('</TR>');
  document.write('<TR>');
  for (i=13; i<26; i++) availableLetters(i);
  document.write('</TR>');
  document.write('</TABLE>');
}

document.write('<BR>');
document.write('<BR>');
document.write('<FONT SIZE=9><TT>');
document.write(DisplayWord);
document.write('</TT></FONT>');
document.write('<FORM>');
document.write('<INPUT TYPE="button" VALUE="New Game"'+ 'ONCLICK="delCookie(\'_HangMan\');history.go(0);">');
document.write('</FORM>');
document.write('</CENTER>');
// -->

