function Question(question, correctAnswer, comment) {
    var args = Question.arguments;
    this.question = question;
    this.correctAnswer = correctAnswer;
	this.comment = comment;
    this.userAnswer = null;
    this.isCorrect = isCorrect;
    this.showForm = showForm;
    this.userChoices = new Array();
    for (var i = 0; i < args.length - 3; i++) { 
        this.userChoices[i] = args[i + 3];
    }
}

function isCorrect() {
    if (this.correctAnswer == this.userAnswer) {
        return true;
    }
    else {
        return false;
    }
}

function showForm(n) {
    document.write((n + 1) + '. ' + this.question + '<form>');
    for (var i = 0; i < this.userChoices.length; i++) {
        document.write('<input type="radio" name="q' + n + 
                       '" onclick="quiz[' + n + '].userAnswer = ' + 
                       i + '">');
        document.write(this.userChoices[i] + '<br />');
    }
    document.write('</form>');
}

// Function to correct the quiz and display score and correct answers
function correctQuiz() {
    // Initialize correct and start correctPage string
    var correct = 0;
    var correctPage ="<html><head><title>Online Interviews</title><link href='../generic/nn4.css' rel='stylesheet' type='text/css'><style type='text/css' rel='stylesheet'>@import url(../generic/main.css);</style></head>" +
                      "<body><div class='canvas'><div class= 'mainborder'><div class= 'maintitle'><h1>Online Interviews</h1></div><div class= 'main'>";

    // Loop through Question objects, call isCorrect(), and count 
    // correct answers
    for (var i = 0; i < quiz.length; i++) {
        if (quiz[i].isCorrect()) {
            correct++;
        }
    }

    var score = Math.round((correct / quiz.length) * 100);
    correctPage += 'Score: <strong>' + correct +'/' + quiz.length + '</strong>';

    if (correct >0 && correct < quiz.length) { 
        correctPage +="<p><strong>Here is a summary of your correct answers:</strong><p>";
        for (var i = 0; i < quiz.length; i++) {
            if (quiz[i].isCorrect()) {
                correctPage += '<p><strong>Question ' + (i + 1) + '. </strong>' +
					quiz[i].question + '</p>' + '<p><strong>Answer: </strong>' +
                    quiz[i].userChoices[quiz[i].correctAnswer] + '</p>' + 
					'<p><strong>Comment: </strong>' +
					quiz[i].comment + '</p><hr />' ;
            }
        }
        correctPage +="<p>&nbsp;</p><p><strong>Here is a summary of your incorrect answers:</strong></p>";
        for (var i = 0; i < quiz.length; i++) {
            if (!quiz[i].isCorrect()) {
                correctPage += '<p><strong>Question ' + (i + 1) + '. </strong>' +
					quiz[i].question + '</p>' + '<p><strong>Your answer:</strong><br />' +
                	quiz[i].userChoices[quiz[i].userAnswer] + '</p>' + '<p><strong>Correct answer:</strong><br />' +
                    quiz[i].userChoices[quiz[i].correctAnswer] + '</p>' + 
					'<p><strong>Comment: </strong>' +
					quiz[i].comment + '</p><hr />' ;
            }
        }
    }
    else if (correct == quiz.length){
        correctPage +="<p>Well done, you answered all the questions correctly.</p>"; 
		correctPage +="<p><strong>Here is a summary of your correct answers:</strong><p>";
        for (var i = 0; i < quiz.length; i++) {
                correctPage += '<p><strong>Question ' + (i + 1) + '. </strong>' +
					quiz[i].question + '</p>' + '<p><strong>Answer: </strong>' +
                    quiz[i].userChoices[quiz[i].correctAnswer] + '</p>' + 
					'<p><strong>Comment: </strong>' +
					quiz[i].comment + '</p><hr />' ;

            }
    }
	    else if (correct == 0){
        correctPage +="<p><strong>Here is a summary of your incorrect answers:</strong></p>";
        for (var i = 0; i < quiz.length; i++) {
            if (!quiz[i].isCorrect()) {
                correctPage +="<p><strong>Question " + (i + 1) + ". </strong>" +
					quiz[i].question + "</p>" + "<p><strong>Your answer:</strong><br />" +
                	quiz[i].userChoices[quiz[i].userAnswer] + "</p>" + "<p><strong>Correct answer:</strong><br />" +
                    quiz[i].userChoices[quiz[i].correctAnswer] + "</p>" + 
					"<p><strong>Comment: </strong>" +
					quiz[i].comment + "</p><hr />" ;
            }
        }
    }

    correctPage +="<p class= 'modlinks'><a href='javascript:void(0);' class='up' onclick='window.close()'> CLOSE </a></p></div></div></div></div></body></html>";
    var correctWin = window.open('corrections.htm','corrections','width=500,height=500,scrollbars=yes');
    correctWin.document.write(correctPage);
    correctWin.document.close();
	correctWin.focus();
}

var quiz = new Array();
quiz[0] = new Question(
    "What is an asynchronous interview?", 
    1,
	"An asynchronous interview is carried out in non-real time, i.e. an interview question is posted via email or on a bulletin board and the respondents can answer at any time.",
    "An interview which takes place in real time.",         
    "An interview which takes place in non-real time.",                
    "Another name for any type of online interview.");           
quiz[1] = new Question(
    "What is a synchronous interview?",    
    0,       
	"A synchronous interview is one which takes place in real time, i.e. the interviewer posts a question to a respondent online at the same time. Responses are simultaneous.",
    "An interview which takes places in real time.",                  
    "An interview which takes place in non real time.", 
    "Another name for an email interview.");          
quiz[2] = new Question(
    "When would it generally be most appropriate to use an online interview?",    
    0,   
	"Whilst an online methodology can be used in a range of circumstances, using an online methodology is often most logical when, as  Gaiser (1997, 136) argues, 'the research question involves an online social phenomenon, (because) a potential strength of the method is to be researching in the location of interest'.",
    "When you are researching an online community.",                  
    "When you have not got enough time to arrange face-to-face interviews.", 
    "When interviewing any computer user.");
quiz[3] = new Question(
    "Which of the following approaches can be used to contact online interviewees?",    
    3,   
	"All are possible, but a and b are more likely to generate responses from potential interviewees. See for example, O'Connor and Madge (2001) for a discussion of the benefits of making contact through a website advert and Kivits (2005) and Illingworth (2001) for a discussion of the use of bulletin boards as a means of contacting respondents.  The use of email contact is more problematic because this would require the researcher to have access to a list of email addresses  (see Mann and Stewart, 2000 and Orgad, 2005) or the means to generate a list of email addresses.",
    "Advertising on an appropriate website.",                  
    "Posting a message on a bulletin board.", 
    "Directly emailing individuals.",
	"All of the above.");  
quiz[4] = new Question(
    "Where can a synchronous interview be carried out?",    
    2,   
	"This is the only place where users can chat simultaneously.",
    "Via email.",                  
    "Via postings to bulletin boards.", 
	"In a chatroom."); 
function correctQuiz2() {
var suggAns1 ="<p>Possible answers include:</p><p>Savings of Cost, Location, Geography and Travel, Equipment, Flexibility, Venue, Engagement in the Online Interview and Speed.</p><p>More details about each of these possibilities can be found in the 'advantages and disadvantages' section.</p>";
var suggAns2 ="<p>Possible answers include:</p><p>Distracted Participants, Participant Interest and Motivation, Language Use, Technological Competence, Access, Identity Verification, and Absence of Visual Cues.</p><p>More details about each of these possibilities can be found in the 'advantages and disadvantages' section.</p>";
var suggAns3 ="<p>Paralinguistic expressions replace the visual and tactile communication which characterises much face-to-face communication.</p><p>Some examples of these expressions are: <code>lol</code> (laugh out loud), <code>imho</code>  (in my humble opinion) <code>btw</code> (by the way) <code>hth</code> (hope this helps).</p>";
var suggAns4 ="<p>Emoticons (emotional icons used to express feelings can be used by the interviewees to replace facial expressions and voice quality.</p><p>Some examples are: <code>:-(</code> (sad) |  <code>:-o</code> (surprised) | <code>;-)</code> (wink).</p><p>See the 'Design' section for more details.</p>";
var ans1 = window.document.form1.textarea1.value;
var ans2 = window.document.form1.textarea2.value;
var ans3 = window.document.form1.textarea3.value;
var ans4 = window.document.form1.textarea4.value;

    var correctPage2 ="<html><head><title>Online Interviews</title><link href='../generic/nn4.css' rel='stylesheet' type='text/css'><style type='text/css' rel='stylesheet'>@import url(../generic/main.css);</style></head>" +
                      "<body><div class='canvas'><div class= 'mainborder'><div class= 'maintitle'><h1>Online interviews</h1></div><div class= 'main'>";
					  correctPage2 +="<h2>Advantages of online interviews </h2><h4>Your answer: </h4><p>"+ ans1 +"</p><h4>Suggested answer: </h4>" + suggAns1 + "<hr /><h2>Disadvantages of online interviews </h2><h4>Your answer: </h4><p>"+ ans2 +"</p><h4>Suggested answer: </h4>" + suggAns2 + "<hr /><h2>Paralinguistic cues </h2><p>What are paralinguistic cues in the context of text-based communication?             Give two examples.</p><h4>Your answer: </h4><p>"+ ans3 +"</p><h4>Suggested answer: </h4>" + suggAns3 + "<hr /><h2>Emoticons</h2><p>What are emoticons? Give two examples.</p><h4>Your answer: </h4><p>"+ ans4 +"</p><h4>Suggested answer: </h4>" + suggAns4 + "<p class= 'modlinks'><a href='javascript:void(0);' class='up' onclick='window.close()'> CLOSE </a></p></div></div></div></div></body></html>";
	var correctWin2 = window.open('corrections.htm','corrections','width=500,height=500,scrollbars=yes');
    correctWin2.document.write(correctPage2);
    correctWin2.document.close();
	correctWin2.focus();
}
