// Dynamic Layer Object
// sophisticated layer/element targeting and animation object which provides the core functionality needed in most DHTML applications
// 19990604

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

function DynLayer(id,nestref,frame) {
	if (!is.ns5 && !DynLayer.set && !frame) DynLayerInit()
	this.frame = frame || self
	if (is.ns) {
		if (is.ns4) {
			if (!frame) {
				if (!nestref) var nestref = DynLayer.nestRefArray[id]
				if (!DynLayerTest(id,nestref)) return
				this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			}
			else this.css = (nestref)? eval("frame.document."+nestref+".document."+id) : frame.document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		else if (is.ns5) {
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
	}
	else if (is.ie) {
		this.elm = this.event = this.frame.document.all[id]
		this.css = this.frame.document.all[id].style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.y = this.elm.offsetTop
		this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
		this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
	}
	this.id = id
	this.nestref = nestref
	this.obj = id + "DynLayer"
	eval(this.obj + "=this")
}
function DynLayerMoveTo(x,y) {
	if (x!=null) {
		this.x = x
		if (is.ns) this.css.left = this.x
		else this.css.pixelLeft = this.x
	}
	if (y!=null) {
		this.y = y
		if (is.ns) this.css.top = this.y
		else this.css.pixelTop = this.y
	}
}
function DynLayerMoveBy(x,y) {
	this.moveTo(this.x+x,this.y+y)
}
function DynLayerShow() {
	this.css.visibility = (is.ns4)? "show" : "visible"
}
function DynLayerHide() {
	this.css.visibility = (is.ns4)? "hide" : "hidden"
}
DynLayer.prototype.moveTo = DynLayerMoveTo
DynLayer.prototype.moveBy = DynLayerMoveBy
DynLayer.prototype.show = DynLayerShow
DynLayer.prototype.hide = DynLayerHide
DynLayerTest = new Function('return true')

// DynLayerInit Function
function DynLayerInit(nestref) {
	if (!DynLayer.set) DynLayer.set = true
	if (is.ns) {
		if (nestref) ref = eval('document.'+nestref+'.document')
		else {nestref = ''; ref = document;}
		for (var i=0; i<ref.layers.length; i++) {
			var divname = ref.layers[i].name
			DynLayer.nestRefArray[divname] = nestref
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'","'+nestref+'")')
			}
			if (ref.layers[i].document.layers.length > 0) {
				DynLayer.refArray[DynLayer.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
			}
		}
		if (DynLayer.refArray.i < DynLayer.refArray.length) {
			DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
		}
	}
	else if (is.ie) {
		for (var i=0; i<document.all.tags("DIV").length; i++) {
			var divname = document.all.tags("DIV")[i].id
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
			}
		}
	}
	return true
}
DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

// Slide Methods
function DynLayerSlideTo(endx,endy,inc,speed,fn) {
	if (endx==null) endx = this.x
	if (endy==null) endy = this.y
	var distx = endx-this.x
	var disty = endy-this.y
	this.slideStart(endx,endy,distx,disty,inc,speed,fn)
}
function DynLayerSlideBy(distx,disty,inc,speed,fn) {
	var endx = this.x + distx
	var endy = this.y + disty
	this.slideStart(endx,endy,distx,disty,inc,speed,fn)
}
function DynLayerSlideStart(endx,endy,distx,disty,inc,speed,fn) {
	if (this.slideActive) return
	if (!inc) inc = 10
	if (!speed) speed = 20
	var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc
	if (num==0) return
	var dx = distx/num
	var dy = disty/num
	if (!fn) fn = null
	this.slideActive = true
	this.slide(dx,dy,endx,endy,num,1,speed,fn)
}
function DynLayerSlide(dx,dy,endx,endy,num,i,speed,fn) {
	if (!this.slideActive) return
	if (i++ < num) {
		this.moveBy(dx,dy)
		this.onSlide()
		if (this.slideActive) setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+num+","+i+","+speed+",\""+fn+"\")",speed)
		else this.onSlideEnd()
	}
	else {
		this.slideActive = false
		this.moveTo(endx,endy)
		this.onSlide()
		this.onSlideEnd()
		eval(fn)
	}
}
function DynLayerSlideInit() {}
DynLayer.prototype.slideInit = DynLayerSlideInit
DynLayer.prototype.slideTo = DynLayerSlideTo
DynLayer.prototype.slideBy = DynLayerSlideBy
DynLayer.prototype.slideStart = DynLayerSlideStart
DynLayer.prototype.slide = DynLayerSlide
DynLayer.prototype.onSlide = new Function()
DynLayer.prototype.onSlideEnd = new Function()

// Clip Methods
function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (is.ie) {
		if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft)
		else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0)
	}
}
function DynLayerClipTo(t,r,b,l) {
	if (t==null) t = this.clipValues('t')
	if (r==null) r = this.clipValues('r')
	if (b==null) b = this.clipValues('b')
	if (l==null) l = this.clipValues('l')
	if (is.ns) {
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	}
	else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}
function DynLayerClipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}
function DynLayerClipValues(which) {
	if (is.ie) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
	if (which=="t") return (is.ns)? this.css.clip.top : Number(clipv[0])
	if (which=="r") return (is.ns)? this.css.clip.right : Number(clipv[1])
	if (which=="b") return (is.ns)? this.css.clip.bottom : Number(clipv[2])
	if (which=="l") return (is.ns)? this.css.clip.left : Number(clipv[3])
}
DynLayer.prototype.clipInit = DynLayerClipInit
DynLayer.prototype.clipTo = DynLayerClipTo
DynLayer.prototype.clipBy = DynLayerClipBy
DynLayer.prototype.clipValues = DynLayerClipValues

// Write Method
function DynLayerWrite(html) {
	if (is.ns) {
		this.doc.open()
		this.doc.write(html)
		this.doc.close()
	}
	else if (is.ie) {
		this.event.innerHTML = html
	}
}
DynLayer.prototype.write = DynLayerWrite

// BrowserCheck Object
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

// CSS Function
function css(id,left,top,width,height,color,vis,z,other) {
	if (id=="START") return '<STYLE TYPE="text/css">\n'
	else if (id=="END") return '</STYLE>'
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
function writeCSS(str,showAlert) {
	str = css('START')+str+css('END')
	document.write(str)
	if (showAlert) alert(str)
}


// List Object
// generic selection widget built primarily to be incorporated into other List-based widgets (MenuList, ScrollList, SelectList)
// 19990410

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

// Thanks to: Knut Dale <Knut.S.Dale@eto.ericsson.se>
function aaa()
{
	alert('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
}
// function List(x,y,width,itemH,iconid) {
function List(width,styleData) {
	this.name = "List"+(List.count++)
	this.x = 1
	this.y = 1
	this.w = width
	
	this.styleData = styleData

// default css
	this.color = new Object()
	
// css get
	this.itemHset = true
	this.h = -1

	this.visibility = 'inherit'

	this.overOpen = false
	this.menulist = null
	
	this.allowDeselect = false
	this.multiSelect = false
	this.preSelect = null

	this.items = new Array()
	this.selectedIndex = null
	this.obj = this.name + "ListObject"
	eval(this.obj + "=this")

	this.add = ListAdd
	this.build = ListBuild
	this.activate = ListActivate
	this.over = ListOver
	this.out = ListOut
	this.down = ListDown
	this.select = ListSelect
	this.setCols = ListSetCols
	this.image = new Object()
	this.setImage = ListSetImage
	this.deselect = ListDeselect
	this.onSelect = new Function()

/*
	this.color.textNormal	= (document.styleSheets[0].rules[0].style.textNormal == null)?		'#000000'		: document.styleSheets[0].rules[0].style.textNormal
	this.color.textSelected	= (document.styleSheets[0].rules[0].style.textSelected == null)?	'#FFFFFF'		: document.styleSheets[0].rules[0].style.textSelected
	this.color.bgNormal	= (document.styleSheets[0].rules[0].style.bgNormal == null)?		'#FAE989'		: document.styleSheets[0].rules[0].style.bgNormal
	this.color.bgSelected	= (document.styleSheets[0].rules[0].style.bgSelected == null)?		'#03C0D6'		: document.styleSheets[0].rules[0].style.bgSelected
	this.color.bgRollover	= (document.styleSheets[0].rules[0].style.bgRollover == null)?		'#F8DB10'		: document.styleSheets[0].rules[0].style.bgRollover
	this.color.bg		= (document.styleSheets[0].rules[0].style.bg == null)?			'#FFFFFF'		: document.styleSheets[0].rules[0].style.bg

 	this.fontname		= (document.styleSheets[0].rules[0].style.fontname == null)?		'New Times Roman'	: document.styleSheets[0].rules[0].style.fontname
	this.fontsize		= (document.styleSheets[0].rules[0].style.fontsize == null)?		10			: document.styleSheets[0].rules[0].style.fontsize
	this.indent		= (document.styleSheets[0].rules[0].style.indent == null)?		5			: document.styleSheets[0].rules[0].style.indent

	this.itemH		= (eval(document.styleSheets[0].rules[0].style.itemH) == null)?		16			: eval(document.styleSheets[0].rules[0].style.itemH)

	this.itemSpacing	= (eval(document.styleSheets[0].rules[0].style.itemSpacing) == null)?	1			: eval(document.styleSheets[0].rules[0].style.itemSpacing)


*/
	this.setStyle = ListSetStyle
	this.color.textNormal	= this.styleData.textNormal
	this.color.textSelected	= this.styleData.textSelected
	this.color.bgNormal	= this.styleData.bgNormal
	this.color.bgSelected	= this.styleData.bgSelected
	this.color.bgRollover	= this.styleData.bgRollover
	this.color.bg		= this.styleData.bg

 	this.fontname		= this.styleData.fontname
	this.fontsize		= this.styleData.fontsize
	this.indent		= this.styleData.indent

	this.itemH		= this.styleData.itemH

	this.itemSpacing	= this.styleData.itemSpacing
//	this.setStyle()

	
/*
	this.color.textNormal	= (this.styleData.textNormal	== null)?	((document.styleSheets[0].rules[0].style.textNormal		== null)?	'#000000'		: document.styleSheets[0].rules[0].style.textNormal)		: this.styleData.textNormal
	this.color.textSelected	= (this.styleData.textSelected	== null)?	((document.styleSheets[0].rules[0].style.textSelected		== null)?	'#FFFFFF'		: document.styleSheets[0].rules[0].style.textSelected)		: this.styleData.textSelected
	this.color.bgNormal	= (this.styleData.bgNormal	== null)?	((document.styleSheets[0].rules[0].style.bgNormal		== null)?	'#FAE989'		: document.styleSheets[0].rules[0].style.bgNormal)		: this.styleData.bgNormal
	this.color.bgSelected	= (this.styleData.bgSelected	== null)?	((document.styleSheets[0].rules[0].style.bgSelected		== null)?	'#03C0D6'		: document.styleSheets[0].rules[0].style.bgSelected)		: this.styleData.bgSelected
	this.color.bgRollover	= (this.styleData.bgRollover	== null)?	((document.styleSheets[0].rules[0].style.bgRollover		== null)?	'#F8DB10'		: document.styleSheets[0].rules[0].style.bgRollover)		: this.styleData.bgRollover
	this.color.bg		= (this.styleData.bg		== null)?	((document.styleSheets[0].rules[0].style.bg			== null)?	'#FFFFFF'		: document.styleSheets[0].rules[0].style.bg)			: this.styleData.bg

 	this.fontname		= (this.styleData.fontname	== null)?	((document.styleSheets[0].rules[0].style.fontname		== null)?	'New Times Roman'	: document.styleSheets[0].rules[0].style.fontname)		: this.styleData.fontname
	this.fontsize		= (this.styleData.fontsize	== null)?	((document.styleSheets[0].rules[0].style.fontsize		== null)?	10			: document.styleSheets[0].rules[0].style.fontsize)		: this.styleData.fontsize
	this.indent		= (this.styleData.indent	== null)?	((document.styleSheets[0].rules[0].style.indent			== null)?	5			: document.styleSheets[0].rules[0].style.indent)		: this.styleData.indent

	this.itemH		= (this.styleData.itemH		== null)?	((eval(document.styleSheets[0].rules[0].style.itemH)		== null)?	16			: eval(document.styleSheets[0].rules[0].style.itemH))		: this.styleData.itemH

	this.itemSpacing	= (this.styleData.itemSpacing	== null)?	((eval(document.styleSheets[0].rules[0].style.itemSpacing)	== null)?	1			: eval(document.styleSheets[0].rules[0].style.itemSpacing))	: this.styleData.itemSpacing
*/
	

}
function ListSetStyle() {
	
	this.color.textNormal	= this.styleData.textNormal
	this.color.textSelected	= this.styleData.textSelected
	this.color.bgNormal	= this.styleData.bgNormal
	this.color.bgSelected	= this.styleData.bgSelected
	this.color.bgRollover	= this.styleData.bgRollover
	this.color.bg		= this.styleData.bg

 	this.fontname		= this.styleData.fontname
	this.fontsize		= this.styleData.fontsize
	this.indent		= this.styleData.indent

	this.itemH		= this.styleData.itemH

	this.itemSpacing	= this.styleData.itemSpacing
}
function ListSetCols() {
	this.cols = arguments
	this.multiCol = true
}
function ListSetImage(image0,image1,width,height) {
	this.image.image0 = new Image()
	this.image.image0.src = image0
	this.image.image1 = new Image()
	this.image.image1.src = image1
	this.image.w = width
	this.image.h = height
}
function ListAdd(linkaddress,show) {
	var argumentsnum = 2;
	var i = this.items.length
	this.items[i] = new Array()
	this.items[i].selected = false
	this.items[i].value = new Array()
	this.items[i].value.linkaddress	= linkaddress
	this.items[i].value.show	= show
	if (arguments.length > argumentsnum + 1) {
		this.items[i].textNormal = this.items[i].textSelected = '<table border=0 cellpadding=0 cellspacing=0><tr>'
		this.items[i].text = new Array()
		for (var j=argumentsnum;j<arguments.length;j++) {
			this.items[i].text[j-1] = ''+arguments[j]
			this.items[i].textNormal += '<td width='+this.cols[j-1]+'><div class="'+this.name+'TextNormal">'+arguments[j]+'</div></td>'
			this.items[i].textSelected += '<td width='+this.cols[j-1]+'><div class="'+this.name+'TextSelected">'+arguments[j]+'</div></td>'
		}
		this.items[i].textNormal += '</tr></table>'
		this.items[i].textSelected += '</tr></table>'
	}
	else {
		this.items[i].text = arguments[argumentsnum]
		
		this.items[i].textNormal = '<div id="'+this.name+'ListItemWord'+i+'" class="'+this.name+'TextNormal" onmouseout="'+this.obj+'.out('+i+')" onmouseover="'+this.obj+'.over('+i+')" onmousedown="'+this.obj+'.down('+i+')">'+arguments[argumentsnum]+'</div>'
		this.items[i].textSelected = '<div id="'+this.name+'ListItemWordC'+i+'" class="'+this.name+'TextSelected">'+arguments[argumentsnum]+'</div>'
	}
	if (this.itemH) {
		this.h += this.itemH+this.itemSpacing
		this.items[i].y = i*this.itemH+i*this.itemSpacing
	}
	else this.items[i].y = 0
}
function ListBuild() {
//	this.css += css(this.name+'List',this.x,this.y,this.w,this.h,this.color.bg,(this.itemHset)?this.visibility:'hidden')

	this.css = ''
	this.css += css(this.name+'List',this.x,null,this.w,this.h,this.color.bg,(this.itemHset)?this.visibility:'hidden')
	for (var i=0;i<this.items.length;i++) {
		this.css += css(this.name+'ListItem'+i,0,this.items[i].y,this.w,this.itemH,this.color.bgNormal)
		if (this.items[i].hasImage) this.css += css(this.name+'ListItemImgLyr'+i,this.w-this.image.w,this.items[i].y)
		this.css += css(this.name+'ListItemC'+i,0,this.items[i].y,this.w,this.itemH)
	}
	this.css += '.'+this.name+'TextNormal {font-family:"'+this.fontname+'"; font-size:'+this.fontsize+'pt; color:'+this.color.textNormal+'; background-image: ' + this.bgimageF + '; background-color: transparent; margin-left:'+this.indent+'px;}\n'+
	'.'+this.name+'TextSelected {font-family:"'+this.fontname+'"; font-size:'+this.fontsize+'pt; color:'+this.color.textSelected+'; background-image: ' + this.bgimageB + '; background-color: transparent; margin-left:'+this.indent+'px;}\n'

	this.div = '<div id="'+this.name+'List" style="cursor:hand;">\n'
	for (var i=0;i<this.items.length;i++) {
		this.div += '<div id="'+this.name+'ListItem'+i+'" style="">'+this.items[i].textNormal+'</div>\n'
		if (this.items[i].hasImage) this.div += '<div id="'+this.name+'ListItemImgLyr'+i+'"><img name="'+this.name+'ListItemImg'+i+'" src="'+this.image.image0.src+'" width='+this.image.w+' height='+this.image.h+'></div>\n'
		this.div += '<div id="'+this.name+'ListItemC'+i+'" style=""></div>\n'
	}
	this.div += '</div>'
}
function ListActivate() {
	if (is.ie) this.h -= 1001
	this.lyr = new DynLayer(this.name+'List')
	this.lyr.clipInit()

	for (var i=0;i<this.items.length;i++) {
		this.items[i].lyr = new DynLayer(this.name+'ListItem'+i)
		this.items[i].lyr.setbg = DynLayerSetbg
		this.items[i].lyre = new DynLayer(this.name+'ListItemC'+i)
		if (is.ns) this.items[i].lyre.event.captureEvents(Event.MOUSEDOWN)
		this.items[i].lyre.event.onmouseover = new Function(this.obj+'.over('+i+'); return false;')
		this.items[i].lyre.event.onmouseout = new Function(this.obj+'.out('+i+'); return false;')
		this.items[i].lyre.event.onmousedown = new Function(this.obj+'.down('+i+'); return false;')
		if (!this.itemHset) {
			this.itemH = (is.ns)? this.items[0].lyr.doc.height : this.items[0].lyr.event.offsetHeight
			this.items[i].lyr.moveTo(null,i*this.itemH+this.itemSpacing*i)
			this.items[i].lyre.moveTo(null,i*this.itemH+this.itemSpacing*i)
			if (is.ns) {
				this.items[i].lyr.clipInit()
				this.items[i].lyr.clipTo(0,this.w,this.itemH,0)
				this.items[i].lyre.clipInit()
				this.items[i].lyre.clipTo(0,this.w,this.itemH,0)
			}
			this.h += this.itemH+this.itemSpacing
		}
		if (this.items[i].hasImage) {
			this.items[i].imagelyr = new DynLayer(this.name+'ListItemImgLyr'+i)
		}
	}
	if (!this.itemHset) {
		this.lyr.clipTo(0,this.w,this.h,0)
		if (is.ie) this.lyr.css.height = this.h
	}
	if (this.preSelect!=null) this.select(this.preSelect)
	this.lyr.css.visibility = this.visibility
}
function ListOver(i) {
	if (!this.items[i].selected) {
	   this.items[i].lyr.setbg(this.color.bgRollover)
	}
	if (this.overOpen && i!=this.selectedIndex) {
		this.menulist.hideMenu()
		this.deselect(this.selectedIndex)
		if (this.items[i].hasChild) this.select(i)
	}
}
function ListOut(i) {
	if (!this.items[i].selected) this.items[i].lyr.setbg(this.color.bgNormal)
}
function ListDown(i) {
	if (!this.items[i].selected) {
		if (!this.multiSelect && this.selectedIndex!=null) this.deselect(this.selectedIndex)
		this.select(i)		
	}
	else {
		if (this.multiSelect || this.allowDeselect) {
			this.menulist.hideMenu()
			this.deselect(i)
		}
	}
}
function ListSelect(i) {
	if (this.items[i]!=null) {	
		this.selectedIndex = i
		this.value = this.items[i].value
		
		if (this.items[i].hasImage) this.items[i].imagelyr.doc.images[this.name+'ListItemImg'+i].src = this.image.image1.src
		this.items[i].lyr.setbg(this.color.bgSelected)
		this.items[i].lyr.write(this.items[i].textSelected)
		this.items[i].selected = true
		this.onSelect()
	}
}

function ListDeselect(i) {
	if (this.items[i]!=null) {
	   if (this.items[i].selected) {
		if (this.items[i].hasImage) this.items[i].imagelyr.doc.images[this.name+'ListItemImg'+i].src = this.image.image0.src
		this.items[i].lyr.setbg(this.color.bgNormal)
		this.items[i].lyr.write(this.items[i].textNormal)
		this.items[i].selected = false
		if (!this.multiSelect) this.selectedIndex = null
	   }
	}
}
function ListRedirect() {
	location.href = this.value
}
List.count = 0

// Dynlayer setbg() required
function DynLayerSetbg(color) {
	if (is.ns) this.doc.bgColor = color
	else if (is.ie) this.css.backgroundColor = color
}




// MenuList Object
// a cascading menu widget utilizing the List Object
// 19990326

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/

// Thanks to: Knut Dale <Knut.S.Dale@eto.ericsson.se>

function MenuList() {
	if (arguments.length==2) {

		this.isChild = false
		
		this.x = 0
		this.y = 0
		this.w = arguments[0]
		this.subOnSelect = false
		this.offsetX = -1
		this.offsetY = 0
		this.styleData = arguments[1]
		
//		document.write(this.styleData.bg)
		this.list = new List(this.w-2,this.styleData)
	}
	else {
		this.isChild = true
		this.parent = arguments[0]
		var index = arguments[1]
		this.parent.list.items[index].hasImage = true
		this.parent.list.items[index].hasChild = true
		this.parent.list.items[index].child = this
		this.x = this.parent.w
		this.y = this.parent.list.items[index].y
		this.w = (arguments.length>=3 && arguments[2]!=null)? arguments[2] : this.parent.w
		this.childShown = null
		this.subOnSelect = this.parent.subOnSelect
		this.offsetX = this.parent.offsetX
		this.offsetY = this.parent.offsetY
		this.styleData = this.parent.styleData
		
		this.list = new List(this.w-2,this.styleData)
	}
	
	this.name = "MenuList"+(MenuList.count++)
	this.obj = this.name + "MenuListObject"
	eval(this.obj + "=this")

	this.list.visibility = 'inherit'
	this.list.allowDeselect = true
	this.list.menulist = this

	this.visibility = 'inherit'
	this.zIndex = null
	this.overOpen = false
	
	if (this.isChild) {
		this.list.image = this.parent.list.image
		this.list.fontname = this.parent.list.fontname
		this.list.fontsize = this.parent.list.fontsize
	}
	
	this.cssChildren = ''
	this.divChildren = ''

	this.build = MenuListBuild
	this.activate = MenuListActivate
	this.showMenu = MenuListShowMenu
	this.hideMenu = MenuListHideMenu
	this.show = MenuListShow
	this.hide = MenuListHide
	this.toggle = MenuListToggle
	this.select = MenuListSelect
	if (this.isChild) this.onSelect = this.parent.onSelect
	else this.onSelect = new Function()
}
function MenuListBuild(write) {
	for (var i=0;i<this.list.items.length;i++) {
		if (this.list.items[i].hasChild) {
			this.list.items[i].child.overOpen = this.overOpen
			this.list.items[i].child.build()
		}
	}
	this.list.overOpen = this.overOpen
	this.list.build()

	this.css = css(this.name,this.x+this.offsetX,this.y+this.offsetY,null,null,null,(this.isChild)?'hidden':this.visibility,this.zIndex)+
	css(this.name+'ListW',0,0,this.w,this.list.h+2,'black')+
	this.list.css+
	this.cssChildren

	this.div = '<div id="'+this.name+'" style="z-index: 8;">\n'+
	'<div id="'+this.name+'ListW">\n'+
	this.list.div+
	'</div>\n'+
	this.divChildren+
	'</div>\n'

	if (this.isChild) {
		this.parent.cssChildren += this.css
		this.parent.divChildren += this.div
	}
}
function MenuListActivate() {
	this.list.activate()
	this.lyr = new DynLayer(this.name)
	this.h = this.list.h+2
	if (is.ns && !this.isChild) {
		this.lyr.clipInit()
		this.lyr.clipTo(0,this.w,this.h,0)
	}
	this.list.onSelect = new Function(this.obj+'.select(); return false;')
	for (var i=0;i<this.list.items.length;i++) {
		if (this.list.items[i].hasChild) this.list.items[i].child.activate()
	}
}
function MenuListSelect() {
	var i = this.list.selectedIndex
	if (i!=null) {
	if (this.childShown==i) {
		this.hideMenu(this.childShown)
	}
	else {
		this.hideMenu()
		if (this.list.items[i].hasChild) this.showMenu(i)
		if (!this.list.items[i].hasChild || this.subOnSelect) this.onSelect()
	}
	}
}
function MenuListHideMenu() {
	var i = this.childShown
	if (i!=null && this.list.items[i]!=null) {
		this.childShown = null
		this.list.items[i].child.lyr.hide()
		this.list.items[i].child.hideMenu()
		if (this.list.items[i].child.list.selectedIndex!=null) {
			this.list.items[i].child.list.deselect(this.list.items[i].child.list.selectedIndex)
		}
		if (is.ns && !this.isChild) this.lyr.clipTo(0,this.w,this.h,0)
	}
}
function MenuListShowMenu(i) {
	if (is.ns && !this.isChild) this.lyr.clipTo(0,this.lyr.w,this.lyr.h,0)
	this.list.items[i].child.lyr.show()
	this.childShown = i
}
function MenuListToggle() {
	if (!this.visible) this.show()
	else this.hide()
}
function MenuListHide() {
	this.hideMenu()
	this.list.deselect(this.list.selectedIndex)
	this.lyr.hide()
	this.visible = false
}
function MenuListShow() {
	this.lyr.css.visibility = 'inherit'
	this.visible = true
}
function MenuListRedirect() {
	this.hide()
	location.href = this.list.value
}
MenuList.count = 0







function DataArr(index,Width,parentObj,indexnum) {
	this.name = "DataArr"+(DataArr.count++)
	
	this.index	= index
	this.Width	= Width
	
	if(parentObj != null) {
		this.parent = parentObj
		this.parent.item[indexnum].child = this
	}

	this.item = new Array()
	
	this.obj = this.name + "DataArrObject"
	eval(this.obj + "=this")

	this.add = DataArrAdd
}

function DataArrAdd(linkaddress,KindShow,KindName) {
	var i = this.item.length
	this.item[i]	= new Array()
	this.item[i].linkaddress	= linkaddress
	this.item[i].KindShow		= KindShow
	this.item[i].KindName		= KindName
}
MenuListArr	= new Array()


function StyleData(blank, textNormal, textSelected, bgNormal, bgSelected, bgRollover, bg, fontname, fontsize, indent, itemH, itemSpacing) {
	this.name = "StyleData"+(StyleData.count++)
	
	this.obj = this.name + "SytleDataObject"
	eval(this.obj + "=this")
	
//	this.setStyle = setStyle

	this.blank		= (blank == null)?		'' : blank
	this.textNormal		= (textNormal == null)?		((document.styleSheets[0].rules[0].style.textNormal == null)?		'#000000'		: document.styleSheets[0].rules[0].style.textNormal)		: textNormal
	this.textSelected	= (textSelected == null)?	((document.styleSheets[0].rules[0].style.textSelected == null)?		'#000000'		: document.styleSheets[0].rules[0].style.textSelected)		: textSelected
	this.bgNormal		= (bgNormal == null)?		((document.styleSheets[0].rules[0].style.bgNormal == null)?		'#000000'		: document.styleSheets[0].rules[0].style.bgNormal)		: bgNormal
	this.bgSelected		= (bgSelected == null)?		((document.styleSheets[0].rules[0].style.bgSelected == null)?		'#000000'		: document.styleSheets[0].rules[0].style.bgSelected)		: bgSelected
	this.bgRollover		= (bgRollover == null)?		((document.styleSheets[0].rules[0].style.bgRollover == null)?		'#000000'		: document.styleSheets[0].rules[0].style.bgRollover)		: bgRollover
	this.bg			= (bg == null)?			((document.styleSheets[0].rules[0].style.bg == null)?			'#000000'		: document.styleSheets[0].rules[0].style.bg)			: bg

 	this.fontname		= (fontname == null)?		((document.styleSheets[0].rules[0].style.fontname == null)?		'New Times Roman'	: document.styleSheets[0].rules[0].style.fontname)		: fontname
	this.fontsize		= (fontsize == null)? 		((document.styleSheets[0].rules[0].style.fontsize == null)?		10			: document.styleSheets[0].rules[0].style.fontsize)		: fontsize
	this.indent		= (indent == null)?		((document.styleSheets[0].rules[0].style.indent == null)?		5			: document.styleSheets[0].rules[0].style.indent)		: indent

	this.itemH		= (itemH == null)?		((eval(document.styleSheets[0].rules[0].style.itemH) == null)?		16			: eval(document.styleSheets[0].rules[0].style.itemH))		: itemH
	this.itemSpacing	= (itemSpacing == null)?	((eval(document.styleSheets[0].rules[0].style.itemSpacing) == null)?	1			: eval(document.styleSheets[0].rules[0].style.itemSpacing))	: itemSpacing

//	this.textWord		= document.styleSheets[0].rules.namedItem('icon0101').style.textNormal
}

/*
function StyleData(blank, textNormal, textSelected, bgNormal, bgSelected, bgRollover, bg, fontname, fontsize, indent, itemH, itemSpacing) {
	this.name = "StyleData"+(StyleData.count++)
	
	this.obj = this.name + "SytleDataObject"
	eval(this.obj + "=this")
	
//	this.setStyle = setStyle

	this.blank		= blank
	this.textNormal		= textNormal
	this.textSelected	= textSelected
	this.bgNormal		= bgNormal
	this.bgSelected		= bgSelected
	this.bgRollover		= bgRollover
	this.bg			= bg

 	this.fontname		= fontname
	this.fontsize		= fontsize 
	this.indent		= indent

	this.itemH		= itemH
	this.itemSpacing	= itemSpacing
}

function setStyle(textNormal, textSelected, bgNormal, bgSelected, bgRollover, bg, fontname, fontsize, indent, itemH, itemSpacing) {
	this.StyleArr	= new Array()

	this.StyleArr.textNormal	= textNormal
	this.StyleArr.textSelected	= textSelected
	this.StyleArr.bgNormal		= bgNormal
	this.StyleArr.bgSelected	= bgSelected
	this.StyleArr.bgRollover	= bgRollover
	this.StyleArr.bg		= bg

 	this.StyleArr.fontname		= fontname
	this.StyleArr.fontsize		= fontsize 
	this.StyleArr.indent		= indent

	this.StyleArr.itemH		= itemH
	this.StyleArr.itemSpacing	= itemSpacing
}
*/










function MakeList(MenuListArrF, DoNum, Gindex, FieldNum, GMenuListArr) {
	if (DoNum == 1) {
//		numbers[MenuListArrF.index] = new MenuList(MenuListArrF.Width ,GMenuListArr.icon, GMenuListArr.iconid)
		numbers[MenuListArrF.index] = new MenuList(MenuListArrF.Width ,GMenuListArr.styleData)
		numbers[MenuListArrF.index].overOpen = true
		numbers[MenuListArrF.index].list.setImage(GMenuListArr.imgopen,GMenuListArr.imgclose,12,18)
//		numbers[MenuListArrF.index].list.setImage('/nexus/front-end/img/list-node0.gif','/nexus/front-end/img/list-node1.gif',12,18)
		numbers[MenuListArrF.index].onSelect = menuListHandler
	} else {
		numbers[MenuListArrF.index] = new MenuList(numbers[Gindex], FieldNum,MenuListArrF.Width)
	}
	for(var i=0; i<MenuListArrF.item.length; i++) {
		numbers[MenuListArrF.index].list.add(MenuListArrF.item[i].linkaddress,MenuListArrF.item[i].KindShow,MenuListArrF.item[i].KindName)
	}
	for(var i=0; i<MenuListArrF.item.length; i++) {
	        if (MenuListArrF.item[i].child != null) {
			MakeList(MenuListArrF.item[i].child, DoNum + 1, MenuListArrF.index, i, GMenuListArr);
		}
	}
	if (DoNum == 1) {
		numbers[MenuListArrF.index].build()
		writeCSS(numbers[MenuListArrF.index].css)
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////

function init() {
	for(i=0;i<MenuListArr.length;i++) {
		numbers[MenuListArr[i][MenuListArr[i].index].index].activate()
	}
}

function menuListHandler() {
	if (this.list.value.show == 'B' || this.list.styleData.blank == '_blank') {
		window.open(this.list.value.linkaddress)
	} else {
		location=this.list.value.linkaddress
	}
}

function iconMouseOver(OverIndex) {
	for(var i=0; i < MenuListArr.length; i++) {
		numbers[MenuListArr[i].index].hideMenu(0)
//		document.all['IconDiv' + MenuListArr[i].index].style.filter = ''
//		document.all['IconDiv' + MenuListArr[i].index].style.backgroundColor = 'transparent'
		document.all['IconDiv' + MenuListArr[i].index].style.color = 'blue'
//		document.all['IconDiv' + MenuListArr[i].index].className = 'icon_text04'
	}
	if(OverIndex != null) {
//		this.className = document.all['IconDiv' + OverIndex].className
		numbers[OverIndex].showMenu(0)
//		document.all['IconDiv' + OverIndex].style.filter = 'invert()'
//		document.all['IconDiv' + OverIndex].style.backgroundColor = '#CCCCCC'
		document.all['IconDiv' + OverIndex].style.color = 'red'
//		document.all['IconDiv' + OverIndex].className = 'icon_text03'
	}	
}

function iconMouseOut(OutIndex) {
	if(OutIndex != null) {
//		document.all['IconDiv' + OutIndex].style.backgroundColor = 'transparent'
//		document.all['IconDiv' + OutIndex].style.color = 'blue'
	}
}

function iconMake(i) {
//	document.write('<tr><td><div class="icon1' + MenuListArr[i].iconid + '" style="cursor:hand; z-index:9;' + MenuListArr[i].style + ' " onmouseover="iconMouseOver(\'' + MenuListArr[i].index + '\')">' + MenuListArr[i][MenuListArr[i].index].item[0].KindName + '</div>\n')
//	document.write('<tr><td><div ' + MenuListArr[i].style + ' onmouseover="iconMouseOver(\'' + MenuListArr[i].index + '\')">' + MenuListArr[i][MenuListArr[i].index].item[0].KindName + '</div>\n')

//	document.write('<tr><td><div id="IconDiv' + MenuListArr[i].index + '" ' + MenuListArr[i].style + ' onmouseover="iconMouseOver(\'' + MenuListArr[i].index + '\')" onmouseout="iconMouseOut(\'' + MenuListArr[i].index + '\')">' + MenuListArr[i][MenuListArr[i].index].item[0].KindName  + '</div>')
	document.write('<tr><td ' + MenuListArr[i].style + '><div id="IconDiv' + MenuListArr[i].index + '" onmouseover="iconMouseOver(\'' + MenuListArr[i].index + '\')" onmouseout="iconMouseOut(\'' + MenuListArr[i].index + '\')">' + MenuListArr[i][MenuListArr[i].index].item[0].KindName  + '</div>')

	document.write('<div style="position: relative; visibility: hidden; left: ' + MenuListArr[i].rightmove + 'px; top: -20px; z-index:80; text-indent: 0px; background-color:#0000FF; font-size: 12px; line-height: 20px; text-decoration: none; letter-spacing: 1pt; vertical-align: middle; overflow: hidden; clip:   rect(   );background-repeat: no-repeat; cursor:hand; background-position: center;">\n')
	document.write(numbers[MenuListArr[i][MenuListArr[i].index].index].div)
	document.write('</div>\n')
	
	document.write('</td></tr>\n')

}

function writediv(i) {
//	document.write('<div style="position: relative; visibility: hidden; left: 80px; top: -20px; z-index:80; text-indent: 0px; background-color:#0000FF; font-size: 12px; line-height: 20px; text-decoration: none; letter-spacing: 1pt; vertical-align: middle; overflow: hidden; clip:   rect(   );background-repeat: no-repeat; cursor:hand; background-position: center;">\n')

}

function iconMakewritediv(i) {
	iconMake(i)
	writediv(i)
}

function makeMenuList() {
	var j = MenuListArr.number++
	MakeList(MenuListArr[j][MenuListArr[j].index],1,0,0,MenuListArr[j])
	iconMakewritediv(j)
}

numbers			= new Array()
MenuListArr.number	= 0

//for(j=0;j<MenuListArr.length;j++) {
//	MakeList(MenuListArr[j][MenuListArr[j].index],1,0,0,MenuListArr[j])
//}