function Browser()
{
	if (parseInt(navigator.appVersion) >= 4)
	{
		if (document.all)
			return('IE');
		else if (document.getElementById)
			return('NS6');
		else if (document.layers)
			return('NS4');
	}
}
var browser = Browser();

function Menu(parentMenuNum, numOfItems, contentCentered, markOption)
{
	propName.numOfMenus++;
	this.num          = propName.numOfMenus - 1;
	this.numOfItems   = numOfItems;
	this.markOption   = markOption;
	this.parent       = parentMenuNum;
	this.items        = new Array();
	this.items.length = 0;
	this.addItem      = AddItem;
	if (browser == 'IE' || browser == 'NS6')
		this.compile = CompileA;
	else if (browser == 'NS4')
		this.compile = CompileB;

	if (contentCentered)
	{
		this.centerTag1 = '<center>';
		this.centerTag2 = '</center>';
	}
	else
	{
		this.centerTag1 = '';
		this.centerTag2 = '';
	}

	if (this.num == 0)
	{
		this.vis  = 'visible';
		this.left = propName.mainLeft;
		this.top  = propName.mainTop;
	}
	else if (this.num !== 0)
	{
		this.vis  = 'hidden';
		this.left = 0;
		this.top  = 0;
	}

	if (propName.brdrBtwnItems)
	{
		this.height = 0;
		this.width  = 0;
		this.border = '';
	}
	else if (!propName.brdrBtwnItems)
	{
		this.height = 0;
		this.width  = 0;
		this.border = 'border:' + propName.borderSize + 'px ' + propName.borderStyle + ' ' + propName.borderColor + ';';
	}

	if (propName.bgType == 'color')
		this.background = 'background-color:' + propName.bgColorOut + ';';
	else if (this.bgType == 'image')
		this.background = 'background:url(\'' + propName.bgImage + '\');';
}

var collectedHeight = 0;
var collectedWidth  = 0;

function AddItem(itemHeight, itemWidth, itemLink, itemTarget, itemContent, menuToOpenNum, showDirection)
{
	this.items.length++;
	var num = this.items.length - 1;
	this.items[num]        = new Object();
	this.items[num].height = itemHeight;
	this.items[num].width  = itemWidth;
	this.items[num].left   = this.width;
	this.items[num].top    = this.height;
	parentMenuNum          = this.num;

	

	if (propName.mainMenuH && parentMenuNum == 0)
	{
		if (propName.brdrBtwnItems)
		{
			if (num !== 0)
			{
				if (browser == 'IE')
					this.items[num].left -= propName.borderSize * num;
				else if (browser == 'NS6')
					this.items[num].left += propName.borderSize * num;
				else if (browser == 'NS4')
					this.items[num].left -= propName.borderSize * num;
			}
			if (num == this.numOfItems - 1)
			{
				this.width    -= collectedWidth;
				collectedWidth = 0;
			}
			else
			{
				if (num == 0)
					collectedWidth += propName.borderSize;
				else
					collectedWidth += propName.borderSize * num;
			}

		}
		else
			this.width += propName.borderSize * 2;

		this.height += 0;
		this.width  += itemWidth;
	}
	else
	{
		if (propName.brdrBtwnItems)
		{
			if (num !== 0)
			{
				if (browser == 'IE')
					this.items[num].top -= propName.borderSize * num;
				else if (/*browser == 'NS4' || */browser == 'NS6')
					this.items[num].top += propName.borderSize * num;
			}
			if (num == this.numOfItems - 1)
			{
				this.height    -= collectedHeight;
				collectedHeight = 0;
			}
			else
			{
				if (num == 0)
					collectedHeight += propName.borderSize;
				else
					collectedHeight += propName.borderSize * num;
			}
		}
		else
			this.height += propName.borderSize * 2;

		this.height += itemHeight;
		this.width  += 0;
	}

// check the direction here and if it is near the edge of the screen make it open to the left

	if((screen.width==800) && (screen.height==600) && (showDirection=='r') && (num >8))
	{
		showDirection='l';
	}

	if (propName.showOption == 'over')
	{
		if (menuToOpenNum == 0)
			this.items[num].showFunction1 = 'HideAfter(' + parentMenuNum + ');';
		else





			this.items[num].showFunction1 = 'Show(' + menuToOpenNum + ', ' + parentMenuNum + ', ' + num + ', \'' + showDirection + '\');';
		this.items[num].showFunction2 = '';
	}
	else if (propName.showOption == 'click')
	{
		this.items[num].showFunction1 = '';
		if (menuToOpenNum == 0)
			this.items[num].showFunction1 = 'HideAfter(' + parentMenuNum + ');';
		else




			this.items[num].showFunction2 = 'Show(' + menuToOpenNum + ', ' + parentMenuNum + ', ' + num + ', \'' + showDirection + '\');';
	}

	if (propName.bgType == 'color')
	{
		this.items[num].background  = 'background-color:' + propName.bgColorOut + ';';
		if (browser == 'IE' || browser == 'NS6')
		{
			this.items[num].bgFunction1 = 'ChangeBg(' + parentMenuNum + ', ' + num + ');';
			this.items[num].bgFunction2 = 'ChangeBgBack(' + parentMenuNum + ', ' + num + ');';
		}
		else if (browser == 'NS4')
		{
			this.items[num].bgFunction1 = 'this.bgColor=\'' + propName.bgColorOver + '\';';
			this.items[num].bgFunction2 = 'this.bgColor=\'' + propName.bgColorOut + '\';';
		}
	}
	else if (propName.bgType == 'image')
	{
		this.items[num].background  = '';
		this.items[num].bgFunction1 = '';
		this.items[num].bgFunction2 = '';
	}

	if (propName.brdrBtwnItems)
		this.items[num].border = 'border:' + propName.borderSize + 'px ' + propName.borderStyle + ' ' + propName.borderColor + ';';
	else if (!propName.brdrBtwnItems)
		this.items[num].border = '';

	this.items[num].linkStart = '<a href="' + itemLink + '" onClick="' + this.items[num].showFunction2 + '" style="text-decoration:none;" target="' + itemTarget + '">';
	this.items[num].linkEnd   = '</a>';

	if (itemContent.indexOf('rollover:') !== -1)
	{
		var tempContent = itemContent.split(':');
		this.items[num].content = '<a href="' + itemLink + '" target="' + itemTarget + '"><img border="0" onMouseover="ChangeImg(this, \'' + tempContent[2] + '\')" onMouseout="ChangeImgBack(this, \'' + tempContent[1] + '\')" src="' + tempContent[1] + '"></a>';
		this.items[num].fontFunction1 = '';
		this.items[num].fontFunction2 = '';
	}
	else
	{
		if (itemContent.indexOf('img') !== -1)
			itemContent = '<a href="' + itemLink + '" target="' + itemTarget + '">' + itemContent + '</a>';
		this.items[num].content  = '<font color="' + propName.fontColorOut + '" face="' + propName.fontFamily + '" id="menu' + parentMenuNum + 'Font' + num + '" style="padding-left:2px; width:' + (itemWidth - propName.borderSize - 15) + 'px; font-size:' + propName.fontSize + 'px; font-style:' + propName.fontStyle + '; font-weight:' + propName.fontWeight + '; text-decoration:' + propName.textDec + ';">' + itemContent + '</font>';
		this.items[num].content2 = '<font color="' + propName.fontColorOver + '" face="' + propName.fontFamily + '" id="menu' + parentMenuNum + 'Font' + num + '" style="padding-left:2px; width:' + (itemWidth - propName.borderSize - 15) + 'px; font-size:' + propName.fontSize + 'px; font-style:' + propName.fontStyle + '; font-weight:' + propName.fontWeight + '; text-decoration:' + propName.textDec + ';">' + itemContent + '</font>';
		if (browser == 'IE' || browser == 'NS6')
		{
			this.items[num].fontFunction1 = 'ChangeFont(\'menu' + parentMenuNum + 'Font' + num + '\');';
			this.items[num].fontFunction2 = 'ChangeFontBack(\'menu' + parentMenuNum + 'Font' + num + '\');';
		}
		else if (browser == 'NS4')
		{
			this.items[num].fontFunction1 = 'ChangeLayer(' + this.num + ', ' + num + ');';
			this.items[num].fontFunction2 = 'ChangeLayerBack(' + this.num + ', ' + num + ')';
		}
	}

	if (this.markOption)
	{
		if (propName.markType == 'image')
		{
			var markOverSrc, markOutSrc;
			if (propName.mainMenuH && parentMenuNum == 0)
			{
				markOverSrc = propName.markImgHOver;
				markOutSrc  = propName.markImgHOut;
			}
			else
			{
				markOverSrc = propName.markImgVOver;
				markOutSrc  = propName.markImgVOut;
			}

			if (menuToOpenNum == 0)
			{
				this.items[num].mark = '';
				this.items[num].markFunction1 = '';
				this.items[num].markFunction2 = '';
			}
			else
			{
				this.items[num].mark = '<img border="0" name="menu' + parentMenuNum + 'Mark' + num + '" src="' + markOutSrc + '" style="position:absolute; left:' + (itemWidth - propName.borderSize - 15) + 'px; top:' + (itemHeight / 2 - 5) + 'px;">';
				this.items[num].markFunction1 = 'ChangeMarkImg(\'menu' + parentMenuNum + 'Mark' + num + '\', \'' + markOverSrc + '\');';
				this.items[num].markFunction2 = 'ChangeMarkImgBack(\'menu' + parentMenuNum + 'Mark' + num + '\', \'' + markOutSrc + '\');';
			}	
		}
		else if (propName.markType == 'symbol')
		{
			var theMark;
			if (propName.mainMenuH && parentMenuNum == 0)
				theMark = propName.markSymH;
			else
				theMark = propName.markSymV;

			if (menuToOpenNum == 0)
			{
				this.items[num].mark  = '';
				this.items[num].mark2 = '';
				this.items[num].markFunction1 = '';
				this.items[num].markFunction2 = '';
			}
			else
			{
				var markLeft, markTop;
				if (browser == 'IE' || browser == 'NS6')
				{
					markLeft = (itemWidth - propName.borderSize - 15);
					markTop  = (itemHeight / 2 - 10);
				}
				else if (browser == 'NS4')
				{
					markLeft = (itemWidth - propName.borderSize - 15);
					markTop  = (itemHeight / 2 - 6);
				}
				this.items[num].mark  = '<font color="' + propName.fontColorOut + '" face="' + propName.fontFamily + '" id="menu' + parentMenuNum + 'Mark' + num + '" style="position:absolute; left:' + markLeft + 'px; top:' + markTop + 'px; font-size:' + propName.fontSize + 'px; font-style:' + propName.fontStyle + '; font-weight:' + propName.fontWeight + '; text-decoration:' + propName.textDec + ';">' + theMark + '</font>';
				this.items[num].mark2 = '<font color="' + propName.fontColorOver + '" face="' + propName.fontFamily + '" id="menu' + parentMenuNum + 'Mark' + num + '" style="position:absolute; left:' + markLeft + 'px; top:' + markTop + 'px; font-size:' + propName.fontSize + 'px; font-style:' + propName.fontStyle + '; font-weight:' + propName.fontWeight + '; text-decoration:' + propName.textDec + ';">' + theMark + '</font>';
				if (browser == 'IE' || browser == 'NS6')
				{
					this.items[num].markFunction1 = 'ChangeMark(\'menu' + parentMenuNum + 'Mark' + num + '\');';
					this.items[num].markFunction2 = 'ChangeMarkBack(\'menu' + parentMenuNum + 'Mark' + num + '\');';
				}
				else if (browser == 'NS4')
				{
					this.items[num].markFunction1 = '';
					this.items[num].markFunction2 = '';
				}
			}
		}
		else if (this.markType == 'none')
		{
			this.items[num].mark  = '';
			this.items[num].mark2 = '';
			this.items[num].markFunction1 = '';
			this.items[num].markFunction2 = '';
		}
	}
	else if (!this.markOption)
	{
		this.items[num].mark  = '';
		this.items[num].mark2 = '';
		this.items[num].markFunction1 = '';
		this.items[num].markFunction2 = '';
	}

	if (browser == 'IE')
		this.items[num].cursorType = 'cursor:' + propName.cursorIE + ';';
	else if (browser == 'NS6')
		this.items[num].cursorType = 'cursor:' + propName.cursorNS6 + ';';
	else
		this.items[num].cursorType = ''; 

	if (this.items.length == this.numOfItems)
	{
		if (propName.mainMenuH && parentMenuNum == 0)
		{
			if (!propName.brdrBtwnItems)
				this.height = itemHeight + propName.borderSize * 2;
			else
				this.height = itemHeight;
		}
		else
		{
			if (!propName.brdrBtwnItems)
				this.width = itemWidth + propName.borderSize * 2;
			else
				this.width = itemWidth;
		}
	}

}

function CompileA()
{
	propName.code += '<div id="menu' + this.num + '" onMouseover="KeepOpen()" onMouseout="Check()" class="' + this.parent + '" style="visibility:' + this.vis + '; position:absolute; left:' + this.left + 'px; top:' + this.top + 'px; height:' + this.height + 'px; width:' + this.width + 'px; z-index:' + propName.menuZIndex + '; ' + this.background + ' ' + this.border + '">\r';
	for (i=0; i<=this.items.length-1; i++)
	{
		propName.code += '  ' + this.items[i].linkStart + '\r';
		propName.code += '  <div id="menu' + this.num + 'Item' + i + '" onClick="' + this.items[i].showFunction2 + '" onMouseover="' + this.items[i].showFunction1 + ' ' + this.items[i].bgFunction1 + ' ' + this.items[i].fontFunction1 + ' ' + this.items[i].markFunction1 + '" onMouseout="' + this.items[i].bgFunction2 + ' ' + this.items[i].fontFunction2 + ' ' + this.items[i].markFunction2 + '" style="visibility:inherit; position:absolute; left:' + this.items[i].left + 'px; top:' + this.items[i].top + 'px; height:' + this.items[i].height + 'px; width:' + this.items[i].width + 'px; z-index:' + (propName.menuZIndex + 1) + '; ' + this.items[i].background + ' ' + this.items[i].border + ' ' + this.items[i].cursorType + '">\r';
		propName.code += '    ' + this.centerTag1 + this.items[i].content + this.centerTag2 + this.items[i].mark + '\r';
		propName.code += '  </div>\r';
		propName.code += '  ' + this.items[i].linkEnd + '\r';
	}
	propName.code += '</div>\r\r';
}

function CompileB()
{
	var loadFunction, hideFunction2;

	if (this.num == 0)
		loadFunction = 'onLoad="this.moveBy(' + propName.mainLeft + ', ' + propName.mainTop + ')"';
	else
		loadFunction  = '';
	
	if (this.num == 0)
		hideFunction2 = 'Check();';
	else
		hideFunction2 = '';

	var menuIndex = propName.menuZIndex + this.num;

	propName.code += '<layer bgColor="' + propName.bgColorOut + '" height="' + this.height + '" left="' + this.left + '" id="menu' + this.num + '" onMouseover="KeepOpen()" onMouseout="Check()" style="' + this.background + ' ' + this.border + '" top="' + this.top + '" visibility="' + this.vis + '" width="' + this.width + '" z-index="' + menuIndex + '">\r';
	for (i=0; i<=this.items.length-1; i++)
	{
		propName.code += '  <layer bgColor="' + propName.bgColorOut + '" height="' + this.items[i].height + '" left="' + this.items[i].left + '" name="menu' + this.num + 'Item' + i + 'Content1" ' + loadFunction + ' onMouseover="' + this.items[i].showFunction1 + ' ' + this.items[i].bgFunction1 + ' ' + this.items[i].fontFunction1 + '" onMouseout="' + hideFunction2 + ' ' + this.items[i].bgFunction2 + ' ' + this.items[i].fontFunction2 + '" top="' + this.items[i].top + '" visibility="inherit" width="' + this.items[i].width + '" z-index="' + (menuIndex + 1) + '">\r';
		propName.code += '    <div style="height:' + this.items[i].height + 'px; width:' + this.items[i].width + 'px; ' + this.items[i].border + '">' + this.items[i].linkStart + this.centerTag1 + this.items[i].content + this.centerTag2 + this.items[i].linkEnd + this.items[i].mark + '</div>\r';
		propName.code += '  </layer>\r';
		propName.code += '  <layer bgColor="' + propName.bgColorOut + '" height="' + this.items[i].height + '" left="' + this.items[i].left + '" name="menu' + this.num + 'Item' + i + 'Content2" ' + loadFunction + ' onMouseover="' + this.items[i].showFunction1 + ' ' + this.items[i].bgFunction1 + ' ' + this.items[i].fontFunction1 + '" onMouseout="' + hideFunction2 + ' ' + this.items[i].bgFunction2 + ' ' + this.items[i].fontFunction2 + '" top="' + this.items[i].top + '" visibility="hidden" width="' + this.items[i].width + '" z-index="' + (menuIndex + 1) + '">\r';
		propName.code += '    <div style="height:' + this.items[i].height + 'px; width:' + this.items[i].width + 'px; ' + this.items[i].border + '">' + this.items[i].linkStart + this.centerTag1 + this.items[i].content2 + this.centerTag2 + this.items[i].linkEnd + this.items[i].mark2 + '</div>\r';
		propName.code += '  </layer>\r';
	}
	propName.code += '</layer>\r\r';
}

function Write()
{
	document.write(this.code);
}

function MenuProps(offsetH, offsetV, mainMenuH, mainLeft, mainTop, showOption, bgType, bgColorOver, bgColorOut, bgImage, brdrBtwnItems, borderSize, borderStyle, borderColor, fontFamily, fontSize, fontStyle, fontWeight, fontColorOver, fontColorOut, markType, markImgHOver, markImgHOut, markImgVOver, markImgVOut, markSymH, markSymV, menuZIndex, cursorIE, cursorNS6, textDec, imgTrans)
{
	this.numOfMenus    = 0;
	this.offsetH       = offsetH;
	this.offsetV       = offsetV;
	this.mainMenuH     = mainMenuH;
	this.mainLeft      = mainLeft;
	this.mainTop       = mainTop;
	this.showOption    = showOption;
	this.bgType        = bgType;
	this.bgColorOver   = bgColorOver;
	this.bgColorOut    = bgColorOut;
	this.bgImage       = bgImage;
	this.brdrBtwnItems = brdrBtwnItems;
	this.borderSize    = borderSize;
	this.borderStyle   = borderStyle;
	this.borderColor   = borderColor;
	this.fontFamily    = fontFamily;
	this.fontSize      = fontSize;
	this.fontStyle     = fontStyle;
	this.fontWeight    = fontWeight;
	this.fontColorOver = fontColorOver;
	this.fontColorOut  = fontColorOut;
	this.markType      = markType;
	this.markImgHOver  = markImgHOver;
	this.markImgHOut   = markImgHOut;
	this.markImgVOver  = markImgVOver;
	this.markImgVOut   = markImgVOut;
	this.markSymH      = markSymH;
	this.markSymV      = markSymV;
	this.menuZIndex    = menuZIndex;
	this.cursorIE      = cursorIE;
	this.cursorNS6     = cursorNS6;
	this.textDec       = textDec;
	this.imgTrans      = imgTrans;
	this.code          = '';
	this.write         = Write;
}