<HTML>
<HEAD>
<SCRIPT>
<!--
var turn = 1;  // which turn is it?
var point;      // current point
var bank=100;  // bucks




function changeText(id, str) {
    if (document.all)
        document.all[id].innerHTML = str;
    else if (document.layers) {
              document.layers[id].document.open();
              document.layers[id].document.write(str);
              document.layers[id].document.close();
      }
 }




function init()
  {
  changeText("hbank",bank);
  }
  
function go()
  {
  changeText("title","");  // clear title after first roll
// first turn: get point, check for 7 or 11 win
  if (turn==1) {
    point=document.dice.roll();
// if you want to see d1 and d2 uncomment
//    alert(document.dice.d1);
//    alert(document.dice.d2);
    if (point==7||point==11) {
       alert("Winner!");
       bank+=10;
       changeText("hbank",bank);
       changeText("hpoint",bank);
       }
    else {
      changeText("hpoint","Point is " + point); 
      turn++;
      }
    }
  else {
// subsequent roll: check for point, 7/11 loser
    var d=document.dice.roll();
    if (d==7||d==11) {
      alert("Craps!");
      turn=1;
      bank-=10;
      changeText("hbank",bank);
      changeText("hpoint","");
      }
    if (d==point) {
      alert("Winner!");
      bank+=10;
      changeText("hbank",bank);
      changeText("hpoint","");
      turn=1;
      }
    }
  }
//-->
</SCRIPT>
</HEAD>
<BODY onLoad='init();'>
<CENTER>
<h1><SPAN ID=title STYLE="position: absolute;">Play Craps... a Game of Chance</h1>
<APPLET NAME=dice code=ScriptDice.class WIDTH=125 HEIGHT=60>
<PARAM NAME="delay" VALUE=100>
<PARAM NAME="rolls" VALUE=15>
</APPLET><BR>
</CENTER>
<FORM>
<INPUT TYPE=BUTTON onClick=go() VALUE=Roll>
</FORM>
<P><SPAN ID=hpoint STYLE="position: absolute;">Press Roll to Play!</SPAN></P><BR>
<P>Bank = <SPAN ID="hbank" STYLE="position: absolute;"></SPAN></P>
<P><FONT size=1>by Al Williams for Web Techniques Magazine</font></p>
<NOSCRIPT>
<P>Warning.... you do not appear to have JavaScript enabled 
   which is required.</P>
</NOSCRIPT>
</BODY>
</HTML>