function generateQuestionsAndAnswers(question_index,total_score,answer_number)
 {
	
	var html_code="";	
	var lover = window.document.getElementById("depression-quiz-contents");
	
	if (0 == question_index)
	 {
		var good_times = window.document.getElementById("depression-test-image");
		good_times.innerHTML = "";
	 }
	
	if (18 == question_index)
	 {
		var good_times = window.document.getElementById("depression-test-image");
		good_times.innerHTML = "<img src=\"/wp-content/themes/thesis_18/custom/images/depression-test-masthead06.png\">";
	 }
	
	if ((answer_number != 50))
	 {
		total_score += answerValueArray[(question_index-1)][answer_number];
		//alert("total_score="+total_score);
	 }
	
 	if (question_index < 18)
	 {
		//generate question
		html_code+="<br><br><span class=\"question\">"+(question_index+1)+". "+questionArray[question_index]+"</span><br>"; 

		//generate possible answers
		//turn into loop
		var number_of_answers = answerValueArray[question_index].length;
		jjj=0;
		while (jjj < number_of_answers)
		 {
			if (0 == jjj)
			 {
				html_code+="<div id=\"answers-div\"><br>";
			 }
		//generateQuestionsAndAnswers("+question_index+");
			html_code+="<input type=\"radio\" name=\"depression-quiz\" class=\"radio-button\" onClick=\"generateQuestionsAndAnswers("+(question_index+1)+","+total_score+","+jjj+");\"  value=\""+answerValueArray[question_index][jjj]+"\"> <span class=\"answer\">"+answerTextArray[question_index][jjj]+"</span><br><br>";
			
			if ((number_of_answers -1) == jjj)
			 {
				html_code+="</div>";
			 }
			jjj++;
		 }
	 
		//generate number of questions remaining
		html_code+="<span class=\"questions-left\">"+(18-(question_index+1))+" QUESTIONS REMAIN</span><br>";
	 }	
	
	 else
	 {
	
		var weighted_total_score = (total_score)*Math.pow(2,total_score/46 - 1);
		var percent_depressed = parseInt((weighted_total_score/46)*100);
		
		html_code = "<br><br><span class=\"quiz-results\"><p>You are "+percent_depressed+"% depressed.</p></span>";
	html_code += "<p style=\"margin-top:-3em;\">";
	
		if (percent_depressed <= 20)
		 {
			html_code += "<span class=\"questions-left\">You're probably in the normal range.</span> You might have a rough day sometimes, but you generally have a good perspective on yourself and your life.</p>";
		 }
		else if (20 < percent_depressed <= 40)
		 {
			html_code += "<span class=\"questions-left\">You might be suffering from mild depression.</span> This means that you have several of the more minor symptoms associated with depression, and you might be experiencing some difficulty maintaining a good mood throughout the day. It might be a good time to schedule a consultation with your doctor for a possible diagnosis.</p>";
		 }
		else if (40 < percent_depressed < 66)
		 {
			html_code += "<span class=\"questions-left\">You're probably suffering from moderate depression.</span> You're probably experiencing a lack of interest in activities you used to enjoy, possible fatigue and your personal relationships are suffering. You need to schedule an appointment with your doctor so that he can evaluate you.</p>";
		 }
		else
		 {
			html_code += "<span class=\"questions-left\">You're possibly suffering from major depression.</span> If you've been thinking often of death or dying, had thoughts of suicide or are experiencing despair and constant hopelessness, you should seek treatment immediately.</p>";
		 }
	
		html_code += "<p>If you suspect that you're depressed know that there is help available and that you don't have to continue battling it alone. There are many treatments available, but you won't start feeling better until you take the first step to getting help.</p>";
	
	 }
	html_code += "</p>";
	lover.innerHTML = html_code;
	
 }
