// After adding new data set this variable. Shows the number of questions on this page

var questions=0;

// opens answer with a given ID and closes all other answers

function setQuestions(quests){

this.questions=quests;	

}

function openAnswer(ansID){

		if (document.getElementById(ansID).style.display=="none"){

		/*for (i=1; i<=questions; i++){

			var answer='ans'+i;

			

			document.getElementById(answer).style.display="none";		

			}//end for loop

			*/

			

		document.getElementById(ansID).style.display="";

		}//end if

		else

		{

		document.getElementById(ansID).style.display="none";		

		}

}//end fucntion 
//----------------------------------------------------------------------- CHANGES MADE BY HARIS ---------------------------------------------------
var result;
function openSection(section)
{	
	divs = document.getElementsByTagName("div");												//get all divs in the page
	
	for(var i=0; i<divs.length; i++)
	{
		divId = divs[i].id.toString();
		
		if(divId.indexOf('Qs') != -1 || divId.indexOf('Ans') != -1)								//if id refers to the qs or ans
		{
			if(divId.indexOf(section + 'Qs') == -1)												//if it is not a section's qs make it disappear
			{
				divs[i].style.display = "none";
			}
		}
		
		if(divId.indexOf(section + 'Qs') != -1)													//open or close the section's qs
		{
			if(divId == result && result != "undefined")
			{
				if(divs[i-1].style.display == "none")
				{
					divs[i].style.display = "block";
					result = "undefined";
					continue;
				}
			}
			swap(divId);
		}
	}
}

function openAnswer(ansId)
{
	swap(ansId);
	
	switch(ansId)
	{
		case "instalAns1":
			swap('instalAns1_a');
		break;
		case "instalAns2":
			swap('instalAns2_a');
		break;
	}
}

function openForTop5(ansId)
{
	//get all divs in the page
	divs = document.getElementsByTagName("div");
	
	for(var i=0; i<divs.length; i++)
	{
		divId = divs[i].id.toString();
		
		//first close all qs and ans
		if(divId.indexOf('Qs') != -1 || divId.indexOf('Ans') != -1)
		{
			divs[i].style.display = "none";
		}
	}
	
	var strToReplace = "Ans";									// replace e.g techReqAns1 with techReqQs1
	var strToReplaceWith = "Qs";
	var regex = new RegExp(strToReplace , "g");					// g for global replacement
	result = ansId.replace(regex, strToReplaceWith);	
				
	swap(result);												//open the qs
	swap(ansId);												//open the ans
}

function swap(id)
{
	if (document.getElementById(id).style.display == "none" || document.getElementById(id).style.display == "")
		document.getElementById(id).style.display = "block";
	else
		document.getElementById(id).style.display = "none";
}

function gotoPage(page)
{
	location.href = page;
}
