var shiftkeydown = false; function resetter(i) { //key = String.fromCharCode(i).toLowerCase(); key = String.fromCharCode(i); keyitem = "key_"+key; if (document.getElementById(keyitem) != null) {document.getElementById(keyitem).style.backgroundColor="";} return; } document.onkeyup = resetKeycode function resetKeycode() { for (var i=65;i<=122;i++) { resetter(i); } } document.onkeydown = checkKeycode; checkKeycode function checkKeycode(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; doKeys(keycode,String.fromCharCode(keycode)) } function doKeys(keycode,id,mode) { if (keycode == 8) //backspace { str = document.getElementById('sspstxt').innerHTML; if (str.length > 0) {document.getElementById('sspstxt').innerHTML = str.substr(0,str.length-1);} } if (keycode == 16 || keycode == 20 ) { mode = 'qwerty'; shiftkeydown = !shiftkeydown; if (document.getElementById("key_shiftkey") !=null) { if (shiftkeydown) {document.getElementById("key_shiftkey").style.backgroundColor="red"; } else {document.getElementById("key_shiftkey").style.backgroundColor="";} } } for (var i=65;i<=123;i++) { jkey = String.fromCharCode(i); //key = String.fromCharCode(keycode).toLowerCase(); key = String.fromCharCode(i); keyitem = "key_"+key; //alert (keyitem); if (document.getElementById(keyitem) != null && mode == 'qwerty') { if (shiftkeydown) {document.getElementById(keyitem).value = document.getElementById(keyitem).value.toUpperCase();} else { document.getElementById(keyitem).value = document.getElementById(keyitem).value.toLowerCase(); //document.getElementById(keyitem).value = document.getElementById(keyitem).value; } } } if (keycode > 64 && keycode < 91 || keycode > 96 && keycode < 123 ) //letters and spacebar { if (mode == 'qwerty') {key = String.fromCharCode(keycode).toLowerCase();} else {key = String.fromCharCode(keycode)}; keyitem = "key_"+key; str = document.getElementById('sspstxt').innerHTML; if (document.getElementById(keyitem) != null) { document.getElementById(keyitem).style.backgroundColor="red"; if (shiftkeydown || (id != id.toLowerCase())) {document.getElementById('sspstxt').innerHTML = document.getElementById('sspstxt').innerHTML + key.toUpperCase();} else {document.getElementById('sspstxt').innerHTML = document.getElementById('sspstxt').innerHTML + key.toLowerCase();} } } if (keycode == 32) //space { str = document.getElementById('sspstxt').innerHTML; if (str.length > 0) {document.getElementById('sspstxt').innerHTML = str+' ';} } //document.getElementById('sspstxt').focus(); } function checkanswer(val,iscorrect) {if (iscorrect==1) {alert ("correct!\nWell done!");} else {alert ("sorry, please try again!");} } /** * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ maxL=1500; var bName = navigator.appName; function taLimit(taObj,cnt) { if (taObj.value.length>=cnt) { objVal=taObj.value; if (objVal.length>maxL) objVal=objVal.substring(0,cnt); taObj.value=objVal; //return false; } return true; } function taCount(taObj,Cnt) { objCnt=createObject(Cnt); objVal=taObj.value; if (objVal.length>maxL) objVal=objVal.substring(0,maxL); taObj.value=objVal; if (objCnt) { if(bName == "Netscape"){ objCnt.textContent=maxL-objVal.length;} else{objCnt.innerText=maxL-objVal.length;} } return true; } function createObject(objId) { if (document.getElementById) return document.getElementById(objId); else if (document.layers) return eval("document." + objId); else if (document.all) return eval("document.all." + objId); else return eval("document." + objId); } function countLines(strtocount, cols) { var hard_lines = 1; var last = 0; while ( true ) { last = strtocount.indexOf("\n", last+1); hard_lines ++; if ( last == -1 ) break; } var soft_lines = Math.round(strtocount.length / (cols-1)); var hard = eval("hard_lines " + unescape("%3e") + "soft_lines;"); if ( hard ) soft_lines = hard_lines; return soft_lines; } function cleanForm() { var the_form = document.forms["engform"]; for ( var x in the_form ) { if ( ! the_form[x] ) continue; if( typeof the_form[x].rows != "number" ) continue; the_form[x].rows = countLines(the_form[x].value,the_form[x].cols) +1; } setTimeout("cleanForm();", 300); } function HideContent(d) { document.getElementById(d).style.display = "none"; } function ShowContent(d) { document.getElementById(d).style.display = "block"; } function ReverseDisplay(d) { if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; } else { document.getElementById(d).style.display = "none"; } }