

// ------------------------------------------------------------------------------------------------------------------------------------------------
// NAVIGREATª NAVIGATION SYSTEM
// Written by Don Charlton
// http://home.comcast.net/~d.charlton
// ------------------------------------------------------------------------------------------------------------------------------------------------
function NAVIGREAT() 
			{
			var vLevel		=	"closed"	// vLevel determines if the current sub level should be used
			var vFound		=	"no"		// vFound tells me if I found the sub set with the currentpage
			// Grab page from URL
			var URL = window.location;
			// Put the URL in an invisible field
			document.invisibleForm.invisibleField.value = URL;
			// Set a varibale to the value of the invisible field
			var grabbedURL	= document.invisibleForm.invisibleField.value;
			// Pull the current page from the variable and store it variable for use in nav builder.
			var vCurrentPage = grabbedURL.slice( (grabbedURL.lastIndexOf("/")+1) , grabbedURL.length );
			// Begin loop through all pages
			for ( x = 0; x < vPages.length; x++ )
				{
				// Runs this code if the current link type is a section
				if ( vPages[x].LinkType == 'section' )
						{
						// If this is the current page...
						if ( vPages[x].LinkName == vCurrentPage )
							{
							// ... Write the page name to the screen ...
							document.writeln( '<p class="sectionlinkcurrent">' + vPages[x].PageName + '</p>');
							// ... Look at next page to see if it is a subsection page...
							if ( vPages[x+1].LinkType == 'subsection')
								{
								// ... Begin loop through next pages and find all subsections ...
								for (q=(x+1); q<vPages.length; q++)
									{
									// If the next page is set as a subsection ...
									if ( vPages[q].LinkType == 'subsection')
										{
										// ... Print page link. 
										document.writeln('<p class="subsectionlink"><a href="' + vPages[q].LinkName + '">' + vPages[q].PageName + '</a></p>');
										}
									else
										{
										
										break;
										}
									}
								}
							}
						else
							{
							// ... else if it's not the current page print a link.
							document.writeln('<p class="sectionlink"><a href="' + vPages[x].LinkName + '">' + vPages[x].PageName + '</a></p>')
							}}
				// Runs this code if the current page in loop is a subsection
				else if ( vPages[x].LinkType == 'subsection')
						{
						// Run a loop looking ahead to see if any of the upcoming subsections in this section are the current page.
						for (z=x; z<vPages.length; z++)
								{
								// If the next link type is not a subsection, then stop the loop.
								if (vPages[z].LinkType != 'subsection')
									{
									break;
									}
								// Else if there is a match with the current page, set this set of subsections to open in next steps in script.
								else if (vPages[z].LinkName == vCurrentPage )
									{
									vLevel = "open"
									}}
						// If this is the currenr page... 
						if ( vPages[x].LinkName == vCurrentPage && vLevel == 'open' )
							{
							// ... Write the name of this page to the screen ...
							document.writeln( '<p class="subsectioncurrent">' + vPages[x].PageName + '</p>' )
							// If next page is also a subsction ...
							if ( vPages[x+1].LinkType == "subsection" )
								{
								// ... Tell the loop that there are more subsections to come
								vLevel = "open"
								}
							else
								{
								// ... Else tell the main loop to no longer print sub sections, because they're all found.
								vLevel = "closed"
								}}
						// If this is not the current page, print the link here. Then check to see if more text links are coming.
						else if ( vLevel == 'open' )
							{
							// ... Write the link to the page ...
							document.writeln('<p class="subsectionlink"><a href="' + vPages[x].LinkName + '">' + vPages[x].PageName + '</a></p>')
							// If next page is also a subsction
							if ( vPages[x+1].LinkType == "subsection" )
								{
								// ... Tell the loop that there are more subsections to come
								vLevel = "open"
								}
							else
								{
								// ... Else tell the main loop to no longer print sub sections, because they're all found.
								vLevel = "closed"
								}}
					}}}

// ------------------------------------------------------------------------------------------------------------------------------------------------
// END NAVIGREATª NAVIGATION SYSTEM
// ------------------------------------------------------------------------------------------------------------------------------------------------














