// Class QuestionGroup

QuestionGroup = function() {
	this.questions = new Array();
}

new QuestionGroup();

QuestionGroup.prototype.add = function(theQuestion) {
	this.questions[this.questions.length] = theQuestion;
}

QuestionGroup.prototype.getAverage = function() {
	var numerator = 0;
	var denominator = 0;
	for (var i = 0; i < this.questions.length; i++) {
		if (this.questions[i].answered) {
			denominator++;
			numerator += this.questions[i].choice;
		}
	}
	if (denominator > 0) {
		num = (numerator/denominator);
		aft = num - Math.floor(num);
		return (aft >= 0.6) ? Math.ceil(num) : Math.floor(num);
	} else {
		return -1;
	}
}

QuestionGroup.prototype.findQuestion = function(where) {
	where = where.slice((where.lastIndexOf("/")) + 1).replace(".htm","").replace("#","");
	for (var i = 0; i < this.questions.length; i++) {
		if (where.toString() == this.questions[i].ident.toString()) return true;
	}
	return false;
}

QuestionGroup.prototype.getQuestion = function(where) {
	where = where.slice((where.lastIndexOf("/")) + 1).replace(".htm","");
	for (var i = 0; i < this.questions.length; i++) {
		if (where.toString() == this.questions[i].ident.toString()) return this.questions[i];
	}
	return new Question("");
}
