function submitHHATabForm(sCurrentURL, sNavParam, sAnchor)
{
	document.frmTabs.action = sCurrentURL + '?dest=' + sNavParam + '#' + sAnchor;
	document.frmTabs.submit();
}	

//-------------------------------------------------------------------------------------

function showHideDiv(vsPrefix, vsID, vsText, vsLang)
{
	var vDivId = vsPrefix + vsID;
	var vImageId = "Image-" + vsID;
	var vAId = "A-" + vsID;

	var image01= new Image();
	var image02= new Image();

	image01.src = "/HHCompare/images/plus.gif";
	image02.src = "/HHCompare/images/minus.gif";
		
	var objEl = document.getElementById(vDivId);

	var vShowTxtMsg = "";
	var vHideTxtMsg = "";
	
	switch(vsLang)
	{
		case 'English':
			vShowTxtMsg = "Click to show the " + vsText + ".";
			vHideTxtMsg = "Click to hide the " + vsText + ".";
		break;
		case 'Spanish':
			vShowTxtMsg = "Haga 'clic' para ver " + vsText + ".";
			vHideTxtMsg = "Haga 'clic' para ocultar " + vsText + ".";
		break;
	}

	if (objEl.style.display == "")
	{
		objEl.style.display = "none";
		if (document.getElementById(vImageId) != null)
		{
			document.getElementById(vImageId).src = image01.src;
			document.getElementById(vImageId).title = vShowTxtMsg;
		}
		document.getElementById(vAId).title = vShowTxtMsg;
	}
	else
	{
		objEl.style.display = "";
		if (document.getElementById(vImageId) != null)
		{
			document.getElementById(vImageId).src = image02.src;
			document.getElementById(vImageId).title = vHideTxtMsg;
		}
		document.getElementById(vAId).title = vHideTxtMsg;
	}
}

//-------------------------------------------------------------------------------------

function showAllQMCharts(vsLangID)
{
	var vChart="Chart-"
	var vImage="Image-"
	var vA="A-"
	
	var imgMinus=new Image();
	imgMinus.src="/HHCompare/images/minus.gif"

	var divList = document.getElementsByTagName("div");
		
	if (divList.length > 0) 
	{
		if (document.getElementById("ShowHideAll"))
		{
			if (vsLangID==1)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"hideAllQMCharts(1);\" title=\"Click to hide the graphs for all Quality Measures.\">Hide All</a><br/><br/>"
			}
			if (vsLangID==2)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"hideAllQMCharts(2);\" title=\"Haga 'clic' para ocultar las gráficas de todas las medidas de calidad.\">Ocultar todo</a><br/><br/>"
			}
		}
	}
	
	//Look at each div, and if it corresponds to a QM chart, show it
	for(var i = 0; i < divList.length; i++)
	{
		if (divList[i].id.substring(0,6) == vChart )
		{
			document.getElementById(divList[i].id).style.display="";

			if (document.getElementById(vImage + divList[i].id.substring(6)) != null)
			{
				document.getElementById(vImage + divList[i].id.substring(6)).src = imgMinus.src;
				if (vsLangID==1)
				{
					document.getElementById(vImage + divList[i].id.substring(6)).title = "Click to hide the results for this Quality Measure.";
				}
				if (vsLangID==2)
				{
					document.getElementById(vImage + divList[i].id.substring(6)).title = "Haga 'clic' para ocultar los resultados de esta medida de calidad.";
				}
			}
			if (document.getElementById(vA + divList[i].id.substring(6)) != null)
			{
				if (vsLangID==1)
				{
					document.getElementById(vA + divList[i].id.substring(6)).title = "Click to hide the results for this Quality Measure.";
				}
				if (vsLangID==2)
				{
					document.getElementById(vA + divList[i].id.substring(6)).title = "Haga 'clic' para ocultar los resultados de esta medida de calidad.";
				}
			}
		}
	}
}

//-------------------------------------------------------------------------------------

function hideAllQMCharts(vsLangID)
{
	var vChart="Chart-";
	var vImage="Image-";
	var vA="A-";
	
	var imgPlus=new Image();
	imgPlus.src="/HHCompare/images/plus.gif";

	var divList = document.getElementsByTagName("div");
	
	if (divList.length > 0) 
	{
		if (document.getElementById("ShowHideAll"))
		{
			if (vsLangID==1)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"showAllQMCharts(1);\" title=\"Click to show the graphs for all Quality Measures.\">Show All</a><br/><br/>"
			}
			if (vsLangID==2)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"showAllQMCharts(2);\" title=\"Haga 'clic' para ver las gráficas de todas las medidas de calidad.\">Mostrar todo</a><br/><br/>"
			}
		}
	}

	//Look at each div, and if it corresponds to a QM chart, hide it
	for(var i = 0; i < divList.length; i++)
	{
		if (divList[i].id.substring(0,6) == vChart )
		{
			document.getElementById(divList[i].id).style.display="none";

			if (document.getElementById(vImage + divList[i].id.substring(6)) != null)
			{
				document.getElementById(vImage + divList[i].id.substring(6)).src = imgPlus.src;
				if (vsLangID==1)
				{
					document.getElementById(vImage + divList[i].id.substring(6)).title = "Click to show the results for this Quality Measure.";
				}
				if (vsLangID==2)
				{
					document.getElementById(vImage + divList[i].id.substring(6)).title = "Haga 'clic' para mostrar los resultados de esta medida de calidad.";
				}
			}
			if (document.getElementById(vA + divList[i].id.substring(6)) != null)
			{
				if (vsLangID==1)
				{
					document.getElementById(vA + divList[i].id.substring(6)).title = "Click to show the results for this Quality Measure.";
				}
				if (vsLangID==2)
				{
					document.getElementById(vA + divList[i].id.substring(6)).title = "Haga 'clic' para mostrar los resultados de esta medida de calidad.";
				}
			}
		}
	}
}

//-------------------------------------------------------------------------------------
//This method is called from the Results by Agency to show the bodies
//of all HHA results tables
function showAllHHATables(vsLangID)
{
	var imgMinus=new Image();
	imgMinus.src="/HHCompare/images/minus.gif";

	var tableList = document.getElementsByTagName("table");
		
	if (tableList.length > 0) 
	{
		if (document.getElementById("ShowHideAll"))
		{
			if (vsLangID==1)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"hideAllHHATables(1);\" title=\"Click to hide the results for all Home Health Agencies.\">Hide All</a><br/><br/>";
			}
			if (vsLangID==2)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"hideAllHHATables(2);\" title=\"Haga 'clic' para ocultar los resultados de todas las agencias.\">Ocultar todo</a><br/><br/>";
			}
		}
	}
	
	for(var i = 0; i < tableList.length; i++)
	{
		if (tableList[i].id.substring(0,6) == 'Table-' )
		{
			showHHATableRowsBody(tableList[i].id.substring(6),vsLangID);
		}
	}
}

//-------------------------------------------------------------------------------------
//This method is called from the Results by Agency to hide the bodies
//of all HHA results tables
function hideAllHHATables(vsLangID)
{
	var imgPlus=new Image();
	imgPlus.src="/HHCompare/images/plus.gif";

	var tableList = document.getElementsByTagName("table");

	if (tableList.length > 0) 
	{
		if (document.getElementById("ShowHideAll"))
		{
			if (vsLangID==1)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"showAllHHATables(1);\" title=\"Click to show the results for all Home Health Agencies.\">Show All</a><br/><br/>";
			}
			if (vsLangID==2)
			{
				document.getElementById("ShowHideAll").innerHTML = "<a href=\"javascript:void(0)\" style=\"cursor:pointer;cursor:hand\" language=\"JavaScript\" onclick=\"showAllHHATables(2);\" title=\"Haga 'clic' para ver los resultados de todas las agencias.\">Mostrar todo</a><br/><br/>";
			}
		}
	}

	for(var i = 0; i < tableList.length; i++)
	{
		if (tableList[i].id.substring(0,6) == 'Table-' )
		{
			hideHHATableRowsBody(tableList[i].id.substring(6),vsLangID);
		}
	}
}

//-------------------------------------------------------------------------------------
// This routine provides show/hide functionality for an individual HHA table.
// The div associated with the given table is examined and its current state
// is toggled between show/hide
function showHideHHAResults(vsID, vsLangID)
{
	var vDiv="Div-"

	// Look for the footer that is associated with this table.
	if (document.getElementById(vDiv + vsID) != null)
	{
		// ...and if it is currently hidden...
		if (document.getElementById(vDiv + vsID).style.display == 'none')
		{
			// ...then toggle it so that it will be displayed...
			showHHATableRowsBody(vsID,vsLangID);
		}				
		else
		{
			// The elment is currently being displayed, so toggle it to be hidden...
			hideHHATableRowsBody(vsID,vsLangID);
		}
	} 
}

//-------------------------------------------------------------------------------------
//This routine provides show functionality used to reveal the body of an
//HHA results table.
function showHHATableRowsBody(vsID,vsLangID)
{
	// Some images do not display correctly in certain browsers. To help 
	// alleviate this issue,  the images are pre-loaded...
	var imgMinus=new Image();
	
	var vTableRow="TableRow-";
	var vImage="Image-";
	var vDiv="Div-";
	var vA="A-";
	
	imgMinus.src="/HHCompare/images/minus.gif";

	var trList = document.getElementsByTagName("tr");

	var vHideTxtMsg = "";
	switch(vsLangID)
	{
		case "1":
			vHideTxtMsg = "Click to hide the results for this Agency.";
		break;
		case "2":
			vHideTxtMsg = "Haga 'clic' para ocultar los resultados para esta agencia.";
		break;
	}

	// Look at each table row on the page
	for(var i = 0; i < trList.length; i++)
	{
		// if the TR is a part of the table for the given HHA
		if ( trList[i].id == (vTableRow + vsID) )
		{
			// ...then toggle it so that it will be displayed...
			trList[i].style.display = '';
		}				
	} 

	// ...switch the image to collapse
	if (document.getElementById(vImage + vsID) != null)
	{
		document.getElementById(vImage + vsID).src = imgMinus.src;
		document.getElementById(vImage + vsID).title = vHideTxtMsg;
	}
	
	// ...switch the title on the link
	if (document.getElementById(vA + vsID) != null)
	{
		document.getElementById(vA + vsID).title = vHideTxtMsg;
	} 
				
	// ...reveal the div (footer with footnotes and anchor)
	if (document.getElementById(vDiv + vsID) != null)
	{
		document.getElementById(vDiv + vsID).style.display = '';
	}

	return false;
}

//-------------------------------------------------------------------------------------
//This routine provides show functionality used to hide the body of an
//HHA results table.
function hideHHATableRowsBody(vsID,vsLangID)
{
	// Some images do not display correctly in certain browsers. To help 
	// alleviate this issue,  the images are pre-loaded...
	var imgPlus=new Image();
	
	var vTableRow="TableRow-";
	var vImage="Image-";
	var vDiv="Div-";
	var vA = "A-";
	
	imgPlus.src="/HHCompare/images/plus.gif";

	var trList = document.getElementsByTagName("tr");

	var vShowTxtMsg = "";
	switch(vsLangID)
	{
		case "1":
			vShowTxtMsg = "Click to show the results for this Agency.";
		break;
		case "2":
			vShowTxtMsg = "Haga 'clic' para mostrar los resultados para esta agencia.";
		break;
	}

	// Look at each table row on the page
	for(var i = 0; i < trList.length; i++)
	{
		// if the TR is a part of the table for the given HHA
		if ( trList[i].id == (vTableRow + vsID) )
		{
			// The elment is currently being displayed, so toggle it to be hidden...
			trList[i].style.display = 'none';
		}
	} 
	// ...switch the image to expand
	
	if (document.getElementById(vImage + vsID) != null)
	{
		document.getElementById(vImage + vsID).src = imgPlus.src;
		document.getElementById(vImage + vsID).title = vShowTxtMsg;
	}
	
	// ...switch the title on the link
	if (document.getElementById(vA + vsID) != null)
	{
		document.getElementById(vA + vsID).title = vShowTxtMsg;
	} 
				
	// ...hide the div (footer with footnotes and anchor)
	if (document.getElementById(vDiv + vsID) != null)
	{
		document.getElementById(vDiv + vsID).style.display = 'none';
	}
				
	return false;
}
