/**
 * @author vhaannjonesj1
 * 
 * Class to populate and process the H1N1 Questionnaire
 */
var myAlertPanel = "";
var selfAdministered = true;//(window.location.href == "http://vhaann47279.v11.med.va.gov/H1N1/index.html#self") ? true : false;
var theSubject = "";
var theSubjectPossessive = "";

medora.utilities.eraseCookie("InitFactorCount");

medora.utilities.addLoadListener(function()
{ 
	if ($get("SubmitAge")) medora.utilities.addEvent($get("SubmitAge"),"click",medora.poppies.h1n1.Handle_H1N1_1);
	if ($get("SubmitSelfChildTemp")) medora.utilities.addEvent($get("SubmitSelfChildTemp"),"click",medora.poppies.h1n1.Handle_Guard_Child_Q1);
	if ($get("SubmitChildTemp")) medora.utilities.addEvent($get("SubmitChildTemp"),"click",medora.poppies.h1n1.Handle_Guard_Child_Q1a);
	if ($get("SubmitChildFeverish")) medora.utilities.addEvent($get("SubmitChildFeverish"),"click",medora.poppies.h1n1.Handle_Guard_Child_Q1b);
	if ($get("SubmitChildSoreThroat")) medora.utilities.addEvent($get("SubmitChildSoreThroat"),"click",medora.poppies.h1n1.Handle_Guard_Child_Q2);
	if ($get("ChildSeverityButton")) medora.utilities.addEvent($get("ChildSeverityButton"),"click",medora.poppies.h1n1.Handle_Guard_Child_SA);
	if ($get("ChildSeverity2Button")) medora.utilities.addEvent($get("ChildSeverity2Button"),"click",medora.poppies.h1n1.Handle_Guard_Child_SA2);
	if ($get("ChildCoMorbidityButton")) medora.utilities.addEvent($get("ChildCoMorbidityButton"),"click",medora.poppies.h1n1.Handle_Guard_Child_CoMorb);
	if ($get("SubmitOlderChild_Adult_WU_Temp")) medora.utilities.addEvent($get("SubmitOlderChild_Adult_WU_Temp"),"click",medora.poppies.h1n1.Handle_OlderChild_Adult_WU_Q1);
	if ($get("SubmitOlderChild_Adult_WU_Q1a")) medora.utilities.addEvent($get("SubmitOlderChild_Adult_WU_Q1a"),"click",medora.poppies.h1n1.Handle_OlderChild_Adult_WU_Q1a);			
	if ($get("SubmitOlderChild_Adult_WU_Q1b")) medora.utilities.addEvent($get("SubmitOlderChild_Adult_WU_Q1b"),"click",medora.poppies.h1n1.Handle_OlderChild_Adult_WU_Q1b);
	if ($get("SubmitSoreThroat")) medora.utilities.addEvent($get("SubmitSoreThroat"),"click",medora.poppies.h1n1.Handle_OlderChild_Adult_Q2);
	if ($get("Submit_OlderChild_Adult_SA")) medora.utilities.addEvent($get("Submit_OlderChild_Adult_SA"),"click",medora.poppies.h1n1.Handle_OlderChild_Adult_SA);
	if ($get("Submit_OlderChild_Adult_WA_CoMorb")) medora.utilities.addEvent($get("Submit_OlderChild_Adult_WA_CoMorb"),"click",medora.poppies.h1n1.Handle_OlderChild_Adult_WA_CoMorb);
	if ($get("self")) medora.utilities.addEvent($get("self"),"click",medora.poppies.h1n1.SetSelfTrack);	
	if ($get("child")) medora.utilities.addEvent($get("child"),"click",medora.poppies.h1n1.SetChildTrack);	
	if ($get("thirdperson")) medora.utilities.addEvent($get("thirdperson"),"click",medora.poppies.h1n1.SetThirdPartyTrack);	
});


if (typeof medora == 'undefined')
{
	Type.registerNamespace('medora');
}
if (typeof medora.poppies == 'undefined')
{
	Type.registerNamespace('medora.poppies');
}
if (typeof medora.poppies.h1n1 == 'undefined')
{
	medora.poppies.h1n1=function() 
	{ 
		medora.poppies.lookup.initializeBase(this);
	}
}

medora.poppies.h1n1.SetSelfTrack = function()
{
	$get("introMenu").className += " hidden";
	medora.poppies.h1n1.SetTagText("you","your","Are","Do","Have","you");
	$get("OlderChild_Adult_WU_Q1").className = $get("OlderChild_Adult_WU_Q1").className.replace(" hidden","");
}

medora.poppies.h1n1.SetChildTrack = function()
{
	$get("introMenu").className += " hidden";
	$get("Guard_Child_Q1").className = $get("Guard_Child_Q1").className.replace(" hidden","");
}

medora.poppies.h1n1.SetThirdPartyTrack = function()
{
	$get("introMenu").className += " hidden";
	medora.poppies.h1n1.SetTagText("the patient","the patient's","Is","Does","Has","He/she");
	$get("OlderChild_Adult_WU_Q1").className = $get("OlderChild_Adult_WU_Q1").className.replace(" hidden","");
}
medora.poppies.h1n1.SetTagText = function(val1,val2,val3,val4,val5,val6)
{
	var nodeList = document.getElementsByTagName("span");
	for (var i=0;i<nodeList.length;i++)
	{
		if (nodeList[i].className == "subjectpossessive")
		{
			nodeList[i].innerHTML = val2;
		}
		else if (nodeList[i].className.substr(0,9) == "subjecttp")
		{
			nodeList[i].innerHTML = val6;
		}	
		else if (nodeList[i].className.substr(0,7) == "subject")
		{
			nodeList[i].innerHTML = val1;
		}
		else if (nodeList[i].className.substr(0,9) == "beingverb")
		{
			nodeList[i].innerHTML = val3;
		}
		else if (nodeList[i].className == "doingverb")
		{
			nodeList[i].innerHTML = val4;
		}
		else if (nodeList[i].className.substr(0,8) == "possVerb")
		{
			nodeList[i].innerHTML = val5;
		}	
	}
}
medora.poppies.h1n1.WriteNoun = function(val)
{
	if (val == "possessive") 
	{
		document.write($get("subjectPossessive").value)
	}
	else
	{
		document.write($get("subject").value)
	}
}
medora.poppies.h1n1.Handle_H1N1_1 = function() 
{
	var ageRangeForm = $get("H1N1_1");
	var age = "";

	var checked = false;
	
	for (var i=0;i<ageRangeForm.AgeRange.length;i++)
	{
		if (ageRangeForm.AgeRange[i].checked)
		{
			checked = true;
			if (ageRangeForm.AgeRange[i].value == "Under11")
			{
				//Show the guardian-administered Child Questions.
				//var childGuardianQuestions = questionSet.questionnaires.questionnaires[0].sections.sections.pages.pages.sections.subsections;
				$get("H1N1_1").className += " hidden";
				$get("Guard_Child_Q1").className = $get("Guard_Child_Q1").className.replace(" hidden","");

			}
			else
			{

				//Create the self-administered Adult Questions.");
				if ($get("H1N1_1").className.indexOf("hidden")< 0) $get("H1N1_1").className += " hidden";
				$get("OlderChild_Adult_WU_Q1").className = $get("OlderChild_Adult_WU_Q1").className.replace(" hidden","");

			}
		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}

}

medora.poppies.h1n1.Handle_Guard_Child_Q1 = function()
{
	var selfChildTempForm = $get("Guard_Child_Q1");
	var checked = false;
	
	for (var i=0;i<selfChildTempForm.SelfChildTemp.length;i++)
	{
		if (selfChildTempForm.SelfChildTemp[i].checked)
		{
			checked = true;
			if (selfChildTempForm.SelfChildTemp[i].value == "Yes")
			{
				medora.poppies.h1n1.Show_Guard_Child_Q1a();
			}
			else
			{
				medora.poppies.h1n1.Show_Guard_Child_Q1b();
			}
		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}
}

medora.poppies.h1n1.Show_Guard_Child_Q1a = function()
{
	if ($get("Guard_Child_Q1").className.indexOf("hidden")< 0) $get("Guard_Child_Q1").className += " hidden";
	$get("Guard_Child_Q1a").className = $get("Guard_Child_Q1a").className.replace(" hidden","");
	if ($get("Guard_Child_Q1b").className.indexOf("hidden")< 0) $get("Guard_Child_Q1b").className += " hidden";
}

medora.poppies.h1n1.Handle_Guard_Child_Q1a = function()
{
	var childTempForm = $get("Guard_Child_Q1a");
	var checked = false;
	
	for (var i = 0; i < childTempForm.childTemp.length; i++) 
	{
		if (childTempForm.childTemp[i].checked != "") 
		{
			checked = true;
			if (childTempForm.childTemp[i].value == "MoreThan100_2") medora.utilities.createCookie("InitFactorCount", "1");
			//Now go to sore throat check
			medora.poppies.h1n1.Show_Guard_Child_Q2();
		}
	}
	if (!checked) 
	{
		alert("Please select child's temperature range.");
		return false;
	}
}
medora.poppies.h1n1.Show_Guard_Child_Q1b = function()
{
	$get("Guard_Child_Q1").className += " hidden";
	$get("Guard_Child_Q1b").className = $get("Guard_Child_Q1b").className.replace(" hidden","");
}
medora.poppies.h1n1.Handle_Guard_Child_Q1b = function()
{
	var ChildIsFeverishForm = $get("Guard_Child_Q1b");
	var checked = false;
	
	for (var i=0;i<ChildIsFeverishForm.ChildIsFeverish.length;i++)
	{
		if (ChildIsFeverishForm.ChildIsFeverish[i].checked)
		{
			checked = true;
			if (ChildIsFeverishForm.ChildIsFeverish[i].value == "Yes")
			{
				medora.utilities.createCookie("InitFactorCount","1")
				medora.poppies.h1n1.Show_Guard_Child_Q2();
			}
			else
			{
				medora.poppies.h1n1.Show_Guard_Child_Q2();
			}
		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}
}
medora.poppies.h1n1.Show_Guard_Child_Q2 = function()
{
	//Sore Throat Check
	if ($get("Guard_Child_Q1a").className.indexOf("hidden")< 0) $get("Guard_Child_Q1a").className += " hidden";
	if ($get("Guard_Child_Q1b").className.indexOf("hidden")< 0) $get("Guard_Child_Q1b").className += " hidden";
	$get("Guard_Child_Q2").className = $get("Guard_Child_Q2").className.replace(" hidden","");
}
medora.poppies.h1n1.Handle_Guard_Child_Q2 = function()
{
	var Guard_Child_Q2 = $get("Guard_Child_Q2");
	var checked = false;
	
	for (var i=0;i<Guard_Child_Q2.ChildSoreThroat.length;i++)
	{
		if (Guard_Child_Q2.ChildSoreThroat[i].checked)
		{
			checked = true;
			if (Guard_Child_Q2.ChildSoreThroat[i].value == "Yes")
			{
				var initFactorCount = medora.utilities.readCookie("InitFactorCount");
				initFactorCount++;
				medora.utilities.createCookie("InitFactorCount",initFactorCount)
				if (initFactorCount > 1) 
				{
					medora.poppies.h1n1.Show_Guard_Child_SA();
					return;
				}
			}
		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}
	myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin","","<div class=\"alignLeft\"><h2 class='blue center'>Not A Likely Candidate</h2><p>Based on the answers to these questions, the child does not have symptoms that suggest a need for urgent medical attention. If the child&#39;s symptoms change or if you remain concerned, please talk to your child&#39;s healthcare provider.</p></div><br clear='both'><div class=\"center\"><img src='images/no-risk.gif' width='100' height='100' border='0' alt=\"No Risk Icon\" /><br /><a href=\"http://www1.va.gov/vhapublications/ViewPublication.asp?pub_ID=1966\">Home Care and Preventing Spread</a><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>","","");
	myAlertPanel.show();
	window.location.hash = "#top";
	if ($get("Guard_Child_Q2").className.indexOf("hidden")< 0) $get("Guard_Child_Q2").className += " hidden";
	medora.poppies.h1n1.ClearCookieSetCookieComplete();
}

medora.poppies.h1n1.Show_Guard_Child_SA = function()
{
	if ($get("Guard_Child_Q2").className.indexOf("hidden")< 0) $get("Guard_Child_Q2").className += " hidden";
	$get("Guard_Child_SA").className = $get("Guard_Child_SA").className.replace(" hidden","");
}

medora.poppies.h1n1.Handle_Guard_Child_SA = function()
{
	var result = medora.poppies.h1n1.CheckYesNoFields("Guard_Child_SA",8,"","");
	if (result > 0) document.SavedValues.outcome.value = "childhigh";
	if (result < 0) return;
	medora.poppies.h1n1.Show_Guard_Child_SA2();
}

medora.poppies.h1n1.Show_Guard_Child_SA2 = function()
{
	if ($get("Guard_Child_SA").className.indexOf("hidden")< 0) $get("Guard_Child_SA").className += " hidden";
	$get("Guard_Child_SA2").className = $get("Guard_Child_SA2").className.replace(" hidden","");
}

medora.poppies.h1n1.Handle_Guard_Child_SA2 = function()
{
	var result = medora.poppies.h1n1.CheckYesNoFields("Guard_Child_SA2",3,"","");
	if (result > 0 && document.SavedValues.outcome.value == "") document.SavedValues.outcome.value = "childintermediate";
	if (result < 0) return;
	medora.poppies.h1n1.Show_Guard_Child_CoMorb();
}

medora.poppies.h1n1.Show_Guard_Child_CoMorb = function()
{
	if ($get("Guard_Child_SA2").className.indexOf("hidden")< 0) $get("Guard_Child_SA2").className += " hidden";
	$get("Guard_Child_CoMorb").className = $get("Guard_Child_CoMorb").className.replace(" hidden","");
}

medora.poppies.h1n1.Handle_Guard_Child_CoMorb = function()
{
	var result = medora.poppies.h1n1.CheckCheckBoxFields("Guard_Child_CoMorb",7,"","");
	
	//Code to save results to DB, including Co-Morbs, will go here.
	//-------------------
	if (document.SavedValues.outcome.value != "") 
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", medora.poppies.h1n1.GetModalWindowContent(document.SavedValues.outcome.value), "300", "450");
	}
	else if (result > 0)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", medora.poppies.h1n1.GetModalWindowContent("childintermediate"), "350", "400");	
	}
	else if (result <= 0) myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin","",medora.poppies.h1n1.GetModalWindowContent("childlow"),"","");
	if ($get("Guard_Child_CoMorb").className.indexOf("hidden")< 0) $get("Guard_Child_CoMorb").className += " hidden";
	window.location.hash = "#top";
	medora.poppies.h1n1.ClearCookieSetCookieComplete();	
	myAlertPanel.show();
	
}

//Older Child/Adult Walk-up section

medora.poppies.h1n1.Handle_OlderChild_Adult_WU_Q1 = function()
{

	var OlderChild_Adult_WU_Q1 = $get("OlderChild_Adult_WU_Q1");
	var checked = false;
	
	for (var i=0;i<OlderChild_Adult_WU_Q1.OlderChild_Adult_WU_Temp.length;i++)
	{
		if (OlderChild_Adult_WU_Q1.OlderChild_Adult_WU_Temp[i].checked)
		{
			checked = true;
			if (OlderChild_Adult_WU_Q1.OlderChild_Adult_WU_Temp[i].value == "Yes")
			{
				medora.poppies.h1n1.Show_OlderChild_Adult_WU_Q1a();
			}
			else
			{
				medora.poppies.h1n1.Show_OlderChild_Adult_WU_Q1b();
			}
		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}
}

medora.poppies.h1n1.Show_OlderChild_Adult_WU_Q1a = function()
{
	if ($get("OlderChild_Adult_WU_Q1").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q1").className += " hidden";
	if ($get("OlderChild_Adult_WU_Q1b").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q1b").className += " hidden";
	$get("OlderChild_Adult_WU_Q1a").className = $get("OlderChild_Adult_WU_Q1a").className.replace(" hidden","");
}
medora.poppies.h1n1.Show_OlderChild_Adult_WU_Q1b = function()
{
	if ($get("OlderChild_Adult_WU_Q1").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q1").className += " hidden";
	$get("OlderChild_Adult_WU_Q1b").className = $get("OlderChild_Adult_WU_Q1b").className.replace(" hidden","");
}

medora.poppies.h1n1.Handle_OlderChild_Adult_WU_Q1a = function()
{
	var adultTempForm = $get("OlderChild_Adult_WU_Q1a");
	var checked = false;
	
	for (var i = 0; i < adultTempForm.adultTemp.length; i++) 
	{
		if (adultTempForm.adultTemp[i].checked != "") 
		{
			checked = true;
			if (adultTempForm.adultTemp[i].value == "MoreThan100_2") medora.utilities.createCookie("InitFactorCount", "1");
			//Now go to sore throat check
			medora.poppies.h1n1.Show_OlderChild_Adult_Q2();
		}
	}
	if (!checked) 
	{
		alert("Please select " + theSubject + " temperature range.");
		return false;
	}
}

medora.poppies.h1n1.Handle_OlderChild_Adult_WU_Q1b = function()
{
	var OlderChild_Adult_WU_Q1b = $get("OlderChild_Adult_WU_Q1b");
	var checked = false;
	
	for (var i=0;i<OlderChild_Adult_WU_Q1b.AreYouFeverish.length;i++)
	{
		if (OlderChild_Adult_WU_Q1b.AreYouFeverish[i].checked)
		{
			checked = true;
			if (OlderChild_Adult_WU_Q1b.AreYouFeverish[i].value == "Yes")
			{
				medora.utilities.createCookie("InitFactorCount","1")
				//Now go to sore throat check
				medora.poppies.h1n1.Show_OlderChild_Adult_Q2();
			}
			else
			{
				//Now go to sore throat check
				medora.poppies.h1n1.Show_OlderChild_Adult_Q2();
			}
		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}
}
//Sore Throat Check
medora.poppies.h1n1.Show_OlderChild_Adult_Q2 = function()
{
	if ($get("OlderChild_Adult_WU_Q1a").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q1a").className += " hidden";
	if ($get("OlderChild_Adult_WU_Q1b").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q1b").className += " hidden";	
	$get("OlderChild_Adult_WU_Q2").className = $get("OlderChild_Adult_WU_Q2").className.replace(" hidden","");
}

medora.poppies.h1n1.Handle_OlderChild_Adult_Q2 = function()
{	
	var OlderChild_Adult_WU_Q2 = $get("OlderChild_Adult_WU_Q2");
	var checked = false;
	
	for (var i=0;i<OlderChild_Adult_WU_Q2.HaveSoreThroat.length;i++)
	{
		if (OlderChild_Adult_WU_Q2.HaveSoreThroat[i].checked)
		{
			checked = true;
			if (OlderChild_Adult_WU_Q2.HaveSoreThroat[i].value == "Yes")
			{
				var initFactorCount = medora.utilities.readCookie("InitFactorCount");
				initFactorCount++;
				medora.utilities.createCookie("InitFactorCount",initFactorCount)
				if (initFactorCount > 1) 
				{
					medora.poppies.h1n1.Show_OlderChild_Adult_SA();
					return;
				}

			}

		}		
	}
	if (!checked)
	{
			alert("You must provide an answer to continue.");
			return false;
	}
	if ($get("OlderChild_Adult_WU_Q2").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q2").className += " hidden";
	myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin","","<div class=\"alignLeft\"><h2 class='blue center'>Not A Likely Candidate</h2><p>It is unlikely that you have H1N1 Flu, based on your answers.</p></div><br clear='both'><div class=\"center\"><img src='images/no-risk.gif' width='100' height='100' border='0' alt=\"No Risk Icon\" /><br /><a href=\"http://www1.va.gov/vhapublications/ViewPublication.asp?pub_ID=1966\">Home Care and Preventing Spread</a><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>","","");
	myAlertPanel.show();
	window.location.hash = "#top";
}

medora.poppies.h1n1.Show_OlderChild_Adult_SA = function()
{
	if ($get("OlderChild_Adult_WU_Q2").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WU_Q2").className += " hidden";
	$get("OlderChild_Adult_SA").className = $get("OlderChild_Adult_SA").className.replace(" hidden","");	
}

medora.poppies.h1n1.Handle_OlderChild_Adult_SA = function()
{
	var result = medora.poppies.h1n1.CheckYesNoFields("OlderChild_Adult_SA",9,"","");
	if (result > 0) document.SavedValues.outcome.value = "high";
	if (result < 0) return;
	medora.poppies.h1n1.Show_OlderChild_Adult_WA_CoMorb();
}


medora.poppies.h1n1.Show_OlderChild_Adult_WA_CoMorb = function()
{
	if ($get("OlderChild_Adult_SA").className.indexOf("hidden")< 0) $get("OlderChild_Adult_SA").className += " hidden";
	$get("OlderChild_Adult_WA_CoMorb").className = $get("OlderChild_Adult_WA_CoMorb").className.replace(" hidden","");		
}

medora.poppies.h1n1.Handle_OlderChild_Adult_WA_CoMorb = function()
{
	var result = medora.poppies.h1n1.CheckCheckBoxFields("OlderChild_Adult_WA_CoMorb",16,"","");
	
 	//Code to save all responses, including Co-Morbs.
	// ------
	//
	
	if (document.SavedValues.outcome.value != "") 
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", medora.poppies.h1n1.GetModalWindowContent(document.SavedValues.outcome.value), "300", "450");
	}
	else if (result > 0)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin","",medora.poppies.h1n1.GetModalWindowContent("intermediate"),"320","450");
	}
	else if (result <= 0)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin","",medora.poppies.h1n1.GetModalWindowContent("low"),"","");
	}
	if ($get("OlderChild_Adult_WA_CoMorb").className.indexOf("hidden")< 0) $get("OlderChild_Adult_WA_CoMorb").className += " hidden";		
	window.location.hash= "#top";
	medora.poppies.h1n1.ClearCookieSetCookieComplete();
	myAlertPanel.show();	
}




//Utility methods /////////////////////////////////////
//Refresh application (clears cookies, puts app back at starting point)
medora.poppies.h1n1.RefreshApp = function()
{
	myAlertPanel.hide();
	location.href= "end.html";
}

medora.poppies.h1n1.ClearCookieSetCookieComplete = function()
{
	medora.utilities.eraseCookie("InitFactorCount");
	medora.utilities.createCookie("taken", "true");
}

medora.poppies.h1n1.CheckCheckBoxFields = function(fieldName,numberOfFields,modalMessage,yesLmt)
{
	var yeses = 0;
	var nos = 0;
	var yesLimit = (yesLmt != "") ? yesLmt : 1;
	var theField = "";
		
	for (var i=1;i<numberOfFields+1;i++)
	{
		theField = eval("document." + fieldName + "." + fieldName + "_" + i)

		if (theField.checked)
		{
			yeses++
		}
		else
		{
			nos++;
		}
	}	
	
	if (modalMessage == "") return yeses;
	
	if (yeses >= yesLimit)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", modalMessage, "300", "200");
		myAlertPanel.show();
	}
	else if (yeses > 0 && yeses < yesLimit)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", medora.poppies.h1n1.GetModalWindowContent("intermediate"), "300", "200");
		myAlertPanel.show();	
	}
	return yeses;
	
}

medora.poppies.h1n1.CheckYesNoFields = function(fieldName,numberOfFields,modalMessage,yesLmt)
{
	var yeses = 0;
	var nos = 0;
	var yesLimit = (yesLmt != "") ? yesLmt : 0;
	var theField = "";
		
	for (var i=1;i<numberOfFields+1;i++)
	{
		theField = eval("document." + fieldName + "." + fieldName + "_" + i)
		var checked = false;
		for (var j=0;j<theField.length;j++)
		{
			if (theField[j].checked)
			{
				if (theField[j].value == "Yes")
				{
					yeses++
					checked = true;
				}
				else if (theField[j].value == "No")
				{
					nos++;
					checked = true;
				}
			}
			else if (j>0 && !checked)
			{
				alert("You must provide an answer to continue.");
				theField[j].focus();
				return -1;
			}		
		}
	}	

	if (modalMessage == "") return yeses;
	
	if (yeses >= yesLimit && yeses != 0)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", modalMessage, "300", "200");
		myAlertPanel.show();
	}
	if (yeses > 0 && yeses < yesLimit)
	{
		myAlertPanel = medora.poppies.utilities.CreateModalWindow("myWin", "", medora.poppies.h1n1.GetModalWindowContent("intermediate"), "300", "200");
		myAlertPanel.show();	
	}
	return yeses;
	
}

medora.poppies.h1n1.GetModalWindowContent = function(windowType)
{
	if (windowType == "high") return "<div class=\"alignLeft\"><h2 class='red center'>HIGH RISK</h2><p>Recommend you (or patient) immediately seek care in an Emergency Department. Antiviral treatment should follow CDC guidelines. You are advised to contact your VA facility as soon as possible. <br /><br />Please note: If you are seen in a non-VA Emergency Department contact your VA facility as soon as possible to determine if VA will authorize treatment in the non-VA facility.</p></div><div class=\"center\"><img src='images/warning.gif' width='100' height='100' border='0' alt=\"Warning Icon\" /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>";	
	if (windowType == "childhigh") return "<div class=\"alignLeft\"><h2 class='red center'>HIGH RISK</h2><p>We recommend that you immediately contact your child&#39;s healthcare provider or take your child to an Emergency Department.</p></div><div class=\"center\"><img src='images/warning.gif' width='100' height='100' border='0' align='center' alt=\"Warning Icon\" /><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>";
	
	if (windowType == "intermediate" ) return "<div class=\"alignLeft\"><h2 class='red center'>INTERMEDIATE RISK</h2><p>Recommend person contact their primary care MD or seek care in clinic. <br>Antiviral treatment should follow CDC guidelines. Please note: If you are seen in a non-VA Emergency Department contact your VA facility as soon as possible to determine if VA will authorize treatment in the non-VA facility.</p></div><div class=\"center\"><br clear='both'><img src='images/warning.gif' width='100' height='100' border='0'alt=\"Warning Icon\" /><br /><a href=\"http://www1.va.gov/vhapublications/ViewPublication.asp?pub_ID=1966\">Home Care and Preventing Spread</a><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>";
	if (windowType == "childintermediate" ) return "<div class=\"alignLeft\"><h2 class='red center'>INTERMEDIATE RISK</h2><p>We recommend that you immediately contact your child&#39;s healthcare provider or take your child to an Emergency Department.</p></div><br clear='both'><div class=\"center\"><img src='images/warning.gif' width='100' height='100' border='0' alt=\"Warning Icon\" /><br /><a href=\"http://www1.va.gov/vhapublications/ViewPublication.asp?pub_ID=1966\">Home Care and Preventing Spread</a><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>";
	
	if (windowType == "low") return  "<div class=\"alignLeft\"><h2 class='red center'>LOW RISK</h2><p>OK for individual to receive self-care at home. Repeat self-assessment if condition worsens.</p><br /></div><div class=\"center\"><img src='images/warning-low.gif' width='100' height='100' border='0' alt=\"Warning Icon\" /><br /><a href=\"http://www.cdc.gov/h1n1flu/guidance_homecare.htm\">Link to Self-Care Guide</a><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>";
	if (windowType == "childlow") return  "<div class=\"alignLeft\"><h2 class='red center'>LOW RISK</h2><p>OK for child to receive self-care at home. Repeat self-assessment if condition worsens.</p><br /></div><div class=\"center\"><img src='images/warning-low.gif' width='100' height='100' border='0' alt=\"Warning Icon\" /><br /><a href=\"http://www.cdc.gov/h1n1flu/guidance_homecare.htm\">Link to Self-Care Guide</a><br /><br /><input type='button' id='closeIt' value='Close' onclick='myAlertPanel.hide();medora.poppies.h1n1.RefreshApp()' /></div>";
}
