var alphabet = '1234';
rett = 'All Questions Answered Correctly - Congratulations!';

function popupMsg(rett) {
  alert(rett);
}

function showQuestion(question,answer,choice1,choice2,choice3,choice4) {
    var output = '<P><font size="2"><strong>Question ' + (numberOfQuestions + 1) + ':</font></strong> ' + question + '<P>';

    for (var i = 3, j = 1; i<showQuestion.arguments.length; i++, j++) {
        output += alphabet.substring(j-1,j) + '. ';
        if (answer == j) output += '<INPUT TYPE="RADIO" NAME="q' + numberOfQuestions + '" VALUE="true">';
        else             output += '<INPUT TYPE="RADIO" NAME="q' + numberOfQuestions + '" VALUE="false">';
        output += ' ' + showQuestion.arguments[i] + '<BR>';
    }
 
    numberOfQuestions++;

    return output;
}

function validateAnswers() {
    var correct = 0, wrong = 0, blank = 0;
    for (var i=0;i<numberOfQuestions;i++) {
        var CA = eval("document.quizForm.q" + i + "[0].checked");
        var CB = eval("document.quizForm.q" + i + "[1].checked");
        var CC = eval("document.quizForm.q" + i + "[2].checked");
        var CD = eval("document.quizForm.q" + i + "[3].checked");
        var AA = eval("document.quizForm.q" + i + "[0].value");
        var AB = eval("document.quizForm.q" + i + "[1].value");
        var AC = eval("document.quizForm.q" + i + "[2].value");
        var AD = eval("document.quizForm.q" + i + "[3].value");

        if (CA == CB == CC == CD) blank++; 
        else
            if ((CA.toString() == AA) && (CB.toString() == AB) && (CC.toString() == AC) && (CD.toString() == AD))
                correct++;
            else wrong++;
    }
    document.quizForm.correct.value = correct;
    document.quizForm.wrong.value = wrong;
    document.quizForm.blank.value = blank;

    if (correct != numberOfQuestions) return false; else popupMsg(rett); return true;
}
var numberOfQuestions = 0;
var o = '<FORM NAME="quizForm" ENCTYPE="text/plain" onSubmit="return validateAnswers()">';

o += showQuestion('What is THX 1138 imprisoned for?',3,'','Assaulting a police officer','Loitering with intent to use a pedestrian crossing','Drug evasion and sexual perversion','Misuse of administration forms');
o += showQuestion('The theatre of noise is proof of our?',3,'','Policies','Capabilities','Potential','Ability');
o += showQuestion('What is SRT?',2,'','A government official','A hologram','A police robot','A priest');
o += showQuestion('SEN 5241 hands THX 1138 a contract, what does it state?',4,'','I&#39;ll give you 4 cubes of food in exchange for assistance out of here','You give me one idea that could get us out of here and I will help you','Stay out of things you don&#39;t understand, we&#39;re in this together though','You&#39;re with me; we&#39;re all in this together');
o += showQuestion('What number is on the door where THX purchases a red dendrite?',1,'','3','4','5','6');
o += showQuestion('What happened when THX was found to be suffering from severe sedation depletion whilst working?',3,'','He was fired from his job','He was given enerval','He was given a mindlock','He was sent home');
o += showQuestion('How many tablets do you see in the tray when LUH switches THX&#39;s Medication?',2,'','3','5','4','2');
o += showQuestion('Who is the first character shown at the start of the movie after the credits?',4,'','SEN 5241','LUH 3417','SRT','THX 1138');
o += showQuestion('SRT was stuck in the same what for too long?',1,'','Circuit','Chip','Semiconductor','Valve');
o += showQuestion('Where does LUH say that THX and her could escape to and live?',1,'','Superstructure','Outer regions','Underground','Substructure');
o += showQuestion('What is THX diagnosed with?',2,'','Cancer','Chemical imbalance','A mental defect','Stress');
o += showQuestion('How does THX and SEN find their way out of the white space?',4,'','CAM shows them','IMM shows them','By accident','SRT shows them');
o += showQuestion('What tablet does LUH change in the tray?',3,'','Red one','Yellow one','Green one','White one');

o += showQuestion('What happened to SEN&#39;s roommate?',1,'','Destroyed','Imprisoned','Conditioned','Moved to different section');
o += showQuestion('How many hunter portapods?',2,'','6','23','12','56');
o += showQuestion('What did the child give SEN?',3,'','ID card','Food','A inducer','A transducer');
o += showQuestion('What question is asked when someone opens a medicine cabinet?',2,'','Who are you?','What&#39;s wrong?','Can I help you?','Not well?');
o += showQuestion('What does THX do after SEN says that he has "programmed her to are 5450"',4,'','He hits SEN','He Cries','He shakes SEN&#39;s hand','He submits a violation report');
o += showQuestion('How many units of enerval are birthborns allowed?',1,'','5','22','9','10');
o += showQuestion('What happened to SRT&#39;s car?',3,'','It won&#39;t start','It hits a wall','It crashes into a post','It gets wheel clamped');
o += showQuestion('Why does the jet car THX stole cut out?',2,'','Fan belt fell off','Temperature overheat','Electrical problem','Unspecified anomaly');
o += showQuestion('Where are you not supposed to park?',4,'','Loading Areas','Causeways','Outer dispersal area','Inner dispersal area');
o += showQuestion('What is nondescript 6431399?',2,'','A rat','A shelldweller','A holdall','Unknown');
o += showQuestion('THX purchases a red dendrite, after placing it on the table what does he do with it?',3,'','Sells it','Eats it','Disposes of it','Gives it to LUH');
o += showQuestion('Where should you be if you want to talk to OMM?',1,'','A unichapel','Ommnichapel','Church','House of OMM');

o += '<center>';
o += '<P><INPUT TYPE="SUBMIT" VALUE="Click Here for Score">';
o += ' Correct: <INPUT TYPE="TEXTBOX" NAME="correct" VALUE="" SIZE="2">';
o += ' Wrong: <INPUT TYPE="TEXTBOX" NAME="wrong" VALUE="" SIZE="2">';
o += ' Blank: <INPUT TYPE="TEXTBOX" NAME="blank" VALUE="" SIZE="2" >';
o += '</center>';
o += '</FORM>';

document.write(o);
