<!doctype html>
<html>
<head>
<title>Golden Ratio Game - RJM Programming - January, 2017</title>
<script type='text/javascript'>

var dcone=-1, score=0, goes=0, altgratis=0.0, gratis=1.6180339887, oneside=0, ming=eval(eval(gratis * 1000.0) - 200.0), max=eval(eval(gratis * 1000.0) + 200.0), which=Math.floor(Math.random() * 3), loss=Math.floor(Math.random() * 2), bcols=["green","blue","aqua","olive","magenta","cyan","yellow","red","brown","purple","orange"];

function choosethings() {
var ions, jons, onetwothree=["","",""],colis=["","",""];
which=Math.floor(Math.random() * 3);
document.getElementById('mytbody').innerHTML="<tr id='row1'><td id='cell_1_1'></td><td id='cell_1_2'></td><td id='cell_1_3'></td></tr><tr id='row2'><td id='cell_2_1'></td><td id='cell_2_2'></td><td id='cell_2_3'></td></tr><tr id='row3'><td id='cell_3_1'></td><td id='cell_3_2'></td><td id='cell_3_3'></td></tr>";

onetwothree[0]="cell_" + eval(Math.floor(Math.random() * 3) + 1) + "_" + eval(Math.floor(Math.random() * 3) + 1);
colis[0]=bcols[Math.floor(Math.random() * bcols.length)];
for (ions=1; ions<=2; ions++) {
onetwothree[ions]=onetwothree[0];
while (onetwothree[ions] == onetwothree[0] || onetwothree[ions] == onetwothree[eval(-1 + ions)]) {
onetwothree[ions]="cell_" + eval(Math.floor(Math.random() * 3) + 1) + "_" + eval(Math.floor(Math.random() * 3) + 1);
colis[ions]=bcols[Math.floor(Math.random() * bcols.length)];
}
}


oneside=eval(Math.floor(Math.random() * 200.0) + 200.0);
if (loss == 0) {
document.getElementById(onetwothree[which]).innerHTML="<div style='height:" + oneside + "px;width:" + eval(oneside / gratis) + "px;border:1px solid black;background-color:" + colis[which] + ";'>" + eval(1 + which) + "</div>";
} else {
document.getElementById(onetwothree[which]).innerHTML="<div style='height:" + oneside + "px;width:" + eval(oneside * gratis) + "px;border:1px solid black;background-color:" + colis[which] + ";'>" + eval(1 + which) + "</div>";
}

for (ions=0; ions<3; ions++) {
if (ions != which) {
loss=Math.floor(Math.random() * 2);
altgratis=gratis;
while (Math.abs(altgratis - gratis) < 0.09) {
altgratis=eval(eval(Math.floor(Math.random() * eval(max - ming)) + ming) / 1000.0);
if (loss == 0) {
document.getElementById(onetwothree[ions]).innerHTML="<div style='height:" + oneside + "px;width:" + eval(oneside / altgratis) + "px;border:1px solid black;background-color:" + colis[ions] + ";'>" + eval(1 + ions) + "</div>";
} else {
document.getElementById(onetwothree[ions]).innerHTML="<div style='height:" + oneside + "px;width:" + eval(oneside * altgratis) + "px;border:1px solid black;background-color:" + colis[ions] + ";'>" + eval(1 + ions) + "</div>";
}
}
}
}


}

function isit(ch) {
goes++;
if (ch == eval(1 + which)) {
score++;
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
} else {
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
var ihbits="", jhbits, tdbits=document.getElementsByTagName('td');
for (jhbits=0; jhbits<tdbits.length; jhbits++) {
ihbits+=tdbits[jhbits].innerHTML;
}
alert('No, sorry, answer was ' + eval(1 + which) + ' ... ' + ihbits);
}
choosethings();
}
</script>

</head>
<body onload=' choosethings();'>
<h1>Golden Ratio Game - RJM Programming - January, 2017</h1>
<h3 id='score'>Score: 0/0</h3>
<span id='myspan'>Which rectangle below is closest to the <a target=_blank title='Golden Ratio information from Wikipedia ... thanks' href='https://en.m.wikipedia.org/wiki/Golden_ratio'>Golden Ratio</a>? <input type=button id=b1 value='1' onclick='isit(1);'></input>&nbsp;&nbsp;<input type=button id=b1 value='2' onclick='isit(2);'></input>&nbsp;&nbsp;<input type=button id=b1 value='3' onclick='isit(3);'></input></span>
<br><br>
<table id='mytable'><tbody id='mytbody'>
<tr id='row1'><td id='cell_1_1'></td><td id='cell_1_2'></td><td id='cell_1_3'></td></tr>
<tr id='row2'><td id='cell_2_1'></td><td id='cell_2_2'></td><td id='cell_2_3'></td></tr>
<tr id='row3'><td id='cell_3_1'></td><td id='cell_3_2'></td><td id='cell_3_3'></td></tr>
</tbody></table>
</html>