var Feedback = '';
var Correct = 'Correct!';
var Incorrect = 'Sorry! Try again.';
var GiveHint = 'A correct letter has been added.';
var CaseSensitive = 'False';
var YourScoreIs = 'Your score is:';
var platform = 'win';
var CurrentWord = 0;
var WinLowerString='abcdefghijklmnopqrstuvwxyz%9A%9C%E0%E1%E2%E3%E4%E5%E6%E7%E8%E9%EA%EB%EC%ED%EE%EF%F0%F1%F2%F3%F4%F5%F6%F8%F9%FA%FB%FC%FD%FE%FF';
var WinUpperString='ABCDEFGHIJKLMNOPQRSTUVWXYZ%8A%8C%C0%C1%C2%C3%C4%C5%C6%C7%C8%C9%CA%CB%CC%CD%CE%CF%D0%D1%D2%D3%D4%D5%D6%D8%D9%DA%DB%DC%DD%DE%9F';
var LowerString = '';
var UpperString = '';
WinAnswers = new Array();
AnswerList = new Array();
var IsWrong = 0;
WinAnswers[1] = 'don\'t study';
WinAnswers[2] = 'do not study';
WinAnswers[3] = 'do not study';
WinAnswers[4] = 'do not study';
WinAnswers[5] = 'will fail';
WinAnswers[6] = '\'ll fail';
WinAnswers[7] = '\'ll fail';
WinAnswers[8] = '\'ll fail';
WinAnswers[9] = 'will die';
WinAnswers[10] = '\'ll die';
WinAnswers[11] = '\'ll die';
WinAnswers[12] = '\'ll die';
WinAnswers[13] = 'don\'t get';
WinAnswers[14] = 'do not get';
WinAnswers[15] = 'do not get';
WinAnswers[16] = 'do not get';
WinAnswers[17] = 'look';
WinAnswers[18] = 'look';
WinAnswers[19] = 'look';
WinAnswers[20] = 'look';
WinAnswers[21] = 'will find';
WinAnswers[22] = '\'ll find';
WinAnswers[23] = '\'ll find';
WinAnswers[24] = '\'ll find';
WinAnswers[25] = 'is';
WinAnswers[26] = '\'s';
WinAnswers[27] = '\'s';
WinAnswers[28] = '\'s';
WinAnswers[29] = 'will break';
WinAnswers[30] = '\'ll break';
WinAnswers[31] = '\'ll break';
WinAnswers[32] = '\'ll break';
WinAnswers[33] = 'will lend';
WinAnswers[34] = '\'ll lend';
WinAnswers[35] = '\'ll lend';
WinAnswers[36] = '\'ll lend';
WinAnswers[37] = 'need';
WinAnswers[38] = 'need';
WinAnswers[39] = 'need';
WinAnswers[40] = 'need';
WinAnswers[41] = 'will rise';
WinAnswers[42] = 'will rise';
WinAnswers[43] = 'will rise';
WinAnswers[44] = 'will rise';
WinAnswers[45] = 'gets';
WinAnswers[46] = 'gets';
WinAnswers[47] = 'gets';
WinAnswers[48] = 'gets';
WinAnswers[49] = 'eat';
WinAnswers[50] = 'eat';
WinAnswers[51] = 'eat';
WinAnswers[52] = 'eat';
WinAnswers[53] = 'won\'t have';
WinAnswers[54] = 'will not have';
WinAnswers[55] = 'will not have';
WinAnswers[56] = 'will not have';
WinAnswers[57] = 'will be';
WinAnswers[58] = '\'ll be';
WinAnswers[59] = '\'ll be';
WinAnswers[60] = '\'ll be';
WinAnswers[61] = 'wear';
WinAnswers[62] = 'wear';
WinAnswers[63] = 'wear';
WinAnswers[64] = 'wear';
WinAnswers[65] = 'saves';
WinAnswers[66] = 'saves';
WinAnswers[67] = 'saves';
WinAnswers[68] = 'saves';
WinAnswers[69] = 'will be able to go';
WinAnswers[70] = '\'ll be able to go';
WinAnswers[71] = '\'ll be able to go';
WinAnswers[72] = '\'ll be able to go';
WinAnswers[73] = 'won\'t come';
WinAnswers[74] = 'will not come';
WinAnswers[75] = '\'ll not come';
WinAnswers[76] = '\'ll not come';
WinAnswers[77] = 'don\'t bring';
WinAnswers[78] = 'do not bring';
WinAnswers[79] = 'do not bring';
WinAnswers[80] = 'do not bring';
platform = 'win';
for (i = 1; i < WinAnswers.length; i++){
AnswerList[i] = unescape(WinAnswers[i]);
LowerString = unescape(WinLowerString);
UpperString = unescape(WinUpperString);
}
function ConvertCase(InString, Direction){
var FromString = '';
var ToString = '';
if (Direction == 0){
FromString = UpperString;
ToString = LowerString;
}
else{
FromString = LowerString;
ToString = UpperString;
}
var i = 0;
j = 0;
var OutString = '';
for (i=0; i
j = FromString.indexOf(InString.charAt(i));
OutString += ToString.charAt(j);
}
else{
OutString += InString.charAt(i);
}
}
return OutString;
}
function CheckAllAnswers(){
var x = 0;
var y = 0;
var AnsNum = 0;
var InString = '';
IsWrong = 0;
var Answers = new Array(4);
var Tries = Math.floor((AnswerList.length) / 4);
var NumberCorrect = 0;
var Score = 0;
for (x=0; x<(document.cloze.elements.length); x++){
InString = TrimString(document.cloze.elements[x].value);
AnsNum = (x*4) +1;
Answers[1] = AnswerList[AnsNum];
Answers[2] = AnswerList[AnsNum+1];
Answers[3] = AnswerList[AnsNum+2];
Answers[4] = AnswerList[AnsNum+3];
if (CaseSensitive == 'False') {
InString = ConvertCase(InString, 1);
for (y=1; y<5; y++) {
Answers[y] = ConvertCase(Answers[y], 1);
}
}
if ((InString == Answers[1]) || (InString == Answers[2]) ||(InString == Answers[3]) || (InString == Answers[4])) {
NumberCorrect++;
}
else {
IsWrong = 1;
document.cloze.elements[x].value = '';
}
}
Score = Math.floor((NumberCorrect*100)/Tries);
if (IsWrong == 1) {
Feedback = Incorrect;
Feedback+= '
' + YourScoreIs + ' ' + Score + '%.';
}
else {
Feedback = Correct;
Feedback+= ' ' + YourScoreIs + ' ' + Score + '%.'+ '
';
}
WriteFeedback(Feedback);
}
function TrimString(InString){
var x = 0;
if (InString.length != 0) {
while ((escape(InString.charAt(InString.length - 1)) == '%20') || (escape(InString.charAt(InString.length - 1)) == '%0A') || (escape(InString.charAt(InString.length - 1)) == '%0D')){
InString = InString.substring(0, InString.length - 1);
}
while ((escape(InString.charAt(0)) == '%20') || (escape(InString.charAt(0)) == '%0A') || (escape(InString.charAt(0)) == '%0D')){
InString = InString.substring(1, InString.length);
}
while (InString.indexOf(' ') != -1) {
x = InString.indexOf(' ');
InString = InString.substring(0, x) + InString.substring(x+1, InString.length );
}
return InString;
}
else {
return '';
}
}
function WriteFeedback(Feedback) {
var x=document.getElementById("xfeedback")
var e = window.event
getMouseXY(e)
//x.style.top="300px"
//x.style.left="100px"
//alert(mY)
x.style.left=mX+20+"px"
x.style.top=mY-25+"px"
x.style.visibility="visible"
x.innerHTML=Feedback
//Object.style.visibility=visible|hidden|collapse
//alert(Feedback);
}
function getMouseXY(e) {
var IE = document.all?true:false;
if (IE) { // grab the x-y pos.s if browser is IE
mX = document.body.scrollLeft;
mY = document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
mX = e.pageX;
mY = e.pageY;
}
}
function HideFeedback() {
document.getElementById("xfeedback").style.visibility="hidden" ;
}
function Cheat(){
CurrentAnswers = new Array(4);
CorrectBits = new Array(4);
var CurrentAnswer = FindCurrent();
if (CurrentAnswer == -1) {
return;
}
CurrentAnswers[1] = AnswerList[(CurrentAnswer * 4) + 1];
CurrentAnswers[2] = AnswerList[(CurrentAnswer * 4) + 2];
CurrentAnswers[3] = AnswerList[(CurrentAnswer * 4) + 3];
CurrentAnswers[4] = AnswerList[(CurrentAnswer * 4) + 4];
CorrectBits[1] = CheckBeginning(document.cloze.elements[CurrentAnswer].value, CurrentAnswers[1]);
CorrectBits[2] = CheckBeginning(document.cloze.elements[CurrentAnswer].value, CurrentAnswers[2]);
CorrectBits[3] = CheckBeginning(document.cloze.elements[CurrentAnswer].value, CurrentAnswers[3]);
CorrectBits[4] = CheckBeginning(document.cloze.elements[CurrentAnswer].value, CurrentAnswers[4]);
Longest = FindLongest(CorrectBits[1], CorrectBits[2], CorrectBits[3], CorrectBits[4]);
document.cloze.elements[CurrentAnswer].value = CorrectBits[Longest];
WriteFeedback(GiveHint);
}
function TrackFocus(BoxNumber){
CurrentWord = BoxNumber;
}
function CheckBeginning(Guess, Answer){
var OutString = '';
var i = 0;
var UpperGuess = '';
var UpperAnswer = '';
if (CaseSensitive == 'False') {
UpperGuess = ConvertCase(Guess, 1);
UpperAnswer = ConvertCase(Answer, 1);
}
else {
UpperGuess = Guess;
UpperAnswer = Answer;
}
while (UpperGuess.charAt(i) == UpperAnswer.charAt(i)) {
OutString += Guess.charAt(i);
i++;
}
OutString += Answer.charAt(i);
return OutString;
}
function CheckAnswer(Guess, AnsNum){
if (CaseSensitive == 'True'){
if ((Guess == AnswerList[(AnsNum * 4) + 1]) || (Guess == AnswerList[(AnsNum * 4) + 2]) || (Guess == AnswerList[(AnsNum * 4) + 3]) || (Guess == AnswerList[(AnsNum * 4) + 4])) {
return true;
}
else {
return false;
}
}
else{
Guess = ConvertCase(Guess, 1);
if ((Guess == ConvertCase(AnswerList[(AnsNum * 4) + 1], 1)) || (Guess == ConvertCase(AnswerList[(AnsNum * 4) + 2], 1)) || (Guess == ConvertCase(AnswerList[(AnsNum * 4) + 3], 1)) || (Guess == ConvertCase(AnswerList[(AnsNum * 4) + 4], 1))) {
return true;
}
else {
return false;
}
}
}
function FindCurrent() {
var FoundCurrent = -1;
var x = 0;
if (CheckAnswer(document.cloze.elements[CurrentWord].value, CurrentWord) == false) {
FoundCurrent = CurrentWord;
}
else {
x=CurrentWord + 1;
while ((FoundCurrent == -1) && (x
FoundCurrent = x;
}
x++;
}
}
if (FoundCurrent == -1){
x = 0;
while ((FoundCurrent == -1) && (x
FoundCurrent = x;
}
x++;
}
}
return FoundCurrent;
}
function FindLongest(First, Second, Third, Fourth){
var Longest = 0;
var LongString = '';
Longest = 4;
LongString = Fourth;
if (Third.length >= LongString.length){
Longest = 3;
LongString = Third;
}
if (Second.length >= LongString.length){
Longest = 2;
LongString = Second;
}
if (First.length >= LongString.length){
Longest = 1;
LongString = First;
}
return Longest;
}