var Highlights = new Array();

//================================================================================
//writes box type 2 

//files required: 
//		images/spacer.gif
//		css/base.css
//		../common/swap.js
//		script/page_init.js

//arguments:
//		iWidth = 		integer, width of layer
//		iHeight = 		integer, hieght of layer
//		sName = 		string, name/id of layer
//		sPos = 			postion of box
//		sHeader = 		string, header text
//		sText = 		string, body text
//		sLinkText = 		string, link text
//		sHref = 		string, href link
//		borderColor = 	string, box border color
//		bgColor = 		string, starting background color of box
//================================================================================
function writeBox2(iWidth, iHeight, sName, sPos, sHeader, sText, sLinkText, sHref, borderColor, bgColor, iHorzSpacer)
{	if (NS4)
	{	writeBox2NS4(iWidth, iHeight, sName, sPos, sHeader, sText, sLinkText, sHref, borderColor, bgColor, iHorzSpacer);
	}
	else
	{	writeBox2DOM(sName, sPos, sHeader, sText, sLinkText, sHref, borderColor, bgColor);
	}
}

function writeBox2DOM(sName, sPos, sHeader, sText, sLinkText, sHref, borderColor, bgColor)
{ 	var outterClass = "";
	var innerClass = "";
	
	if (sPos == "r1c1")
	{	outterClass = "box2r1c1"
		middleClass = "box2r1c1m"
		innerClass = "box2inner"
	}
	else if (sPos == "r1cx")
	{	outterClass = "box2r1cx"
		middleClass = "box2r1cxm"
		innerClass = "box2inner"
	}
	else if (sPos == "rxc1")
	{	outterClass = "box2rxc1"
		middleClass = "box2rxc1m"
		innerClass = "box2inner"
	}
	
	else if (sPos == "rxcx")
	{	outterClass = "box2rxcx"
		middleClass = "box2rxcxm"
		innerClass = "box2inner"
	}	

	document.write("<div id='" + sName + "' class='" + outterClass + "'>");
	document.write("<div class='" + middleClass + "' onmouseover=\"boxOverDOM(this, '" + borderColor + "');\" onmouseout=\"boxOutDOM(this, '" + bgColor + "');\">");
	document.write("<div class='" + innerClass + "' onclick=\"window.location = '" + sHref + "'\">");
	
	document.write("<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0'>");
	document.write("<tr><td class='box2header' height='35' valign='top'>" + sHeader + "</td></tr>");
	document.write("<tr><td valign='top'><img src='images/spacer.gif' alt='' width='1' height='5' border='0'</td></tr>");
	document.write("<tr><td class='box2text' valign='top'>" + sText + "</td></tr>");
	document.write("<tr><td valign='top' height='100%'><img src='images/spacer.gif' alt='' width='1' height='8' border='0'</td></tr>");
	document.write("<tr><td class='box2link' valign='bottom'><a href='" + sHref + "' class='box2link'>" + sLinkText + "</a></td></tr>");
	document.write("<tr><td valign='top'><img src='images/spacer.gif' alt='' width='1' height='5' border='0'</td></tr>");
	document.write("</table>")
	
	document.write("</div>");
	document.write("</div>");
	document.write("</div>");
}

function writeBox2NS4(iWidth, iHeight, sName, sPos, sHeader, sText, sLinkText, sHref, borderColor, bgColor, iHorzSpacer)
{	var iInnerWidth;
	var iInnerHeight;
	var iTop;
	var iLeft; 
	
	if (sPos == "r1c1")
	{	iMiddleWidth = (iWidth - 2);
		iMiddleHeight = (iHeight -2);
		iInnerWidth = (iWidth - 4);
		iInnerHeight = (iHeight - 4);
		mTop = 1;
		mLeft = 1;
		iTop = 1;
		iLeft = 1;
	}
	else if (sPos == "r1cx")
	{	iMiddleWidth = (iWidth - 1);
		iMiddleHeight = (iHeight - 2);	
		iInnerWidth = (iWidth - 3);
		iInnerHeight = (iHeight -4);
		mTop = 1;
		mLeft = 0;
		iTop = 1;
		iLeft = 1;
	}
	else if (sPos == "rxc1")
	{	iMiddleWidth = (iWidth - 2);
		iMiddleHeight = (iHeight -1);	
		iInnerWidth = (iWidth - 4);
		iInnerHeight = (iHeight -3);
		mTop = 0;
		mLeft = 1;
		iTop = 1;
		iLeft = 1;
	}
	else if (sPos == "rxcx")
	{	iMiddleWidth = (iWidth - 1);
		iMiddleHeight = (iHeight - 1);	
		iInnerWidth = (iWidth - 3);
		iInnerHeight = (iHeight - 3);
		mTop = 0;
		mLeft = 0;
		iTop = 1;
		iLeft = 1;
	}
	
	document.write("<ilayer bgcolor='" + borderColor + "' width='" + iWidth + "' height='" + iHeight + "'>");
	document.write("<layer name='middle" + sName + "' bgcolor='" + bgColor + "' width='" + iMiddleWidth + "' height='" + iMiddleHeight + "' top='" + mTop + "' left='" + mLeft + "' onmouseover=\"boxOverNS4(this, '" + borderColor + "');\" onmouseout=\"boxOutNS4(this, '" + bgColor + "');\">");
	document.write("<layer name='inner" + sName + "' bgcolor='" + bgColor + "' width='" + iInnerWidth + "' height='" + iInnerHeight + "' top='" + iTop + "' left='" + iLeft + "'>");
	
	document.write("<span class='box2header'>" + sHeader + "</span><br>");
	
	if (sHeader.length <= 21)
	{	var iSubHead = 24;
	}
	else
	{	var iSubHead = 7;
	}
	
	document.write("<span class='box2text'><img src='images/spacer.gif' alt='' width='1' height='" + iSubHead + "' border='0'></span><br>");
	document.write("<span class='box2text'>" + sText + "</span><br>");
	document.write("<span class='box2text'><img src='images/spacer.gif' alt='' width='1' height='" + iHorzSpacer + "' border='0'></span><br>");
	document.write("<span><a href='" + sHref + "' class='box2link'>" + sLinkText + "</a></span><br>");
	
	document.write("</layer>")
	document.write("</ilayer>")
	document.write("</ilayer>")
}

function boxOverDOM(oBox, sBGColor)
{	oBox.style.backgroundColor = sBGColor;
}

function boxOutDOM(oBox, sBGColor)
{	oBox.style.backgroundColor = sBGColor;
}

function boxOverNS4(oBox, sBGColor)
{	oBox.bgColor = sBGColor;
}

function boxOutNS4(oBox, sBGColor)
{	oBox.bgColor = sBGColor;
}

//highlights constructor
function Highlight(sId, sHref, sLink)
{	this.id = sId;
	this.href = sHref;
	this.linkText = sLink;
}

function addHighlight(sId, sHref, sLink)
{	var oHi = new Highlight(sId, sHref, sLink);
	
	if (Highlights.length < 1)
	{ 	var i = 0;
	}
	else
	{	var i = Highlights.length
	}
	
	Highlights[i] = oHi;
}

//================================================================================
//writes the highlights to the page

//files required: 
//		images/spacer.gif
//		css/base.css

//arguments:
//		iWidth = 	integer, width of image (required to make NS work)
//================================================================================
function writeHighlights(iWidth)
{	writeHighlightsHeader(iWidth);
	writeHighlightSpacer((iWidth - 1), 10);
	
	for (var i = 0; i <= (Highlights.length - 1); i++)
	{	writeHighlightItem(Highlights[i].href, Highlights[i].linkText);
		
		//if the loop is on the last item  then
		//get out, we do not need the seperator
		if (i == (Highlights.length - 1))
		{	break;
		}
		else
		{	writeHighlightSpacer((iWidth - 1), 10);
		}
	}
	
	//close the table
	document.write("</table>");
}

//================================================================================
//writes the main table structure and header of the resouces section

//files required: 
//		images/spacer.gif
//		css/base.css

//arguments:
//		iWidth = 	integer, width of image (required to make NS work)
//		sHeader = 	string, header text
//================================================================================
function writeHighlightsHeader(iWidth)
{	document.write("<table width='" + iWidth + "' border='0' cellpadding='0' cellspacing='0'>");
	document.write("<tr>");
	document.write("<td width='" + (iWidth - 6) + "' align='left' valign='top'><img src='images/header_highlights.gif' alt='Highlights' width='106' height='10' border='0'></td>");
	document.write("</tr>");
}

//================================================================================
//write a sinlge row to the highlight table, which
//contains a resource item.  Each item represents a link
//to a PDF document.

//files required: 
//		images/spacer.gif
//		images/pdf.gif
//		images/pdf_green.gif
//		css/base.css
//		..common/swap.js

//arguments:
//		sHref =		string, href tag value
//		sLink = 	string, link  text
//================================================================================
function writeHighlightItem(sHref, sLink)
{	document.write("<tr>");
	document.write("<td width='100%' align='left' valign='top'>");
	document.write("<table width='100%' border='0' cellpadding='0' cellspacing='0'>");
	document.write("<tr>")
	document.write("<td width='100%' align='left' valign='top'><a href='" + sHref + "' class='link';>" + sLink + "</a></td>");
	document.write("<td width='5' align='left' valign='top'><img src='images/spacer.gif' alt='' width='5' height='1' border='0'></td>");
	document.write("</tr>");
	document.write("</table>");
	document.write("</td>");
	document.write("</tr>");
}

//================================================================================
//writes a sinlge row to the highlight table, which
//represents a horizontal spacer row
//to a PDF document.

//files required: 
//		images/spacer.gif
//		css/base.css

//arguments:
//		iWidth = 	integer, width of image (required to make NS work)
//		iHeight = 	integer, height of row
//================================================================================
function writeHighlightSpacer(iWidth, iHeight)
{	document.write("<tr>");
	document.write("<td width='" + iWidth + "' colspan='2'><img src='images/spacer.gif' alt='' width='1' height='" + iHeight + "' border='0'></td>");
	document.write("</tr>");
}

