<!--
function updatePollAnswer(Qtype,Qval)
{
	//updates the hidden answer field with the value from the questio type
	switch(Qtype)
	{
		case "MC":
			//the answer is the Qval
			var ans = document.getElementById("Answer")
			ans.value = Qval;
			//alert(ans.value);
			break;
		case "KT":
			//the answer must be calculated by the selected answers
			var F1 = document.getElementById("Foil1cb");
			var F2 = document.getElementById("Foil2cb");
			var F3 = document.getElementById("Foil3cb");
			var F4 = document.getElementById("Foil4cb");

			var ans = document.getElementById("Answer");
			var anslst = document.getElementById("AnswerList");
			var pollbtn = document.getElementById("PollSubmit");
			//in invalid selection, inactivate the NextQuestionButton
			
			switch(anslst.options[anslst.selectedIndex].value)
			{
				case "7"://valid 1,2,3 selected
					ans.value = "7";
					F1.checked = true;
					F2.checked = true;
					F3.checked = true;
					F4.checked = false;
					pollbtn.disabled = false;
					break;
				case "5"://valid 1,3 selected
					ans.value = "5";
					F1.checked = true;
					F2.checked = false;
					F3.checked = true;
					F4.checked = false;
					pollbtn.disabled = false;
					break;
				case "10"://valid 2,4 selected
					ans.value = "10";
					F1.checked = false;
					F2.checked = true;
					F3.checked = false;
					F4.checked = true;
					pollbtn.disabled = false;
				break;
				case "8"://valid 4 selected
					ans.value = "8";
					F1.checked = false;
					F2.checked = false;
					F3.checked = false;
					F4.checked = true;
					pollbtn.disabled = false;
					break;
				case "15": //valid (ALL selected)
					ans.value = "15";
					F1.checked = true;
					F2.checked = true;
					F3.checked = true;
					F4.checked = true;
					pollbtn.disabled = false;
				break;
			}
			break;
		case "TF":
			//the answer is the Qval
			var ans = document.getElementById("Answer")
			ans.value = Qval;
			//alert(ans.value);
			break;
		case "YN":
			//the answer is the Qval
			var ans = document.getElementById("Answer")
			ans.value = Qval;
			//alert(ans.value);
			break;
	}

}
function getNextPollQuestion(PollID,NextQNum,MMFid)
{
	//ajaxes the next question number 
	//first get the answer value (a hidden field)
	var ans = document.getElementById("Answer");
	//save the current question data
	if(ans.value != "")
	{		
		var url = "/phpajax/poll_next_question.php?PollID=" + PollID + "&&NextQuestionNum=" + NextQNum + "&&Answer=" + ans.value + "&&MMFid=" + MMFid;
		getXML(url,"TakeAPoll");
	}else
	{
		self.status = "Please select a poll foil!";
		alert("Please select a poll foil!");
	}
}

function updatePollAnswerList(Qtype,Qval)
{
	//updates the poll answer list after foils selected
	
	var F1 = document.getElementById("Foil1cb");
	var F2 = document.getElementById("Foil2cb");
	var F3 = document.getElementById("Foil3cb");
	var F4 = document.getElementById("Foil4cb");
	//calc the total
	var total = 0;
	if(F1.checked){total = total + parseInt(F1.value);}
	if(F2.checked){total = total + parseInt(F2.value);}
	if(F3.checked){total = total + parseInt(F3.value);}
	if(F4.checked){total = total + parseInt(F4.value);}

	var ans = document.getElementById("Answer");
	var anslst = document.getElementById("AnswerList");
	var pollbtn = document.getElementById("PollSubmit");
	//in invalid selection, inactivate the NextQuestionButton

	switch(total)
	{
		case 0://valid None selected
		case 1://not valid - 1 Selected
		case 2://not valid - 2 selected
		case 3://not valid - 3 selected
		case 4://not valid - 4 selected
		case 6://not valid 2,3 selected
		case 9://Not valid 1,4 selected
		case 11://not valid A+B+D selected
		case 12://not valid C+D selected
		case 13://not valid A+C+D selected
		case 14://not valid B+C+D selected
			pollbtn.disabled = true;
			ans.value = "0";
			anslst.options[anslst.selectedIndex].value = "";
			anslst.options[anslst.selectedIndex].text = "Select a K-Type Answer";
			self.status = "Please select a K-Type Answer.";
			break;
		//values below are all valid selections
		case 7://valid 1,2,3 selected
			ans.value = "7";
			anslst.options[anslst.selectedIndex].value = "7";
			anslst.options[anslst.selectedIndex].text = "A (1,2 & 3 True)";
			pollbtn.disabled = false;
			self.status = "This is a compatible K-Type Answer.";
			break;
		case 5://valid 1,3 selected
			ans.value = "5";
			anslst.options[anslst.selectedIndex].value = "5";
			anslst.options[anslst.selectedIndex].text = "B (1 & 3 True)";
			pollbtn.disabled = false;
			self.status = "This is a compatible K-Type Answer.";
			break;
		case 10://valid 2,4 selected
			ans.value = "10";
			anslst.options[anslst.selectedIndex].value = "10";
			anslst.options[anslst.selectedIndex].text = "C (2 & 4 True)";
			pollbtn.disabled = false;
			self.status = "This is a compatible K-Type Answer.";
			break;
		case 8://valid 4 selected
			ans.value = "8";
			anslst.options[anslst.selectedIndex].value = "8";
			anslst.options[anslst.selectedIndex].text = "D (4 True)";
			pollbtn.disabled = false;
			self.status = "This is a compatible K-Type Answer.";
			break;
		case 15: //valid (ALL selected)
			ans.value = "15";
			anslst.options[anslst.selectedIndex].value = "15";
			anslst.options[anslst.selectedIndex].text = "E (All True)";
			pollbtn.disabled = false;
			self.status = "This is a compatible K-Type Answer.";
			break;
	}
}
function getPollResults(PollID,NextQuestNum)
{
	var ans = document.getElementById("Answer");
	var QuestNum = parseInt(NextQuestNum) - 1;
	//save the current question data
	if(ans.value != "")
	{
		var url = "/phpscripts/poll_answer.php?PollID=" + PollID + "&NextQuestionNum=" + NextQuestNum + "&Answer=" + ans.value;
		//setTimeout(self.status="getting poll results",5000);
		//alert(url);
		getXMLtxt(url);
		//can't return a result from the AJAX so I put it on the status bar, a function inside a function cannot return a variable
		//*****************************************************************************************************
		//**********need to work on this later to return a result if the answer was added!!!!******************
		//*****************************************************************************************************
		//if(!result){alert("The poll question failed to be saved.");}
		//following serves up the next question
		QuestNum = "1";
		var url = "/phpajax/display_poll.php?PollID=" + PollID + "&QuestionNum=" + QuestNum;
		//alert (url);
		getXML(url,"TakeAPoll");
	}else
	{
		self.status = "Please selecte an answer!";
		alert("Please select an answer.");
	}
}

function displayPollResults(PollID,QuestNum)
{
	var url = "/phpajax/display_poll.php?PollID=" + PollID + "&QuestionNum=" + QuestNum;
	//alert (url);
	getXML(url,"TakeAPoll");
}












-->