// JavaScript Document
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/

//define level one nav arrays
var ulDivs=new Array()
ulDivs[0]='subOne';
ulDivs[1]='subTwo';

//define level two nav arrays
var ulLevelTwo = new Array()
ulLevelTwo[0]='oneSubL';
ulLevelTwo[1]='twoSubL';
ulLevelTwo[2]='threeSubL';
ulLevelTwo[3]='fourSubL';
ulLevelTwo[4]='fiveSubL';
ulLevelTwo[5]='sixSubL';

//check for the XMLHttpRequest
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

//this function opens the navs
function msubNav(navID,htmlArea,levelTwo,loaded,thisPage) {
	//check if it is NOT level two
	if (!checkLevelTwo(htmlArea)) {
		//this "for" closes level one navs that do not match the htmlArea
		//for each level one nav in the array
		for (i=0;i<=ulDivs.length;i++) {
			//if the htmlArea is equal to a value in the array...skip it (leave it open)
			if (ulDivs[i] == htmlArea) {
				continue;
			} else {
				//if the htmlArea is NOT equal to a value in the array...set it to be blank (close it)
				if (ulDivs[i] != null) {
					document.getElementById(ulDivs[i]).innerHTML = '';
				} else {
					break;	
				}
			}
		}
	} else {
		//if htmlArea is a level two nav, then call the function to close them
		closeLevelTwo(htmlArea);	
	}
	//get the information via XMLHttpRequest
	xmlhttp.open("GET", "/includes/msubnav.asp?id="+ navID +""+ levelTwo +""+ loaded +"&page="+ thisPage,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			 document.getElementById(''+ htmlArea +'').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}
function closeLevelTwo(htmlArea) {
	//this "for" closes level two navs that do not match the htmlArea
	//for each level two nav in the array
	for (i=0;i<=ulLevelTwo.length;i++) {
		//if the htmlArea is equal to a value in the array...skip it (leave it open)
		if (ulLevelTwo[i] == htmlArea) {
			continue;	
		} else {
			//if the htmlArea is NOT equal to a value in the array...set it to be blank (close it)
			if (ulLevelTwo[i] != null) {
				document.getElementById(ulLevelTwo[i]).innerHTML = '';
			} else {
				break;	
			}
		}
	}
}
function checkLevelTwo(arrayVal) {
	//for each level two in the array
	for (i=0;i<=ulLevelTwo.length;i++) {
		//if there is a match with the htmlArea and the array then return TRUE
		if (arrayVal==ulLevelTwo[i]) {
			return true;
		} else {
			//else skip it
			continue;
		}
	}
}
