
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Values global to this calculator
///////////////////////////////////////////////////////////////////////////////////////////////////////////

var m_ThisCalculatorsName = "BMICalculator";
var m_CurrentQueryString = location.search.substring(1);
var m_PreCalculationQueryString = GetPreCalculationQueryString();
var m_ExpectedNumberOfParameters = 3;
var m_Parameters = []; // this will be initialized if and when appropriate values are present in the query string

// this code runs whenever the page loads
//check to see if there's something in the querystring, if so, parse it.
if(m_CurrentQueryString.length > 0)  
{
	BMICalculator_ParseQueryString();
	
	// run the calculator if values are present for it to work on
	if(m_Parameters.length == m_ExpectedNumberOfParameters)
	{	
    // persist the textbox value the user entered in for their weight
		BMICalculator_PrePopulateCalculator();
		
		// run the calculation code
		BMICalculator_Calculate();
	}
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Button on-click handlers
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function BMICalculator_Submit()
{
	if(BMICalculator_Validate() == true)
	{
		// assemble query string to be used for calculation work
		BMICalculator_CreateQuerystring();
	}
}

function BMICalculator_Reset()
{
	window.location.href = location.pathname + ((m_PreCalculationQueryString.length > 0) ? ("?" + m_PreCalculationQueryString) : "");
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Query string-related functions
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function BMICalculator_ParseQueryString()
{
	var calculatorPair;
	var isFound = false;		
	
	//split the query and get out the params
	if(m_CurrentQueryString.indexOf("_Parameters=") >= 0) 
	{
		var queryPairs = m_CurrentQueryString.split("&");
		
		for(i = 0; i < queryPairs.length && !isFound; i++) 
		{
			if(queryPairs[i].indexOf("_Parameters=") >= 0) 
			{
				isFound = true;
				calculatorPair = queryPairs[i].split("=");
				m_Parameters = calculatorPair[1].split(",");
			}
		}
	}
}

function BMICalculator_CreateQuerystring()
{
	//gather the answers and put them in the querystring, repost to the same page
	var newQuerystring = m_ThisCalculatorsName + "_Parameters=";
	
	var elemWeight = document.getElementById(m_ThisCalculatorsName + "_Weight");
	newQuerystring +=elemWeight.value + ",";
	
	var elemHeightFt = document.getElementById(m_ThisCalculatorsName + "_Height_Feet");
	newQuerystring += elemHeightFt.value + ",";
	
	var elemHeightIn = document.getElementById(m_ThisCalculatorsName + "_Height_Inches");
	newQuerystring += elemHeightIn.value;
	
	//newQuerystring += "#Results";
	
	if(m_PreCalculationQueryString.length > 0)
	{
		window.location.href = location.pathname + "?" + m_PreCalculationQueryString + "&" + newQuerystring;
	}
	else
	{
		window.location.href = location.pathname + "?" + newQuerystring;
	}	
}


function GetPreCalculationQueryString()
{
	m_PreCalculationQueryString = "";
	
	var tmpArray = m_CurrentQueryString.split("&"); //get the paired querysting parameters.
	
	// look for and retain all query string values extant prior to calculator being used
	for(x = 0; x < tmpArray.length; x++)
	{
		if(tmpArray[x].indexOf("_Parameters=") < 0) //if you dont find it, append to the newQuerystring
		{	  
			m_PreCalculationQueryString += tmpArray[x] + "&";
		}		
	}
	// if there were any non-calculator query string values prior to running the calc, append those to this page's url
	return (m_PreCalculationQueryString.length > 0) ? (m_PreCalculationQueryString.substring(0, m_PreCalculationQueryString.length-1)) : "";	
}


function BMICalculator_PrePopulateCalculator()
{
	var elemWeight = document.getElementById(m_ThisCalculatorsName + "_Weight");
	elemWeight.value = m_Parameters[0]; // m_Parameters[0] = weight entered by user
	
	var elemHeightFeet = document.getElementById(m_ThisCalculatorsName + "_Height_Feet");
	elemHeightFeet.value = m_Parameters[1]; // m_Parameters[1] = height in feet entered by user
	
	var elemHeightInches = document.getElementById(m_ThisCalculatorsName + "_Height_Inches");
	elemHeightInches.value = m_Parameters[2]; // m_Parameters[2] = height in inches entered by user
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Validation Functions
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function BMICalculator_IsNumeric(sText) 
{
	var rxNumber = new RegExp("^[\\d\\.]+$", "g");
	return (rxNumber.exec(sText) != null);
}

function BMICalculator_Validate()
{
	var strError = "The following errors occured while validating your information:\r";
	var isError = false;
	

	//check the height_feet
	var elemHeightFt = document.getElementById(m_ThisCalculatorsName + "_Height_Feet");
	if(elemHeightFt.value == "")
	{
		strError += " - Height: Feet is required\r";
		isError = true;
	}
	else
	{
		if(!BMICalculator_IsNumeric(elemHeightFt.value))
		{
			strError += " - Height: Feet is not a valid number\r";
			isError = true;
		}
	}

	//check the height_ inches
	var elemHeightIn = document.getElementById(m_ThisCalculatorsName + "_Height_Inches");
	if(elemHeightIn.value == "")
	{
		strError += " - Height: Inches is required\r";
		isError = true;
	}
	else
	{
		if(!BMICalculator_IsNumeric(elemHeightIn.value))
		{
			strError += " - Height: Inches is not a valid number\r";
			isError = true;
		}
		else
		{
			if(elemHeightIn.value > 11)
			{
				strError += " - Height: Inches must be less than 12\r"
			}
		}
	}

	//check the weight
	var elemWeight = document.getElementById(m_ThisCalculatorsName + "_Weight");
	if(elemWeight.value == "") 
	{
		strError += " - Weight is required\r";
		isError = true;
	}
	else 
	{
		if(!BMICalculator_IsNumeric(elemWeight.value))
		{
			strError += " - Weight is not a valid number\r";
			isError = true;
		}
	}

	//if there was an error, display alert, and return to form.
	if(isError)
	{
		alert(strError);
		return false;
	}
	else
	{
		return true;
	}		
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main calculator code
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function BMICalculator_Calculate()
{
	var weight = eval(m_Parameters[0]);
	var heightFeet = eval(m_Parameters[1]);
	var heightInches = eval(m_Parameters[2]);
	var heightFeetConvertedToInches = heightFeet * 12;
	var totalHeightInInches = heightFeetConvertedToInches + heightInches;

	
	if((weight < 60) || (weight > 800) || (totalHeightInInches < 48) || (totalHeightInInches > 96))
	{
		alert ("The information you have entered is incomplete or exceeds the range of this calculator.  Please check your entries and try again.  If your entries are correct, please consult with your physician.");
		return;
	}
	else
	{
		var displaybmi = Math.round(weight * 703 * 10 / totalHeightInInches / totalHeightInInches) / 10;
		document.getElementById(m_ThisCalculatorsName + "_Result").value = displaybmi;
	}
}









//Check the querystring for values, if they exist, then process them (printer friendly)
var urlQuery = location.search.substring(1);
if(urlQuery.length > 0)  {
AllergyQuiz_ParseQueryString(urlQuery);
}

function AllergyQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	AllergyQuiz_calculate(QuizName, UserAnswers);
}
}

function AllergyQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function AllergyQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function AllergyQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}



//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
AsthmaQuiz_ParseQueryString(urlQuery);
}

function AsthmaQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	AsthmaQuiz_calculate(QuizName, UserAnswers);
}
}

function AsthmaQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function AsthmaQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function AsthmaQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}



//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
GlaucomaQuiz_ParseQueryString(urlQuery);
}

function GlaucomaQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	GlaucomaQuiz_calculate(QuizName, UserAnswers);
}
}

function GlaucomaQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(y=0;y<ChoicesNodes.length;y++)
		{
			ChoicesElement = ChoicesNodes[y];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function GlaucomaQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function GlaucomaQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(y=0;y<ChoicesNodes.length;y++)
		{
			ChoicesElement = ChoicesNodes[y];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}


//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
DiabetesQuiz_ParseQueryString(urlQuery);
}

function DiabetesQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	DiabetesQuiz_calculate(QuizName, UserAnswers);
}
}

function DiabetesQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function DiabetesQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function DiabetesQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}

//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
BloodQuiz_ParseQueryString(urlQuery);
}

function BloodQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	BloodQuiz_calculate(QuizName, UserAnswers);
}
}

function BloodQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function BloodQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function BloodQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}

//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
ChildhoodObesityQuiz_ParseQueryString(urlQuery);
}

function ChildhoodObesityQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	ChildhoodObesityQuiz_calculate(QuizName, UserAnswers);
}
}

function ChildhoodObesityQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function ChildhoodObesityQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function ChildhoodObesityQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}

//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
CholesterolQuiz_ParseQueryString(urlQuery);
}

function CholesterolQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	CholesterolQuiz_calculate(QuizName, UserAnswers);
}
}

function CholesterolQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function CholesterolQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function CholesterolQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}

//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
GERDQuiz_ParseQueryString(urlQuery);
}

function GERDQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	GERDQuiz_calculate(QuizName, UserAnswers);
}
}

function GERDQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function GERDQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function GERDQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}


//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
HypertensionQuiz_ParseQueryString(urlQuery);
}

function HypertensionQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	HypertensionQuiz_calculate(QuizName, UserAnswers);
}
}

function HypertensionQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function HypertensionQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function HypertensionQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}

//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
PlateletQuiz_ParseQueryString(urlQuery);
}

function PlateletQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	PlateletQuiz_calculate(QuizName, UserAnswers);
}
}

function PlateletQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function PlateletQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function PlateletQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}

//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
SmokingQuiz_ParseQueryString(urlQuery);
}

function SmokingQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	SmokingQuiz_calculate(QuizName, UserAnswers);
}
}

function SmokingQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function SmokingQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function SmokingQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}


//Check the querystring for values, if they exist, then process them (printer friendly)

if(urlQuery.length > 0)  {
WeightQuiz_ParseQueryString(urlQuery);
}

function WeightQuiz_ParseQueryString(urlQuery)
{
var bolProcessAnswers = false;	//assume we dont need to do anything
var UserAnswers;
var QuizName = "";

//the key is 'CustomAnswers='
if(urlQuery.indexOf("CustomAnswers") >= 0) {
	var pairs = urlQuery.split("&");		//pairs are going to be bla=foo
	for(a = 0;a < pairs.length; a++)
	{
		if(pairs[a].indexOf("CustomAnswers") >= 0)
		{
			tempArray = pairs[a].split("=")
			//split the tempArray and extrac the QuizName
			tmpQnameKey = tempArray[0].split("_");
			QuizName = tmpQnameKey[1];
			//split the tempArray and extract the Answers
			UserAnswers = tempArray[1].split(",")
			if(QuizName.length > 0 && UserAnswers.length > 0)
				bolProcessAnswers = true;
		}
	}
}

if(bolProcessAnswers) {
	WeightQuiz_calculate(QuizName, UserAnswers);
}
}

function WeightQuiz_MakeQueryString(QuizName) {
//when the submit button is clicked, we want to take their answers and put them in the query string
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;
var QuizDiv = document.getElementById(QuizName);
var QuizNodes = QuizDiv.childNodes;
var MyQuery = "";
var existingURL = "";

//decide if we should prepend it with a '?" or a "&"
if(location.search.substring(1).length > 0)
	existingURL = "?" + location.search.substring(1);

for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			if(ChoicesElement.checked)
			{
				YourAnswer = ChoicesElement;					
				var answerId = YourAnswer.id.substring(YourAnswer.id.indexOf("_")+1, YourAnswer.id.length);
				MyQuery += answerId + ",";		//keep this id
			}
		}
	}
}
//check to see if they didnt answer any of the questions
if(MyQuery.length == 0)		
	MyQuery = "CustomAnswers_" + QuizName + "=none";
else
	MyQuery = "CustomAnswers_" +QuizName + "=" + MyQuery.substring(0, MyQuery.length-1);		//take of the last ','

//redirect the browser to add in the querystring, for printer friendly version	
if(existingURL.length > 0)
	window.location.href = location.pathname + existingURL + "&" + MyQuery;
else
	window.location.href = location.pathname + "?" + MyQuery;
}

function WeightQuiz_ResetQuiz() {
var currQueryString = "";
var newQueryString = "";

currQueryString = location.search.substring(1);
var tmpArray = currQueryString.split("&");	//get the paird querysting parameters.
for(x = 0; x < tmpArray.length; x++)
{
	if(tmpArray[x].indexOf("CustomAnswers") < 0) {	  //if you dont find it, append to the newQuerystring
		newQueryString += tmpArray[x] + "&";
	}		
}

if (newQueryString.length > 0) {
	newQueryString = "?" + newQueryString.substring(0, newQueryString.length-1);	
	window.location.href = location.pathname + newQueryString;
}
else
	window.location.href = location.pathname;

}

function WeightQuiz_calculate(QuizName, UserAnswers) {
var questionCount = 0.0;
var correctCount = 0.0;
var NODE_TYPE_ELEMENT = 1;
var NODE_TYPE_TEXT = 3;

var QuizDiv = document.getElementById(QuizName);

document.getElementById(QuizDiv.id + "_submit").style.display = "none";
document.getElementById(QuizDiv.id + "_reset").style.display = "";

var QuizNodes = QuizDiv.childNodes;
for(x=0;x<QuizNodes.length;x++)
{
	var currentNode = QuizNodes[x];
	if(currentNode.nodeType == NODE_TYPE_ELEMENT && currentNode.id.indexOf(QuizDiv.id + "_q") == 0)
	{
		var QuestionDiv = currentNode;

		var ChoicesDiv = document.getElementById(QuestionDiv.id + "a");
		var NoAnswerSpan = document.getElementById(QuestionDiv.id + "aNoAnswer");
		var YourAnswerSpan = document.getElementById(QuestionDiv.id + "aText");
		var CorrectAnswerSpan = document.getElementById(QuestionDiv.id + "aRightAnswer");
		var ExplainSpan = document.getElementById(QuestionDiv.id + "Exp");
		questionCount++;

		NoAnswerSpan.style.display = ""; // Assume they didn't answer the question.
		ExplainSpan.style.display = "";
		CorrectAnswerSpan.style.display = "";
		
		// now look at each radio button.
		var ChoicesNodes = ChoicesDiv.getElementsByTagName("input");
		
		var YourAnswer;
		var YourAnswerTextId;
		var CorrectAnserTextId;
		var ChoicesElement;
		for(ct=0;ct<ChoicesNodes.length;ct++)
		{
			ChoicesElement = ChoicesNodes[ct];
			
			for(var i = 0; i < UserAnswers.length; i++) {
				//loop through the querystring and see if it matches the current ChoicesElement
				var currAnswer = QuizName + "_" + UserAnswers[i];
				if(ChoicesElement.id == currAnswer) {
					
					var RightWrongClass = "Wrong";
					
					YourAnswer = ChoicesElement;
					NoAnswerSpan.style.display = "none"; // they did answer this question.
					YourAnswerSpan.style.display = "";
					YourAnswerTextId = YourAnswer.id;
					if(YourAnswerTextId.indexOf("_c") > 0)
					{
						correctCount ++;
						RightWrongClass = "Right";
						YourAnswerTextId = YourAnswerTextId.replace("_c","") + "Text";
					}
					else
					{
						YourAnswerTextId = YourAnswerTextId + "Text";
					}
					
					var YourAnswerText = document.getElementById(YourAnswerTextId);
					var s = document.createElement("span");
					s.className = YourAnswerText.className + " " + RightWrongClass;
					s.innerHTML = YourAnswerText.innerHTML;
					YourAnswerSpan.appendChild(s);
					YourAnswerSpan.innerHTML += ". ";
					YourAnswerSpan.className += " " + RightWrongClass;
					
				}
				
			}	
				
				if(ChoicesElement.id.indexOf("_c") > 0)
				{
					CorrectAnswerTextId = ChoicesElement.id.replace("_c","") + "Text";
					var CorrectAnswerText = document.getElementById(CorrectAnswerTextId);
					CorrectAnswerSpan.appendChild(CorrectAnswerText);
					CorrectAnswerSpan.innerHTML += ". ";
				}			
							
		}
		// Now go find the text of the option they chose plus the correct answer and display them.
		ChoicesDiv.style.display = "none";
	}
	//Clear all "local" variables before iterating the loop.
	currentNode = null;
	QuestionDiv = null;
	ChoicesDiv = null;
	NoAnswerSpan = null;
	YourAnswerSpan = null;
	CorrectAnswerSpan = null;
	ExplainSpan = null;
	ChoicesNodes = null;
	YourAnswer = null;
	YourAnswerTextId = null;
	CorrectAnserTextId = null;
	ChoicesElement = null;
	YourAnswerText = null;
	CorrectAnswerText = null;
}
var Score = document.getElementById(QuizDiv.id + "_score");
Score.style.display = "";
Score.innerHTML += Math.round((correctCount / (questionCount/100))) + "%";
}
