<!-- Javascript will write out the menu below with correct active/inactive links displayed. Menus based on successfully determining the page's file name -->

// this script determines the correct section page name to display, then displays it

function itemCount(stringVar,delimeter)
// this function returns the number of items in the string, as marked by the delimiter character
{
matches = 0;
stringVarLength = stringVar.length;
	for (var P = 1; P <= stringVarLength; P++)
	{
		charVal = stringVar.charAt(P);
		if (charVal == delimeter) { matches = matches + 1; }
	}
matches = matches + 1;
return (matches);
}

function getItem(posNum,stringVar,delimeter)
{
// set variables
stringVarLength = stringVar.length;
matches = 0;
prevPos = 0;
currentPos = -1;

// end if  if delimeter is at first character (nothing before that!)
if ( (posNum == 1) && (stringVar.charAt(0) == delimeter) )
	{ zResult = ""; }
else
{
// continue on, find position in string based on delimiter
	for (var P = 1; P <= stringVarLength; P++)
	{
		if (stringVar.charAt(P) == delimeter)
			{
				prevPos = currentPos;
				currentPos = P;
				matches = matches + 1;
			}
		if (matches == posNum) {break}
	}

	if (P > stringVarLength)
		{
			prevPos = currentPos;
			currentPos = (P - 1);
		}
	prevPos = prevPos + 1;

	position = stringVar.substring(prevPos,currentPos);
}

	return (position);
}



// set up variables

thisURL = document.URL;
numURLparts = itemCount(thisURL,"/");
pageURLname = getItem(numURLparts,thisURL,"/");

pageURLpart = getItem(1,pageURLname,".");	// take off any file extensions

numLevels = itemCount(pageURLpart,"_");	// number of hierarchy levels


// determine section and page you are in
if (numLevels == 1)
{
	sectionName = pageURLpart;	// section IS the current page
	pageName = "";	// empty variable means you are on top section page

}
else
{
// levels = 2
	sectionName = getItem(1,pageURLpart,"_");
	pageName = getItem(2,pageURLpart,"_");
}


// write out correct menu, with cuttent page highlighted (also handle case that current page IS section page)


document.write('<div class="sidebar">');

// About Us
	if (sectionName == "about") {
		if (pageName == "")
		{ document.write('<span class="sbCurrent sbHeadSelect">About Us<br><\/span>'); }
		else { document.write('<span><a href="about_what.shtml" class="sbHead">About Us<\/a><br><\/span>'); }

		if (pageName == "what")
		{ document.write('<span class="sbLine sbSelLine">&bull; What We Do<br><\/span>'); }
		else { document.write('<span class="sbLine">&bull; <a href="about_what.shtml" class="sbLink">What We Do<\/a><br><\/span>'); }

		if (pageName == "people")
		{ document.write('<span class="sbLine sbSelLine">&bull; People<br><\/span>'); }
		else { document.write('<span class="sbLine">&bull; <a href="about_people.shtml" class="sbLink">People<\/a><br><\/span>'); }
	}




// Technology
	if (sectionName == "tech") {
		if (pageName == "")
		{ document.write('<span class="sbCurrent sbHeadSelect">Technology<br><\/span>'); }
		else { document.write('<span><a href="tech_overview.shtml" class="sbHead">Technology<\/a><br><\/span>'); }

		if (pageName == "overview")
		{ document.write('<span class="sbLine sbSelLine">&bull; Overview<br><\/span>'); }
		else { document.write('<span class="sbLine"><a href="tech_overview.shtml" class="sbLink">&bull; Overview<\/a><br><\/span>'); }

		if (pageName == "pdtaction")
		{ document.write('<span class="sbLine sbSelLine">&bull; PDT in Action<br><\/span>'); }
		else { document.write('<span class="sbLine"><a href="tech_pdtaction.shtml" class="sbLink">&bull; PDT in Action<\/a><br><\/span>'); }

		if (pageName == "pdtvalidation")
		{ document.write('<span class="sbLine sbSelLine">&bull; PDT Validation<br><\/span>'); }
		else { document.write('<span class="sbLine"><a href="tech_pdtvalidation.shtml" class="sbLink">&bull; PDT Validation<\/a><br><\/span>'); }

		if (pageName == "pdtpower")
		{ document.write('<span class="sbLine sbSelLine">&bull; PDT\'s Power<br><\/span>'); }
		else { document.write('<span class="sbLine"><a href="tech_pdtpower.shtml" class="sbLink">&bull; PDT\'s Power<\/a><br><\/span>'); }
	}




// Contact
	if (sectionName == "contact") {
		if (pageName == "")
		{ document.write('<span class="sbCurrent sbHeadSelect">Contact Us<br><\/span>'); }
		else { document.write('<span><a href="contact.shtml" class="sbHead">Contact Us<\/a><br><\/span>'); }
	}


document.write('<\/div>');

