// JavaScript Document

function ToggleDiv(theDivName)
{
	InitializeGlobalData();

	if (null == theDivName || typeof(theDivName) == "undefined") return; var theDiv = allDivsInPage[theDivName]; if (null == theDiv || typeof(theDiv) == "undefined") return;

	if (theDiv.style.display.toUpperCase() != "BLOCK")
		ExpandDiv(theDivName);
	else
		CollapseDiv(theDivName);
}

function ExpandDiv(theDivName)
{
	InitializeGlobalData();

	if (null == theDivName || typeof(theDivName) == "undefined") return; 
	var theDiv = allDivsInPage[theDivName]; 
	if (null == theDiv || typeof(theDiv) == "undefined") return;
	theDiv.style.display = "block";

	var thePic = allImagesInPage[theDivName + "_img"];
	if (null != thePic && typeof(thePic) != "undefined")
		{
		thePic.src = "images/minus.gif";
		}
}

function CollapseDiv(theDivName)
{
	InitializeGlobalData();

	if (null == theDivName || typeof(theDivName) == "undefined") return; var theDiv = allDivsInPage[theDivName]; if (null == theDiv || typeof(theDiv) == "undefined") return;
	theDiv.style.display = "none";

	var thePic = allImagesInPage[theDivName + "_img"];
	if (null != thePic && typeof(thePic) != "undefined")
		{
		thePic.src = "images/plus.gif";
		}
}

function ToggleALL()
{
	InitializeGlobalData();
	var spans = document.body.getElementsByTagName("SPAN");
	countSpan = spans.length;
	var thePic = allImagesInPage['ques_0_img'];
	for (i=0; i < countSpan; i++)
	{
		thePic = allImagesInPage["ques_" + (i+1) + "_img"];
		if (spans[i].style.display!='block')
		{	spans[i].style.display = "block";
			thePic.src = "images/minus.gif";
		} else {
			spans[i].style.display = "none";
			thePic.src = "images/plus.gif";
		}
	}
}

function InitializeGlobalData()
{
	if ('undefined' != typeof(strRtl))
		strIsRtl = strRtl;

	var divs = document.body.getElementsByTagName("DIV");
	var spans = document.body.getElementsByTagName("SPAN");

	var countDiv = 0;
	var countSpan = 0;
	if (typeof(divs) != "undefined" && null != divs)
		countDiv = divs.length;

	if (typeof(spans) != "undefined" && null != spans)
		countSpan = spans.length;

	allDivsInPage = new Array();
	for (i=0; i < countDiv; i++)
		if (typeof(divs[i].id) != "undefined" &&
			null != divs[i].id &&
			divs[i].id.length > 0)
			allDivsInPage[divs[i].id] = divs[i];

	for (i=0; i < countSpan; i++)
		if (typeof(spans[i].id) != "undefined" &&
			null != spans[i].id &&
			spans[i].id.length > 0)
			allDivsInPage[spans[i].id] = spans[i];

	allImagesInPage = document.body.getElementsByTagName("IMG");
}

function AppendPopup(oSource, sPopup)
{
	InitializeGlobalData();
	if (typeof(allDivsInPage) == 'undefined' || null == allDivsInPage) return;
	var theDiv = allDivsInPage['divInlineDef_' + sPopup];
	if (typeof(theDiv) == 'undefined' || null == theDiv)
		{
		InlineDefNotFound();
		return;
		}
	if (theDiv.style.display.toUpperCase() != 'INLINE')
		theDiv.style.display = 'inline';
	else
		theDiv.style.display = 'none';
}