<!doctype html>
<html>
<head>
<title>Scientific Research - RJM Programming - April, 2017 ... thanks to Science Puzzles for Young Einsteins by Helene Hovanec page 71</title>
<script type='text/javascript'>

var vsnw=[0];
var which=0, score=0, goes=0;
var clue_heading="Scientist";

function Scientific_Research(name, darray) {
this.name = name;
this.clues = [darray[0].split('|')[0]];
this.answers = [darray[0].split('|')[1]];
this.numletters = eval(darray[0].split('|')[0].length - darray[0].split('|')[1].length);
}

var thedefaults = [
new Scientific_Research('Smart person',['brattain|brain']),
new Scientific_Research('Secret agent',['sperry|spy']),
new Scientific_Research('Rabbit',['harvey|hare']),
new Scientific_Research('Price',['cousteau|cost']),
new Scientific_Research('Shade of colour',['hubble|hue']),
new Scientific_Research('Swimming place',['leakey|lake']),
new Scientific_Research('Ache',['pauling|pain']),
new Scientific_Research('Face part',['chapin|chin']),
new Scientific_Research('Adult male',['marconi|man']),
new Scientific_Research('Iced or hot drink',['tesla|tea']),
new Scientific_Research('Veggie on the cob',['copernicus|corn']),
new Scientific_Research('Fib',['lister|lie']),
new Scientific_Research('Squiggly fish',['zeppelin|eel']),
new Scientific_Research('Half of twenty',['einstein|ten']),
new Scientific_Research('Measles symptom',['eratosthenes|rash']),
new Scientific_Research('Grassy area',['lawrence|lawn']),
new Scientific_Research('Car fuel',['goethals|gas'])
];

var defsel='<select style="width:50px;" id=? onchange="changed(this);"><option value="">Reject this letter</option><option value="a">a</option><option value="b">b</option><option value="c">c</option><option value="d">d</option><option value="e">e</option><option value="f">f</option><option value="g">g</option><option value="h">h</option><option value="i">i</option><option value="j">j</option><option value="k">k</option><option value="l">l</option><option value="m">m</option><option value="n">n</option><option value="o">o</option><option value="p">p</option><option value="q">q</option><option value="r">r</option><option value="s">s</option><option value="t">t</option><option value="u">u</option><option value="v">v</option><option value="w">w</option><option value="x">x</option><option value="y">y</option><option value="z">z</option></select>';

function changed(what) {
var whichrow=eval(-1 + eval(what.id.split('_')[1])), dosub=false;
var whichcol=eval(-1 + eval(what.id.split('_')[2]));
var wcol=whichcol;
var hm=what.innerHTML.split(' selecte')[1].split('>')[1].split('<')[0];
if (what.value == "") {
//alert(whichrow + ' row col ' + whichcol + ' ... ' + vsnw[0] + ' ::: ' + which);
dosub=false;
wcol=eval(thedefaults[which].clues[whichrow].length) - eval(whichcol);
//alert(thedefaults[which].answers[whichrow] + ' ' + wcol + "=" + eval(thedefaults[which].clues[whichrow].length) + " - " + eval(whichcol));
wcol=eval(document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.length) - eval(wcol);
//alert(wcol);
if (document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.length > wcol && whichcol > 0) {
if (document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.substring(wcol).indexOf(hm) != -1) {
//alert(wcol + ' ' + document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.substring(wcol) + " " + hm + ' ' + whichrow + ' row col ' + whichcol + ' ... ' + vsnw[0] + ' ::: ' + which + ' ;;; ' + thedefaults[which].answers[whichrow].length + ' --- ' + document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML + ' +++ ' + thedefaults[which].clues[whichrow] + ' === ' + thedefaults[which].answers[whichrow]);
document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML=document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.substring(0,wcol) + document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.substring(wcol).replace(hm,"");
dosub=true;
}
}
if (!dosub) document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML=document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.replace(hm,"");
what.innerHTML=what.innerHTML.replace("Reject this letter"," ");
what.value="";
what.style.display='none';
vsnw[0]--;
if (0 == (vsnw[0])) {
if (document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML == thedefaults[which].answers[whichrow]) {
goes++;
score+=5;
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
} else {
goes++;
score--;
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes;
alert('Bad luck. Answer is ' + thedefaults[which].answers[whichrow]);
}
pickobject();
vsnw[0]=thedefaults[which].numletters;
}
} else {
document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML=document.getElementById('whatisleft' + eval(1 + whichrow)).innerHTML.replace(hm,what.value);
}
}

function pickobject() {
var tdbit='',j,k;
if (document.getElementById('col1').innerHTML == "") document.getElementById('col1').innerHTML=clue_heading;
which=Math.floor(Math.random() * thedefaults.length);
document.getElementById('nameof').innerHTML=thedefaults[which].name;
vsnw[0]=thedefaults[which].numletters;
for (j=0; j<1; j++) {
tdbit='';
document.getElementById('clue' + eval(1 + j)).innerHTML=thedefaults[which].clues[j];
document.getElementById('whatisleft' + eval(1 + j)).innerHTML=thedefaults[which].clues[j];
for (k=0; k<thedefaults[which].clues[j].length; k++) {
if (thedefaults[which].clues[j].substring(k, eval(1 + k)) == " ") {
tdbit+="<select style='background-color:yellow;'><option value=' '> </option></select>";
} else {
tdbit+=defsel.replace('?', 'ans_' + eval(1 + j) + '_' + eval(1 + k)).replace(">" + thedefaults[which].clues[j].substring(k, eval(1 + k)) + "<"," selected>" + thedefaults[which].clues[j].substring(k, eval(1 + k)) + "<").replace(">" + thedefaults[which].answers[j].substring(k, eval(1 + k)) + "<"," title=' '>" + thedefaults[which].answers[j].substring(k, eval(1 + k)) + "<");
}
}
document.getElementById('answer' + eval(1 + j)).innerHTML=tdbit;
}
}

</script>
</head>
<body onload=' pickobject(); ' style='background-color:yellow;'>
<div style='width:100%; text-align:center;'>
<h1>Scientific Research</h1>
<h3>RJM Programming - March, 2017</h3>
<h4> ... thanks to Science Puzzles for Young Einsteins by Helene Hovanec</h4>

<h2>Reject letters in dropdown Scientist Name words to be words answering the clues shown.</h2>
<h3 id='score'>Score: 0/0</h3>

<table border=50 style='width:100%; text-align:center;background-color:lightgreen;'>
<tbody>
<tr><th id='col1'></th><th>Answer So Far</th><th id='nameof'></th></tr>
<tr><td id='clue1'></td><td id='whatisleft1'></td><td id='answer1'></td></tr>
</tbody>
</table>

</div>
</body>
</html>