
var displayedAnswer = "answer1"

function questionsAnswers()	{
	
	/* check the browser is capable of recognising the DOM objects
	   we need to implement the script - otherwise return false and allow the normal link to be executed */
	   
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("questionsText")) return false;
	
	
	/* get the reference to the productRange object and then create an array 
	   of all the <a> tags found in the array. To each tag assign a function to
	   the onmouseover and onmouseout events - which calls the changeColour and changeColour functions. */	
	
	var menu = document.getElementById("questionsText");
	var menulinks = menu.getElementsByTagName("h2");
	
		for(i = 0; i < menulinks.length; i++) {
		
			
			menulinks[i].onclick = function() {
			
					  return showAnswer(this);		
			}
			
			
			
			
			
			
		}
}


function showAnswer(thisQuestion)	{
	

var thisNodeName = thisQuestion.nextSibling.nodename

if (thisQuestion.nextSibling.nodeName.toLowerCase() == "div") {
	
	//alert(thisQuestion.nextSibling.id)
	
	thisQuestion.nextSibling.style.display = "block"
	
	document.getElementById(displayedAnswer).style.display = "none"
	
	
		if ((thisQuestion.nextSibling.id) == (displayedAnswer)) {
			
			
			thisQuestion.nextSibling.style.display = "block"
		
		}
			
	displayedAnswer = thisQuestion.nextSibling.id
	
}

else if (thisQuestion.nextSibling.nextSibling.nodeName.toLowerCase() == "div") {

	//alert(thisQuestion.nextSibling.nextSibling.id)
	
	thisQuestion.nextSibling.nextSibling.style.display = "block"
	
	document.getElementById(displayedAnswer).style.display = "none"
			
	displayedAnswer = thisQuestion.nextSibling.nextSibling.id

	
			if ((thisQuestion.nextSibling.nextSibling.id) == (displayedAnswer)) {
			
			
			thisQuestion.nextSibling.nextSibling.style.display = "block"
		
			}
		
}
		
	

	//var anchorPos = document.getElementById(displayedAnswer).offsetTop
	
	//window.scrollTo("0",(anchorPos + 100))
	
	//alert(displayedAnswer)
				
}



