<!--// JavaScript Document
///////////////////////////////////////////BASIC UTILITY CODE///////////////////////////////////////////
var lastID = "";//Global variable needed for togSub.

function changeBG(theImg, theSrc)//Changes images onmouseover.
{
 var picName = theImg;
 document.images[picName].src = theSrc;
}

function togSection(theSection, results)//Shows or hides the relevant hidden section div onclick of visible control.
{
 var theDivs = theSection.options;  var divName = theSection.value;  var theDiv = document.getElementById(divName);
 if (results == 'yes') 
    {var resultsDiv = document.getElementById('results');  resultsDiv.style.visibility = 'hidden';  resultsDiv.style.display = 'none';}
     for (i = 0; i < theDivs.length; i++)
     {
	  var x = document.getElementById(theDivs[i].value);
	  if (x.style.visibility == 'visible') {x.style.visibility = 'hidden';  x.style.display = 'none';}
	 }
 theDiv.style.visibility  = 'visible';  theDiv.style.display = 'block';
}

function togSub1(divID)//Shows or hides the relevant hidden sub div onclick of visible control.
{
 var theDiv = document.getElementById(divID);
 if (theDiv.style.visibility == 'visible') {theDiv.style.visibility = 'hidden';  theDiv.style.display = 'none';}
 else {theDiv.style.visibility = 'visible';  theDiv.style.display = 'block';}
}

function togSub2(divID)//Shows or hides the last clicked sub div onclick of visible control.
{
 var theDiv = document.getElementById(divID);
 if (lastID == "") {lastID = divID;}
 var lastDiv = document.getElementById(lastID);
 if (lastDiv.style.visibility == 'visible') {lastDiv.style.visibility = 'hidden';  lastDiv.style.display = 'none';}
 theDiv.style.visibility = 'visible';  theDiv.style.display = 'block';
 lastID = divID;
}


function togMaterialDiv1(materialID)//Fills, positions and turns on the visibility of the material guide div.
{
 var theDiv = document.getElementById('materialDiv'); var theWidth; var theHeight;
 if (document.documentElement.clientWidth) {theWidth = document.documentElement.clientWidth;}
 else {theWidth = document.body.clientWidth;}
 if (document.body.scrollTop) {theHeight = document.body.scrollTop + 130;}
 else {theHeight = document.documentElement.scrollTop + 130;}
 theDiv.style.left = (((theWidth - 1024)/2) + 270) + 'px';  theDiv.style.top = theHeight + 'px';
 theDiv.style.visibility = 'visible';  theDiv.style.display = 'block';
 getContents(materialID,'mgScript.asp','materialDiv');
}

function togMaterialDiv2()//Closes and empties the material guide div onclick of visible control.
{
 var theDiv = document.getElementById('materialDiv');
 theDiv.style.visibility = 'hidden';
 theDiv.style.display = 'none';
 theDiv.innerHTML = ''; 
}

function clearIt(theElmnt, theValue)//Clears the value of a form element if it has a certain value.
{if (theElmnt.value == theValue) {theElmnt.value = "";}}

function openWin(theUrl)//Opens a new full window for out-of-site links.
{
 var newWin;
 if (!newWin)
    {newWin = window.open(theUrl, 'newWin', 'width=1024,height=600,top=100,left=100,location=1,menubar=1,resizable=1,scrollbars=1,statusbar=1,toolbar=1');}
 else {newWin.location = theUrl;}
 if (window.focus) {newWin.focus();}
}

function openPop(theUrl, w, h)//Opens a new pop-up window for out-of-site links.
{
 var newPop;
 if (!newPop)
    {newPop = window.open(theUrl, 'newPop', 'width='+w+',height='+h+',top=100,left=100,location=0,menubar=0,resizable=1,scrollbars=1,statusbar=1,toolbar=0');}
 else {newPop.location = theUrl;}
 if (window.focus) {newPop.focus();}
}

///////////////////////////////////////////HTTP REQUEST CODE///////////////////////////////////////////
function setRequester()//Makes the xmlhttp request object.
{
 var xmlHttp;
 try {xmlHttp = new XMLHttpRequest();}//Firefox, Opera 8.0+, IE7, Safari
 catch (e) 
     {try{xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');}//Internet Explorer 6+
      catch (e)
         {try{xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');}//Internet Explorer 5-
          catch (e) {alert('Your browser does not support AJAX!');  return false;}//All others
         }
     }
 return xmlHttp;
}

function getContents(theID, theTask, part)//Posts the form to the relevant Script.asp via xmlHttp.
{
 var requester;  var formValues = 'theID='+theID;
 requester = setRequester();
 requester.onreadystatechange = function () {if(requester.readyState == 4 && requester.status == 200) {document.getElementById(part).innerHTML = requester.responseText; xmlHttp = null;}}
 requester.open('POST',theTask,true);
 requester.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
 requester.setRequestHeader("Content-length", formValues.length);
 requester.send(formValues);
}

-->