var row = 0;
var col = 0;
var currTop = 0;
var tempTop = 0;
var browserName = navigator.appName;
var browserAppVersion = navigator.appVersion;
var browserAppMajorVersion = parseInt(browserAppVersion);
var browserAppMinorVersion = parseInt(browserAppVersion.substring(2,3));

//date function
var date = new Date();
var d  = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

function getToday(){
	document.write(month + "." + day + "." + year);
}
function getLetterDate(){
	x = (m - 1);
	document.write("Today is " + monthNames[x] + " " + d + ", " + year);
}


function buildMenu(){
  if ((navigator.appVersion.indexOf("Mac") !=-1) || ((browserName == "Netscape") && (browserAppMajorVersion == 4) && (browserAppMinorVersion < 7)))
	{
	// do a watered down version of the layers so they aren't visible and don't do anything but are still there to accomodate the script that does the rollovers 
	  for (z=0; z<arrMenu.length; z++){
		SubMenu = arrMenu[z];
		MenuItem = SubMenu[0];
		//the style for the layer had to be written this way instead of in the style sheet because the top value is a variable.  NS4 would not recognize the style when put in the write statement.		
		document.write("<style type=\"text/css\">");
		document.write("<!--");
		document.write("#" + MenuItem[0] + " { position: absolute; visibility: hidden; z-index: 99; left: 1px; width: 1px; top: 1px}");
		document.write("-->");
		document.write("</style>");
		document.write("<div id=\"" + MenuItem[0] + "\">");
		document.write("</div>");
	  }
  }
  else {
	for (z=0; z<arrMenu.length; z++){
		SubMenu = arrMenu[z];
		MenuItem = SubMenu[0];
		MenuImg = MenuItem[2];
		row = 0;
		col = 0;
		currTop = 0;
		tempTop = 0;

		//calculate the y coordinate of the layer's location based on the image it's associated with
		if (browserName=="Microsoft Internet Explorer"){
			currTop = eval(MenuImg).offsetTop;
			tempTop = eval(MenuImg).offsetParent;
			while (tempTop != null) {
	  			currTop += tempTop.offsetTop;
	  			tempTop = tempTop.offsetParent;
	  		}
		}else{
			currTop = document.images[MenuImg].y;
		}

		//the style for the layer had to be written this way instead of in the style sheet because the top value is a variable.  NS4 would not recognize the style when put in the write statement.		
		document.write("<style type=\"text/css\">");
		document.write("<!--");
		document.write("#" + MenuItem[0] + " { position: absolute; overflow: visible; visibility: hidden; z-index: 1; left: 171px; width: 142px; top: " + currTop + "px; border: 2px #999999 solid; background-color: #E5E5E5; layer-background-color: #E5E5E5; text-decoration: none }");
		document.write("-->");
		document.write("</style>");
		document.write("<div id=\"" + MenuItem[0] + "\" onMouseOver=\"stopTime();\" onMouseOut=\"startTime();\">");
		
		document.write("<table cellpadding=2 cellspacing=0 border=0 width=100%>");

		for (x=1; x<SubMenu.length; x++){
			row++;
			col++;
			currMenuItem = SubMenu[x];
			document.write("<tr><td id=\"cell_" + MenuItem[1] + row + col + "\"><a href=\"" + currMenuItem[1] + "\" id=\"menuItem_" + MenuItem[1] + row + col + "\" name=\"menuItem_" + MenuItem[1] + row + col + "\" onMouseOver=" + "\"" + "stopTime(); cellOn('" + MenuItem[1] + "','" + row + "','" + col + "')\" onMouseOut=\"startTime(); cellOff('" + MenuItem[1] + "','" + row + "','" + col + "')\"><img src=%22/images/spacer.gif/%22 width=2 height=17 border=0 alt=\"\"></a></td>");
			col++;
			document.write("<td id=\"cell_" + MenuItem[1] + row + col + "\" onMouseOver=\"cellOn('" + MenuItem[1] + "','" + row + "','" + col + "')\" onMouseOut=\"cellOff('" + MenuItem[1] + "','" + row + "','" + col + "');\">");
			document.write("<a href=\"" + currMenuItem[1] + "\" id=\"menuItem_" + MenuItem[1] + row + col + "\" name=\"menuItem_" + MenuItem[1] + row + col + "\" class=\"flyout-menuitems\" onMouseOver=" + "\"" + "stopTime();\" onMouseOut=\"startTime();\">" + currMenuItem[0] + "</a>");
			document.write("</td></tr>");
			col = 0;
		}

		document.write("</table>");
		document.write("</div>");
	}
  }
}


