active=false
menusReady = false
currentMenu = ""

var NS4 = false
var IE4 = false
var DOM = false
var IE = false
var NS6 = false

oldIE = ( navigator.appName.indexOf('Microsoft') >= 0 && navigator.appVersion.indexOf('MSIE 4.') >= 0) ? true:false
if (document.getElementById) { DOM = true; browser="DOM"; }
if (document.layers && !DOM) { NS4 = true; browser="NS4"; }
if (document.all && !DOM) IE4 = true
if (navigator.appName.indexOf("Microsoft Internet Explorer") > -1) IE = true
if (DOM && !IE) NS6 = true


function initLayers() {

	menuArray = eval(currentSection + "Array")
	for (x=0; x<menuArray.length; x++) {
		layerName = menuArray[x] + 'Layer'
		useArray = eval(menuArray[x])
		if (NS4) { menu = '<layer id="' + layerName + '" width=' + menuWidth + ' z-index=20 visibility=hide onmouseout="unLock(\'' + menuArray[x] + 'Lyr\')" onmouseover="lock(\'' + menuArray[x] + 'Lyr\')">\n' }
		else { menu = '<div id="' + layerName + '" style="position: absolute; z-index: 20; visibility: hidden;" onmouseout="unLock(\'' + menuArray[x] + 'Lyr\')" onmouseover="lock(\'' + menuArray[x] + 'Lyr\')">\n' }
		menu += (currentSection != "home") ? '<table border=0 cellpadding=0 cellspacing=0 height=80><tr><td valign=bottom>\n' : ''
		menu += '<table border=0 cellpadding=0 cellspacing=' + ((currentSection != "home") ? '4' : '5') + '>\n'
		for (v=0;v<useArray.length;v++) {
			menu += '<tr><td><a href="' + useArray[v][1] + '" class=menuLink' + ((currentSection != "home") ? '2>' : '1>') + useArray[v][0] + '</a></td></tr>\n';
		}
		menu += (currentSection != "home") ? '</table></td></tr></table>\n' : '</table>\n'
		if (NS4) { menu += '</layer>\n' }
		else { menu += '</div>\n' }
		document.write(menu);
	}

	for (x=0; x<menuArray.length; x++) {
		layerName = menuArray[x] + 'Layer'
		useArray = eval(menuArray[x])
		eval(menuArray[x] + 'Lyr = new domObject("' + layerName + '")')
		//positionLayers(menuArray[x],menuHposition[x],menuVposition[x])
	}
	menusReady = true

}

if (!oldIE) initLayers()

function domObject(theName) {
	if (DOM) {
		this.sty = document.getElementById(theName).style
	}
	if (NS4) {
		this.sty = document.layers[theName]
	}
	if (IE4) {
		this.sty = this.document.all[theName].style
	}
	this.theName = theName
	this.active = false
	this.locked = false
	this.hideMenu = dropit
}

function showMenu(theMenu) {  //receives the layer object name
	if (menusReady && !oldIE) {
		theName = theMenu.replace(/Lyr/, "")
		theObject = eval(theMenu)
		if (currentMenu != theName && currentMenu != "") {
			theOldMenu = eval(currentMenu + "Lyr")
			theOldMenu.hideMenu()
		}
		currentMenu = theName;
		argMenu = theMenu
		theObject.active = true
		show = setTimeout("showIt(argMenu)", 100)
	}
}

function showIt(theMenu) {
	if (eval(theMenu + ".active") == true) {
		eval(theMenu + '.sty.visibility = (NS4)? "show" : "visible"')
		theName = theMenu.replace(/Lyr/, "")
		turnon(theName)
	}
}

function dropMenu(theMenu) {
	if (menusReady && !oldIE) {
		theObject = eval(theMenu)
		theObject.active = false
		wait = setTimeout("theObject.hideMenu()", 0)
	}
}

function dropit() {
	if (!oldIE && !this.locked) {
		this.sty.visibility = (NS4)? "hide" : "hidden"
		layerName = this.theName.replace(/Layer/, "")
		turnoff(layerName)
	}
}

function lock(theMenu) {
	eval(theMenu + ".locked = true")
}

function unLock(theMenu) {
	theObject = eval(theMenu)
	theObject.locked = false
	dropMenu(theMenu)
}


function positionLayers(layerq,posq,vposq) {
	refPoint = getRefPoint()
	eval(layerq + 'Lyr.sty.left = ' + (posq + refPoint))
	eval(layerq + 'Lyr.sty.top = ' + vposq)
}

function getRefPoint() {
	if (document.layers) thewidth = innerWidth - 16
	if (document.all) thewidth = document.body.clientWidth 
	if (document.getElementById && !document.all) thewidth = innerWidth // + 10 //- 20
	referencepoint = Math.round((thewidth - 671) / 2)
	if (thewidth < 672) referencepoint = 0
	return referencepoint
}



