Netscape = (document.layers) ? 1 : 0;
Explorer = (document.all) ? 1 : 0;

function Menu(MenuName) {

	this.display = MenuDisplay;
	this.construct = MenuConstruct;
	this.hide = MenuHide;
	this.slideout = MenuSlide;

	this.name = MenuName;
	this.layer = MenuName + 'Div';
	this.selection = "None";
	this.offset = 1;
	this.arrow = true;

	this.item = new Array();
	this.execute = new Array();
	this.submenu = new Array();

}

function Clone(MenuName, ParentName) {

	this.display = MenuDisplay;
	this.construct = MenuConstruct;
	this.hide = MenuHide;
	this.slideout = MenuSlide;
	this.selection = "None";

	this.name = MenuName;
	this.layer = MenuName + 'Div';
	this.height = ParentName + ".height";
	this.width = ParentName + ".width";
	this.bgcolor = ParentName + ".bgcolor";
	this.highlight = ParentName + ".highlight";
	this.texthighlight = ParentName + ".texthighlight";
	this.border = ParentName + ".border";
	this.offset = ParentName + ".offset";
	this.left = ParentName + ".left";
	this.top = ParentName + ".top";
	this.color = ParentName + ".color";
	this.font = ParentName + ".font";
	this.fontsize = ParentName + ".fontsize";
	this.shadow = ParentName + ".shadow";
	this.arrow = ParentName + ".arrow";

	this.item = new Array();
	this.execute = new Array();
	this.submenu = new Array();
}

function MenuConstruct() {

	this.horizontal = (this.horizontal) ? this.horizontal : false;
	this.slide = (this.slide) ? this.slide : false;
	

	if (Explorer) {

		for (var i=0;i < this.item.length;i++) {

			layer = "<DIV ID=" + this.layer + i + 'border' + " STYLE='position:absolute; visibility : hidden;'></DIV>";
			document.body.insertAdjacentHTML("BeforeEnd", layer);

			layer = "<DIV ID=" + this.layer + i + " STYLE='position:absolute; visibility : hidden; font-Size : " + this.fontsize + "pt ;'></DIV>";
			document.body.insertAdjacentHTML("BeforeEnd", layer);

			newBorder = document.all[this.layer + i + 'border'];
			newLayer = document.all[this.layer + i];
			newBorder.style.backgroundColor = this.border;
			newBorder.style.width = this.width + 2; 
			newBorder.style.height = this.height + 2;
			newLayer.style.backgroundColor = this.bgcolor;
			newLayer.style.width = this.width; 
			newLayer.style.height = this.height;

			if (this.horizontal) {
				newBorder.style.pixelLeft = this.left + (this.width * i) + (this.offset * i) - 1 ;
				newBorder.style.pixelTop = this.top - 1;
				newLayer.style.pixelLeft = this.left + (this.width * i) + (this.offset * i);
				newLayer.style.pixelTop = this.top;
			}
			else {
				newBorder.style.pixelLeft = this.left - 1;
				newBorder.style.pixelTop = this.top + (this.height * i) + (this.offset * i) - 1;
				newLayer.style.pixelLeft = this.left;
				newLayer.style.pixelTop = this.top + (this.height * i) + (this.offset * i);
			}

			newLayer.style.color = this.color;
			newLayer.style.cursor = "hand";
			newLayer.onmousemove = MenuOver;
			newLayer.onmouseout = MenuOut;
			newLayer.onmousedown = MouseDown;
			newLayer.highlight = this.highlight;
			newLayer.texthighlight = this.texthighlight;
			newLayer.color = this.color;
			newLayer.bgcolor = this.bgcolor;
			newLayer.submenu = (this.submenu[i]) ? this.submenu[i] : "None";
			newLayer.execute = (this.execute[i]) ? this.execute[i] : "None";
			newLayer.objectname = this.name;
			
			if (this.align == "Left") { this.item[i] = "&nbsp;" + this.item[i]; }
			if (this.align == "Right") { this.item[i] = this.item[i] + "&nbsp;"; }
			if (document.all[this.layer + i].submenu != "None" && this.arrow) {
				newLayer.innerHTML = "<IMG SRC='images/arrow.gif' VSPACE=3 ALIGN=RIGHT><P ALIGN=" + this.align + "><FONT FACE='" + this.font + "'>" + this.item[i] + "</FONT>"

			}
			else { 
					newLayer.innerHTML = "<P ALIGN=" + this.align + "><FONT FACE='" + this.font + "'>" + this.item[i] + "</FONT>"; 
			}
		}
	}
}

function MenuDisplay() {

	if (this.slide) { 
		this.slideSpeed = (this.slideSpeed) ? this.slideSpeed : 50;
		this.hault = false;
		this.slideItem = 0;
		this.slidePos = 0;
		this.slideout(); 
	}

	else if (Explorer) {
		for (var i=0;i < this.item.length;i++) {
			document.all[this.layer + i + 'border'].style.visibility = "visible";
			document.all[this.layer + i].style.visibility = "visible";
		}
	}
}

function MenuSlide() {

	if (Explorer) {
		if (this.slidePos == 0) {
			document.all[this.layer + this.slideItem + 'border'].style.visibility = "visible";
			document.all[this.layer + this.slideItem].style.visibility = "visible";
		}

		this.slidePos++;
		slidePos = this.slidePos + 2;		

		if (this.horizontal) {
			document.all[this.layer + this.slideItem + 'border'].style.clip = "rect(0px " + this.width + 2 + "px " + slidePos + "px 0px)";
			document.all[this.layer + this.slideItem].style.clip = "rect(0px " + this.width + "px " + this.slidePos + "px 0px)";
			if (this.slidePos == this.height + 2) {
				this.slidePos = 0;
				this.slideItem++;
			}
		}
		else {
			document.all[this.layer + this.slideItem + 'border'].style.clip = "rect(0px " + slidePos + "px " + this.height + 2 + "px 0px)";
			document.all[this.layer + this.slideItem].style.clip = "rect(0px " + this.slidePos + "px " + this.height + "px 0px)";

			if (this.slidePos == this.width + 2) {
				this.slidePos = 0;
				this.slideItem++;
			}
		}

		if (this.slideItem < this.item.length && this.hault == false) {
			setTimeout(this.name + ".slideout()",this.slideSpeed);
		}
	}
}

function MenuHide() {

	this.hault = true;

	if (this.selection != "None") {	
		this.selection + ".hide()";
	}	

	if (Explorer) {
		for (var i=0;i < this.item.length;i++) {
			document.all[this.layer + i + 'border'].style.visibility = "hidden";
			document.all[this.layer + i].style.visibility = "hidden";
		}
	}
}

function MenuOver() {

	if (Explorer) {
		this.style.backgroundColor = this.highlight; 
		this.style.color = this.texthighlight;
	}
	if (eval(this.objectname + ".selection") != "None" && eval(this.objectname + ".selection") != this.submenu) {
		hidemenu = eval(this.objectname + ".selection");
		eval(hidemenu + ".hide()");
		eval(this.objectname + ".selection = 'None'");
			
	}
	if (this.submenu != "None" && eval(this.objectname + ".selection") != this.submenu) {
		eval(this.submenu + ".display()");
		eval(this.objectname + ".selection = this.submenu"); 	
	}

}

function MenuOut() {

	if (Explorer) {	
		this.style.backgroundColor = this.bgcolor;
		this.style.color = this.color;
	}
}

function MouseDown() {
	
	if (this.execute != "None") {
		parent.location = this.execute;
	}
}




