var Boxes = new Array();

function Box(sId, iTop, iLeft, iWidth, iHeight, sText, sHref, sBGColor, sHLColor)
{	this.id = sId;
	this.top = iTop;
	this.left = iLeft;
	this.width = iWidth;
	this.height = iHeight;
	this.text = sText;
	this.href = sHref;
	this.bgColor = sBGColor;
	this.hlColor = sHLColor;
	
	this.addBox = addBox;
}

function addBox(sId, iTop, iLeft, iWidth, iHeight, sText, sHref, sBGColor, sHLColor)
{	var oBox = new Box(sId, iTop, iLeft, iWidth, iHeight, sText, sHref, sBGColor, sHLColor);

	if (Boxes.length < 1)
	{	var i = 0;
	}
	else
	{	var i = Boxes.length;
	}
	
	Boxes[i] = oBox;
}

function writeBoxes()
{	if (NS4)
	{	writeBoxesNS4();
	}
	else
	{	writeBoxesDOM();
	}
}

function writeBoxesDOM()
{	for (var i = 0; i <= (Boxes.length - 1); i++)
	{	document.write("<div id='" + Boxes[i].id + "' class='boxisoutter' style='top:" + Boxes[i].top + ";left:" + Boxes[i].left + ";' onmouseover='boxRolloverDOM(this,\"" + Boxes[i].hlColor + "\");' onmouseout='boxRolloffDOM(this, \"" + Boxes[i].bgColor + "\");' onclick='navigateBox(\"" + Boxes[i].href + "\")'>");
		document.write("<div class='boxisinner'>");
		document.write(Boxes[i].text);
		document.write("</div>");
		document.write("</div>");
	}
}
		
function boxRolloverDOM(oBox, sBGColor)
{	var timer = null;
	
	activeBox = oBox;
	
	if (window.activeMenus.length != 0)
	{	timer = setTimeout("showBorderDOM('" + sBGColor + "')", 500);
	}
	else
	{	showBorderDOM(sBGColor);
	}
}

function showBorderDOM(sBGColor)
{		activeBox.style.zIndex = 99;
		activeBox.style.backgroundColor = sBGColor;
}

function boxRolloffDOM(oBox, sBGColor)
{	oBox.style.zIndex = "";
	oBox.style.backgroundColor = sBGColor;
}

function writeBoxesNS4()
{	for (var i = 0; i <= (Boxes.length - 1); i++)
	{	document.write("<layer name='" + Boxes[i].id + "' top='" + Boxes[i].top + "' left='" + Boxes[i].left + "' width='" + Boxes[i].width + "' height='" + Boxes[i].height + "' bgcolor='" + Boxes[i].bgColor + "' onmouseover='boxRolloverNS4(this, \"" + Boxes[i].hlColor + "\");' onmouseout='boxRolloffNS4(this, \"" + Boxes[i].bgColor + "\");'>");
		document.write("<layer top='2' left='2' width='" + (Boxes[i].width - 4) + "' height='" + (Boxes[i].height - 4) + "' bgcolor='#FFFFFF'>");
		document.write("<span class='boxisinner'><a href='javascript:navigateBox(\"" + Boxes[i].href + "\");' class=\"boxisinner\">" + Boxes[i].text + "</a></span>");
		document.write("</layer>");
		document.write("</layer>");
	}
}

function boxRolloverNS4(oBox, sBGColor)
{	var timer = null;
	
	activeBox = oBox;
	
	if (window.activeMenus.length != 0)
	{	timer = setTimeout("showBorderNS4('" + sBGColor + "')", 500);
	}
	else
	{	showBorderNS4(sBGColor);
	}
}

function showBorderNS4(sBGColor)
{		activeBox.zIndex = 99;
		activeBox.bgColor = sBGColor;
}

function boxRolloffNS4(oBox, sBGColor)
{	oBox.zIndex = null;
	oBox.bgColor = sBGColor;
}
