// JavaScript Document

function returnObjById( id ) 
 { 
  if(document.getElementById) 
  var returnVar = document.getElementById(id);
  else if (document.all)
  var returnVar = document.all[id];
  else if (document.layers)
  var returnVar = document.layers[id];
  return returnVar;
 } 


function calculateQuiz(f){
	var o = f.score
	var total = 0
	var checkTotal = 0
	for(i=0;i<o.length;i++){
		if(o[i].checked){
			total += parseInt(o[i].value)
			checkTotal++
		}
	}
	
	
	
	//alert(o.length)
	
	var extraText = '<h5>The more times you ticked \'Yes\' the greater your risk of having a heart attack or stroke. Please see your doctor within the next few weeks for a heart health check.</h5>'
	
	if((o[0].checked || o[2].checked) && total == 0)
			extraText = '<h5>You are at low risk of Heart Disease. However see your doctor or practise nurse for a risk assesment at a age 45 years for men and 55 for women. If you are still concerned, then please see your doctor.</h5>'
	
	//if(o[6].checked) //Smoking
		extraText += '<b>Smoking</b> is major risk factor for heart disease. Click <a href="/index.asp?PageID=2145828156">here</a> for further information.'	

	//if(o[10].checked) //Food
		extraText += '<br><b>Improving your diet</b> will help reduce your risk. Click <a href="/index.asp?PageID=2145828145">here</a> for further information.'	

	//if(o[11].checked) //Exercise
		extraText += '<br><b>Regular exercise</b> will help your reduce your risk. Click <a href="/index.asp?PageID=2145828149">here</a> for further information.'	
	
	//if(o[12].checked) //Loosing Weight
		extraText += '<br><b>Loosing weight</b> will help reduce your risk. Click <a href="/index.asp?PageID=2145828154">here</a> for further information.'	
	
	if(f.worry.checked){
		extraText = '<h5>You are already at high risk of, or have heart disease, and should be seeing your doctor for regular check ups.<p>Check with your doctor to see whether you should be taking aspirin and medications to lower your blood pressure and cholesterol levels.</p></h5>'
	}
	
	var div = returnObjById('quiztotal')

	div.innerHTML = extraText
	return false
}