function Question(question, answer, answerCount) {
this.question=question;
this.answer=answer;
this.answerCount=answerCount;
}
function Answer(value, answer) {
this.value=value;
this.answer=answer;
}
function showQuestion(questionNo) {
updateBar();
currentQuestion = questionNo;
document.getElementById('question_number').innerHTML = 'QUESTION ' + questionNo + ' OF ' + questionCount;
var strQ = '
' + questions[questionNo - 1].question + '
';
for(i = 0; i < questions[questionNo - 1].answerCount; i++)
strQ += '- ' + questions[questionNo - 1].answer[i].answer + '
';
strQ += '
';
document.getElementById('question').innerHTML = strQ;
}
function answerQuestion(answerNo) {
currentScore += questions[currentQuestion - 1].answer[answerNo].value;
if(currentQuestion == questionCount)
showComplete();
else
showQuestion(currentQuestion + 1);
}
function showComplete() {
updateBar();
document.getElementById('score').value = currentScore;
document.forms[0].submit();
}
function updateBar() {
document.getElementById('quiz_bar').style.width = ((500 / maxScore) * currentScore) + 'px';
}
var questionCount = 11;
var maxScore = 11;
var currentQuestion = 0;
var currentScore = 0;
var questions = [];
var answers = [];
answers = [];
answers[0] = new Answer(1, 'Ignore it');
answers[1] = new Answer(0, 'Investigate it');
questions[0] = new Question('Its night time, you hear a noise outside, do you :', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Go in a group');
answers[1] = new Answer(0, 'Go alone');
questions[1] = new Question('If you had to investigate, would you :', answers, 2);
answers = [];
answers[0] = new Answer(1, 'No');
answers[1] = new Answer(0, 'Yes');
questions[2] = new Question('Do you have a tendency to fall over ?', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Ignore them');
answers[1] = new Answer(0, 'Follow them to the letter');
questions[3] = new Question('If you are lost and a redkneck gas station man gave you directions :', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Not a chance');
answers[1] = new Answer(0, 'Yeah, he looks harmless enough');
questions[4] = new Question('If travelling by car, late at night, would you pick up a lone hitchhiker ?', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Finish them off while you have the chance');
answers[1] = new Answer(0, 'Run away!');
questions[5] = new Question('If you are battling an intruder and they go down, would you :', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Yes, without a moments hesitation');
answers[1] = new Answer(0, 'Nope, theyre still my friend inside. Sob.');
questions[6] = new Question('If your friend got a zombie/vampire/wearwolf bite would you kill them if they turned ?', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Nope');
answers[1] = new Answer(0, 'Yep!');
questions[7] = new Question('Are you are a girl with long blonde hair, blue eyes and big boobs ?', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Nope!');
answers[1] = new Answer(0, 'Hell yeah!');
questions[8] = new Question('If the killer is wearing a mask and temporarily disabled, would you peak ?', answers, 2);
answers = [];
answers[0] = new Answer(1, 'No, me gots partying to do');
answers[1] = new Answer(0, 'Yeah, Id happy to.');
questions[9] = new Question('Would you babysit for someone on halloween night ?', answers, 2);
answers = [];
answers[0] = new Answer(1, 'Easy, Im a crack shot');
answers[1] = new Answer(0, 'No, I think they should be banned.');
questions[10] = new Question('Can you handle a gun ?', answers, 2);