// ************************************
// Check LHN Status
// ************************************
function checkLHNStatus(CatLevel, deadlist) { 
	var Status = "Enabled"; 
	if (deadlist == "") { } else {  
		var deadArray = deadlist.split(";"); 
		for (j = 0; j < deadArray.length; j++) { 
			var check = deadArray[j]; 
			var slength = check.length; 
			var level = CatLevel.slice(0, slength); 
			if (check == level) { 
		 		Status = "Disabled"; 
		 		break; 
			} else { } 
		} 
	} 
	return Status; 
} 
// ************************************
// Initialise LHN
// ************************************
function initLeftNavigation(){
	var validity = strValid;
	if (validity == "No") { return;} else {}
	if(IE4){
		tempColl = document.all.tags("DIV");
	}else{
		tempColl = document.getElementsByTagName("DIV");
	}
	for (i=0; i < tempColl.length; i++) {
		if(IE4){
			if(strLHNType == "FULL"){
				if (tempColl[i].className == "level1") tempColl[i].style.display = "block";
				if (tempColl[i].className == "level2") tempColl[i].style.display = "none";
			}else{
				if (tempColl[i].className == "level2") tempColl[i].style.display = "block";
			}
			if (tempColl[i].className == "level3") tempColl[i].style.display = "none";
			if (tempColl[i].className == "level4") tempColl[i].style.display = "none";
			if (tempColl[i].className == "level5") tempColl[i].style.display = "none";
		}else{
  			whichEl = tempColl[i].getAttribute('class');
			if(strLHNType == "FULL"){
				if (whichEl == "level1") tempColl[i].style.display = "block";
  				if (whichEl == "level2") tempColl[i].style.display = "none";
			}else{
				if (whichEl == "level2") tempColl[i].style.display = "block";
			}
	  		if (whichEl == "level3") tempColl[i].style.display = "none";
  			if (whichEl == "level4") tempColl[i].style.display = "none";
  			if (whichEl == "level5") tempColl[i].style.display = "none";
		}
	}
	var strComp  = initStrComp;
	var strIm = strComp.replace("sec","im");
	var sectionArr = strComp.split("_");
	var strCat = "";
	if(strLHNType == "FULL"){
		if(doesDivExist(sectionArr[0]) == 'True'){
			expandItInit(sectionArr[0], sectionArr[0].replace("sec","im"));
		}
	}
	for (j = 1; j < sectionArr.length; j++) {
		strCat = strCat + "_" + sectionArr[j];
		if (doesDivExist(sectionArr[0] + strCat) == 'True') {
			expandItInit(sectionArr[0] + strCat, sectionArr[0].replace("sec","im") + strCat);
		}
	}
}
// ************************************
// Expand from Navigation
// ************************************
function expandIt(el, strArgs2, imID) { 
	if (!ver4) return; 
	expandItInit(el,imID);
	collapseOthers(el,strArgs2,imID);
} 
// ************************************
// Expand It Init
// ************************************
function expandItInit(el,imID) {
	if(IE4){
		whichEl = eval(el);
	}else{
		whichEl = document.getElementById(el);
	}
	SwapImage(imID);
	if (whichEl.style.display == "none") {
		switchSubLevel(el, "block",imID);
	}else{
		switchSubLevel(el, "none",imID);
	}
}
// ************************************
// Collapse It Init
// ************************************
function collapseItInit(el, imID) {
	var LevelArray = el.split("_");
	var Level;
	if(strLHNType == "FULL"){
		Level = LevelArray.length;
		LevelCheck = "1";
	}else{
		LevelArray.length == 2 ? Level = "2": Level = "x";
		LevelCheck = "2";
	}
	collapseImage(imID);
	if(IE4){
		if (Level == LevelCheck) {
			document.all[el].style.display = "block";
		}else{
			document.all[el].style.display = "none";
		}
	}else{
		if (Level == LevelCheck) {
			document.getElementById(el).style.display = "block";
		}else{
			document.getElementById(el).style.display = "none";
		}
	}
}
// ************************************
// Collapse Others
// ************************************
function collapseOthers(el,level,imID) {
	var strComp;
	var newType;
	var newLevelArray;
	var newLevel;
	if(strLHNType == "FULL"){}else{
		var levelArray = el.split("_");
		var match = levelArray[0] + "_" + levelArray[1];
	}
	if(IE4){
		tempColl = document.all.tags("DIV");
	}else{
		tempColl = document.getElementsByTagName("DIV");
	}
	for (i = 0; i < tempColl.length; i++) {
		if(IE4){
			strComp = new String(tempColl[i].id);
		}else{
			strComp = new String(tempColl[i].getAttribute("id"));		
		}
		newType = strComp.substring(0,3);
	
		if(strLHNType == "FULL"){
			if(strComp.length > el.length){
				if(newType == "sec"){
					if(strComp.substring(0, el.length) != el){
						collapseItInit(strComp,"im" + strComp.substring(3));
					}
				}
			}
			if(strComp.length == el.length){
				if(newType == "sec"){
					if(strComp.substring(0, el.length) != el){
						collapseImage("im" + strComp.substring(3));
					}
				}
			}
		}else{
			newLevelArray = strComp.split("_");
			newLevel = newLevelArray[0] + "_" + newLevelArray[1];
			if (newType == "sec") {
				if(newLevel != match) {
					collapseItInit(strComp,"im" + strComp.substring(3));
				}
			}
		}			
	}
}
// ************************************
// Switch Sub Level
// ************************************
function switchSubLevel(level, mode, imID) {
	//seeks out sub levels below this menu option and either expands them or collapses them
	var strComp;
	var toplevel = level;
	level = level + "_";
	var levelArr;
	var toplevelArr;
	if(IE4){
		tempColl = document.all.tags("DIV");
	}else{
		tempColl = document.getElementsByTagName("DIV");
	}
	for (i = 0; i < tempColl.length; i++) {
		if(IE4){
			strComp = new String(tempColl[i].id);
		}else{
			strComp = new String(tempColl[i].getAttribute("id"));
		}
		levelArr = strComp.split("_");		
		toplevelArr = toplevel.split("_");
		if (strComp.indexOf(level) != -1) {
			// Then key matches
			whichEl = eval(strComp);
			if(IE4){
				if ( (document.all[strComp].style.display == "none") && (levelArr.length - toplevelArr.length == 1) ){
					document.all[strComp].style.display = "block";
				}else{
					document.all[strComp].style.display = "none";
				}
			}else{
				if ( (document.getElementById(strComp).style.display == "none") && (levelArr.length - toplevelArr.length == 1) ){
					document.getElementById(strComp).style.display = "block";
				}else{
					document.getElementById(strComp).style.display = "none";
				}
			}
		}
	}
}
// ************************************
// Collapse Image
// ************************************
function collapseImage(imID) { 
	eval('var strImg = document.' + imID + '.src;'); 
	var arrImg = strImg.split('/'); 
	var imgFile = arrImg[arrImg.length-1]; 
	if (imgFile == 'SI_10.gif') { 
		eval('document.' + imID + '.src = strImg.replace(imgFile,\'SI_9.gif\');'); 
	} else if (imgFile == 'SI_7.gif') { 
		eval('document.' + imID + '.src = strImg.replace(imgFile,\'SI_6.gif\');'); 
	} 
}
// ************************************
// Swap Image
// ************************************
function SwapImage(imID) { 
	eval('var strImg = document.' + imID + '.src;'); 
	var arrImg = strImg.split('/'); 
	var imgFile = arrImg[arrImg.length-1]; 
	if (imgFile == 'SI_9.gif') { 
		eval('document.' + imID + '.src = strImg.replace(imgFile,\'SI_10.gif\');'); 
	} else if (imgFile == 'SI_6.gif') { 
		eval('document.' + imID + '.src = strImg.replace(imgFile,\'SI_7.gif\');'); 
	} else if (imgFile == 'SI_10.gif') { 
		eval('document.' + imID + '.src = strImg.replace(imgFile,\'SI_9.gif\');'); 
	} else if (imgFile == 'SI_7.gif') { 
		eval('document.' + imID + '.src = strImg.replace(imgFile,\'SI_6.gif\');'); 
	} 
}
