<!--
var openMenu = new Array('','','','','')

timerOn=false
disableMenu=false
drawLoadingDoneOnce=false
timecount=250

i=0

while ((deptChildrenID[0][i] + '' != '')&&(typeof deptChildrenID[0][i]!='undefined')) {
	a=document.getElementById("pMenu" + deptChildrenID[0][i])
	a.hasSubMenu=1
	a.level=0

	if ((dURL[deptChildrenID[0][i]]!='TEXT')&&(deptName[deptChildrenID[0][i]]!='<hr>')&&(typeof deptName[deptChildrenID[deptChildrenID[0][i]][0]] !='undefined')) {
		//a.innerHTML=deptName[deptChildrenID[0][i]]
		a.onmouseover = function () {doShowMenu(this.id.substr(5),this.hasSubMenu,this.level)}
		a.onmouseout = function () {doHideMenu(this.id.substr(5), this.level)}
		a.onclick = function () {disableMenu=true;hideByLevel('0'); menuRedirect(deptID[this.id.substr(5)], dURL[this.id.substr(5)])}
	}
	else if ((dURL[deptChildrenID[0][i]]=='TEXT')||(deptName[deptChildrenID[0][i]]=='<hr>')){
		a.innerHTML=deptName[deptChildrenID[0][i]]
		a.className="barHR"
	}
	else {
		a.hasSubMenu=0
		a.onmouseover = function () {highlightMOver(this.id.substr(5),this.level)}
		a.onmouseout = function () {doHideMenu(this.id.substr(5), this.level)}
		a.onclick = function () { disableMenu=true;hideByLevel('0'); menuRedirect(deptID[this.id.substr(5)], dURL[this.id.substr(5)])}

		
	}
	i++
}


//---------------------------------------------------------------------

function menuRedirect(deptIDx, url) {
	
	
	if (typeof url =='undefined') {
		urlAdder=''
		qString=(window.location.search.toLowerCase())
		//alert(qString)
		if (qString.indexOf("ts=custom")>=0) {
			urlAdder="http://www.nrsweb.com"	
			//alert("a")
		}
		else if (qString.indexOf("ts=b2b")>=0) {
			urlAdder="http://www.nrsb2b.com"
			//alert("b")
		}
		else if (qString.indexOf("ts=rescue")>=0) {
			urlAdder="http://www.nrsrescue.com"
			//alert("c")
		}
		else if (qString.indexOf("ts=outlet")>=0) {
			urlAdder="http://www.nrsoutlet.com"
			//alert("d")
		}
		//alert("e")
		document.location=urlAdder + 'gallery.asp?deptid=' + deptIDx;
	}
	else {
		if (url.indexOf("?")>=0) {
			str="&tn="
		}
		else {
			str="?tn="
		}
	 document.location=url + str + deptIDx;
	}
}

function hideSelect()
{
	if (document.all){
		ij=0
		if (typeof document.all.formselect!='undefined') {
			if (typeof document.all.formselect.style=='undefined') {
				while (typeof document.all.formselect[ij]!='undefined') {
					document.all.formselect[ij].style.visibility="hidden"
					ij++;
				}
			}
			else {
				document.all.formselect.style.visibility="hidden";
			}
		}
		
		//if (typeof document.all.formselect!='undefined')	{document.all.formselect.style.visibility="hidden";}
	}
}

function unhideSelect()
{
	if (document.all){
		ij=0
		if (typeof document.all.formselect!='undefined'){
			if (typeof document.all.formselect.style=='undefined') {
				while (typeof document.all.formselect[ij]!='undefined') {
					document.all.formselect[ij].style.visibility="visible"
					ij++;
				}		
			}
			else {
				document.all.formselect.style.visibility="visible";
			}
		}
		//if (typeof document.all.formselect!='undefined'){document.all.formselect.style.visibility="visible";}
	}	
}

function drawLoading(parentID) {	
	//LBdy=document.getElementById("Bdy")
	//if (drawLoadingDoneOnce==true) {
	//	LMenu=document.getElementById("loading")
	//	LMenu.parentNode.removeChild(LMenu)
	//}
	//else { 
	//	drawLoadingDoneOnce=true }
	//parentM=document.getElementById('pMenu' + parentID)
	//LMenu=document.createElement("DIV")
	//LMenu.innerHTML="**Loading " + deptName[parentID] + "**"
	//LMenu.id="loading"
	//LMenu.className='menu'
	//LMenu.className='loading'
	//LBdy.appendChild(LMenu)
	//LMenu=document.getElementById("loading")
	//eval('LMenu' + styleString).visibility = "visible"
	//eval('LMenu' + styleString).position = "absolute"
	//	if (thisbrowser=="IE") {
	//		eval('LMenu' + styleString).pixelLeft = getPos('L',parentM) + getPos('W',parentM)-5// + Bdy.scrollTop //+ parentID.offsetHeight  + Bdy.scrollLeft + parentID.offsetWidth //parentID.getBoundingClientRect().left
	//		eval('LMenu' + styleString).pixelTop =  getPos('T',parentM) + getscrolltop() -2
	//	}
	//	else {
	//		pl=getPos('L',parentM) + getPos('W',parentM)-5
	//		pt=getPos('T',parentM) + getPos('H', parentM) - 24
	//		eval('LMenu' + styleString).left = pl + 'px'// + Bdy.scrollTop //+ parentID.offsetHeight  + Bdy.scrollLeft + parentID.offsetWidth //parentID.getBoundingClientRect().left
	//		eval('LMenu' + styleString).top =  (pt) +'px'
	//	}
		
	//a.width=200
	//a.innerHTML="<span style=\"position: absolute;right: 150px;color=#7c1e1f;\">&nbsp;**Loading**</span>" + a.innerHTML
}

function doShowMenu(parentID, hasSubMenu, parentLevel) { //actions to perform when Menu is mousedOver
		stopTime()
		highlightMOver(parentID, parentLevel)
		timerID=setTimeout('showSubMenu(' + parentID + ',' + hasSubMenu + ',' + parentLevel + ')' , timecount)
		timerOn=true
}

function doHideMenu(parentID, parentLevel) {
	highlightMOut(parentID, parentLevel)
	stopTime()
	timerID=setTimeout('hideByLevel(' + 0 + ')' , timecount); 
	timerOn = true; 
}
function doHideMenuHR(parentID, parentLevel) {
	stopTime()
	timerID=setTimeout('hideByLevel(' + 0 + ')' , timecount); 
	timerOn = true; 
}
function startTime() { 
	if (timerOn == false) { 
		timerID=setTimeout( "HideMenu(menuBar)" , timecount); 
		timerOn = true; 
	} 
}
function stopTime() { 
	if (timerOn) { 
		clearTimeout(timerID); 
		timerID = null; 
		timerOn = false; 
	} 
}
//---------------------------------------------------------------------
function showSubMenu(parentID, hasSubMenu, parentLevel) {
	LBdy=document.getElementById("Bdy")
	if (disableMenu==false) {
		
		LBdy=document.getElementById("Bdy")
		hideByLevel(parentLevel) //hide submenus that are below the current menu
		hideSelect()
		
		a=document.getElementById('img' +parentID)
		if ( a != null) {	eval('a' + styleString).visibility = "visible" }
		
		if (hasSubMenu != 0) {//if it has sub menus
			openMenu[parentLevel]=parentID; //indicate the current MenuID for the current level
			overDiv=document.createElement("DIV")
			overDiv.className='menu'
			overDiv.id='Menu' + parentID
			i=0
			while (deptChildrenID[parentID][i] + '' != '' && i < 50) {
			menuItemID=deptChildrenID[parentID][i]
			newDiv=document.createElement("DIV")
			newDiv.id='pMenu' + menuItemID
			//newDiv.innerHTML='<a class="navSideItem" href="gallery.asp?deptid=' + deptID[menuItemID] + '">' + deptName[menuItemID] + '</a>'
			newDiv.className='menuItem'
			if ((dURL[menuItemID] =='TEXT' )||(deptName[menuItemID]=='-')) {
					newDiv.className='barHRTN'
					newDiv.innerHTML=deptName[menuItemID]
				}
			else {			
				if (typeof dURL[menuItemID]=='undefined') {
					newDiv.innerHTML='<a class="navSideItem" href="gallery.asp?deptid=' + deptID[menuItemID] + '">' + deptName[menuItemID] + '</a>'	
				}
				else {
					(dURL[menuItemID].indexOf('?')>1)?qStr="&tn=":qStr="?tn=";			
					newDiv.innerHTML='<a class="navSideItem" href="' + dURL[menuItemID] + qStr + deptID[menuItemID] + '">' + deptName[menuItemID] + '</a>'	
				}
			}
			
			
			
			
			newDiv.level=parentLevel+1
			newDiv.hasSubMenu=0
			if (deptChildrenID[menuItemID][0] + '' != '') {//see if this menu item has children
				newDiv.hasSubMenu=1
				//newDiv.innerHTML += "&nbsp;&nbsp;<img class=\"Arrow\" src=\"/images/navigation/menuarrow.gif\">"
				newDiv.innerHTML = "<img class=\"Arrow\" src=\"/images/navigation/menuarrow.gif\">" + newDiv.innerHTML
				//newDiv2=document.createElement("DIV")
				//newDiv2.className='Arrow'
				//newDiv2.innerHTML += "<img src=\"/images/navigation/menuarrow.gif\">"
			} 
			
			if (dURL[menuItemID] !='TEXT' ) {
				newDiv.onmouseover = function () {doShowMenu(this.id.substr(5),this.hasSubMenu,this.level)}
				newDiv.onmouseout = function () {doHideMenu(this.id.substr(5), this.level)}
				newDiv.onclick = function () {disableMenu=true;hideByLevel('0');menuRedirect(deptID[this.id.substr(5)], dURL[this.id.substr(5)])}
			}
			else {
				newDiv.onmouseover = function () {stopTime()}
				newDiv.onmouseout = function () {doHideMenuHR(this.id.substr(5), this.level)}
			}
			overDiv.appendChild(newDiv)

			//if (deptChildrenID[menuItemID][0] + '' != '') { overDiv.appendChild(newDiv2) }
			
			i++
			}
			LBdy.appendChild(overDiv)
	
			
			parentM=eval('document.getElementById(\'pMenu' + parentID + '\')')
			LMenu=eval('document.getElementById(\'Menu' + parentID + '\')')
			eval('LMenu' + styleString).visibility = "visible"
			if ((parentLevel == 0) && ((parentM.className.indexOf('Top')>=0)||(parentM.className.indexOf('BT')>=0))) { //if dropping from above menu

				if (thisbrowser=="IE") {
					
					eval('LMenu' + styleString).pixelLeft = getPos('L',parentM)-5// + Bdy.scrollTop //+ parentID.offsetHeight  + Bdy.scrollLeft + parentID.offsetWidth //parentID.getBoundingClientRect().left
					eval('LMenu' + styleString).pixelTop =  getPos('T',parentM) + getscrolltop() + parentM.offsetHeight
				}
				else {
					pl = getPos('L',parentM)
					pt = getPos('T',parentM) + (LBdy.scrollTop) + parentM.offsetHeight
					eval('LMenu' + styleString).left = (pl-5) + 'px'// + Bdy.scrollTop //+ parentID.offsetHeight  + Bdy.scrollLeft + parentID.offsetWidth //parentID.getBoundingClientRect().left
					eval('LMenu' + styleString).top =  pt +'px'
				}
			}
			else {
				if (thisbrowser=="IE") {
					eval('LMenu' + styleString).pixelLeft = getPos('L',parentM) + getPos('W',parentM)-5// + Bdy.scrollTop //+ parentID.offsetHeight  + Bdy.scrollLeft + parentID.offsetWidth //parentID.getBoundingClientRect().left
					th=getPos("H",LMenu)
					eval('LMenu' + styleString).pixelTop =  getPos('T',parentM) + getscrolltop() -2 -(th/2) +10
				}
				else {
					pl=getPos('L',parentM) + getPos('W',parentM)-5
					pt=getPos('T',parentM) + getPos('H', parentM) - 24 - (getPos('H',LMenu)/2) + 15
					eval('LMenu' + styleString).left = pl + 'px'// + Bdy.scrollTop //+ parentID.offsetHeight  + Bdy.scrollLeft + parentID.offsetWidth //parentID.getBoundingClientRect().left
					eval('LMenu' + styleString).top =  (pt) +'px'
				}
			}
			//reposition menu if it is off screen
			wh=getWindow("H")
			ww=getWindow("W")
			mh=getPos("H",LMenu)
			mt=getPos("T",LMenu)
			mw=getPos("W",LMenu)
			ml=getPos("L",LMenu)
		
			if (thisbrowser=="IE") {
			
				if (mh + mt > wh) { eval('LMenu' + styleString).pixelTop=wh - mh + getscrolltop()}
				if ((wh<mh)||(mt<0)) { eval('LMenu' + styleString).pixelTop = getscrolltop()}
				if (mw + ml > ww) { eval('LMenu' + styleString).pixelLeft=getPos('L',parentM) - mw }

				//alert(eval('LMenu' + styleString).pixelTop)
				//alert(eval('LMenu' + styleString).pixelLeft)
				//eval('LMenu' + styleString).pixelTop=300
				//eval('LMenu' + styleString).pixelLeft=300
				//alert(eval('LMenu' + styleString).pixelTop)
			//	alert(eval('LMenu' + styleString).pixelLeft)
			//	alert(newDiv.innerHTML)
			}
			else {
				if (mh + mt - getscrolltop() > wh) { 	eval('LMenu' + styleString).top = (wh - mh+getscrolltop()) + 'px' }
				if ((wh<mh)||(mt-getscrolltop()<0)) { eval('LMenu' + styleString).top = 0 + getscrolltop() + 'px' }
				if (mw + ml > ww) { eval('LMenu' + styleString).left=(getPos('L',parentM) - mw) + 'px' }
			}
		}
	}
}
//---------------------------------------------------------------------
function hideSubMenu(MenuID) {
if (MenuID!=0) {
	a=document.getElementById('img' +MenuID)
	if (a != null) {	eval('a' + styleString).visibility = "hidden" }
	
	LMenu=document.getElementById('Menu' + MenuID)	
	upLevID=LMenu.id.substr(4)
	b=document.getElementById('pMenu' + upLevID)
	if (b !=null) {
		if (b.className=='barSelected') {	b.className='bar'	}//change upper menu to normal State
		else if (b.className=='barTopSelected') {	b.className='barTop'	}//change upper menu to normal State
		else if  (b.className=='menuItemSelected'){ b.className='menuItem' }
	}
	LMenu.parentNode.removeChild(LMenu)
}
}
//---------------------------------------------------------------------
function hideByLevel(parentLevel) {//hide submenus that are below (higher level number) the current menu
	i=0
	unhideSelect()
	while (i < 5) {
		if (i>=parentLevel) { 
			if (openMenu[i] != '') { hideSubMenu(openMenu[i]) } //Hide the open Menu by ID
			openMenu[i]='' //Remove the just closed menu from the openMenu list
		}
	i++;}}
//---------------------------------------------------------------------
function debug(str){
document.getElementById("x").innerHTML+=str + '<br>'
}
//---------------------------------------------------------------------


function highlightMOver(parentID, parentLevel) {
	a=document.getElementById('pMenu' + parentID)
	if (parentLevel==0) {
		if (a.hasSubMenu==1) {
			c=document.getElementById('img' +parentID)
			if ( c != null) {	eval('c' + styleString).visibility = "visible" }
		}
				
		if (a.className.indexOf('Top')>=0) { a.className='barTopOver' }
		else if (a.className.indexOf('bar')>=0){(a.className='barOver')}
	}
	else {
		a.className='menuItemOver'
		upLevID=a.parentNode.id.substr(4)
		b=document.getElementById('pMenu' + upLevID)
		eval('b' + styleString).visibility = "visible" 
		if (parentLevel==1) {
			if (b.className.indexOf('Top')>=0) { b.className='barTopSelected' }
			else if(b.className.indexOf('bar')>=0){(b.className='barSelected')}
		}
		else {
		b.className='menuItemSelected';
		}
	}
}
function highlightMOut(parentID, parentLevel) {
a=document.getElementById("pMenu" + parentID);
openMenu[parentLevel]==a.id.substr(5)?sText="Selected":sText='';
if (parentLevel==0) {
	if (a.className.indexOf('Top')>=0) { a.className='barTop'+sText }
	else if (a.className.indexOf('bar')>=0)	{
		(a.className='bar'+sText);
		if (sText=='') {
			a=document.getElementById('img' +parentID)
			if (a != null) {	eval('a' + styleString).visibility = "hidden" }
			}
		}
}
else {
a.className='menuItem' +sText;
}
}
//-->

