

// If a thirdLevelLinks variable set is not set,
// set it here, as an empty array, to avoid javascript errors.
if(!subsection) {var subsection = new Array(); }
if(!thirdLevelLinks) { var thirdLevelLinks = new Array(); }

// The one argument to this function should be the unquoted name of a link array above.
// This function will use the names and URLs in that array to generate left nav links.
function makeLeftNavLinks(linkArray) {
	var linkCode = "";					// this is the html code that the function will return
	var elementCount = 0;				// this is a counter, for looping thru the list of links
	var url;							// this is the url to which the link points
	var linkName;						// this is the link text that the user will be able to click on
	var image;							// this will be either a clear gif or a bullet gif
	var putSubNavHere;					// this will be true only when we get to the highlighted link
										// then the subnav will be printed below the highlighted link

	if(linkArray) {
		// Open the link table
		linkCode += '<table cellspacing="0" cellpadding="3" border="0" background="../images/clear.gif" width="137">';
		// Macintosh IE 5.0 cannot interpret or display this table correctly unless all three
		// cells are explicitly defined. Whithout the following line, Mac/IE5 misinterprets
		// "colspan=3" attributes and expands this table's cells into the containing 168px table,
		// pushing all content to the right and ruining the entire page.
		// This row is invisible in all browsers.
		//linkCode += "<tr><td width=12></td><td width=12></td><td width=95></td></tr>"

		while(elementCount < linkArray.length) {
			url = linkArray[elementCount];
			linkName = linkArray[++elementCount];

			putSubNavHere = false;
			if (linkName == leftNavHighlight && thirdLevelLinks.length > 0) {
				putSubNavHere = true;
			}

			// If this is the link to be highlighted, put a blue square gif in the cell next to the link name.
			if(linkName == leftNavHighlight) {
				image = '<img src="../images/bluesq.gif" width="51" height="12" alt="" border="0" hspace="2" />';
			}
			// If not highlighted, put in a yellowsquare gif.
			else {
				image = '<img src="../images/yellowsq.gif" width="51" height="12" alt="" border="0" hspace="2" />';
			}

			// Make the first cell, with yellow or blue sqaure gif.
			linkCode += '<tr><td width="51" valign="top"><a href="..' + url +'" class="nav">' + image + '</a></td>'
			// Make the second cell, with the actual link.
			linkCode += '<td valign="top" width="86"><a href="..' + url + '" class="nav">' + linkName + '</a></td></tr>';

			// If there should be a subnav (a.k.a. 3rd level nav) here, display it now.
			// The subnav should always go directly below the highlighted link.
			if(putSubNavHere == true) { linkCode += makeThirdLevelNav(); }

			// Step to the next name/URL pair in the list.
			elementCount++;
		}
		// Now close the table.
		linkCode += "</table>";
		return linkCode;
	}
	else { return "global.js - makeLeftNavLinks: Invalid link list: <b>" + linkArray + "</b>"; }
}

function makeThirdLevelNav() {
	// This function makes the nav links that appear in the left nav bar.
	// It gets link urls and link text from the global variable "thirdLevelLinks,"
	// which should be set within the html page.
	// These links are indented somewhat more than the rest of the left nav links.
	// The main difference between this function and makeLeftNavLinks is the width of the
	// columns. Also, this function does not open or close a table. It only produces rows & cells.
	var thirdLevelCode = "";
	var elementCount = 0;
	var url;
	var linkName;
	var image;
	var line;						// either a clear gif or a circle gif

	if(thirdLevelLinks) {
		thirdLevelCode += '<tr><td colspan="2"><table border="0" cellspacing="0" cellpadding="0">'
		while(elementCount < thirdLevelLinks.length) {
			url = thirdLevelLinks[elementCount];
			linkName = thirdLevelLinks[++elementCount];

			image = '<img src="../images/circle.gif" width=51 height=12 alt="" border="0" hspace="4" />';

			// Make the first two cells: one with circle gif, one with either clear gif.
			thirdLevelCode += '<tr><td valign="top">' + image + '</td>'
			thirdLevelCode += '<td><img src="../images/clear.gif" width="5" height="1" alt="" border="0" /></td>'
			// Make the second cell, with the actual link, and the one- or two-pixel clear line.
			thirdLevelCode += '<td valign="top"><a href="..' + url + '" class="activesub">' + linkName + '</a></td></tr>'
			thirdLevelCode += '<tr><td valign="top" colspan="3"><img src="../images/clear.gif" width="5" height="4" alt="" border="0" /></td></tr>';
			// Step to the next name/URL pair in the list.
			elementCount++;
		}
		thirdLevelCode += '</table></td></tr>'
		return thirdLevelCode;
	}
	else { return "global.js - makeThirdLevelNav: Invalid link list: <b>" + thirdLevelLinks + "</b>"; }
}



// ************************** BEGIN 3RD LEVEL SWITCH **********************************************
switch(subsection) {

	case "investorRelations":
			thirdLevelLinks = InvestorRelationsLinks
			break;

	case "essentialInformation":
			thirdLevelLinks = EssentialInformationLinks
			break;

	case "firstHealthHistory":
			thirdLevelLinks = FirstHealthHistoryLinks
			break;

	case "mediaRoom":
			thirdLevelLinks = MediaRoomLinks
			break;

	case "contactUs":
			thirdLevelLinks = ContactUsLinks
			break;

	case "welcome":
			thirdLevelLinks = WelcomeLinks
			break;

	case "valuableResources":
			thirdLevelLinks = ValuableResourcesLinks
			break;

	case "groupHealth":
			thirdLevelLinks = GroupHealthLinks
			break;
	case "complianceIntegrity":
			thirdLevelLinks = ComplianceIntegrityLinks
			break;

	case "workersComp":
			thirdLevelLinks = WorkersCompLinks
			break;

	case "services":
			thirdLevelLinks = ServicesLinks
			break;

	case "positions":
			thirdLevelLinks = PositionsLinks
			break;

}
// ************************** END 3RD LEVEL SWITCH ************************************************



// ************************** BEGIN SWITCH **********************************************

var yLine="";
switch(section) {

	case "about":
			linkCode = makeLeftNavLinks(AboutLinks);
			yLine += '<img src=\"../images/linegrow.gif\" height=\"4\" width=\"342px\" alt=\"\" />';
			break;

	case "careers":
			linkCode = makeLeftNavLinks(CareersLinks);
			yLine += '<img src=\"../images/linegrow.gif\" height=\"4\" width=\"718px\" alt=\"\" />';
			break;

	case "members":
			linkCode = makeLeftNavLinks(MembersLinks);
			yLine += '<img src=\"../images/linegrow.gif\" height=\"4\" width=\"434px\" alt=\"\" />';
			break;

	case "clients":
			linkCode = makeLeftNavLinks(ClientsLinks);
			yLine += '<img src=\"../images/linegrow.gif\" height=\"4\" width=\"503px\" alt=\"\" />';
			break;

	case "DoctorsHospitals":
			linkCode = makeLeftNavLinks(DoctorsHospitalsLinks);
			yLine += '<img src=\"../images/linegrow.gif\" height=\"4\" width=\"652px\" alt=\"\" />';
			break;

	case "Nil":
	        linkCode = "";
	        break;
}

// ************************** END SWITCH **********************************************


