if (!POPUPMENU_REFERENCE) {
	var POPUPMENU_REFERENCE = new Object();
}
var PopupMenu = function(divID, dataArray) {
	this.setDivID(divID);
	this.setDataArray(dataArray);
	this.setWidth("160px");
	this.setFontFamily("Verdana, Arial, Helvetica, sans-serif");
	this.setFontSize("10px");
	this.setFontWeight("bold");
	this.setMargin("1px");
	this.setPadding("2px");
	this.setTextAlign("left");
	this.setBorderStyle("solid");
	this.setBorderWidth("0px");
	this.setNormalFontColor("#FFFFFF");
	this.setOverFontColor("#FFFFFF");
	this.setDownFontColor("#FFFFFF");
	this.setNormalBackgroundColor("#236B27");
	this.setOverBackgroundColor("#DD722E");
	this.setDownBackgroundColor("#428A46");
	this.setNormalBackgroundImage("none");
	this.setOverBackgroundImage("none");
	this.setDownBackgroundImage("none");
	this.setNormalBorderColor("#95BA94 #95BA94 #95BA94 #95BA94");
	this.setOverBorderColor("#95BA94 #95BA94 #95BA94 #95BA94");
	this.setDownBorderColor("#95BA94 #95BA94 #95BA94 #95BA94");
	this.status = "NULL";
	this.xMin = 0;
	this.yMin = 0;
	this.xMax = 0;
	this.yMax = 0;
}
PopupMenu.prototype.setDivID = function(value) {
	if (document.getElementById(value)) {
		this.divID = value;
	}
}
PopupMenu.prototype.setDataArray = function(value) {
	this.dataArray = value;
}
PopupMenu.prototype.setWidth = function(value) {
	this.width = value;
}
PopupMenu.prototype.setFontFamily = function(value) {
	this.fontFamily = value;
}
PopupMenu.prototype.setFontSize = function(value) {
	this.fontSize = value;
}
PopupMenu.prototype.setFontWeight = function(value) {
	this.fontWeight = value;
}
PopupMenu.prototype.setMargin = function(value) {
	this.margin = value;
}
PopupMenu.prototype.setPadding = function(value) {
	this.padding = value;
}
PopupMenu.prototype.setTextAlign = function(value) {
	this.textAlign = value;
}
PopupMenu.prototype.setBorderStyle = function(value) {
	this.borderStyle = value;
}
PopupMenu.prototype.setBorderWidth = function(value) {
	this.borderWidth = value;
}
PopupMenu.prototype.setNormalFontColor = function(value) {
	this.normalFontColor = value;
}
PopupMenu.prototype.setOverFontColor = function(value) {
	this.overFontColor = value;
}
PopupMenu.prototype.setDownFontColor = function(value) {
	this.downFontColor = value;
}
PopupMenu.prototype.setNormalBackgroundColor = function(value) {
	this.normalBackgroundColor = value;
}
PopupMenu.prototype.setOverBackgroundColor = function(value) {
	this.overBackgroundColor = value;
}
PopupMenu.prototype.setDownBackgroundColor = function(value) {
	this.downBackgroundColor = value;
}
PopupMenu.prototype.setNormalBackgroundImage = function(value) {
	this.normalBackgroundImage = value;
}
PopupMenu.prototype.setOverBackgroundImage = function(value) {
	this.overBackgroundImage = value;
}
PopupMenu.prototype.setDownBackgroundImage = function(value) {
	this.downBackgroundImage = value;
}
PopupMenu.prototype.setNormalBorderColor = function(value) {
	this.normalBorderColor = value;
}
PopupMenu.prototype.setOverBorderColor = function(value) {
	this.overBorderColor = value;
}
PopupMenu.prototype.setDownBorderColor = function(value) {
	this.downBorderColor = value;
}
PopupMenu.prototype.checkParams = function() {
	if (this.divID && this.dataArray && this.width) {
		return true;	
	} else {
		return false;	
	}
}
PopupMenu.prototype.resize = function() {
	if (this.checkParams()) {
		document.getElementById(this.level0DivID).style.fontFamily = this.fontFamily;
		document.getElementById(this.level0DivID).style.fontSize = this.fontSize;
		document.getElementById(this.level0DivID).style.fontWeight = this.fontWeight;
		document.getElementById(this.level1DivID).style.fontFamily = this.fontFamily;
		document.getElementById(this.level1DivID).style.fontSize = this.fontSize;
		document.getElementById(this.level1DivID).style.fontWeight = this.fontWeight;
	}
}
PopupMenu.prototype.attach = function() {
	if (this.checkParams()) {
		POPUPMENU_REFERENCE[this.divID] = this;
		var counter = 1;
		for (var i in POPUPMENU_REFERENCE) {
			counter++;	
		}
		this.depth = counter * 100;
		this.level0DivID = this.divID + '_main';
		this.level1DivID = this.divID + '_sub';
		document.getElementById(this.divID).innerHTML = '<div id="' + this.level0DivID + '"></div>';
		document.getElementById(this.divID).innerHTML += '<div id="' + this.level1DivID + '" style=" position:absolute; z-index:' + this.depth + '; left:0px; top:0px; "></div>';
		this.resize();
		var x = document.getElementById(this.divID).offsetLeft;
		var y = document.getElementById(this.divID).offsetTop;
		var width = parseInt(this.width);
		for (var i = 0; i < this.dataArray.length; i++) {
			var thisID = this.level0DivID + "_" + i.toString() + "_0";
			var name = this.dataArray[i][0].name;
			document.getElementById(this.level0DivID).innerHTML += this.createDivTag(thisID, name, i, 0, 0, x, y, width);
			y += document.getElementById(thisID).offsetHeight;
		}
		if (document.all) {
			document.getElementById(this.divID).attachEvent("onmouseover", this.eventListener);
			document.getElementById(this.divID).attachEvent("onmouseout", this.eventListener);
			document.getElementById(this.divID).attachEvent("onmousedown", this.eventListener);
			document.getElementById(this.divID).attachEvent("onmouseup", this.eventListener);
		} else {
			document.getElementById(this.divID).addEventListener("mouseover", this.eventListener, false);
			document.getElementById(this.divID).addEventListener("mouseout", this.eventListener, false);
			document.getElementById(this.divID).addEventListener("mousedown", this.eventListener, false);
			document.getElementById(this.divID).addEventListener("mouseup", this.eventListener, false);
		}
	}
}
PopupMenu.prototype.createDivTag = function(divID, name, level0, level1, depth, x, y, width) {
	var myDiv = '<div ';
	myDiv += 'id="' + divID + '" ';
	myDiv += 'style=" ';
	myDiv += 'background-color:' + this.normalBackgroundColor + '; ';
	myDiv += 'background-image:' + this.normalBackgroundImage + '; ';
	myDiv += 'border-color:' + this.normalBorderColor + '; ';
	myDiv += 'color:' + this.normalFontColor + '; ';
	myDiv += 'border-style:' + this.borderStyle + '; ';
	myDiv += 'border-width:' + this.borderWidth + '; ';
	if (level1 != 0 || this.dataArray[level0].length == 1) {
		myDiv += 'cursor:pointer; ';
	}
	myDiv += 'float:left; ';
	myDiv += 'display:block; ';
	myDiv += 'margin:' + this.margin + '; ';
	myDiv += 'padding:' + this.padding + '; ';
	myDiv += 'text-align:' + this.textAlign + '; ';
	myDiv += 'left:' + x + 'px; ';
	myDiv += 'top:' + y + 'px; ';
	myDiv += 'width:' + width + 'px; ';
	if (depth > 0) {
		myDiv += 'position:absolute; ';
		myDiv += 'z-index:' + depth + '; ';
	}
	myDiv += '"';
	myDiv += '>';
	myDiv += name;
	myDiv += '</div>';
	return myDiv;
}
PopupMenu.prototype.eventListener = function(evt) {
	if (document.all) {
		var div = evt.srcElement;
	} else {
		var div = evt.target;
	}
	var levelArray = div.id.split("_");
	var level1 = levelArray.pop();
	var level0 = levelArray.pop();
	var referenceID = div.parentNode.parentNode.id;
	if (referenceID) {
		switch (evt.type) {
		case "mouseover" :
			POPUPMENU_REFERENCE[referenceID].doRollOver(div, level0, level1);
			break;
		case "mouseout" :
			if (document.all) {
				var xMouse = event.x + document.body.parentNode.scrollLeft;
				var yMouse = event.y + document.body.parentNode.scrollTop;
			} else {
				var xMouse = evt.pageX;
				var yMouse = evt.pageY;
			}
			POPUPMENU_REFERENCE[referenceID].doRollOut(div, level0, level1, xMouse, yMouse);
			break;
		case "mousedown" :
			POPUPMENU_REFERENCE[referenceID].doPress(div, level0, level1);
			break;
		case "mouseup" :
			POPUPMENU_REFERENCE[referenceID].doRollOver(div, level0, level1);
			POPUPMENU_REFERENCE[referenceID].doRelease(level0, level1);
			break;
		}
	}
}
PopupMenu.prototype.localToGlobal = function(div) {
	var myObject = new Object();
	myObject.x = 0;
	myObject.y = 0;
	while (div != null) {
		myObject.x += div.offsetLeft;
		myObject.y += div.offsetTop;
		div = div.offsetParent;
	}
	return myObject;
}
PopupMenu.prototype.doRollOut = function(div, level0, level1, xMouse, yMouse) {
	if (document.all) {
		window.status = this.status;
	}
	if (this.dataArray[level0].length == 1 || level1 > 0) {
		div.style.backgroundColor = this.normalBackgroundColor;
		div.style.backgroundImage = this.normalBackgroundImage;
		div.style.borderColor = this.normalBorderColor;
		div.style.color = this.normalFontColor;
	}
	if (this.dataArray[level0].length > 1) {
		var plusLeft = parseInt(div.style.borderRightWidth);
		var plusTop = parseInt(div.style.borderTopWidth);
		var plusBottom = parseInt(div.style.borderBottomWidth);
		var rollout = true;
		if (xMouse > this.xMin - plusLeft && xMouse < this.xMax && yMouse > this.yMin + plusTop && yMouse < this.yMax - plusBottom) {
			rollout = false;
		}
		if (rollout) {
			document.getElementById(this.level1DivID).innerHTML = '';
			var parentID = this.level0DivID + "_" + level0.toString() + "_0";
			document.getElementById(parentID).style.backgroundColor = this.normalBackgroundColor;
			document.getElementById(parentID).style.backgroundImage = this.normalBackgroundImage;
			document.getElementById(parentID).style.borderColor = this.normalBorderColor;
			document.getElementById(parentID).style.color = this.normalFontColor;
		}
	}
}
PopupMenu.prototype.doRollOver = function(div, level0, level1) {
	if (document.all) {
		if (this.status == "NULL") {
			this.status = window.status;
		}
		var name = this.dataArray[level0][level1].name;
		window.status = name;
	}
	div.style.backgroundColor = this.overBackgroundColor;
	div.style.backgroundImage = this.overBackgroundImage;
	div.style.borderColor = this.overBorderColor;
	div.style.color = this.overFontColor;
	if (level1 == 0) {
		for (var i = 0; i < this.dataArray.length; i++) {
			if (i != level0) {
				var prevID = this.level0DivID + "_" + i.toString() + "_0";
				document.getElementById(prevID).style.backgroundColor = this.normalBackgroundColor;
				document.getElementById(prevID).style.backgroundImage = this.normalBackgroundImage;
				document.getElementById(prevID).style.borderColor = this.normalBorderColor;
				document.getElementById(prevID).style.color = this.normalFontColor;
			}
		}
		document.getElementById(this.level1DivID).innerHTML = '';
		if (this.dataArray[level0].length > 1) {
			var myParentGlobal = this.localToGlobal(div);
			var myParentX = myParentGlobal.x;
			var myParentY = myParentGlobal.y;
			var myParentWidth = div.offsetWidth;
			var myParentHeight = div.offsetHeight;
			var x = myParentX + myParentWidth;
			var y = myParentY;
			var width = parseInt(this.width);
			for (var i = 1; i < this.dataArray[level0].length; i++) {
				var thisID = this.level1DivID + "_" + level0.toString() + "_" + i.toString();
				var name = this.dataArray[level0][i].name;
				document.getElementById(this.level1DivID).innerHTML += this.createDivTag(thisID, name, level0, i, this.depth + i, x, y, width);
				y += document.getElementById(thisID).offsetHeight;
			}
			this.xMin = x;
			this.yMin = myParentY;
			this.xMax = x + width;
			this.yMax = y;
			if (document.all) {
				var iID = this.level1DivID + "_" + level0.toString() + "_iframe";
				var iLevel = this.depth - 1;
				var iWidth = this.xMax - this.xMin;
				var iHeight = this.yMax - this.yMin;
				var iFrame = '<iframe ';
				iFrame += 'id="' + iID + '" ';
				iFrame += 'style=" ';
				iFrame += 'left:' + this.xMin + '; ';
				iFrame += 'top:' + this.yMin + '; ';
				iFrame += 'width:' + iWidth + '; ';
				iFrame += 'height:' + iHeight + '; ';
				iFrame += 'border-style:solid; ';
				iFrame += 'border-width:0px; ';
				iFrame += 'position:absolute; ';
				iFrame += 'z-index:' + iLevel + '; ';
				iFrame += '"';
				iFrame += '>';
				iFrame += '</iframe>';
				document.getElementById(this.level1DivID).innerHTML += iFrame;
			}
		} else {
			this.xMin = 0;
			this.yMin = 0;
			this.xMax = 0;
			this.yMax = 0;
		}
	}
}
PopupMenu.prototype.doPress = function(div, level0, level1) {
	if (level1 != 0 || this.dataArray[level0].length == 1) {
		div.style.backgroundColor = this.downBackgroundColor;
		div.style.backgroundImage = this.downBackgroundImage;
		div.style.borderColor = this.downBorderColor;
		div.style.color = this.downFontColor;
	}
}
PopupMenu.prototype.doRelease = function(level0, level1) {
	if (level1 != 0 || this.dataArray[level0].length == 1) {
		var url = this.dataArray[level0][level1].url;
		var target = this.dataArray[level0][level1].target;
		if (!target) {
			target = "_self";
		}
		if (url) {
			window.open(url, target);
		}
	}
}

