// leftnav.js
// Author: Adam Vickers
// Creates leftside navigation menu for HDS
// Takes an array of values in the form [ "item1", status, "url1",
//										"item2", status, "url2",
//										[ "sub-item1", status, "sub-url1" ],
//										"item3", status, "url3" ];
//
// where "item1" is the text of the link item, status is a value, 1 or 0,
// describing whether the item is in selected state or not,
// "url1" is the link URL. The example contains a nested array (sub-item1...)
// which creates second-tier menu items for the first-tier
// item preceding it.
// 
// This function was created only for the convenience of the UX production team.
// It creates a leftnav menu from an array. It does nothing dynamically
// and is probably of no use in the finished product.

function makeLeftNav( menuAry, lvl2 ) {
	var pad = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) ? "0" : "1";
	for (var i=0; i<menuAry.length; i++) {
		if (typeof menuAry[i] == "object" ) {
			makeLeftNav(menuAry[i], true) }
		else {
			var item = menuAry[i];
			var linkstatus = menuAry[++i];
			var bulletstyle = "class=\"sidemenubulletgrey\"";
			var href = menuAry[++i];
			var blankrow = menuAry[++i];
			var bullet = "<img src=\"images/leftnav_bullet.gif\" width=\"10\" height=\"10\" border=\"0\" />";
			if (lvl2) {
				var leader = "<img src=\"images/shim.gif\" width=\"22\" height=\"1\" border=\"0\">";
//				var styletag = linkstatus ? "class=\"sidemenu_standard_selected\"" : "class=\"sidemenu_standard\"";
				var styletag = linkstatus ? "class=\"rcsidemenuboldleftselected\"" : "class=\"sidemenuboldleft\"";
				if (linkstatus) bulletstyle = "class=\"sidemenubulletcolored\"";
			} else {
//				var leader = (i<4 || /homepage/.test(document.URL)) ? "" : "<img src=\"/images/shim.gif\" width=\"15\" height=\"10\" border=\"0\">";
				var leader = "<img src=\"images/shim.gif\" width=\"10\" height=\"1\" border=\"0\">";
				var styletag = linkstatus ? "class=\"rcsidemenuboldleftselected\"" : "class=\"sidemenuboldleft\"";
				if (linkstatus) bulletstyle = "class=\"sidemenubulletcolored\"";
			}
			document.write( "<table width=\"100%\" border=\"0\" cellpadding=\"" + pad + "\" cellspacing=\"0\">" );
			document.write( "<tr><td>" + leader + "</td>" );
			document.write( "<td>" );
			
			//bullet needs its own table
			document.write( "<table width=\"10\" height=\"1\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" );
			document.write( "<tr>" );
			document.write( "<td width=\"10\"" + bulletstyle + ">" );
			document.write( "<a href=\"" + href + "\" target=\"_top\">" );
			document.write( bullet );
			document.write( "</a>" );
			document.write( "</td></tr></table>" );
			
			document.write( "</td>" );
			document.write( "<td width=\"200\">" );
			document.write( "<img src=\"images/shim.gif\" width=\"2\" height=\"1\" border=\"0\"><a href=\"" + href + "\" target=\"_top\"" + styletag + ">" );
			document.write( item );
			document.write( "</a></td></tr> " );
			if (blankrow) document.write( "<tr><td><img src=\"images/shim.gif\" width=\"1\" height=\"1\" border=\"0\"></td><td><img src=\"images/shim.gif\" width=\"1\" height=\"1\" border=\"0\"></td><td><img src=\"images/shim.gif\" width=\"1\" height=\"1\" border=\"0\"></td></tr>" );
			document.write( "</table>" );
		}
	}
	return;
}
