var isIE = ((document.all)? true: false);
var isNS6 = ((document.getElementById && !document.all)? true: false );

allSubs = ['1','2','3','4'];

var keepSub = 0;
onMenu = false;


function openSub(num) {
	onMenu = true;
	keepSub = num;

	closeAllSub(num);	// closes all menus and children, except for keepSub

	// displays the correct div
	if (isIE){
			document.all["sub" + num].style.visibility = "visible";
			
	} else if (isNS6) {
		document.getElementById("sub" + num).style.visibility = "visible";
	}	
}


function closeAllSub(caller){
	if (caller !=1) {!onMenu;}
	for (i=0; i<allSubs.length; i++){
		if (isIE){
			if (document.all["sub" + allSubs[i]]){		
				if (allSubs[i]!=keepSub) {
					if (document.all){
						document.all["sub" + allSubs[i]].style.visibility = "hidden";
					}
				}		
			}
		}else if (isNS6){
			if (document.getElementById("sub" + allSubs[i])){		
				if (allSubs[i]!=keepSub ) {					
					document.getElementById("sub" + allSubs[i]).style.visibility = "hidden";
				}		
			}
		}
	}
}


function isMenu(toClose){
	// recieved "true" from the main TD - so reseting the keepSub and closing all subs	
	
	if (toClose){
		keepSub="";
		closeAllSub();
	}
}
