// !!!
// Please include common.js before this file
// !!!

function showAllAnswers(show)
{
	try
	{
		var answers = findElements("answer");
    var answerCount = answers.length;

		for(var i=0; i<answerCount; i++)
		{
			displayElement(answers[i], show);
		}
	}
	catch(e)
	{
		// Fail silently...
	}
}

function switchAnswer(event)
{
	var answer = null;
	try
	{
		var currentParent = null;
		if(event.srcElement)   // IE
		  currentParent = event.srcElement;
		else if(event.target)  // DOM
		  currentParent = event.target;

		while(true)
		{
			if(currentParent.tagName == "TABLE")
			{
				// Get the second line of the table to access the answer
				// (the first line is the question)
				answer = currentParent.getElementsByTagName("TR")[1];
				break;
			}
			else
			{
				currentParent = currentParent.parentNode;
			}
		}
	}
	catch(e)
	{
		// Fail silently...
	}

	if(answer != null)
	{
    switchElementDisplay(answer);
	}
}

// If browser support DHTML, hide all answers
if(supportDHTML())
{
	showAllAnswers(false);
}
