// JavaScript Document

var CAnswer=new Array(0,4,3,3,4,1,2,4,3,1,3);
var PAnswer=new Array(0,0,0,0,0,0,0,0,0,0,0);
var Text="";
var score=0;

function SubmitA(Qn,Ans) {
    PAnswer[Qn]=Ans;
}
function CheckAns() {
    for (i=1; i <= 10; i++) {
        if (PAnswer[i] == 0) {
            Text=Text + "Your did not answer question " + i + "\n";
        }
    }
    if (Text == "") {
        display();
    } else {
        Text=Text + "\nDo you still want to continue!";
        var CF=confirm(Text);
        if (CF == true) {
            display();
        }
        Text="";
    }
}

function display() {
    Text="Quiz Answers\n";

    for (i=1; i <= 10; i++) {
        Text=Text + "Question " + i + ": ";
        if (PAnswer[i] == CAnswer[i]) {
            score=score + 1;
            Text=Text + "Correct\n";
        } else if (PAnswer[i] != 0) {
            Text=Text + "Wrong\n";
        } else {
            Text=Text + "Not Answered\n";
        }
    }
    Text=Text + "\nYour score: " + score + "\n\nComments: ";
    switch (score) {
        case 0 :
            Text=Text + "Have you been through the site yet?";
            break;
        case 1 :
            Text=Text + "Have you been through the site yet?";
            break;
        case 2 :
            Text=Text + "Have you been through the site yet?";
            break;
        case 3 :
            Text=Text + "Try a little harder...";
            break;
        case 4 :
            Text=Text + "Try a little harder...";
            break;
        case 5 :
            Text=Text + "A little harder... and you there!";
            break;
        case 6 :
            Text=Text + "A little harder... and you there!";
            break;
        case 7 :
            Text=Text + "Good going! A bit more and you should be sufficiently well equipped to do your part!";
            break;
        case 8 :
            Text=Text + "Good going! A bit more and you should be sufficiently well equipped to do your part!";
            break;
        case 9 :
            Text=Text + "Wow! you've learnt a lot, please put what you have learnt in action to help curb environmental degradation!";
            break;
        case 10 :
            Text=Text + "Wow! you've learnt a lot, please put what you have learnt in action to help curb environmental degradation!";
            break;


    }
    alert(Text);
    Reset();
}
function Reset() {
    PAnswer=new Array(0,0,0,0,0,0,0,0,0,0,0);
    Text="";
    score=0;
}
