function question()
{
	this.questionStr = "";
	this.answersArr = new Array();
	this.correctInt = 0;
	this.messageStr = "";
	this.formHtml = "";
	this.correctBol = false;
	this.img = "";
}


question.prototype.showForm = function()
{
	var i;
	
	this.formHtml = "<form name='questionaire'>\n";
	
	// 9/18/2006
	// other possible location for right aligned image
	// see note just below
	this.formHtml += "<p class='quizquestion'>"+this.questionStr+"</p>\n";
	
	var showImage="";
	for(i=0;i<this.answersArr.length;i++)
	{
		var showImage = ( i==0 ) ? this.img : "";
		// 9/18/2006
		// depending on what the client wants,
		// the 'showImage' could be moved above to where
		// quiz question is formatted and line above can be discarded.
		this.formHtml += "<p>"+showImage+"<input type='radio' name='group' value='"+this.answersArr[i]+"'>" + this.answersArr[i] +"</p>\n";	
	}
	
	this.formHtml += "<p><a href='javascript:calculate()'>Next &gt;</a></p>\n";
	
	this.formHtml += "</form>\n";
	
	return this.formHtml;
}

question.prototype.registerAnswer = function(checked)
{
	if(this.correctInt == checked)
	{	
		this.correctBol = true;
		totalCorrectInt++;
	}	
	else
		this.correctBol = false;			
		
}



var q1 = new question();

q1.questionStr = "How many times a week should you get at least 30 minutes of moderate physical activity (including activities such as washing the car, brisk walking, or mowing the lawn)?";
 
q1.answersArr = ["0-1","2-3","4 or more"];

q1.correctInt = 2;

q1.messageStr = "<p><strong>Answer: C</strong></p><p>For health benefits to the heart, lungs, and circulation, perform any moderate-to-vigorous aerobic activity for at least 30 minutes on most days of the week.</p>";

q1.img = '<img src="images/photo_callouts/callout_15.gif" width="205" height="132" border="0" align="right" />';

var q2 = new question();

q2.questionStr = "Physical activity and exercise is the same thing.";
 
q2.answersArr = ["True","False"];

q2.correctInt = 1;

q2.messageStr = "<p><strong>Answer: False</strong></p><p>There is a difference between the two terms. Physical activity is any bodily movement produced by skeletal muscles that result in an expenditure of energy. This means that activities such as gardening, washing the car, and playing with the kids are considered physical activity.</p><p>Exercise is physical activity that is planned or structured. It involves repetitive bodily movement done to improve or maintain one or more of the components of physical fitness. This can include activities such as participating in sports, as well as jogging, walking, lifting weights, and use of exercise machines such as the treadmill or stationary bike.</p><p>It is important to note that both moderate forms of physical activity such as gardening, washing the car, and exercises such as biking and jogging are all beneficial for the heart.</p>";

q2.img = '<img src="images/photo_callouts/callout_16.gif" width="205" height="132" border="0" align="right" />';

var q3 = new question();

q3.questionStr = "Breaking up my activities into short bursts, such as two 15-minute sessions in a day has about the same benefits as one 30-minute session.";
 
q3.answersArr = ["True","False"];

q3.correctInt = 0;

q3.messageStr = "<p><strong>Answer: True</strong></p><p>You may not think you have time to get in the needed amounts of physical activity, but in fact you can break the 30 minutes into bursts of 3 10-minute sessions or 2 15-minute sessions a day. You will still get about the same health benefits as you would exercising consecutive 30 minutes. You might walk briskly for 15 minutes during your lunch break and then 15 minutes more after dinner.</p>";

q3.img = '<img src="images/photo_callouts/callout_17.gif" width="205" height="132" border="0" align="right" />';

var q4 = new question();

q4.questionStr = "To get the most out of physical activity, you must do moderate-vigorous exercise.";
 
q4.answersArr = ["True","False"];

q4.correctInt = 0;

q4.messageStr = "<p><strong>Answer: True</strong></p><p>Moderate-to- vigorous aerobic activities, such as brisk walking, running, swimming, bicycling, roller skating and jumping rope are best for improving the fitness of the heart and lungs. How do you know the proper pace of activity? Try using a &#34conversational pace&#34 during moderate activities like walking. If you can talk and walk at the same time, you aren&#39;t working too hard. If you get out of breath quickly, you&#39;re probably working too hard - especially if you have to stop and catch your breath.</p>";

q4.img = '<img src="images/photo_callouts/callout_18.gif" width="205" height="132" border="0" align="right" />';

var q5 = new question();

q5.questionStr = "People who are thin don&#39;t have to worry about being physically active.";
 
q5.answersArr = ["True","False"];

q5.correctInt = 1;

q5.messageStr = "<p><strong>Answer: False</strong></p><p>Some people don&#39;t have to be physically active to stay thin - but they can still be at risk for heart disease.  Whether you are thin or overweight, incorporating physical activity into your everyday routine can reduce your risk of diseases, increase your metabolism and help you develop stronger bones.  Physical activity is about more than just losing weight.</p>";

q5.img = '<img src="images/photo_callouts/callout_19.gif" width="205" height="132" border="0" align="right" />';

var q6 = new question();

q6.questionStr = "Regular moderate physical activity can positively affect cholesterol levels, blood pressure and glucose intolerance.";
 
q6.answersArr = ["True","False"];

q6.correctInt = 0;

q6.messageStr = "<p><strong>Answer: True</strong></p><p>Regular moderate physical activity increases your fitness level and capacity for exercise. Studies also show that this type of regular physical activity can help control blood lipid (cholesterol and fat) abnormalities, diabetes, and obesity. Moderate physical activity can also help reduce blood pressure, stress, depression, osteoporosis, and breast and colon cancer. Healthy people - as well as many patients with cardiovascular diseases - can improve fitness and exercise performance with training.</p>";

q6.img = '<img src="images/photo_callouts/callout_22.gif" width="205" height="132" border="0" align="right" />';

var q7 = new question();

q7.questionStr = "When it comes to heart disease, blood cholesterol and high blood pressure are bigger risk factors than physical inactivity and low fitness levels.";
 
q7.answersArr = ["True","False"];

q7.correctInt = 1;

q7.messageStr = "<p><strong>Answer: False</strong></p><p>Actually, fitness levels are as important a predictor of death as other established risk factors such as smoking, high blood pressure, high cholesterol and diabetes. In fact, just walking briskly for three hours a week, or exercising vigorously for 1.5 hours a week, can reduce coronary heart disease risk in women by 30 to 40 percent. <em>New England Journal of Medicine, 1999</em></p>";

q7.img = '<img src="images/photo_callouts/callout_23.gif" width="205" height="132" border="0" align="right" />';

var q8 = new question();

q8.questionStr = "Do women get the same benefits from exercise as men?";
 
q8.answersArr = ["Yes","No"];

q8.correctInt = 1;

q8.messageStr = "<p><strong>Answer: No</strong></p><p>actually, they can get more.  Most studies that show the positive effects of exercise involved men.  The few studies that have included women have indicated that women may benefit even more than men from being physically fit.  Early indications show that physically fit women enjoy even greater reduced rates of death from heart disease than men.</p><p>Women who don&#39;t exercise have twice the chance of dying from heart disease as women who exercise. Similarly, women who smoke have twice the chance of dying from heart disease compared to women who don&#39;t smoke. Elderly women who haven&#39;t been physically active experience more disability in their daily functioning than women who have been active.</p>";

q8.img = '<img src="images/photo_callouts/callout_15.gif" width="205" height="132" border="0" align="right" />';


//holds current question
var currentInt;

//array, holds all questions
var questionsArr = [q1,q2,q3,q4,q5,q6,q7,q8]

var totalCorrectInt = 0;

//display form
function display(order)
{
	var stageArea = document.getElementById("stage");
	
	currentInt = order;	
	
	stageArea.innerHTML = questionsArr[currentInt].showForm();	

}


//claculate and register answer after selection then move to next
function calculate()
{
	var i;
	
	var checkedInt;
	
	//go through all radio buttons
	for(i=0;i<document.forms[0].elements.group.length;i++)
	{
		if(document.forms[0].elements.group[i].checked)
			checkedInt = i;		
	}
	
	//regsiter the selected one or display error message if no selection was made
	if(checkedInt!=null)
	{
		//register
		questionsArr[currentInt].registerAnswer(checkedInt);
		
		//move to next 
		//if there are questions left
		if(currentInt<(questionsArr.length-1))
		{
			currentInt ++;
			display(currentInt);
		}
		else
		{
			//show results after last question
			showResults();
		}	
		
	}
	else
	{
		alert("Please select your answer");
	}
	
}

//display results
function showResults()
{
	var outputHtml = "<p>Thanks for taking the Choose to Move Quiz! You got <span class=\"quizresults\">"+totalCorrectInt+"/"+questionsArr.length+"</span> correct.</p>\n <p>See the answers below. All correct answers are highlighted in red:</p>";
	
	var i;
	var j;
	
	var stageArea = document.getElementById("stage");
	
	for(i=0;i<questionsArr.length;i++)
	{
		//Print questions;
		if(questionsArr[i].correctBol)
		{
			outputHtml += "<hr class=\"quizhr\" /><h4>Correct Answer</h4>\n";	
		}
		else
			outputHtml += "<hr class=\"quizhr\" /><p><strong>Incorrect Answer</strong></p>\n";	
			
		outputHtml += "<p>"+questionsArr[i].questionStr+"</p>\n";
		
		//print answers
		for(j=0;j<questionsArr[i].answersArr.length;j++)
		{
			//red if correct
			if(questionsArr[i].correctInt == j)
				outputHtml += "<p class=\"quizanswerright\"><strong>"+questionsArr[i].answersArr[j]+"</strong></p>";
			else//not red otherwise
				outputHtml += "<p class=\"quizansweright\">"+questionsArr[i].answersArr[j]+"</p>";
		}
		
	}

	//print output	
	stageArea.innerHTML = outputHtml;

}