// Philosophical Hangman

 var visit = '01';
 var incvisit = '01';
 var linkstr = '';
 var VerbleibendeVersuche = 10;
 var VersuchNr = 1;
 var Suchwort = '';
 var charPlayed = '';
 var ergstring = '';
 var FehlVersuche = 0;
 var i = 0;
 var b = false;
 var j = 0

function getCookieVal (offset)
 {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
 endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
 }

function GetCookie (name)
 {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen)
 {
 var j = i + alen;
 if (document.cookie.substring(i, j) == arg)
          return getCookieVal (j);
 i = document.cookie.indexOf(" ", i) + 1;
 if (i == 0)
      break;
 }
 return null;
 }

function SetCookie (name, value)
 {
 var argv = SetCookie.arguments;
 var argc = SetCookie.arguments.length;
 var expires = (2 < argc) ? argv[2] : null;
 var path = (3 < argc) ? argv[3] : null;
 var domain = (4 < argc) ? argv[4] : null;
 var secure = (5 < argc) ? argv[5] : false;
 document.cookie = name + "=" + escape (value) +
 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
 ((path == null) ? "" : ("; path=" + path)) +
 ((domain == null) ? "" : ("; domain=" + domain)) +
      ((secure == true) ? "; secure" : "");
 }

function ResetCounts()
 {
 var expdate = new Date();
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
 // Verfallszeit: 365 Tage
 visit = '01';
 SetCookie("philoshangman", visit, expdate , "/", null, false);
 history.go(0);
 }

function SetCounts(zahl)
 {
 var expdate = new Date();
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
 visit = zahl;
 SetCookie("philoshangman", visit, expdate , "/", null, false);
 history.go(0);
 }

function doHelp()
 {
 window.open("TEST 1","");
 }

function IsInString (buchstabe, str)
 {
 b = false;
 j = 0
 while (j < str.length)
 {
 if (buchstabe.substring(0,1) == str.substring(j,j+1))
 {
 b = true
 }
 j++;
 }
 return b
 }

 function playChar(buchstabe)
 {
 var expdate = new Date();
 // Verfallstag 1 Tag
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 1));
 
 if (VerbleibendeVersuche == 0)
 {
 SetCookie("philoshangman", incvisit, expdate , "/", null, false);
 }
 else
 {
 if (IsInString(buchstabe.substring(0,1),charPlayed) == false)
 {
 charPlayed = charPlayed + buchstabe;
       }
 SetCookie("philoshangman", visit + charPlayed, expdate , "/", null, false);
 }
 // test
if ((navigator.userAgent.indexOf('Mozilla') == -1) ||
   (navigator.userAgent.indexOf('compatible') != -1))
  {
    history.go(0);
  }
 }

function gibTaste(buchstabe)
 {
 if (IsInString(buchstabe,charPlayed) == true)
 {
  document.write('<img src="gif/empttast.gif" width=18 height=18 vspace=0 hspace=0 border=0>');
 }
 else
 {
 document.write('<a href="galgen.htm" onClick="playChar(\''+buchstabe+'\');" onMouseOver="parent.self.status=\'\';return true" onMouseOut="parent.self.status=\'\';return true">'
 +'<img src="gif/'+buchstabe.toLowerCase()+'.gif" width=18 height=18 vspace=0 hspace=0 border=0></a>');

  }
 }
 
function makeSpiel ()
 {
 var expdate = new Date();
 // Verfallszeit 365 Tage
 expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
 if(!(visit = GetCookie("philoshangman")))
 {
 visit = '01';
 }
 
 var expdate = new Date();
 
 charPlayed = visit.substring(2,visit.length);
 visit = visit.substring(0,2);
 VersuchNr = charPlayed.length + 1;

if (visit == '01')
 {
 Suchwort = 'LEIBNIZ';
 incvisit = '02';
 linkstr = 'http://www.philosophenlexikon.de/leibniz.htm';
 }

if (visit == '02')
 {
 Suchwort = 'ETHIK';
 incvisit = '03';
 linkstr = 'http://www.phillex.de/ethik.htm';
 }
 
if (visit == '03')
 {
 Suchwort = 'PLATON';
 incvisit = '04';
 linkstr = 'http://www.philosophenlexikon.de/platon.htm';
 }
 
if (visit == '04')
 {
 Suchwort = 'SOKRATES';
 incvisit = '05';
 linkstr = 'http://www.philosophenlexikon.de/sokrates.htm';
 }
 
if (visit == '05')
 {
 Suchwort = 'KANT';
 incvisit = '06';
 linkstr = 'http://www.philosophenlexikon.de/kant.htm';
 }

if (visit == '06')
 {
 Suchwort = 'SKEPSIS';
 incvisit = '07';
 linkstr = 'http://www.phillex.de/skepsis.htm';
 }
 
if (visit == '07')
 {
 Suchwort = 'DIOGENES';
 incvisit = '08';
 linkstr = 'http://www.philosophenlexikon.de/diogen-s.htm';
 }

if (visit == '08')
 {
 Suchwort = 'PERSON';
 incvisit = '09';
 linkstr = 'http://www.phillex.de/person.htm';
 }
 
if (visit == '09')
 {
 Suchwort = 'NIETZSCHE';
 incvisit = '10';
 linkstr = 'http://www.philosophenlexikon.de/nietzsch.htm';
 }
 
if (visit == 10)
 {
 Suchwort = 'WAHRHEIT';
 incvisit = '11';
 linkstr = 'http://www.phillex.de/wahrheit.htm';
 }

if (visit == 11)
 {
 Suchwort = 'EMPIRISMUS';
 incvisit = '12';
 linkstr = 'http://www.phillex.de/empirism.htm';
 }

if (visit == 12)
 {
 Suchwort = 'DEFINITION';
 incvisit = '13';
 linkstr = 'http://www.phillex.de/def.htm';
 }

if (visit == 13)
 {
 Suchwort = 'FREGE';
 incvisit = '14';
 linkstr = 'http://www.philosophenlexikon.de/frege.htm';
 }

if (visit == 14)
 {
 Suchwort = 'ARISTOTELES';
 incvisit = '15';
 linkstr = 'http://www.philosophenlexikon.de/arist.htm';
 }

if (visit == 15)
 {
 Suchwort = 'UTILITARISMUS';
 incvisit = '16';
 linkstr = 'http://www.phillex.de/utilitar.htm';
 }

if (visit == 16)
 {
 Suchwort = 'STOA';
 incvisit = '17';
 linkstr = 'http://www.phillex.de/stoa.htm';
 }

if (visit == 17)
 {
 Suchwort = 'CICERO';
 incvisit = '18';
 linkstr = 'http://www.philosophenlexikon.de/cicero.htm';
 }

if (visit == 18)
 {
 Suchwort = 'REALISMUS';
 incvisit = '19';
 linkstr = 'http://www.phillex.de/realism.htm';
 }

if (visit == 19)
 {
 Suchwort = 'MEINONG';
 incvisit = '20';
 linkstr = 'http://www.philosophenlexikon.de/meinong.htm';
 }

if (visit == 20)
 {
 Suchwort = 'DESCARTES';
 incvisit = '01';
 linkstr = 'http://www.philosophenlexikon.de/descart.htm';
 }

 i = 0;
 ergstring = '';
 while (i < Suchwort.length)
 {
 if (IsInString(Suchwort.substring(i,i+1),charPlayed))
 {
 ergstring = ergstring + Suchwort.substring(i,i+1);
 }
 else
 {
 ergstring = ergstring + '?';
 }
 i++;
 }

 i = 0;
 FehlVersuche = 0;
 while (i < charPlayed.length)
 {
 if (IsInString(charPlayed.substring(i,i+1),Suchwort))
 {
 }
 else
 {
 FehlVersuche = FehlVersuche + 1;
 }
 i++;
 }
 
 VerbleibendeVersuche = 10 - FehlVersuche;



 document.write('<TABLE BORDER="0" width="100%" ALIGN="BOTTOM">');
 document.write('<TR>');
 document.write('<TD width="50%" valign="bottom">');
 document.write('<TABLE BORDER="0" WIDTH="100%" ALIGN="BOTTOM">');
 document.write('<TR>');

 document.write('<TD>');
 document.write('<FONT SIZE=7 COLOR="blue">'+ '<TABLE BORDER="0" align="center">');
 i = 0;
 while (i < ergstring.length)
 {
 document.write('<TD><FONT COLOR="blue" SIZE=5>'
 + ergstring.substring(i,i+1)+'</FONT></TD>');
 i++;
 }
 document.write('</table></FONT><p>');

 document.write('</TD>');
 document.write('</TR>');
 document.write('<TR>');
 document.write('<TD>');
 document.write('<FORM>');
 document.write(' <CENTER>');

 if ((0 < VerbleibendeVersuche) && (ergstring != Suchwort))

 {
 document.write('<FONT SIZE=2>');
 gibTaste('A');
 gibTaste('B');
 gibTaste('C');
 gibTaste('D');
 gibTaste('E');
 gibTaste('F');
 gibTaste('G');
 gibTaste('H');
 gibTaste('I');
 document.write('<br>');

 gibTaste('J');
 gibTaste('K');
 gibTaste('L');
 gibTaste('M');
 gibTaste('N');
 gibTaste('O');
 gibTaste('P');
 gibTaste('Q');
 gibTaste('R');
 document.write('<br>');
 
 gibTaste('S');
 gibTaste('T');
 gibTaste('U');
 gibTaste('V');
 gibTaste('W');
 gibTaste('X');
 gibTaste('Y');
 gibTaste('Z');
 document.write('</FONT>');
 document.write('<p>');
}

document.write('<INPUT TYPE="button" VALUE=" Neues Wort " onClick="SetCounts(incvisit)">');
document.write('</CENTER>');
document.write('<p>');

 if (VerbleibendeVersuche == 0)
 {
 document.write('<FONT SIZE=5>' 
 + 'Schade! Die L&ouml;sung war: <a href=\"'+linkstr+'\">'
 +Suchwort+'</a></FONT><br>');
 }
 else
 {
 if (ergstring == Suchwort)
 {
 VerbleibendeVersuche = 0;
 document.write('<FONT SIZE=5>'
 + 'Mein Gl&uuml;ckwunsch! Besuchen Sie meine <a href=\"'+linkstr+'\">' 
  +Suchwort+'-Seite</a></FONT><br>');
 }
 }
 
 document.write('<P></FORM>');
 document.write('</TD>');
 document.write('</TR>');
 document.write('</TABLE>');
 document.write('</TD>');
 document.write('<TD width="50%" valign="top">');
 document.write('<img src="gif/hangm'+FehlVersuche+'.gif">');
 document.write('</TD>');
 document.write('</TR>');
 document.write('</TABLE>');

 }

makeSpiel();
