<html>
<head>
<title>Match People Game - RJM Programming - May, 2014</title>
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>

<script type='text/javascript'>

// Thanks to Five-Minute Activities by Penny Ur and Andrew Wright p. 50
var jobdescription = ["actor","actress","architect","artist","baker","businessperson","butcher","chemist","clerk","cook","dancer","dentist","doctor","driver","factory worker","farmer","footballer","grocer","policeman","policewoman","postman","postwoman","seaman","secretary","singer","teacher","veterinarian","waiter","writer"];

var jobdescription_actor = ["actor","actress","movie","play","stage","director","theatre","method","role","emotion","mime","expression","timbre","scene","leading man","bitpart","hero"];
var jobdescription_actress = ["actress","actor","movie","play","stage","theatre","director","method","role","emotion","mime","expression","timbre","scene","leading lady","bitpart","heroine"];
var jobdescription_architect = ["architect","partnership","firm","tender","design","hardhat","vest","skyscraper","builder","approval","aesthetics","environmental","materials","house","civic","council","regulations","bylaws","land","surveyor"];
var jobdescription_artist = ["artist","installation","singer","dancer","writer","painting","sculpture","mural","musician","muse","gallery","contemporary","easel","canvas","palette"];
var jobdescription_baker = ["baker","bread","dough","oven","crust","wholemeal","sourdough","wheat","bake","shop","slice","loaf","candlestick maker","butcher"];
var jobdescription_businessperson = ["executive","business practice","salary","email","business","desk","telephone","mobile","secretary","personal assistant","meeting","suit","bank","quote","tender","deal","company","travel","business class","flight","office"];
var jobdescription_butcher = ["butcher","baker","candlestick maker","shop","cut","meat","bone","gristle","fat","lean","sausage","abattoir","tender","tenderise"];
var jobdescription_chemist = ["chemist","doctor","prescription","webster pack","toothpaste","medicine","tablets","capsules","headache","sick","rash","floss","shop"];
var jobdescription_clerk = ["clerk","bank","lawyer","paperwork","clerical","office","Echo Beach","assist","filing","reception"];
var jobdescription_cook = ["cook","chef","pastry","oven","pot","pan","griddle","kitchen","grater","salt","pepper","herbs","ingredients","recipe","cookbook","portions","bon apetit","aperitif","wine","accompaniment","short order","order","restaurant","cafe","bistro","crew"];
var jobdescription_dancer = ["dancer","artist","troupe","reggae","singer","singing","dancing","fitness","Jiffies","point","ballet","jump","expression","emotion","vibrant","leap","school","jive","waltz","foxtrot","ballroom","salsa","jazz","watusi","bossa nova","swing","tango","rumba","cha cha","samba","pasa doble"];
var jobdescription_dentist = ["dentist","nurse","oral","mouthwash","surgery","plaque","waiting room","fee","consultation","enamel","floss","toothpaste","toothache","filling","crown","root canal","wisdom teeth","jaw","gum","tooth","decay","xray","hygiene","chair","ache"];
var jobdescription_doctor = ["doctor","chemist","anaesthesia","inoculate","vaccinate","prescription","lice","symptoms","surgery","operation","diagnosis","hospital","waiting room","fee","consultation","nurse","surgeon","general practice","specialist","headache","migraine","cancer","heart attach","stroke","sick","sore","ache","pulse","blood pressure","blood"];
var jobdescription_driver = ["driver","truck","deadline","motorway","road","speed limit","tiredness","traffic","accident","maintenance","location","address","arrival","manifest","delivery docket","invoice","train","bus","omnibus","minibus","cargo","load","tare","tonnage"];
var jobdescription_factory_worker = ["factory","conditions","production line","noise","earplugs","hardhat","vest","uniform","union","team","change rooms","locker","check in","check out","tools","foreman","foreperson"];
var jobdescription_farmer = ["farmer","farm","rural","crop","yield","livestock","soil","aridity","climate","drought","irrigation","town","harvest","pickers","machinery","tractor","milking","cows","sheep","wool","abattoir","sale yard","show","town","homestead","family","production","sun","water","river","tank","generator","livestock"];
var jobdescription_footballer = ["footballer","football","ball","leather","boot","kick","handpass","pass","ruck","maul","team","injury","captain","coach","soccer","rugby","rugby league","Australian Rules","sport","jump","catch","drop","tackle","dodge","weave","goal","try","conversion","grand final","final","home and away","season","goalposts","referee","umpire","sideline","interchange","fitness","training"];
var jobdescription_grocer = ["grocer","groceries","shopping","shop","freshness","fruit","vegetables","healthy","food","cooking","price","grocery","supermarket","till","cash register","market","produce","farmer"];
var jobdescription_policeman = ["policewoman","police","traffic","ambulance","negotiation","danger","rank","station","sergeant","colleague","law","order","uniform","justice","peace","disturbance","crowd","disobedience","rally","nuisance","truancy","vagrant","arrest","fine","speeding","ticket","headquarters","police car","siren","emergency","fire","disaster","protect","fight","scuffle","riot","barricade","violence","domestic","dispute","mugging","rape","theft","criminal","truncheon","gun","firearm","partner","beat"];
var jobdescription_policewoman = ["policeman","police","traffic","ambulance","negotiation","danger","rank","station","sergeant","colleague","law","order","uniform","justice","peace","disturbance","crowd","disobedience","rally","nuisance","truancy","vagrant","arrest","fine","speeding","ticket","headquarters","police car","siren","emergency","fire","disaster","protect","fight","scuffle","riot","barricade","violence","domestic","dispute","mugging","rape","theft","criminal","truncheon","gun","firearm","partner","beat"];
var jobdescription_postman = ["postwoman","mail","sorting","shop","bicycle","run","mailbox","dogs","stamp","airmail","package","courier","van","address","street","letterbox","cheque","bill","delivery"];
var jobdescription_postwoman = ["postman","mail","sorting","shop","bicycle","run","mailbox","dogs","stamp","airmail","package","courier","van","address","street","letterbox","cheque","bill","delivery"];
var jobdescription_seaman = ["seaman","ship","cruise","captain","first mate","poop deck","deck","bilge","crew","seasick","navy","rank","mast","lookout","swell","sea","ocean","voyage","trip","cargo","hold","steamer"];
var jobdescription_secretary = ["secretary","receptionist","email","boss","office","meeting","personal assistant","assistant","company","firm","shorthand","document","word processing","spreadsheet","stationery","paperwork","filing","management","human resources","regulation","business practice","business","businessman","businessperson","computer","desk","telephone","deliveries","mobile"];
var jobdescription_singer = ["singer","dancer","artist","voice","genre","musicians","instrument","harmony","rhythm","band","group","backup","microphone","dancing","vocal","diva","tenor","bass","soprano","alto","pitch","presence","stage","venue","crowd","audience","jazz","pop","funk","hip hop","reggae","rap","crooner","baritone","opera","sales","encore","rehearsal","gig","pub"];
var jobdescription_teacher = ["teacher","tutor","student","school","endnote","reference","bibliography","essay","university","primary","secondary","headmaster","dean","vice chancellor","lecturer","professor","class","lesson","lesson plan","curriculum","test","examination","timetable","office","library","reference","media","resources","photocopy","excursion","parents","meeting","colleague","subject","degree","discipline","learning","learn","teach","communicate","impart","knowledge","expertise"];
var jobdescription_veterinarian = ["veterinarian","vet","animal","pet","symptoms","fee","anaesthesia","waiting room","fleas","livestock","sick","injury","disease","outbreak","inseminate","vaccinate","inoculate","desex","operation","surgery","hygiene","science","medicine","pills","diagnosis"];
var jobdescription_waiter = ["waiter","waitress","aperitif","beer","cocktail","restaurant","cafe","food","cooking","drinks","serving","uniform","catering","hospitality","wine","menu","specials","pour","cutlery","table","eating","drinking","chef","waitstaff","barrista"];
var jobdescription_writer = ["writer","artist","book","fiction","essay","travel","computer","typewriter","deadline","publisher","launch","script","scriptwriter","play","theatre","movie","sitcom","stageplay","screenwriter","storyboard","stage","director","producer","muse","poem","poetry","verse","prose","flow","chapter","bibliography","index","contents","reference","endnote"];

var njobdescription = jobdescription.length;
var numwords = 0;
var easnames = [];
var score = 0;
var goes = 0;

function check(bis) {
var plusbit = 0, jj, mm, oois, wealsothink = "", wedonotthink = "";
goes = goes + 1;
//alert(bis.id);
var sisvalue = document.getElementById(bis.id.replace("i_", "s_")).value;
var asis = sisvalue.split(";");
var alljobs = asis[1].split(",");
sisvalue = sisvalue.replace(asis[0] + ";", ",") + ",";
var proposedurl = "http://www.thefreedictionary.com/" + asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+");
//alert(sisvalue);
var radis = document.getElementsByName(bis.id.replace("i_", "r_"));
var radvalue = '';
for (var i = 0, length = radis.length; i < length; i++) {
if (radis[i].checked) {
radvalue = radis[i].value;
if (sisvalue.indexOf("," + radvalue + ",") != -1) {
if (sisvalue.indexOf("-2") != -1) {
plusbit = eval(plusbit + 2);
} else {
plusbit = eval(plusbit + 1);
}
for (mm=0; mm<alljobs.length; mm++) {
if (radvalue == alljobs[mm]) alljobs[mm] = '';
}
} else if (wedonotthink == "") {
wedonotthink = "We do not think the following job descriptions work with " + asis[0] + ": " + radvalue;
} else {
wedonotthink = wedonotthink + ", " + radvalue;
}
}
}

if (wedonotthink != "") wedonotthink = wedonotthink + ". ";

if (plusbit < alljobs.length) {

for (mm=0; mm<alljobs.length; mm++) {
if (alljobs[mm] != "") {
if (wealsothink == "") {
wealsothink = "We think the following job descriptions could also work with " + asis[0] + ": " + alljobs[mm];
} else {
wealsothink = wealsothink + ", " + alljobs[mm];
}
}
}
wealsothink = wealsothink + ". ";
}

score = eval(score + plusbit);
document.getElementById('score').innerHTML = "Score: " + score + " from " + goes + " goes";

if (plusbit == 0) {
var maybe = prompt(wealsothink + wedonotthink + "If you want to see a dictionary lookup press OK button.", asis[0].replace("-1", "").replace("-2", ""));
if (maybe != null) {
if (maybe.replace(" ", "+").replace(" ", "+") == asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+")) {
window.open(proposedurl, asis[0].replace("-1", "").replace("-2", "").replace(" ", "+").replace(" ", "+"), "top=20,left=20,width=800,height=600");
}
}
} else if (wedonotthink != "" || wealsothink != '') {
alert("It did not stop you scoring, but ... " + wealsothink + wedonotthink);
}

oois = document.getElementById("s_jobdescription");
oois.value = easnames[Math.floor(Math.random() * numwords) + 0];
}


function writeItOut() {
var i = 0, j = 0, k = 0, m = 0, ois, selbit = '', selbit = '', thisdiv = '', myarr = [], myword = [], answerword = [], thisrb = "", jobdescriptioncell = "<td>", advancedcell = "<td>";
var esnames = new Array(njobdescription);
var tstr = "<table style='background-color: lightblue;' border=5 cellpadding=5 cellspacing=5><tbody id='wctbody'><tr style='background-color: pink;'><th>Job Description (1 point per correct matching job description)</th></tr><tr><td>";
thisrb = "<form action='' id='f_jobdescription' name='f_jobdescription'>";
jobdescription.sort();
for (i=1; i<=njobdescription; i++) {
if ((i % 5) == 0) {
thisrb = thisrb + "<input type='checkbox' name='r_jobdescription' value='" + jobdescription[i - 1] + "'>" + jobdescription[i - 1] + "<br>";
} else {
thisrb = thisrb + "<input type='checkbox' name='r_jobdescription' value='" + jobdescription[i - 1] + "'>" + jobdescription[i - 1];
}
}
thisrb = thisrb + "</form>  <input id='i_jobdescription' type='button' onclick='check(this);' value='Check job description word associations above with word(s) below'></input>";
thisdiv = "<div id='jobdescription' style='border: 2px solid green;'>" + thisrb + "</div>";
tstr = tstr + thisdiv;
selbit = "<br><br>  <select id='s_jobdescription'></select>"
for (i=0; i<njobdescription; i++) {
esnames[i] = "jobdescription_" + jobdescription[i].replace(" ", "_");
//alert(esnames[i] + thisrb);
for (j=0; j<eval(esnames[i] + ".length"); j++) {
myarr[j] = eval(esnames[i] + "[" + j + "]");
//alert("myarr[j]=" + myarr[j] + ":" + selbit);
if (selbit.indexOf(">" + myarr[j] + "<") != -1) {
for (m=0; m<k; m++) {
if (easnames[m].indexOf(myarr[j] + ";") != -1) {
selbit = selbit.replace("'" + myarr[j] + ";", "'" + myarr[j] + ";" + jobdescription[i] + ",");
easnames[m] = easnames[m].replace(myarr[j] + ";", myarr[j] + ";" + jobdescription[i] + ",");
}
}
} else {
selbit = selbit.replace("</select>", "<option value='" + myarr[j] + ";" + jobdescription[i] + "'>" + myarr[j] + "</option></select>");
easnames[k] = myarr[j] + ";" + jobdescription[i];
k = eval(k + 1);
}

}


}
tstr = tstr.replace("</div>", selbit + "</td></div>");

numwords = k;

tstr = tstr + "</tr></tbody></table>";
//alert(tstr);
document.write(tstr);

for (j=0; j<numwords; j++) {
ois = document.getElementById("s_jobdescription");
ois.value = easnames[Math.floor(Math.random() * numwords) + 0];
}
}


function begin() {
writeItOut();
}


</script>
</head>
<body style="background-color: lightgreen;">

<h1 align='center'>Jobs Word Match Game</h1>
<h3 align='center' id='score'>Score: 0 from 0 goes</h3>
<div align='center'>
<script> begin(); </script>
</div>
</body>
</html>