// JavaScript Document
function AddItAllUp()
{
    var elems = document.forms["dietquizform"].length;          	//could even look this up!
    var thisvalue;              				//used to find out if element is a checkbox
    var thistype;               				//number (index) of current checkbox
    var thischq;                				//true if checked
    var grandTotal = 0;							//score the user received
	var cutoff1 = 24;							//cut off for page 
    var cutoff2 = 16;							//cut off for page 
    var cutoff3 = 9;							//cut off for page 
    var radiocount = 0;							//radio count initialized
    var RadioCnt = 14;							//radio max count.


    grandTotal = 0;
	
    while (elems > 0)
      { elems --;
		thistype = document.forms["dietquizform"].elements[elems].type;
        if (thistype == "radio")
           { 

		     thischq = document.forms["dietquizform"].elements[elems].checked;
             thisvalue = document.forms["dietquizform"].elements[elems].value;
             if (thischq)
               { 
					radiocount += 1;
					grandTotal += parseInt(thisvalue);
               };
           };
      };
	
    if (radiocount == RadioCnt)
    {	
	    if (grandTotal >=cutoff1)
	    { 
			location.href = "/surgeongeneral/0,1607,7-216-33084_33090_33111_33917-105609--,00.html";
	    }
 		else if (grandTotal>=cutoff2) 
	 	  {
  			location.href = "/surgeongeneral/0,1607,7-216-33084_33090_33111_33917-105607--,00.html";
		  } else if (grandTotal>=cutoff3) 
   				 {
		 			location.href ="/surgeongeneral/0,1607,7-216-33084_33090_33111_33917-105612--,00.html";
	    		  } 
				  else 
				  { 
		  			location.href ="/surgeongeneral/0,1607,7-216-33084_33090_33111_33917-105626--,00.html";
	    		   } 
	 	}
        else
        {
		
			var obj
			obj = document.getElementById("divError")
			obj.style.visibility = "visible";
			obj.innerHTML = "Please answer all questions."
			
			var obj2
			obj = document.getElementById("divError2")
			obj.style.visibility = "visible";
			obj.innerHTML = "Please answer all questions."
			
     	}
}