  var questionsPicked = new Array(8); //will contain the index of the 8 questions picked this time
  var questions = new Array(); // holds all the questions	

  function makeQuiz()
  {

	//populate the questions array
	var i=0;
	questions[i++] = new Array("How many calories are in a Big Mac large fries and cola?","1320", new Array("850","1320","1140"));
	questions[i++] = new Array("Skimmed milk contains more calcium than full fat milk?","True", new Array("True","False"));
	questions[i++] = new Array("In the sun, what should be the minimum protection sun cream used?","Factor 15", new Array("Factor 10","Factor 12","Factor 15"));
	questions[i++] = new Array("Too much sugar causes your teeth to...","Decay", new Array("Turn blue","Chatter","Decay"));
	questions[i++] = new Array("Smoking and drinking alcohol depletes the quantity of vitamin C in the body","True", new Array("True","False"));
	questions[i++] = new Array("Which of the following is not a good source of iron in food?","shortbread", new Array("green vegetables","shortbread","red meat"));
	questions[i++] = new Array("Do you need to wash raw chicken prior to cooking it thoroughly?","No", new Array("Yes","No"));
	questions[i++] = new Array("How many portions of Fruit and Vegetable are recommended a day?","At least 5 portions", new Array("At least 10 portions","At least 5 portions","At least 2 portions"));
	questions[i++] = new Array("As well as your teeth, you should brush your...","Gums", new Array("Gums","Tonsils","Lips"));
	questions[i++] = new Array("When walking, jogging or running, it's important to your joints for you to wear","Good supportive training shoes", new Array("A tracksuit","Good supportive training shoes","A smile"));
	questions[i++] = new Array("One way of cutting down on salt is to use more","Herbs and spices", new Array("Herbs and spices","Stock cubes","Soy sauce"));
	questions[i++] = new Array("Foods such as avocados, garlic, onions and oily fish such as sardines and mackeral help reduce cholesterol and should be included in your diet","True", new Array("True","False"));
	questions[i++] = new Array("A healthy quick way to cook your vegetables","Microwave", new Array("Boil","Microwave","Steam"));
	questions[i++] = new Array("Fill up on fruit and vegetables because they're full of this","Fibre", new Array("Vitamins","Sugar","Fibre"));
	questions[i++] = new Array("How many portions of Fruit and Vegetable are recommended a day?","At least 5 portions", new Array("At least 10 portions","At least 5 portions","At least 2 portions"));
	questions[i++] = new Array("How many times a day should you brush your teeth?","twice", new Array("once","twice","five times"));
	questions[i++] = new Array("A good source of Calcium is found in","Low fat yoghurt", new Array("Bananas","Low fat yoghurt","Fresh cream"));
	questions[i++] = new Array("Which type of Juice can help reduce acidity and help in the prevention of osteoarthritis?","Celery Juice", new Array("Apple Juice","Orange Juice","Celery Juice"));
	questions[i++] = new Array("Vitamin C, important in maintaining an efficient immune system in the body can be found in which of the following foods","fruits and raw vegetables", new Array("sweets and crisps","fruits and raw vegetables","chocolate"));
	questions[i++] = new Array("How many units of alcohol are recommended per day for a man?","4", new Array("7","4","5"));

	//select 8 questions
	for(var j=0;j<questionsPicked.length;j++)
	{
	  var inserted = false;
	 
	  while(!inserted)
	  {
	    var rand = Math.floor(Math.random()*questions.length);

		inserted = true;
		for(var k=0;k<j;k++)
		{
		 if(questionsPicked[k] == rand) inserted = false;
		}

		if(inserted == true) questionsPicked[j] = rand;
	  }
	}

		//generate the form

	var formHtml = "<form method=post action=\"\"><table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" ID=\"Table1\">";


	for(var j=0;j<questionsPicked.length;j++)
	{
      formHtml = formHtml + "<tr  bgcolor=\"LightGrey\"><td height=\"30\"><strong>"+(j+1)+") "+questions[questionsPicked[j]][0]+"</strong>";
	  formHtml = formHtml + "<input type=hidden name='qNo"+(j+1)+"' value='"+questionsPicked[j]+"'></td></tr>";

	  for(var k=0;k<questions[questionsPicked[j]][2].length;k++)
	  {
	    var inputValue;

		if(questions[questionsPicked[j]][2][k] == questions[questionsPicked[j]][1])inputValue="True";else inputValue ="False";
		 formHtml = formHtml + "<tr><td height='30'><input type='radio' value='"+inputValue+"' name='qAns"+(j+1)+"'>"+questions[questionsPicked[j]][2][k] +"</td></tr>";
	  }
	}

		

	formHtml = formHtml + "<tr><td height='30' align=right><input type=submit value='Submit Answers' onclick='javascript: return checkAnswers();'></td></tr>"

	var quizDiv = document.getElementById("quiz")
	var t = document.createElement('div');
	t.innerHTML = formHtml;
	quizDiv.appendChild(t);


	//document.getElementById("quiz").innerHTML = formHtml;
}


  function checkAnswers()
  {
    var totalCorrect = 0;

    for(var i=0;i<questionsPicked.length;i++)
	{
//		var cQ = questions[document.getElementsByName("qNo"+(i+1))[0].value];
	    var cA = document.getElementsByName("qAns"+(i+1));
			
			for(var k=0;k<cA.length;k++)
			{
				if(cA[k].value == "True")
				{
				  cA[k].parentNode.style.color="#ff0000";
				  if(cA[k].checked)
				  {
					totalCorrect++;
				  }
				}
			}
	}

	alert("You correctly answered "+totalCorrect+" out of "+questionsPicked.length+"!");

	return false;
  }