// global variables var T="T",F="F"; // to avoid lots of quotes var noRight=0; noWrong=0; // mouseover functions classNames from style sheet function wrong(){this.className="wrong";} function wrongOver(){this.className="wrongOver";} function right(){this.className="right";} function rightOver(){this.className="rightOver";} // this is the body onload function function init(){ var bdy=document.body; bdy.onresize=moveBox; bdy.onscroll=moveBox; box.style.visibility="visible"; moveBox(); if(document.location.search.search(/noRight *= *([0-9]*)/)>=0) noRight=parseInt("0"+RegExp.$1,10); if(document.location.search.search(/noWrong *= *([0-9]*)/)>=0) noWrong=parseInt("0"+RegExp.$1,10); boxNoRight.innerHTML=(noRight<100?" ":"")+noRight; boxNoWrong.innerHTML=(noWrong<100?" ":"")+noWrong; } // automate truth tables function makeTable(prims,comps,data){ var p=prims.length,c=comps.length,h,i,j; h=''; for(j=0;j   '+prims[j]+'   '; } h=h+''; for(j=0;j   '+comps[j]+'   '; } h=h+''; h=h+''; for(i=0;i'; for(j=0;j'+data[i][j]+''; for(j=0;j'+TFStr(data[i][p+j])+''; h=h+''; } h=h+'
'; document.write(h); } // True - False questions function doTF(me){ if(me.innerHTML=="T ") me.innerHTML="F "; else if(me.innerHTML=="F ") me.innerHTML="T "; else{ var range=document.selection.createRange(); range.expand("word"); if(range.text=="T " || range.text=="F ") me.innerHTML=" "+range.text; } if(me.innerHTML=="T " || me.innerHTML=="F "){ if(me.innerHTML==me.value+" "){ me.className='right'; if(me.score!=1 && me.score!=-1) celebrate(me.score=1); me.correct=true; }else{ me.className='wrong'; if(me.score!=1 && me.score!=-1) celebrate(me.score=-1); me.correct=false; } } } function TFStr(v){ return ' T / F '; } function TF(v){document.write(TFStr(v));} // Multiple choice questions function doMC(me){ var shown=me.children[0]; choices=me.children[1]; var source=event.srcElement; if(source.name=="help"){ alert('Click one of the choices offered. If correct, your choice will appear in black.'); }else{ while(source!=me && source.name!="alt" && source.name!="shown") source=source.parentElement; if(source.name=="alt"){ shown.innerHTML=source.innerHTML; shown.value=source.value; choices.style.display="none"; mCMOut(shown); me.correct=(shown.value=="correct"); if(me.score!=1 && me.score!=-1) celebrate(me.score=(me.correct?1:-1)); }else if(source.name=="shown"){ if(choices.style.display=="inline") choices.style.display="none"; else choices.style.display="inline"; } } } function mCMOver(my){ if(my.value=="correct") my.className='rightOver'; else my.className='wrongOver'; } function mCMOut(my){ if(my.value=="correct") my.className='right'; else my.className='wrong'; } function mCStr(text,answers,correct){ var i,h; h=''; h=h+''; h=h+text; h=h+''; h=h+' ? '; for(i=0;i'; h=h+answers[i]; h=h+'' } h=h+' >'; return h; } function mC(text,answers,correct){document.write(mCStr(text,answers,correct));} function moveBox(){ box.style.pixelLeft=document.body.scrollLeft+document.body.offsetWidth-box.style.pixelWidth-40; box.style.pixelTop=document.body.scrollTop+document.body.offsetHeight-box.style.pixelHeight-40; box.style.zIndex=-1; } function celebrate(v){ var mood; if(""+v=="1"){ noRight+=1; mood=happy; }else{ noWrong+=1; mood=sad; } mood.style.posLeft=document.body.scrollLeft+window.event.clientX-20; mood.style.posTop=document.body.scrollTop+window.event.clientY-20; if(window.event.clientY