// Copyright 2001-2003 JohnV

function TableOut(thisLayer){
	
	clearTimeout(TimerID);
	//alert(thisLayer)
	if (thisLayer != "none"){
	/*
		thisRow.style.backgroundColor = "";
		//thisImg = document.images["flyImg" + thisLayer]
		//thisLink = document.getElementById("link" + thisLayer)
		//thisMainLink = document.getElementById("mainLink" + thisLayer)
		
		thisRow = document.getElementById("row" + thisLayer)
		thisTopRow = document.getElementById("rowTop" + thisLayer)
		thisBottomRow = document.getElementById("rowBottom" + thisLayer)
		thisTopTd = document.getElementById("topTD" + thisLayer)
		thisBottomTd = document.getElementById("bottomTD" + thisLayer)
		//thisMainImg = document.images["img" + thisLayer]
		
		if(thisTopTd != null && thisBottomTd != null && thisBottomRow != null && thisTopRow != null && thisRow != null){
			thisTopTd.style.backgroundImage = "url(/images/blank.gif)"
			thisBottomTd.style.backgroundImage = "url(/images/blank.gif)"
			thisBottomRow.style.backgroundImage = "url(/images/blank.gif)"
			thisTopRow.style.backgroundImage = "url(/images/blank.gif)"
			thisRow.style.backgroundImage = "url(/images/blank.gif)"
		}
		
		
	
		if(typeof thisImg != "undefined"){
			//thisImg.src = "/scripts/styled_flyout/flyout_arrow.gif"
			//thisLink.className = "flyout_link"
		}
		
		if(typeof thisMainImg != "undefined"){
			//thisMainImg.src = "/images/lnav_arrow_off.gif"
			//thisMainLink.className = "flyout_link"
		}
	*/
	}
	
	
	
    TimerID = setTimeout("ShowLayers('None', 'tableOut')", TimeLayerOut);
    
}


function TableOver(ActiveLayer){
	//alert("TableOver " + ActiveLayer)
	thisRow = document.getElementById("row" + ActiveLayer)
	//thisImg = document.images["flyImg" + ActiveLayer]
	//thisLink = document.getElementById("link" + ActiveLayer)
	//thisMainLink = document.getElementById("mainLink" + ActiveLayer)
	
	thisTopRow = document.getElementById("rowTop" + ActiveLayer)
	thisBottomRow = document.getElementById("rowBottom" + ActiveLayer)
	thisTopTd = document.getElementById("topTD" + ActiveLayer)
	thisBottomTd = document.getElementById("bottomTD" + ActiveLayer)
	//thisMainImg = document.images["img" + ActiveLayer]
		
	if(thisTopTd != null && thisBottomTd != null && thisBottomRow != null && thisTopRow != null && thisRow != null){
		thisTopTd.style.backgroundImage = "url(/scripts/styled_flyout/nav_horiz_border_on.gif)"
		thisBottomTd.style.backgroundImage = "url(/scripts/styled_flyout/nav_horiz_border_on.gif)"
		thisBottomRow.style.backgroundImage = "url(/scripts/styled_flyout/nav_over_cell.gif)"
		thisTopRow.style.backgroundImage = "url(/scripts/styled_flyout/nav_over_cell.gif)"
		thisRow.style.backgroundImage = "url(/scripts/styled_flyout/nav_over_cell.gif)"
	}
	
	
	thisRow.style.backgroundColor = "#DFE1E3";
	if(typeof thisImg != "undefined"){
		thisImg.src = "/scripts/styled_flyout/flyout_arrow_over.gif"
		thisLink.className = "flyout_linkActive"
	}
	
	if(typeof thisMainImg != "undefined"){
		//thisMainImg.src = "/images/lnav_arrow_on.gif"
		//thisMainLink.className = "flyout_linkActive"
	}
	
	clearTimeout(TimerID);
	if(ActiveLayer == LinkLayer){
		clearTimeout(TimerIDLink);
		WaitLink = 0;
	}
	//alert(ActiveLayer)
	ShowLayers(ActiveLayer, "tableOver");
}

function ResetWaitLink(ActiveLayer){
	WaitLink = 0;
	clearTimeout(TimerIDLink);
	ShowLayers(ActiveLayer, "resetWaitLink");
}


function LinkOut(ActiveLayer){
	IsLink = "NO";
	WaitLink = 1;
    TimerIDLink = setTimeout("ResetWaitLink('" + ActiveLayer + "')", TimeLinkOut);
   // alert(ActiveLayer)
    if (ActiveLayer != ""){
		//alert("row" + ActiveLayer)
		
	}
	
	
	
	TableOut("none");
}

function LinkOver(ActiveLayer){
	//alert("linkOver " + ActiveLayer)
	
	//alert("rowL" + ActiveLayer)
	thisRow = document.getElementById("row" + ActiveLayer)
	//thisImg = document.images["flyImg" + ActiveLayer]
	//thisLink = document.getElementById("link" + ActiveLayer)
	//thisMainLink = document.getElementById("mainLink" + ActiveLayer)
	
	thisTopRow = document.getElementById("rowTop" + ActiveLayer)
	thisBottomRow = document.getElementById("rowBottom" + ActiveLayer)
	thisTopTd = document.getElementById("topTD" + ActiveLayer)
	thisBottomTd = document.getElementById("bottomTD" + ActiveLayer)
	//thisMainImg = document.images["img" + ActiveLayer]
	
	
	if(thisTopTd != null && thisBottomTd != null && thisBottomRow != null && thisTopRow != null && thisRow != null){
		thisTopTd.style.backgroundImage = "url(/scripts/styled_flyout/nav_horiz_border_on.gif)"
		thisBottomTd.style.backgroundImage = "url(/scripts/styled_flyout/nav_horiz_border_on.gif)"
		thisBottomRow.style.backgroundImage = "url(/scripts/styled_flyout/nav_over_cell.gif)"
		thisTopRow.style.backgroundImage = "url(/scripts/styled_flyout/nav_over_cell.gif)"
		thisRow.style.backgroundImage = "url(/scripts/styled_flyout/nav_over_cell.gif)"
	}
	
	
	thisRow.style.backgroundColor = "#DFE1E3";
	if(typeof thisImg != "undefined"){
		//thisImg.src = "/scripts/styled_flyout/flyout_arrow_over.gif"
		//thisLink.className = "flyout_linkActive"
	}
	if(typeof thisMainImg != "undefined"){
		//thisMainImg.src = "/images/lnav_arrow_on.gif"
		//thisMainLink.className = "flyout_linkActive"
	}
	
	
	clearTimeout(TimerID);
	clearTimeout(TimerIDLink);
	WaitLink = 0;
	LinkLayer = ActiveLayer;
	IsLink = ActiveLayer;
	
	ShowLayers(ActiveLayer, "linkOver");
}

function ShowLayers(ActiveLayer, from){
	//alert("from " + from)
	if (IsLink != "NO") ActiveLayer = IsLink;

	if (ActiveLayer == "None"){
		//clear all main menus
		
		for(i=0; i<linksCount;i++){
			thisRow = document.getElementById("row" + linksList[i])
			//thisImg = document.images["flyImg" + linksList[i]]
			//thisLink = document.getElementById("link" + linksList[i])
			//thisMainLink = document.getElementById("mainLink" + linksList[i])
			
			thisTopRow = document.getElementById("rowTop" + linksList[i])
			thisBottomRow = document.getElementById("rowBottom" + linksList[i])
			thisTopTd = document.getElementById("topTD" + linksList[i])
			thisBottomTd = document.getElementById("bottomTD" + linksList[i])
			//thisMainImg = document.images["img" + linksList[i]]
			
			arrWhichLayer = linksList[i].split("_")
				if (arrWhichLayer.length == 2){
					//alert(linksList[i])
						thisRow.style.backgroundColor = "";
						if(typeof thisImg != "undefined"){
							//thisImg.src = "/scripts/styled_flyout/flyout_arrow.gif"
							//thisLink.className = "flyout_link"
						}
						if(thisTopTd != null && thisBottomTd != null && thisBottomRow != null && thisTopRow != null && thisRow != null){
							thisTopTd.style.backgroundImage = "url(/images/spacer.gif)"
							thisBottomTd.style.backgroundImage = "url(/images/spacer.gif)"
							thisBottomRow.style.backgroundImage = "url(/images/spacer.gif)"
							thisTopRow.style.backgroundImage = "url(/images/spacer.gif)"
							thisRow.style.backgroundImage = "url(/images/spacer.gif)"
						}
						/*
						if(typeof thisMainImg != "undefined"){
							//alert(linksList[i] + " = " + pageId)
							if (linksList[i] == "L" + pageId){
								thisMainImg.src = "/images/lnav_arrow_on.gif"
								thisMainLink.className = "lnav_link_on"
							} else {
								thisMainImg.src = "/images/lnav_arrow_off.gif"
								thisMainLink.className = "lnav_link"
							}	
						}
						*/
					
				}
		}		
	}

	//alert(PrevLayer + " " + ActiveLayer + " " + WaitLink)
	if (PrevLayer != ActiveLayer && WaitLink == 0){
		//alert(mouseX)
		for(i=0; i<layerCount;i++){
			if (is_nav4) {
				document.layers[layersList[i]].visibility='hide';
			} else if (is_ie4) {
				//alert(layersList[i])
				document.all[layersList[i]].style.visibility='hidden';
			} else if (is_domcom) {
				document.getElementById(layersList[i]).style.visibility='hidden';
			}
			
			
			
			if (ActiveLayer.search(layersList[i]) > -1){
				
				//thisRow.style.backgroundColor = "#DFE1E3";
				if (is_nav4) {
					document.layers[layersList[i]].visibility='show';
				} else if (is_ie4) {
					//alert("show " + layersList[i])
					document.all[layersList[i]].style.visibility='visible';
					
				} else if (is_domcom) {
					
					document.getElementById(layersList[i]).style.visibility='visible';
					
				}
			} else {
			
			
			}
		}
		
		
		//clear any active links styles
		for(i=0; i<linksCount;i++){
		
			
			thisRow = document.getElementById("row" + linksList[i])
			//thisImg = document.images["flyImg" + linksList[i]]
			//thisLink = document.getElementById("link" + linksList[i])
			//thisMainLink = document.getElementById("mainLink" + linksList[i])
			
			thisTopRow = document.getElementById("rowTop" + linksList[i])
			thisBottomRow = document.getElementById("rowBottom" + linksList[i])
			thisTopTd = document.getElementById("topTD" + linksList[i])
			thisBottomTd = document.getElementById("bottomTD" + linksList[i])
			thisMainImg = document.images["img" + linksList[i]]
		
			
			
			if (ActiveLayer.search(linksList[i]) == -1){

				
				arrWhichLayer = linksList[i].split("_")
				arrActiveLayer = ActiveLayer.split("_")
				if (arrWhichLayer.length == arrActiveLayer.length){
					if(ActiveLayer != linksList[i]){
						thisRow.style.backgroundColor = "";
						if(typeof thisImg != "undefined"){
							//thisImg.src = "/scripts/styled_flyout/flyout_arrow.gif"
							//thisLink.className = "flyout_link"
						}
						if(thisTopTd != null && thisBottomTd != null && thisBottomRow != null && thisTopRow != null && thisRow != null){
							thisTopTd.style.backgroundImage = "url(/images/spacer.gif)"
							thisBottomTd.style.backgroundImage = "url(/images/spacer.gif)"
							thisBottomRow.style.backgroundImage = "url(/images/spacer.gif)"
							thisTopRow.style.backgroundImage = "url(/images/spacer.gif)"
							thisRow.style.backgroundImage = "url(/images/spacer.gif)"
						}
						/*
						if(typeof thisMainImg != "undefined"){
							//alert(linksList[i] + " = " + pageId)
							if (linksList[i] == "L" + pageId){
								thisMainImg.src = "/images/lnav_arrow_on.gif"
								thisMainLink.className = "lnav_link_on"
							} else {
								thisMainImg.src = "/images/lnav_arrow_off.gif"
								thisMainLink.className = "lnav_link"
							}	
						}
						*/
					}
				}
				//if (IsLink != "NO") thisRow.style.backgroundColor = "";
			}
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		PrevLayer = ActiveLayer;
	}
}

function showMenu(ActiveLayer, image){
	
	var imgCount = 1

	do {
		var imageId = ("I" + imgCount);
		var imageOn = (imageId + "on");
		var imageOff = (imageId + "off");
		imgCount++;	 
		if (image == imageId) {
			//changeImages(image, imageOn);
		} else {
			//changeImages(imageId, imageOff);
		}
	} while (imgCount <= numOfImages); 

	LinkOver(ActiveLayer);
}

function hideMenu(){
	LinkOut('');
}

