
var qaList = new Array("",
          "qa1.html",
          "qa2.html",
          "qa3.html",
          "qa4.html",
          "qa5.html",
          "qa6.html",
          "qa7.html",
          "qa8.html",
          "qa9.html",
          "qa10.html",
          "qa11.html",
          "qa12.html")
var nq = 12;
var iq = 0;

/////////////////////////////////////////////////////////////////////////////
// script to handle resize problem for some Netscape 4 browsers
var origWidth;
var origHeight;

function NS4()
{
  return ( (navigator.appName == "Netscape") &&
            (navigator.appVersion.charAt(0) == 4) );
}

if (NS4()) {       
  if (!origWidth)
  {
    origWidth = innerWidth; 
    origHeight = innerHeight; 
    onresize = handleResize;
    onload = handleLoad;
 }
}

function handleResize() { 
    if (innerWidth != origWidth || innerHeight != origHeight) 
      location.reload();
} 


function handleLoad()
{
   // if reloading the page in onresize event, may need to reshow the answers 
   if (location.search == null || location.search.length <= 1) {
   }
   else {
     var show = parseInt(location.search.substring(1));
     if (show>=1) {
        // make answer sections visible
	showSection("answer");
        if (show>=2) showSection("answer2");
        if (show>=3) showSection("answer3");
     }
   }
}

////////////////////////////////////



function AddAnswer()
{
// add 'Answer' button
document.write("&nbsp;&nbsp;<input type=\"button\" name=\"bAnswer\" value=\"Answer\" onClick =\"showAnswer(1)\">");
}
function AddPrevious()
{
// add 'Previous' button
if (iq > 1)
document.write("&nbsp;&nbsp;<input type=\"button\" name=\"bPrevious\" value=\"Previous\" onClick =\"previous()\">");
}
function AddNext()
{
// add 'Next' button
if (iq < nq)
document.write("&nbsp;&nbsp;<input type=\"button\" name=\"bNext\" value=\"Next\" onClick =\"next()\">");
}

function showAnswer(ja)
{
  if (NS4())
  {
      var u = qaList[iq];
      if (ja > 0) u += "?" + ja;
      location.href = u;         // reload document and display answer section
  }
  else
  {
    // just have to make the answer sections visible
	if (ja > 1 && ja <= 3)		// should only be one main answer + up to 2 additional in each quiz question
		showSection("answer"+ja);
	else if (ja == 1)
		showSection("answer");
  }
}

function previous()
{
	if (iq > 1)
		location.href = qaList[iq-1];
}
function next()
{
	if (iq < nq)
		location.href = qaList[iq+1];
}

function lastQA()
{
	return qaList[nq];
}

function firstQA()
{
	return qaList[1];
}

function DHTML()
{
  return (document.getElementById || document.all || document.layers);
}

function hideSection(name)
{
	if (!DHTML())
		return;
	var s = new getObj(name);
	if (document.getElementById)
	{
		s.style.display = "none";
		s.style.visibility = "hidden";
	}
	else if (document.all)
	{
		s.style.visibility = "hidden";
	}
	else if (document.layers)
	{
		s.style.visibility = "hidden";
	}
}

function showSection(name)
{
	if (!DHTML()) return;
	var s = new getObj(name);
        if (!s) return;
	if (document.getElementById)
	{
		s.style.display = "";
		s.style.visibility = "visible";
	}
	else if (document.all)
	{
		s.style.visibility = "visible";
	}
	else if (document.layers)
	{
		s.style.visibility = "visible";
	}
}


function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var thereturn;
	for (var i=0; i<x.length; i++)
	{
		if (x[i].id == name)
		 	thereturn = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) thereturn = tmp;
	}
	return thereturn;
}


 

