
function menuHandle() {
	if(this.L.newWindow) {
		openSubwindow('',this.L.value,600,500,'yes');
	} else {
		window.location.href=this.L.value;
	}
}
function showmenus(menuid, vis, dir, bgc,ffam,fsize,fsty,fwei,fcol,w,h,img, e) {
	if(vis==1) {
		eval('themenu=menu'+menuid);
		if(themenu.isactive == 1) {
		if(document.all){
			if(dir == 0) {
				menuX = e.clientX - e.offsetX+w;
				menuY = e.clientY + document.body.scrollTop - e.offsetY+2;
			} else {
				menuX = e.clientX - e.offsetX;
				menuY = e.clientY + document.body.scrollTop - e.offsetY+h; }
		} else {
			var Element = e.target ; 
			var CalculatedTotalOffsetLeft = CalculatedTotalOffsetTop = 0 ; 
			while (Element.offsetParent) 
			{
			CalculatedTotalOffsetLeft += Element.offsetLeft ; 
			CalculatedTotalOffsetTop += Element.offsetTop ; 
			Element = Element.offsetParent ;
			};
			OffsetXForFirefoxOrNetscape = e.pageX - CalculatedTotalOffsetLeft ; 
			OffsetYForFirefoxOrNetscape = e.pageY - CalculatedTotalOffsetTop ; 
			if(dir == 0) {
				menuX = e.clientX - OffsetXForFirefoxOrNetscape+w;
				menuY = e.clientY + document.body.scrollTop -OffsetYForFirefoxOrNetscape+2;
			} else {
				menuX = e.clientX - OffsetXForFirefoxOrNetscape;
				menuY = e.clientY + document.body.scrollTop - OffsetYForFirefoxOrNetscape+h; }
		}
		themenu.show(menuX,menuY);
	
		}
	}
	if(document.all('obj'+menuid)) {
		obj = document.all('obj'+menuid).style;
		obj.backgroundColor = bgc;
		obj.fontFamily	= ffam;
		obj.fontSize	= fsize;
		obj.fontStyle	= fsty;
		obj.fontWeight	= fwei;
		obj.color	= fcol;
	}
	if(document.all('menuimage'+menuid)) {
		if (!(img=='')) {
			if (window.location.href.indexOf("preview/index.html") != -1) {
				document.all('menuimage'+menuid).src = '../images/'+img;
			}
			else {
				document.all('menuimage'+menuid).src = 'images/'+img;
			}
		}
	}
}
function hidemenus(menuid,vis,bgc,ffam,fsize,fsty,fwei,fcol,img,e) {
	if(vis==1) {
		eval('themenu=menu'+menuid);
		if(themenu.isactive == 1) {
		themenu.L.isover = false;
		themenu.hide("menu"+menuid); } }
	if(document.all){
	window.setTimeout("hidethemenus("+menuid+","+vis+",'"+bgc+"','"+ffam+"',"+fsize+",'"+fsty+"','"+fwei+"','"+fcol+"','"+img+"')",1);
	}
}

function hidethemenus(menuid,vis,bgc,ffam,fsize,fsty,fwei,fcol,img) {
	changestuff = true;
	if(vis==1) {
		eval('themenu=menu'+menuid);
		if (themenu.visible) {
			window.setTimeout("hidethemenus("+menuid+","+vis+",'"+bgc+"','"+ffam+"',"+fsize+",'"+fsty+"','"+fwei+"','"+fcol+"','"+img+"')",1);
			changestuff = false; }
	}
	if(changestuff) {
			if(document.all('obj'+menuid)) {
				obj = document.all('obj'+menuid).style;
				obj.backgroundColor = bgc;
				obj.color	= fcol;
				obj.fontFamily	= ffam;
				obj.fontSize	= fsize;
				obj.fontStyle	= fsty;
				obj.fontWeight	= fwei;
				}

			if(!(img=='')) {
				if (window.location.href.indexOf("preview/index.html") != -1) {
					document.all('menuimage'+menuid).src = '../images/'+img;
				}
				else {
					document.all('menuimage'+menuid).src = 'images/'+img;
				}
			}
	}
}
// -------------------------------------------------------------------------------------------------------------------


function L(x,y,width,itemH) {	var t;
	t = this;	t.isover	= false
	t.name = "L"+(L.count++)
	t.x = x
	t.y = y
	t.w = width
	if (arguments.length==4) {
		t.itemH = itemH
		t.itemHset = true
		t.h = -1
	}
	else {
		t.itemH = null
		t.itemHset = false
		t.h = (is.ns)? -1 : 1000
	}

	t.nst			= new Object()
	t.nst.fontname	= 'New Time Roman'
	t.nst.fontsize	= 8
	t.nst.fontstyle	= 'normal'
	t.nst.fontweight	= 'normal'
	t.nst.fontcolor	= '#000000'
	t.nst.bgcolor	= '#E6E6E6'
	t.rst				= new Object()
	t.rst.fontname		= 'New Time Roman'
	t.rst.fontsize		= 8
	t.rst.fontstyle	= 'normal'
	t.rst.fontweight	= 'normal'
	t.rst.fontcolor	= '#000000'
	t.rst.bgcolor		= '#AAAAAA'
	t.sst			= new Object()
	t.sst.fontname	= 'New Time Roman'
	t.sst.fontsize	= 8
	t.sst.fontstyle	= 'normal'
	t.sst.fontweight	= 'normal'
	t.sst.fontcolor	= '#FFFFFF'
	t.sst.bgcolor	= '#000000'	t.bordercolour			= '#000000'
	t.itemSpacing = 0
	t.visibility = 'inherit'

	t.overOpen = false
	t.ML = null
	t.indent = 5
	
	t.allowDeselect = false
	t.multiSelect = false
	t.preSelect = null

	t.items = new Array()
	t.selectedIndex = null
	t.obj = t.name + "LObject"
	eval(t.obj + "=this")

	t.add = LAdd
	t.build = LBuild
	t.activate = LActivate
	t.over = LOver
	t.out = LOut
	t.down = LDown
	t.select = LSelect
	t.setCols = LSetCols
	t.image = new Object()
	t.deselect = LDeselect
	t.onSelect = new Function()	
	t.image.image0 = new Image()
	t.image.image0.src = 'login/images/icons/menunode.gif'
	t.image.image1 = new Image()
	t.image.image1.src = 'login/images/icons/menunode.gif'
	t.image.w = 12
	t.image.h = 18
}
function LSetCols() {
	this.cols = arguments
	this.multiCol = true
}
function LAdd(value) {
	var i = this.items.length
	this.items[i] = new Array()
	this.items[i].selected = false
	this.items[i].value = value	this.items[i].text = arguments[1]
	this.items[i].textNormal = arguments[1]
	this.items[i].textSelected = arguments[1]
	this.items[i].textRollover = arguments[1]
	if (arguments[2]) { this.items[i].newWindow = true; } else { this.items[i].newWindow = false; }
	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 LBuild() {
	this.css = ''
	this.css += css(this.name+'L',this.x,this.y,this.w,this.h,this.bordercolour,(this.itemHset)?this.visibility:'hidden')
	for (var i=0;i<this.items.length;i++) {
		this.css += css(this.name+'LItem'+i,0,this.items[i].y,this.w,this.itemH,this.nst.bgcolor)
		if (this.items[i].hasImage) this.css += css(this.name+'LItemImgLyr'+i,this.w-this.image.w,this.items[i].y)	}
	this.css += '.'+this.name+'TextNormal {font-weight:"'+this.nst.fontweight+'";font-style:"'+this.nst.fontstyle+'";font-family:"'+this.nst.fontname+'"; font-size:'+this.nst.fontsize+'px; color:'+this.nst.fontcolor+'; background-color:transparent; margin-left:'+this.indent+'px;}\n'+
	'.'+this.name+'TextSelected {font-weight:"'+this.sst.fontweight+'";font-style:"'+this.sst.fontstyle+'";font-family:"'+this.sst.fontname+'"; font-size:'+this.sst.fontsize+'px; color:'+this.sst.fontcolor+'; background-color:transparent; margin-left:'+this.indent+'px;}\n'+
	'.'+this.name+'TextRollover {font-weight:"'+this.rst.fontweight+'";font-style:"'+this.rst.fontstyle+'";font-family:"'+this.rst.fontname+'"; font-size:'+this.rst.fontsize+'px; color:'+this.rst.fontcolor+'; background-color:transparent; margin-left:'+this.indent+'px;}\n'

	this.div = '<div id="'+this.name+'L">\n'
	for (var i=0;i<this.items.length;i++) {		this.items[i].textNormal = '<div class="'+this.name+'TextNormal">'+this.items[i].textNormal + "</div>"		this.items[i].textRollover = '<div class="'+this.name+'TextRollover">'+this.items[i].textRollover + "</div>"		this.items[i].textSelected = '<div class="'+this.name+'TextSelected">'+this.items[i].textSelected + "</div>"
	
		if ((this.items[i].hasImage)) this.items[i].textNormal = "<table cellpadding=0 cellspacing=0 border=0 width=95%><tr><td align=left valign=middle class="+this.name+"TextNormal>" + this.items[i].textNormal + "</td><td align=right class="+this.name+"TextNormal><img src="+this.image.image0.src+" height="+(this.itemH-2)+" ></td></tr></table>"		if ((this.items[i].hasImage)) this.items[i].textRollover = "<table cellpadding=0 cellspacing=0 border=0 width=95%><tr><td align=left valign=middle class="+this.name+"TextRollover>" + this.items[i].textRollover + "</td><td align=right class="+this.name+"TextRollover><img src="+this.image.image0.src+" height="+(this.itemH-2)+" ></td></tr></table>"		if ((this.items[i].hasImage)) this.items[i].textSelected = "<table cellpadding=0 cellspacing=0 border=0 width=95%><tr><td align=left valign=middle class="+this.name+"TextSelected>" + this.items[i].textSelected + "</td><td align=right class="+this.name+"TextSelected><img src="+this.image.image0.src+" height="+(this.itemH-2)+" ></td></tr></table>"				if (is.ie55) {			this.div += '<div id="'+this.name+'LItem'+i+'" onmouseenter='+this.obj+'.over('+i+'); onmouseleave='+this.obj+'.out('+i+'); onmousedown='+this.obj+'.down('+i+');>'+this.items[i].textNormal+'</div>\n'		} else {			this.div += '<div id="'+this.name+'LItem'+i+'" onmouseover='+this.obj+'.over('+i+'); onmouseout='+this.obj+'.out('+i+'); onmousedown='+this.obj+'.down('+i+');>'+this.items[i].textNormal+'</div>\n'		}
	}
		this.div += '</div>'
}
function LActivate() {
	if (is.ie) this.h -= 1001
	this.lyr = new DL(this.name+'L')
	this.lyr.clipInit()

	for (var i=0;i<this.items.length;i++) {
		this.items[i].lyr = new DL(this.name+'LItem'+i)
		this.items[i].lyr.setbg = DLSetbg		this.items[i].lyr.css.backgroundColor = this.nst.bgcolor
	}
	this.lyr.css.visibility = this.visibility
}
function LOver(i) {	this.isover = true	theParent = (this.ML.parent)? this.ML.parent : ""	while(theParent != "") {		theParent.L.isover = true;		theParent = (theParent.L.ML.parent)? theParent.L.ML.parent : ""
	}
		if (!this.items[i].selected) {
	   this.items[i].lyr.setbg(this.rst.bgcolor)	   this.items[i].lyr.css.color = this.rst.fontcolor
	   this.items[i].lyr.write(this.items[i].textRollover)	   this.items[i].selected = true;
	}
	if (this.overOpen && i!=this.selectedIndex) {
		this.ML.hideMenu()
		this.deselect(this.selectedIndex)
		if (this.items[i].hasChild) this.select(i)
	}
	this.selectedIndex = i;
}
function LOut(i) {	this.isover = false
	theParent = (this.ML.parent)? this.ML.parent : ""	while(theParent != "") {		theParent.L.isover = false;		theParent = (theParent.L.ML.parent)? theParent.L.ML.parent : ""
	}	if (!this.items[i].selected) {	   this.items[i].lyr.setbg(this.nst.bgcolor)	   this.items[i].lyr.css.color = this.nst.fontcolor
	   this.items[i].lyr.write(this.items[i].textNormal)	}
}
function LDown(i) {
	this.select(i)
}
function LSelect(i) {
	if (this.items[i]!=null) {		this.selectedIndex = i		this.value = this.items[i].value		this.newWindow = this.items[i].newWindow
		this.items[i].lyr.setbg(this.sst.bgcolor)	    this.items[i].lyr.css.color = this.sst.fontcolor		this.items[i].lyr.write(this.items[i].textSelected)
		this.items[i].selected = true
		this.onSelect()
	}
}

function LDeselect(i) {
	if (this.items[i]!=null) {
	   if (this.items[i].selected) {
		//if (this.items[i].hasImage) this.items[i].imagelyr.doc.images[this.name+'LItemImg'+i].src = this.image.image0.src
		this.items[i].lyr.setbg(this.nst.bgcolor)	    this.items[i].lyr.css.color = this.nst.fontcolor
		this.items[i].lyr.write(this.items[i].textNormal)
		this.items[i].selected = false
		if (!this.multiSelect) this.selectedIndex = null
	   }
	}
}
function LRedirect() {
	location.href = this.value
}
L.count = 0

// DL setbg() required
function DLSetbg(color) {
	this.css.backgroundColor = color
}


//------------------------------------------------------------------------------------
function DL(id,nestref,frame) {
	if (!is.ns5 && !DL.set && !frame) DLInit()
	this.frame = frame || self
	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 + "DL"
	eval(this.obj + "=this")
}
function DLMoveTo(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 DLMoveBy(x,y) {
	this.moveTo(this.x+x,this.y+y)
}
function DLShow() {
	this.css.visibility = (is.ns4)? "show" : "visible"
}
function DLHide() {
	this.css.visibility = (is.ns4)? "hide" : "hidden"
}
DL.prototype.moveTo = DLMoveTo
DL.prototype.moveBy = DLMoveBy
DL.prototype.show = DLShow
DL.prototype.hide = DLHide
DLTest = new Function('return true')

// DLInit Function
function DLInit(nestref) {
	if (!DL.set) DL.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
			DL.nestRefArray[divname] = nestref
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DL("'+divname+'","'+nestref+'")')
			}
			if (ref.layers[i].document.layers.length > 0) {
				DL.refArray[DL.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
			}
		}
		if (DL.refArray.i < DL.refArray.length) {
			DLInit(DL.refArray[DL.refArray.i++])
		}
	}
	return true
}
DL.nestRefArray = new Array()
DL.refArray = new Array()
DL.refArray.i = 0
DL.set = false


// Clip Methods
function DLClipInit(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 DLClipTo(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)"
}
DL.prototype.clipInit = DLClipInit
DL.prototype.clipTo = DLClipTo

// Write Method
function DLWrite(html) {	this.event.innerHTML = html
}
DL.prototype.write = DLWrite

// 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.ie55 = (this.version.indexOf('MSIE 5.5')>0)
	this.ie55 = (this.version.indexOf('MSIE 6')>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+' {cursor:hand; 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)
}

//------------------------------------------------------------------------------------

function ML() {
	var t;	t = this;
	t.name = "ML"+(ML.count++)
	t.obj = t.name + "MLObject"	t.isovercount = 0	t.isactive = 0	t.direction = 1	eval(t.obj + "=this")
	if (arguments.length==4) {
		t.isChild = false
		t.x = arguments[0]
		t.y = arguments[1]
		t.w = arguments[2]
		t.itemH = arguments[3]
		t.subOnSelect = false
		t.offsetX = -1
		t.offsetY = 0
	}
	else {
		t.isChild = true
		t.parent = arguments[0]
		if(t.parent) { t.direction = t.parent.direction; }		var index = arguments[1]
		t.parent.L.items[index].hasImage = true
		t.parent.L.items[index].hasChild = true
		t.parent.L.items[index].child = t		if((is.ns) || (t.direction == 1)) { t.x = t.parent.w }		else { t.x = 0-(t.parent.w-2) }
		t.y = t.parent.L.items[index].y
		t.w = (arguments.length==3)? arguments[2] : t.parent.w
		t.itemH = t.parent.itemH
		t.childShown = null
		t.subOnSelect = t.parent.subOnSelect
		t.offsetX = t.parent.offsetX
		t.offsetY = t.parent.offsetY
	}

	t.visibility = 'hidden'
	t.zIndex = 10
	t.overOpen = true	t.isGrown = false
	
	t.L = new L(1,1,t.w-2,t.itemH)
	t.L.visibility = 'inherit'
	t.L.allowDeselect = true
	t.L.ML = this	t.L.bordercolour = '#000000'
	if (t.isChild) {
		t.L.image = t.parent.L.image
		t.L.nst = t.parent.L.nst
		t.L.rst = t.parent.L.rst
		t.L.sst = t.parent.L.sst
		t.L.itemSpacing = t.parent.L.itemSpacing		t.L.bordercolour = t.parent.L.bordercolour
	}
	
	t.cssChildren = ''
	t.divChildren = ''
	t.build = MLBuild
	t.activate = MLActivate
	t.showMenu = MLShowMenu
	t.hideMenu = MLHideMenu
	t.show = MLShow
	t.hide = MLHide
	t.Toggle = MLToggle
	t.select = MLSelect
	if (t.isChild) t.onSelect = t.parent.onSelect
	else t.onSelect = menuHandle
}
function MLBuild(write) {
	for (var i=0;i<this.L.items.length;i++) {
		if (this.L.items[i].hasChild) {
			this.L.items[i].child.overOpen = this.overOpen
			this.L.items[i].child.build()
		}
	}
	this.L.overOpen = this.overOpen
	this.L.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+'LW',0,0,this.w,this.L.h+2,this.L.bordercolour)+
	this.L.css+
	this.cssChildren

	this.div = '<div id="'+this.name+'">\n'+
	'<div id="'+this.name+'LW">\n'+
	this.L.div+
	'</div>\n'+
	this.divChildren+
	'</div>\n'

	if (this.isChild) {
		this.parent.cssChildren += this.css
		this.parent.divChildren += this.div
	}
}
function MLActivate() {
	this.L.activate()	this.lyr = new DL(this.name)	this.h = 0	this.maxh = this.L.items.length * (this.itemH+4)
	if (is.ns && !this.isChild) {
		this.lyr.clipInit()
		this.lyr.clipTo(0,this.w,this.maxh,0)
	}
	this.L.onSelect = new Function(this.obj+'.select(); return false;')
	for (var i=0;i<this.L.items.length;i++) {		if (this.L.items[i].hasChild) this.L.items[i].child.activate()
	}	this.isactive = 1
}
function MLSelect() {
	var i = this.L.selectedIndex
	if (i!=null) {
		if (!this.L.items[i].hasChild || i == this.childShown) this.onSelect()
		this.hideMenu()		if (this.L.items[i].hasChild) this.showMenu(i)
	}
}
function MLHideMenu() {	var i = this.childShown
	if (i!=null && this.L.items[i]!=null) {		this.childShown = null
		this.L.items[i].child.lyr.hide()
		this.L.items[i].child.hideMenu()
		if (this.L.items[i].child.L.selectedIndex!=null) {
			this.L.items[i].child.L.deselect(this.L.items[i].child.L.selectedIndex)
		}
	}
}
function MLShowMenu(i) {
	if (is.ns && !this.isChild) this.lyr.clipTo(0,this.lyr.w,this.lyr.h,0)	this.L.items[i].child.lyr.show()
	this.childShown = i
}
function MLToggle() {
	if (!this.visible) this.show()
	else this.hide()
}
function MLHide(obN) {
	if (this.L.items.length > 0) {
	if(this.L.isover==true) {		this.isovercount = 0
		window.setTimeout(obN+'.hide("'+obN+'")',1);	} else {
		if(this.isovercount < 3) {			this.isovercount = this.isovercount + 1
			window.setTimeout(obN+'.hide("'+obN+'")',1);
		} else {			this.isovercount = 0			this.hideMenu()
			this.L.deselect(this.L.selectedIndex)
			this.lyr.hide()
			this.visible = false
		}	}	}
}
function MLShow(x,y) {	if (this.L.items.length > 0) {
	window.status = false	this.lyr.css.visibility = 'inherit'	this.lyr.moveTo(x-3,y-4)
	this.visible = true	this.L.isover = true	}
}
function MLRedirect() {
	this.hide()	location.href = this.L.value
}
ML.count = 0

