<!--

var numberOfQuestions = 8;

var  sections = new Array(numberOfQuestions);
       questions = new Array(numberOfQuestions);
       rightAnswers = new Array(numberOfQuestions);
       wrongAnswers = new Array(numberOfQuestions);
       choices = new Array(numberOfQuestions);
       rightChoice = new Array(numberOfQuestions);

var questionNumber = 0;
      isFirstAnswerForThisQuestion = true;
      score = 0;

function init()
{
	var i;

   for (i = 0; i < numberOfQuestions; i++) choices [i] = new Array (4);

   sections [0] = "Know Your Numbers";
   questions [0] = "Your cholesterol level is one of the four important health numbers you should know. What should your target for total cholesterol be?";
   wrongAnswers [0] = "<p>The normal range for total cholesterol is <b>200 or less</b>.  Living with high cholesterol can eventually lead to a heart attack or stroke.</p> <p>High cholesterol won't show itself in symptoms.  You need to visit your doctor to have it checked, or visit one of our health screening events where you can have your cholesterol tested for free.</p>";
   rightAnswers [0] = "<p><b>Right on!</b>  Keeping your cholesterol on target helps protect you from heart disease and stroke.  Wise eating and regulat exercise are the best ways to get your cholesterol low and keep it there.</p>";
   choices[0] [0] = "Under 200";
   choices[0] [1] = "At least 120";
   choices[0] [2] = "Under 50";
   choices[0] [3] = "I don't know.  Tell me more about this.";
   rightChoice [0] = 0;

   sections [1] = "Know Your Numbers";
   questions [1] = "Blood pressure is your next number to know.  What's a healthy target blood pressure?";
   wrongAnswers [1] = "<p>Your target blood pressure should be <b>120 over 80</b>.</p><p>Blood pressure measures the amount of force your heart needs to pump blood.  If it's too high, you run the risk of heart attack, stroke and kidney disease.  You can get your blood pressure checked at your doctor, county health clinic, or machines in many pharmacies.</p>";
   rightAnswers [1] = "<p><b>Right.</b>  A blood pressure of 120 over 80 (or even less if you're in very good shape) means that you've lowered your risk of heart attack, stroke and kidney disease, and damage to the brain and eyes.  As many as 300,000 Mississippians may have high blood pressure and not know it.</p>";
   choices[1] [0] = "About 80/60";
   choices[1] [1] = "Less than 150/100";
   choices[1] [2] = "About 120/80";
   choices[1] [3] = "I'm not sure.  Tell me!";
   rightChoice [1] = 2;

   sections [2] = "Know Your Numbers";
   questions [2] = "What's your target blood sugar range?";
   wrongAnswers [2] = "<p>The average healthy blood sugar range is from <b>80 to 120</b>.  If it's higher or lower, you may have diabetes or be at risk for it.</p><p>It's quick and easy to have your blood sugar checked.  Your doctor can do it, or you can have it done along with other simple tests at one of our health screening events around the state.</p>";
   rightAnswers [2] = "<p><b>On target!</b>  Healthy blood sugar remains between 80 and 120.  The right blood sugar level not only helps protect you from diabetes, it keeps you more alert throughout the day.</p>";
   choices [2] [0] = "Under 50";
   choices [2] [1] = "Between 80 and 120";
   choices [2] [2] = "Under 200";
   choices [2] [3] = "Tell me what's best.";
   rightChoice [2] = 1;

   sections [3] = "Know Your Numbers";
   questions [3] = "Body mass index (BMI) measures your weight in relation to your height.  What should your target BMI be?";
   wrongAnswers [3] = "<p>Actually, your BMI should be <b>25 or less</b> to keep the right weight for your height.</p><p>Less extra weight means a lower chance of diabetes and heart disease, and more enjoyment from sports and physical activities.</p>";
   rightAnswers [3] = "<p><b>Yes.</b>  A BMI under 25 signals a healthy weight for you.  Check our BMI chart on this site to help calculate your current Body Mass Index.</p>";
   choices [3] [0] = "1 or greater";
   choices [3] [1] = "Under 35";
   choices [3] [2] = "25 or less";
   choices [3] [3] = "I don't know.  Tell me more about this number.";
   rightChoice [3] = 2;

   sections [4] = "Healthy Living";
   questions [4] = "Regular exercise, even for just 30 minutes a day, is essential for a healthy heart and body.  How often is moderate exercise recommended?";
   wrongAnswers [4] = "<p><b>5 days a week</b> of moderate exercise is the key to making physical activity work for you.  Exercise doesn't only work to build a healthy heart; it can help lower blood sugar, reduce fatugue, and build confidence.  It's as easy as making a short walk part of your daily routine.</p>";
   rightAnswers [4] = "<p><b>Right.</b>  Even three days a week of exercise, if it's more vigorous, can improve your weight, fitness and blood sugar levels.  If you're in the Jackson area, check this site for a map of places to walk for exercise.</p>";
   choices [4] [0] = "Every other day";
   choices [4] [1] = "At least 5 days a week";
   choices [4] [2] = "One or two days a week";
   choices [4] [3] = "Tell me the latest recommendation";
   rightChoice [4] = 1;

   sections [5] = "Healthy Living";
   questions [5] = "We eat about 12 servings of food a day.  How many of these servings should be vegetables and grains?";
   wrongAnswers [5] = "<p>Almost half of what you eat every day - <b>5 or 6 servings</b> - should be vegetables and grains.  If you include fruit, the proportion is even higher.  The easy way to do this is to make half your plate green or colorful food at every meal.</p>";
   rightAnswers [5] = "<p><b>That's right.</b>  A healthy diet is rich in vegetables for nutrition and grains for energy.  Our Nutrition Toolkit can help you find the exact balance that's right for you.</p>";
   choices [5] [0] = "5 or 6 servings a day";
   choices [5] [1] = "Not more than 4 servings";
   choices [5] [2] = "3 or 4 servings a day";
   choices [5] [3] = "I'm not really sure what's best";
   rightChoice [5] = 0;

   sections [6] = "Healthy Living";
   questions [6] = "Your health is a serious matter.  Almost 30,000 Mississipians a year die from illness or injury.  What's the leading health threat in the state?";
   wrongAnswers [6] = "<p>It's not cancer or car accidents that takes the most lives in Mississippi each year.  <b>Cardiovascular disease</b> (heart disease and stroke) is the number one health threat in the state.  40% of deaths are due to it.</p>";
   rightAnswers [6] = "<p><b>Yes.</b>  Despite the fact that it's one of the most preventable of the causes of death in Mississippi, cardiovascular disease (heart disease and stroke) claims about 12,000 lives a year.</p>";
   choices [6] [0] = "Motor vehicle accidents";
   choices [6] [1] = "Heart disease and stroke";
   choices [6] [2] = "Cancer";
   choices [6] [3] = "I don't know.  Tell me the numbers.";
   rightChoice [6] = 1;

   sections [7] = "About You";
   questions [7] = "We'd like to know a little about our visitors.  If you like, you can send us a few facts.";

	 showCurrentQuestion();
}


function showCurrentQuestion ()
{
	var i;
   say ("SectionTitle", sections [questionNumber]);
   say ("QuizQuestion", questions [questionNumber]);
   say ("Choice1", choices [questionNumber] [0]);
   say ("Choice2", choices [questionNumber] [1]);
   say ("Choice3", choices [questionNumber] [2]);
   say ("Choice4", choices [questionNumber] [3]);

   if (sections [questionNumber] == "Know Your Numbers") setImageTo ("TargetIcon.gif", "SectionIcon");
   if (sections [questionNumber] == "Healthy Living") setImageTo ("HealthIcon.gif", "SectionIcon");
   if (sections [questionNumber] == "About You") setImageTo ("PersonalIcon.gif", "SectionIcon");

   for (i = 0; i < numberOfQuestions; i++)
   {
      if (i <= questionNumber)
      {
      	diskOn (i);
      }
      else
      {
         diskOff (i);
      }
   }
}

function nextQuestion ()
{
   if (questionNumber < numberOfQuestions)
   {
      say("QuizAnswer","");
      questionNumber++;
      showCurrentQuestion();
      isFirstAnswerForThisQuestion = true;
   }

   if (questionNumber == (numberOfQuestions - 1))
   {
	   scoreQuiz();
   	enterSurvey();
		setImageTo ("nothing.gif", "NextButton");
   }
}

function enterSurvey()
{
  var strForm = "";
  say("SectionTitle", sections[questionNumber]);
	strForm = '<form name="Isurvey" method="POST" action="http://www.healthyMS.com/HealthyLiving/scripts/TotalsKeeper.asp">';
	strForm += '<p>I am:<br><input type="radio" id="sex" name="a1" value="male" />a man  &nbsp;<input type="radio" id="sFemale" name="a1" value="female" />a woman</p>' +
					   '<p>My age is:<br><input type="radio" id="age1" name="a2" value="under 20" />under 20  &nbsp;<input type="radio" id="age2" name="a2" value="20 - 29" />20-29  &nbsp;<input type="radio" id="age3" name="a2" value="30 - 39" />30-39  &nbsp;<input type="radio" id="age4" name="a2" value="40+" />40 or over</p>';
	strForm += '<p>I\'m interested in:<br><input type="radio" id="loseWeight" name="a3" value="losing weight" />losing weight  &nbsp;<input type="radio" id="getActif" name="a3" value="getting active" />getting active<br><input type="radio" name="a3" id="eatBetter" value="eating better" />eating better  &nbsp;&nbsp;<input type="radio" id="genHealth" name="a3" value="general health" />general health</p>';
	strForm += '<p><input type="hidden" name="nextPage" value="http://www.HealthyMS.com/HealthyLiving" /></p>';
	strForm += '<p align="right"><input type="submit" value="Finish" /></p></form>';

	say("Choices", strForm);
  if(sections[questionNumber] == "About You") setImageTo("PersonalIcon.gif","SectionIcon");
	diskOn(questionNumber);
}


function scoreQuiz()
{
	   if (score <=3) say ("QuizAnswer", "<p>Thanks for spending a few minutes on our quiz.  There's much more you can learn about healthy living on this site.  Enjoy your visit!</p>");
	   if (score >3 && score <= 5) say ("QuizAnswer", '<p><b class="grayBold">Good score!</b>  You can raise your health knowledge even higher with a trip through our site.</p>');
	   if (score >5) say ("QuizAnswer", '<p><b class="grayBold">Excellent score!</b>  We hope the rest of our site can help you put your health knowledge to work.</p>');
}


function checkAnswer (this_choice_number)
{
   if (rightChoice [questionNumber] == this_choice_number)
   {
      say ("QuizAnswer", rightAnswers [questionNumber]);
      if (isFirstAnswerForThisQuestion) score++;
   }
   else
   {
      say ("QuizAnswer", wrongAnswers [questionNumber]);
   }
   isFirstAnswerForThisQuestion = false;
}


function say (this_id, this_str)
{
   objectCalled (this_id).innerHTML = this_str;
}

function diskOn (this_question_number)
{
	setImageTo ("DiskOn.gif", "Q" + this_question_number);
}

function diskOff (this_question_number)
{
	setImageTo ("DiskOff.gif", "Q" + this_question_number);
}


function setImageTo (this_image_name, this_image_id)
{
      objectCalled (this_image_id).src = "http://www.HealthyMS.com/HealthyLiving/images/graphics/Quiz/" + this_image_name;
}

function objectCalled(n, d) {

  var p,i,x;

  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=objectCalled(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n);
  return x;
}

init();

// -->
