// This script is for making the "previous" and "next" buttons on the article pages

function createNav(theArray, theFile)
{

	for (var i=0;i < theArray.length;i++)
	{

		//document.write( theArray[i] + "<br>");

		if (theArray[i] == theFile )
		{
			var h = i - 1;
			var j = i + 1;

			document.write("<p>");
			
			if (h >= 0)
			{
				document.write("<a href='" + theArray[h] + "'>Previous Story</a>");
			} else {
				//document.write("Previous Story | ");			
			}

			if (j < theArray.length)
			{
				if (j>1)
				{
					document.write(" | ");
				}
				document.write("<a href='" + theArray[j] + "'>Next Story</a>");
			} else {
				//document.write(" Next Story");		
			}
			
			document.write("</p>");
		}

	}
}
		
// End function createNav



function getNavSection()
{

	var thisFile 	= document.URL;

	var regExp 	= /http:\/.*\/(.*)\/(.*)/;

	var myFileName 	=	thisFile.replace(regExp,"$2" );
	var myCat	=	thisFile.replace(regExp,"$1" );

	//document.write ("New Name: " + myFileName + "<br>" + myCat + "<br>&nbsp;<br>");

	if (myCat == "people")
	{

		// Define the array of files in the order they should appear

		var theFiles = new Array( 	"bailey.html",
						"chang.html",
						"greenwald.html",
						"hoyt.html",
						"coord.html",
						"rex.html",
						"tocheri.html",
						"west.html",
						"multi_collab.html",
						"scope.html",
					  	"lang_acq.html",						
						"collab.html",
						"com_net.html",
						"wrkng_memory.html",
						"dgtl_mtrls.html",
						"brain.html",
						"optical_phntics.html"
						);

		// Call the function to create the back and forward links

		createNav(theFiles, myFileName);
	}

	if (myCat == "ideas")
	{
		// Define the array of files in the order they should appear

		var theFiles = new Array(	"3d_optical.html",
						"new_know.html",
						"eyetrack.html",
						"kn_biocomp.html",
						"cmnm_groups.html",
						"ozone.html",
						"langlearn.html",
						"multiscale_model.html",
						"biocomplexity.html",
						"decisionmaking.html",
						"contam_water.html",
						"algorithms.html",
						"recveb.html"
						);

		// Call the function to create the back and forward links

		createNav(theFiles, myFileName);
	}

	if (myCat == "tools")
	{
		// Define the array of files in the order they should appear

		var theFiles = new Array(	"alloc.html",
						"kn_biocomp.html",
						"dig_lib.html",
						"deep2.html",
						"solid_liquid.html",
						"dsgn_collab.html",
						"lrng_forum.html",
						"tutoring.html",
						"lifemapper.html",
						"uia.html",
						"tutors.html",
						"archives.html",
						"water_model.html",
						"speech_seen.html"
						);

		// Call the function to create the back and forward links

		createNav(theFiles, myFileName);
	}
}

getNavSection();