/* siteFulcrumJavaScript.js  September 27, 2009  A. B. Jones

This web site uses a dynamic content loader.

Tested with IE 6, 7, 8 and FireFox 2, 3 and Opera 9 and Safari 3

The intent is to make administration tasks of adding menu driven hierarchical content easy
without using server-side includes or server side processing, just file serving.

The draw-backs:
1) the browser must allow JavaScript.   
2) the browser "view source" probably wont show "after JavaScript" content

Please see documentation: About_siteFulcrum.html

The browser will not load content using XMLhttpRequest from a server other than the server source
of the current URL.

Here is the general work flow

1) Browser begins to construct window.document.
2) document header is completed and body begins ( may work in head element but causing trouble with Firefox 3 June 2008 )
3) JavaScript is encountered which performs
    A) get a menu table
    B) select a source document
    C) get the document contents
    D) extract JavaScript from source <head> and insert using document.write
    E) edit the document contents (change <a href= > tags to use siteFulcrum ) and hold as siteFulcrumContent
    F) continue window.document body without adding siteFulcrumContent
    G) Part 1 finished; return construction back to browser

3) Browser encounters JavaScript at "breadcrumb" that constructs the breadcrumb / navigation trail component.
4) Construction returns back to browser.
5) Browser encounters JavaScript at "sidebar" that constructs the sidebar menu component.
6) Construction returns back to browser.
7) Browser encounters JavaScript at "content" that constructs the content component from siteFulcrumContent.
8) Construction returns back to browser.
9) Browser finishes construction and waits for user action.

Optional SearchString parameters:

ss=1 then pass most of the search query string when a menu item is chosen
     except do not pass the siteFulcrum parameters Menu, Title, content_URL, window

Menu=Home.SomePage then load menu itme SomePage

Title=SomePageName then load content area from this title

Content_URL=http://somepath then load content from this source

lastMenu=Home.someName then highlight someName on sidebar menu

href=1 (default) then modify tags <a href="..."  > where not href="http://...
       to be <a href="siteFulcrum_page.html?Content_URL=..."  >

?window=1  when URL in TitleTable has ?window=1 then direct open in new window


Utility Functions:

linkContent_URL() - return string URL to document
PrinterFriendly(1) - alter the document to hide portal, header, breadcrumb, and sidebar
PrinterFriendly(2) - alter the document to hide breadcrumbLeft and sidebar

*/

//--- A number of global variables are used -- all these should be prefixed by "siteFulcrum" but
//--- most are not and may conflict with JavaScript embeded in documents.

//--- Global menuTableName, titleTableName, teamTableName;
//--- may be defined before siteFulcrum.js is loaded.

//--- a test directory may be used for local testing
   if( location.host == '127.0.0.1' ) {
      if(typeof menuTableName  == 'undefined') { menuTableName  = 'test/siteFulcrumMenuTable.txt'; }
      if(typeof titleTableName == 'undefined') { titleTableName = 'test/siteFulcrumTitleTable.txt'; }
      if(typeof teamTableName  == 'undefined') { teamTableName  = 'test/siteFulcrumTeamTable.txt'; }
   }

//--- default table names
   if(typeof menuTableName  == 'undefined') { menuTableName  = 'siteFulcrum/siteFulcrumMenuTable.txt'; }
   if(typeof titleTableName == 'undefined') { titleTableName = 'siteFulcrum/siteFulcrumTitleTable.txt'; }
   if(typeof teamTableName  == 'undefined') { teamTableName  = 'siteFulcrum/siteFulcrumTeamTable.txt'; }

//--- sitefulcrum_UnEscape
//--- if sitefulcrum_UnEscape == 1 then document contents is processed with JavaScript unescape function

//--- sitefulcrum_PrinterFriendly
//--- by default a menu option "show as prnter friendly" is included
//--- if sitefulcrum_PrinterFriendly is defined as 0 then menu option "show as prnter friendly" is not included

//--- parameters ss, Menu, lastMenu, Title, and Content_URL are processed from the search string
   var content_URL = '';

//--- menuStringAppend is appended to the query string portion of a URL in SiteFulcrum getMenu()
   var menuStringAppend = '';

//  if( ss.get('ss') == 1 ) then pass most of the search query string
//  except do not pass the siteFulcrum parameters menu, title, or content_url

//--- list content type that can be loaded into content area
   var siteFulcrum_Loadable = ',.html,.htm,.asp,.shtml,';

   var siteFulcrumEditTime = 0;
   var menuString ='';
   var titleMenu = false;
   var lastMenu = '';
   var documentTitle = '';
   var titleParam = '';
   var headContent = '';
   var scriptTagString = '';
   var titleTagString = '';
   var baseTagString = '';
   var bodyContent = '';
   var bodyString  = '';
   var baseHref = '';
   var docHref = '';
   var siteFulcrumContent = '';
   var siteFulcrumSynchronizationCount = 0;

   var menuTableArray = new Array();
   var menuTitleArray = new Array();
   var titleTableArray = new Array();
   var titleURLArray = new Array();
   var teamPathArray = new Array();
   var teamHomeArray = new Array();
   var responseString = '';
   var textString = '';
//--- elimiate ascii CR ( %0D )
   var rExp = /\r/gi;

//--- test querystring addon
   if( typeof content_url_addon == 'undefined' ) { content_url_addon = ''; }
   if( content_url_addon !== '' && content_url_addon.substr(0,1)!='&' ) { content_url_addon = ''; }
   var ss = new SearchString();
//----------------------------------------------------------

function styleObject(object) {
    if (document.getElementById && document.getElementById(object) != null) {
         return document.getElementById(object).style; }
    else if (document.layers && document.layers[object] != null) {
        return document.layers[object].style; }
    else if (document.all) {
        return document.all[object]; }
}
//----------------------------------------------------------

function elementObject(object) {
    if (document.getElementById && document.getElementById(object) != null)
         return document.getElementById(object);
    else if (document.layers && document.layers[object] != null)
        return document.layers[object];
    else if (document.all)
        return document.all[object];
    else return new Object();
}
//----------------------------------------------------------

function loadXMLDocText( url, mimeType ) {
   if( !mimeType ) { mimeType = "text/plain; charset=x-user-defined"; }
   var resultString= 'loadXMLDocText failed: ';
   var reqObj = null;;
//--- Check for native XMLHttpRequest object
   if (window.XMLHttpRequest) {
      reqObj = new XMLHttpRequest();
//--- Check for Microsoft ActiveX version
   } else if (window.ActiveXObject) {
      reqObj = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
//--- loadXMLDocText is unsupported
       resultString += 'neither window.XMLHttpRequest nor ActiveXObject("Microsoft.XMLHTTP") available';
   }

//--- Document returned in req.
//--- Use only responseText property because type="text/HTML" or other non-XML
   if( reqObj ) {
      var antiCache = '';
if(1){
      if( url.indexOf('?')<0 ) { antiCache += '?'; } else { antiCache += '&'; }
      antiCache += 'requestTime=' + (new Date()).getTime();
      url += antiCache;
}
if( ss.get('debug') > '0' ) { alert('loadXMLDocText("' +  url + '","'+ mimeType + '"' ); }
      reqObj.open("GET", url, false);

      if (typeof reqObj.overrideMimeType != 'undefined' ) { reqObj.overrideMimeType(mimeType); }
      if (typeof reqObj.setRequestHeader != 'undefined' ) { reqObj.setRequestHeader('Content-Type',mimeType); }
      reqObj.send(null);
      if( reqObj.readyState == 4 ) {
        if( reqObj.status == 200 ) {
           resultString = reqObj.responseText;
//if( reqObj.responseXML ) { alert(reqObj.responseXML); }
        } else {
           resultString += 'status="' + reqObj.status + '"';
           resultString += ' ' + reqObj.statusText;
           resultString += ' "' + url + '"';
if(reqObj.responseXML) { alert( reqObj.responseXML ); }
        }
     } else {
        resultString += 'readyState="' + reqObj.readyState + '"';
     }
  }

  reqObj = null;;
  return( resultString );
}
//----------------------------------------------------------


function SearchString(sString) {
//--- return an object of value[name] from the browser search string
//--- with method ".get(name)" to return associated value;
	this.params = new Object();
	this.get=getSearchString;

//--- may pass a string to parse
	if (!sString) { sString=location.search.substring(1,location.search.length) + content_url_addon; }

	if (sString.length > 0) {	
//--- replace pluss with space
		sString = sString.replace(/\+/g, ' ');
//--- name/value pairs separated by &
		var argsArray = sString.split('&');
//--- assign each params as  name=value
		for (var i in argsArray) {
			var nameArray = argsArray[i].split('=');
			if (nameArray[1]) {
                                var name = unescape(nameArray.shift());
				var value = '';
				while( nameArray.length>0 ) {
					value += unescape(nameArray.shift());
					if( nameArray.length > 0 ) { value += '='; }
				}
//alert(name + '=' + value);
				this.params[name] = value;				 
			}
		}
	}
}

function getSearchString(ssObject, defaultValue) {
	if (!defaultValue) { defaultValue = null; }
	var value=this.params[ssObject];
	if (value==null) { value=defaultValue; }	
	return value;
}
//----------------------------------------------------------

function replaceString(sString, sReplaceThis, sWithThis) { 
  if (sReplaceThis !== "" && sReplaceThis !== sWithThis) {
     var counter = 0;
     var start = 0;
     var before = "";
     var after = "";
     while (counter<sString.length) {
        start = sString.indexOf(sReplaceThis, counter);
        if (start == -1){
           break;
        } else {
           before = sString.substr(0, start);
           after = sString.substr(start + sReplaceThis.length, sString.length);
           sString = before + sWithThis + after;
           counter = before.length + sWithThis.length;
        }
     }
   }
   return sString;
}
//----------------------------------------------------------

function ascii_value(c) {
	// restrict input to a single character
	c = c . charAt (0);

	// loop through all possible ASCII values
	var i;
	for (i = 0; i < 256; ++ i)
	{
		// convert i into a 2-digit hex string
		var h = i . toString (16);
		if (h . length == 1)
			h = "0" + h;

		// insert a % character into the string
		h = "%" + h;

		// determine the character represented by the escape code
		h = unescape (h);

		// if the characters match, we've found the ASCII value
		if (h == c)
			break;
	}
	return i;
}
//----------------------------------------------------------

function stripTags(line) {
	var result='';
	var i = line.indexOf('<');
	if( i < 0 ) {
		result = line;
	} else {
		while( i > -1 ) {
			if( i>0 ) { result += line.substr(0,i); }
			if( i<line.length) {
				line = line.substr(i+1,line.length-(i+1));
			} else {
				line = '';
			}                
			i = line.indexOf('>');
			if( i>-1 && i<line.length) {
				line = line.substr(i+1,line.length-(i+1));
			} else {
				line = '';
			}                
			i = line.indexOf('<');
		}
	}
	return result;
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------


function getMenuTitleContent_URL(){
   if( !menuString ) { menuString = '';  }
   lastMenu = menuString;
if( ss.get('debug') > '0' ) { alert( 'content_URL="' + content_URL + '"'); }

//--- look for "Title=xxx" name in the SearchString
   documentTitle = ss.get('Title');
   if( documentTitle == null ) { documentTitle = ss.get('title');  }
   if( documentTitle == null ) { documentTitle = '';  }

//--- look for "Menu=xxx" name in the SearchString
   if( menuString === '' ) { 
      menuString = ss.get('Menu');
      if( !menuString ) { menuString = ss.get('menu');  }
      if( !menuString ) { menuString = '';  }
   }

//--- look for "lastMenu=xxx" name in the SearchString
   lastMenu = ss.get('lastMenu');
   if( !lastMenu ) { lastMenu = ss.get('lastmenu');  }
   if( !lastMenu ) { lastMenu = '';  }

//--- content_URL overrides title - find associated title
   if( content_URL !== '' ) {
      if( content_URL.toLowerCase() != ( 'http://' + location.host + location.pathname ).toLowerCase() ) {
         documentTitle = '';
         for ( var i in titleURLArray ) {
            if( titleURLArray[i] == content_URL ||
               titleURLArray[i] == 'http://' + location.host + location.pathname + content_URL ||
               titleURLArray[i] == baseHref + docHref
              ) {
               documentTitle = titleTableArray[i];
if( ss.get('debug') > '0' ) { alert( 'documentTitle from titleURLArray(' + content_URL + '="' + documentTitle + '"'); }
               break;
            }
         }
      }
   }

   titleMenu = false;
//--- title overrides menu - find associated menu
   if( documentTitle !== '' ) {
      menuString = '';
      for (var i in menuTitleArray ) {
         if( documentTitle == menuTitleArray[i] ) {
            menuString = menuTableArray[i];
if( ss.get('debug') > '0' ) { alert( 'menuString="' + menuString + '"'); }
            titleMenu = true;
            break;
         }
      }
   }

   if( content_URL === '' && documentTitle === '' && menuString === '' ) {
      menuString = menuTableArray[0];
      if( !menuString ) { 
         menuString = menuTableArray[0];
if( ss.get('debug') > '0' ) { alert( 'menuString="' + menuString + '"'); }
      }
   }

//--- find a title from the menu
   if( menuString !== '' ) {
      for (var i in menuTableArray ) {
         if( menuString == menuTableArray[i] ) {
            documentTitle = menuTitleArray[i];
if( ss.get('debug') > '0' ) { alert( 'documentTitle from menuString(' + menuString + ')="' + documentTitle + '"'); }
            break;
         }
      }
   }

//--- find content_URL from title
   if( content_URL === '' && documentTitle !== '' ) {
      if( titleParam === '' ) { titleParam = documentTitle; }
      for (var i in titleTableArray ) {
         if( titleParam === titleTableArray[i] ) {
            content_URL = titleURLArray[i];
if( ss.get('debug') > '0' ) { alert( 'content_URL from documentTitle(' + documentTitle + ')="' + content_URL + '"'); }
            break;
         }
      }
   }
   if( content_URL !== '' ) {
//--- keep the search query string except for siteFulcrum parameters menu, title, and content_url
      var editSearch = ''
      var qsArray = location.search.split('?');
      if( qsArray[1] ) {
         var paramArray = qsArray[1].split('&');
         for ( i in paramArray ) {
            var nameValueArray = paramArray[i].split('=');
            if( nameValueArray[1] &&
                ',menu,title,content_url,'.indexOf(nameValueArray[0].toLowerCase()) == -1 ) {
               editSearch += '&' + paramArray[i];
            }
         }
      }
//if( ss.get('debug') > '0' ) { alert('editSearch="' + editSearch + '"'); }
      if( editSearch !== '' ) {
         if( content_URL.indexOf('?') < 0 ) {
            content_URL += '?';
         } else {
            content_URL += '&'
         }
         content_URL += editSearch.substring(1,editSearch.length);
      }
   }

   return ('menuString="' + menuString + '"  documentTitle="' + documentTitle + '"   content_URL="' + content_URL + '"');
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------


function siteFulcrumTrail() {
//--- assign div id="breadcrumb"
   var breadcrumbDiv = '';
   getMenuTitleContent_URL();
if( ss.get('debug') > '0' ) { alert( 'WriteTrail menuString="' + menuString + '"'); }
   if( !menuString ) { menuString = ''; }
   if( menuString === '' ) { menuString = lastMenu; }
   if( menuString === '' ) { menuString = menuTableArray[0]; }

//--- validate menuString
   var valid_menuString = false;
   for (i in menuTableArray ) {
      if( menuString == menuTableArray[i] ) { valid_menuString = true; }
   }
   if( valid_menuString == false ) { menuString = menuTableArray[0]; }

   if( !menuString ) { menuString = ''; }

   if( menuString !== '' ) {
      var nameArray = menuString.split('.');
      var crumbTrainString = '';
      for (i in nameArray) {
         crumbTrainString += nameArray[i];
         if( breadcrumbDiv !== '' &&
             breadcrumbDiv.length > 11 &&
             breadcrumbDiv.substr(breadcrumbDiv.length-12,12) != ' "></a></li>') {
             breadcrumbDiv += '<li>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;</li>';
         }
         breadcrumbDiv += '<li>';
         if(    (i != nameArray.length-1)
             || (lastMenu!=='' && titleMenu==false && crumbTrainString == lastMenu)
             || (documentTitle==='')
           ) {
            breadcrumbDiv += '<a href="#" onClick="JavaScript:getMenu(\'' +  crumbTrainString + '\');return false;"';
            breadcrumbDiv += ' title="Click here to view ' + nameArray[i] + '">';
            breadcrumbDiv += '<span id="crumb' + i + '">';
         }
            breadcrumbDiv += replaceString(nameArray[i],'_','');
         if(    (i != nameArray.length-1)
             || (lastMenu!=='' && titleMenu==false && crumbTrainString == lastMenu)
             || (documentTitle==='')
           ) {
            breadcrumbDiv += '</span>';
            breadcrumbDiv += '</a>';
         }
         breadcrumbDiv += '</li>';
         if( lastMenu!=='' && titleMenu==false && crumbTrainString == lastMenu ) {
//--- add a crumb for a document without an assigned menu tab
            breadcrumbDiv += '<li>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;</li>';
            breadcrumbDiv += '<li>' + titleParam + '</li>';
         }
         crumbTrainString += '.';
      }
   }
   return( breadcrumbDiv );
}

function siteFulcrumWriteTrail() {
      document.write( siteFulcrumTrail() );
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function siteFulcrumMenu() {
//--- assign div id="sidebar"
   var sidebarDiv = '';
   getMenuTitleContent_URL();
if( ss.get('debug') > '0' ) { alert( 'WriteMenu menuString="' + menuString + '"'); }
   if( !menuString ) { menuString = ''; }
   if( menuString === '' ) { menuString = lastMenu; }
   if( menuString === '' ) { menuString = menuTableArray[0]; }
   if( !menuString ) { menuString = ''; }
   var nameArray = menuString.split('.');
   var rightName = nameArray[nameArray.length-1];
   nameArray.length = nameArray.length - 1;
   var leftNames = nameArray.join('.');

   for (i in menuTableArray ) {
      var crumbString = menuTableArray[i];
      var crumbArray = crumbString.split('.');
      var rightCrumb = replaceString(crumbArray[crumbArray.length-1],'_','&nbsp;&nbsp;');
      crumbArray.length = crumbArray.length-1;
      crumbArrayLen = crumbArray.length;
      var leftCrumbs = crumbArray.join('.');

      if(    ( i != 0 )
           &&
             (
             ( menuString == leftCrumbs )
           ||
             ( 
                  ( leftCrumbs !== '' && leftCrumbs == leftNames.substr(0,leftCrumbs.length) )
               && ( leftCrumbs.substr(leftCrumbs.length-1,2) != '..' )
             ) 
             )
        ) {
          var menuBar = '';
          sidebarDiv += '<li';
          if( menuTitleArray[i] !== '' ) {
             menuBar += '<a';
             if( menuTableArray[i] == menuString ) {
                menuBar += ' class="selected"';
             }
             menuBar += ' href="#" onClick="JavaScript:getMenu(\'' + menuTableArray[i] + '\');return false;"';
             if( menuTitleArray[i] !== '' ) {
                menuBar += ' title="Click here to view ' + stripTags(rightCrumb);
             }
             menuBar += '">';
             if( crumbArrayLen > 3 ) { sidebarDiv +=  ' style="margin-left: 3.5em; width: 7em;"'; }
             else { if( crumbArrayLen > 2 ) { sidebarDiv +=  ' style="margin-left: 2.5em; width: 8em;"'; }
             else { if( crumbArrayLen > 1 ) { sidebarDiv +=  ' style="margin-left: 1.5em; width: 9em;"'; } } }
          }
          menuBar += '<span id="menu' + i + '">' + rightCrumb + '</span>';
          if( menuTitleArray[i] !== '' ) { menuBar += '</a>'; }
          sidebarDiv += '>' + menuBar + '</li>\n';
      }
   }

   if( typeof sitefulcrum_PrinterFriendly == 'undefined' || sitefulcrum_PrinterFriendly != 0 ) {
//---  Show as Printer Friendly menu tab
      sidebarDiv += '<li>&nbsp;<br>&nbsp;<br>&nbsp;</li><li>';
      sidebarDiv += '<a class="specialMenu" href="' + location.href;
//--- JavaScript:printerFriendly()
      if( location.href.indexOf('?') == -1 ) { sidebarDiv += '?'; } else { sidebarDiv += '&amp;'; }
      sidebarDiv += 'pf=1"';
      sidebarDiv += ' title="Click here to show printer friendly content. Use browser Back when done."';

      sidebarDiv += '>Show This Page as<br>Printer Friendly</a></li>';
   }

   return( sidebarDiv );
}

function siteFulcrumWriteMenu() {
   document.write(siteFulcrumMenu());
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function siteFulcrumWriteContent() {

   if( siteFulcrumContent == '' ) { siteFulcrumBuildContent(); }

   siteFulcrumContent = '<base href="' + baseHref + '"/>' + siteFulcrumContent;
   siteFulcrumContent += '<!-- siteFulcrumContentBuilt -->';

//alert('content written');
if( ! document.getElementById("contentHTML") ) {
 	document.write( siteFulcrumContent );
} else {
	return( siteFulcrumContent );
}

}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function getTitle(title) {
//--- trying to prevent loading an extra page when location is on another server
//--- calculate documentTitle from menu item menuString
   if( !title ) { title = ''; }
   documentTitle = title;
   lastMenu = menuString;

   content_URL = '';
   if( documentTitle !== '' ) {
//--- calculate content_URL from title Table item documentTitle
      for ( i in titleTableArray ) {
         if( documentTitle == titleTableArray[i] ) {
            content_URL = titleURLArray[i];
            break;
         }
      }
   }
//--- New Page
   if( content_URL !== '' ) {
       if( ( content_URL.substr(0,7) == 'http://' )
          && ( content_URL.indexOf('http://' + location.host + location.pathname) != 0 )
         ) {
          jumpTitle();
       } else {
         var url= 'http://' 
                        + location.host + location.pathname
                        + '?Title=' + documentTitle.replace(/ /, '+')
                        + '&lastMenu=' + menuString.replace(/ /, '+');
//--- Check for siteFulcrum URL searchString pf
	if( content_URL.indexOf('?pf=1') > 0 ) { url += '&pf=1'; }
if( ss.get('debug') > '0' ) { alert('getTitle url="' + url + '"'); }
          window.location = url
       }
   } else {
//--- title not translated to a content_URL; do nothing
   } 
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function getMenu(menuString) {
//--- trying to prevent loading an extra page when location is on another server
//--- translate documentTitle from menu item menuString
   documentTitle = '';
   if( menuString !== '' ) {
      for ( i in menuTableArray ) {
         if( menuString == menuTableArray[i] ) {
            documentTitle = menuTitleArray[i];
            break;
         }
      }
   }
   content_URL = '';
   if( documentTitle !== '' ) {
//--- translate content_URL from title Table item documentTitle
      for ( i in titleTableArray ) {
         if( documentTitle == titleTableArray[i] ) {
            content_URL = titleURLArray[i];
            break;
         }
      }
   }
//--- New Page
   if( content_URL !== '' ) {
if( ss.get('debug') > '0' ) { alert('getMenu content_URL="' + content_URL + '"'); }
       var newWindow = ( content_URL.indexOf('?window=1') || content_URL.indexOf('&window=1') );
       if( ( content_URL.substr(0,7) == 'http://' )
          && ( content_URL.indexOf('http://' + location.host + location.pathname) != 0 )
          && ( newWindow < 0 )
         ) {
          if( content_URL.indexOf('?') == -1 ) { content_URL += '?'; } else { content_URL += '&'; }
          content_URL += 'Menu=' + menuString.replace(/ /, '+');
          jumpContent_URL(content_URL);
       } else {
          var delimiter = '?';
          var qsArray = new Array();
          var newLocation = 'http://' + location.host + location.pathname;
          if( newWindow > 0 ) {
       		if( content_URL.indexOf('?window=1') > 0 ) {
             		qsArray = content_URL.split('?');
             		newLocation = qsArray[0];
		} else {
             		newLocation = content_URL.substr(0,content_URL.indexOf('&window=1'));
		}
          } else {
             if( newLocation.indexOf('?') == -1 ) { newLocation += '?'; } else { newLocation += '&'; }
             newLocation += 'Menu=' + menuString.replace(/ /, '+');
             delimiter = '&';
             if( ss.get('ss') == 1 ) {
//--- keep the search query string except for siteFulcrum parameters menu, title, and content_url
                qsArray = location.search.split('?');
             }
          }
          if( qsArray[1] ) {
             var paramArray = qsArray[1].split('&');
             for ( i in paramArray ) {
                var nameValueArray = paramArray[i].split('=');
                if( nameValueArray[1] &&
                    ',menu,title,content_url,window,'.indexOf(nameValueArray[0].toLowerCase()) == -1 ) {
                   newLocation += delimiter + paramArray[i];
                   delimiter = '&';
                }
             }
          }

if( ss.get('debug') > '0' ) { 
   alert('getMenu newLocation="' + newLocation + 
         '"\nlocation.host="' + location.host +
         '"\nlocation.pathname="' + location.pathname +
         '"' );
}

//--- pass newLocation search string?
          var leftQ = newLocation.split("?");
          if( leftQ[0].substr(leftQ[0].length-4,4).toLowerCase() === '.pdf'
             ) { newLocation = leftQ[0]; }

          if( ',mailto:,http:/,ftp://,'.indexOf(newLocation.substr(0,6)) < 1 ) {
             if( newLocation.substr(0,1) != '/' ) {
//--- append the path that points to root "index.html" page onto location.pathname
//--- overcomes a problem with the way IE handles base for relative links

if( ss.get('debug') > '0' ) { 
   alert( 'pathnameString="' + pathnameString +
          '"\nnewLocation="' + newLocation +
          '"' );
}
                newLocation = pathnameString + newLocation;
             }
          }
          window.location = newLocation;
       }
   } else {

//--- menu item not translated to a documentTitle; do nothing
alert( 'menuString="' + menuString + '" not translated.') ;

   } 
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function uniqueURLQS(url){
	if( url ) {
		var qs = '';
		var urlArray = url.split('?');
		if( urlArray.length > 1 ) {
			var qsArray = urlArray[1].split('&');
			for( var i in qsArray ) {
				if( (qs+'&').indexOf( '&'+qsArray[i]+'&' ) < 0 ) { qs += '&'+qsArray[i]; }
			}
		}
		url = urlArray[0];
		if( qs!='' ) { url += '?' + qs.substr(1); }
	}
	return(url);
}
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function jumpContent_URL( url ) {
//--- load an absolute URL
   if( !url ) { url = content_URL; }
//--- check url for a link to a Team site
   for ( var i in teamPathArray ) {
     if( url.toLowerCase() != ( teamPathArray[i] + teamHomeArray[i] ).toLowerCase()
         && url.toLowerCase().indexOf(teamPathArray[i].toLowerCase()) == 0 ) {
//--- remove target host path from url
//--- back-reference for each directory in teamHomeArray
        var dirArray = teamHomeArray[i].split('/');
        var backReference = '';
        for ( var j in dirArray) {
           backReference += '../';
        }
        if( backReference !== '' ) { backReference = backReference.substr(3); }
        url = url.substr(teamPathArray[i].length,url.length-teamPathArray[i].length);
        url = teamPathArray[i] + teamHomeArray[i]
            + '?Content_URL=' + backReference + replaceString(url,'?','&');
        if( lastMenu!=='' ) { url += '&lastMenu=' + lastMenu.replace(/ /, '+'); }
        break;
     }
   }

   if( ss.get('ss') == 1 ) {
      var delimiter = '?';
//--- keep the search query string except for siteFulcrum parameters content_url and referer
      var qsArray = location.search.split('?');
      if( qsArray[1] ) {
         var paramArray = qsArray[1].split('&');
         for ( i in paramArray ) {
            var nameValueArray = paramArray[i].split('=');
             if( nameValueArray[1] &&
                ',content_url,referer,'.indexOf(nameValueArray[0].toLowerCase()) == -1 ) {
                if( url.indexOf('?') > -1 ) { delimiter = '&'; }
                url += delimiter + paramArray[i];
            }
         }
      }
   }

   url = uniqueURLQS(url);
   if( url.substr(0,1) == "!" ) {
if( ss.get('debug') > '0' ) { alert('jumpContent_URL url="' + url + '"'); }
      window.location = url.substr(1,url.length-1);
   } else {
if( ss.get('debug') > '0' ) { alert('jumpContent_URL url="' + url + '"'); }
      window.location = url;
   }
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function jumpTitle() {
  var url = '';
//--- load by title
//--- check content_URL for a link to a Team site
  for ( i in teamPathArray ) {
     if( content_URL.toLowerCase() != ( teamPathArray[i] + teamHomeArray[i] ).toLowerCase()
         && content_URL.toLowerCase().indexOf(teamPathArray[i].toLowerCase()) == 0 ) {
        url = teamPathArray[i] + teamHomeArray[i] 
                     + '?Title=' + documentTitle.replace(/ /, '+')
        if( lastMenu!=='' ) { url += '&lastMenu=' + lastMenu.replace(/ /, '+'); }
if( ss.get('debug') > '0' ) { alert('jumpTitle url="' + url + '"'); }
        window.location = url;
        break;
     }
  }
  if( content_URL !== '' && url == '' ) {
    if( ss.get('debug') > '0' ) { alert('jumpTitle content_URL="' + content_URL + '"'); }
    window.location = uniqueURLQS(content_URL);
  }
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function linkContent_URL(searchStringAddOn) {
   if( typeof searchStringAddOn == 'undefined') { searchStringAddOn=''; }
   if( baseHref !== '' && docHref !== '' ) {
if( ss.get('debug') > '0' ) { alert('lnkContent_URL baseHref="' + baseHref + '" docHref="' + docHref + '"'); }
      var newLocation = baseHref + docHref;
      var c = content_URL.split('?');
      if( c[1] ) { newLocation += '?' + c[1]; }
      if( searchStringAddOn ) { if( c[1] ) {
         newLocation += '&' + searchStringAddOn; } else { newLocation += '?' + searchStringAddOn; }
      }
      window.location = uniqueURLQS(newLocation);
   } else {
      if( content_URL !== '' ) { 
         window.location = uniqueURLQS(content_URL);
      }
   }
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function getLinkContent_URL() {
   if( baseHref !== '' && docHref !== '' ) {
      var newLocation = baseHref + docHref;
      var c = content_URL.split('?');
      if( c[1] ) { newLocation += '?' + c[1]; }
      return newLocation;
   } else {
      if( content_URL !== '' ) { 
         return content_URL;
      }
      return '';
   }
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function showName(name) {
   window.location = 'http://'+location.host+location.pathname+location.search + '#'+ name; 
}


function printerFriendly(pf) {

   if( pf=='1' && elementObject('portal') && styleObject('portal') ) {
     elementObject('portal').innerHTML = '';
     styleObject('portal').height = 0;
     styleObject('portal').width = 0;
     styleObject('portal').visibility = 'hidden';
   }

   if( pf=='2' && elementObject('breadcrumbLeft') ) {
     elementObject('breadcrumbLeft').innerHTML = 
	'<ul><li><a HREF="#" onClick="JavaScript:window.close();" title="Close this window">Close Window</a></li>'
	+ '<li style="margin-left: 2em;"><a HREF="#" onClick="JavaScript:linkContent_URL('
	+ "'pf=1'"
	+ ');return false;" title="Direct link to document">'
	+ 'Show This Page as Printer Friendly<' + '/a><' + '/li></ul>';

   }

   if( pf=='1' && elementObject('headerbackground') && styleObject('headerbackground') ) {
     elementObject('headerbackground').innerHTML = '';
     styleObject('headerbackground').height = 0;
     styleObject('headerbackground').width = 0;
     styleObject('headerbackground').visibility = 'hidden';
   }

   if( pf=='1' && elementObject('breadcrumb') && styleObject('breadcrumb') ) {
     elementObject('breadcrumb').innerHTML = '';
     styleObject('breadcrumb').height = 0;
     styleObject('breadcrumb').width = 0;
     styleObject('breadcrumb').visibility = 'hidden';
   }

   if( (pf=='1' || pf=='2') && elementObject('sidebar') && styleObject('sidebar') ) {
     elementObject('sidebar').innerHTML = '';
     styleObject('sidebar').height = 0;
     styleObject('sidebar').width = 0;
     styleObject('sidebar').visibility = 'hidden';
   }

   if( (pf=='1' || pf=='2') && styleObject('contentArea') ) {
     styleObject('contentArea').marginLeft = '1em';
   }
   if( (pf=='1' || pf=='2') && styleObject('content') ) {
      styleObject('content').marginLeft = '1em';
   }

   return( pf );
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function siteMap() {
//--- under construction
//--- Show menu items available under current menu selection
//--- What about documents in the Title Table not referenced by a menu item?

     var sitemapDiv = '';
//   var sitemapDiv = '<Div>Placeholder for Site Map</div>';
     return sitemapDiv;
}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

function siteFulcrumBuildContent() {
if( ss.get('debug') > '0' ) { alert( 'siteFulcrumBuildContent() "'+ content_URL + '"'); }
   textString = '<b>Requested document cannot be found.</b>';
   if( content_URL !== '' ) {
//--- If content_URL does not point to this server we need to jump
      if( content_URL.indexOf('http:') == 0 && content_URL.indexOf('http://' + location.host) != 0 ) { 
         if( documentTitle==='' ) {
            jumpContent_URL(content_URL);
         } else {
            jumpTitle();
         }
      }

//--- assign div id="content"
      if( content_URL.substr(0,1) == "!" ) { content_URL = content_URL.substr(1,content_URL.length-1); }

//--- get the fourth transfer: the document to be written as content.

      if( content_url_addon !== "" && content_URL.indexOf("?") < 1 ) { content_url_addon = "?" + content_url_addon.substr(1); }
if( ss.get('debug') > '0' ) { alert( 'content_URL + content_url_addon = "' + content_URL + content_url_addon + '"'); }

//--- Get the document content.  Content not loadable, such as .pdf, should replace current page
      var content_URL_0 = content_URL.split('?')[0];
      var contentArray = content_URL_0.split('.');
if( ss.get('debug') > '0' ) { alert( 'contentArray[n] = "' + contentArray[contentArray.length-1] + '"'); }
      if( content_URL.indexOf('window=1')>0 ||
          siteFulcrum_Loadable.indexOf( ',.' + contentArray[contentArray.length-1] + ',') < 0 ){
if( ss.get('debug') > '0' ) { alert( 'location = "' + content_URL_0 + '"'); }
	if( content_URL.indexOf('?window=1') > 0 ) {
		location=content_URL_0;
	} else {
		if( content_URL.indexOf('&window=') > 0 ) { location_URL = location_URL.substr(0,content_URL.indexOf('&window=')-1); }
		location = content_URL;
	}
      } else {
         textString = loadXMLDocText( content_URL + content_url_addon, 'text/html' );
      }
   }

//--- the document is parsed for <head> and <body> components.
//--- from head get base tag
//--- from head get title
//--- from head get script(s)
//--- The contents are not written at this time

//--- remove everything down to "<head>" tag
   var i = textString.toLowerCase().indexOf('<head');
   if( i > -1 ) {
      textString = textString.substr(i);
   }

//--- extract the "<head>" tag content
   i = textString.toLowerCase().indexOf('</head');
   if( i > -1 ) {
      headContent = textString.substr(0,i);
//--- remove the "<head..>" tag from headContent
      i = headContent.indexOf('>');
      if( i > -1 ) {
         headContent = headContent.substr(i+1);
      }

//--- do not load a siteFulcrum "index" page into the content <div>
      if( headContent.toLowerCase().indexOf('sitefulcrum/sitefulcrumjavascript.js" type="text/javascript">')>0) {
//--- problem with using siteFulcrum generated query parameters, so for now, remove potenial problem items
         var urlArray = content_URL.split('?');
         var qArray = urlArray[1].split('&');
         var qString = '';
         for ( var j in qArray ) {
            paramArray = qArray[j].split('=');
            if( (',title,menu,content_url,lastmenu,').indexOf(paramArray[0].toLowerCase()) < 0 ) { qString += '&' + qArray[j]; }            
         }
         if( qString!= '' ) { qString = '?' + qString.substr(1); }
         location = urlArray[0] + qString;
      }
   }

//--- get script tags
   i = headContent.toLowerCase().indexOf('<script ');
   while( i > -1 ){
      j = headContent.toLowerCase().indexOf('</script>')+9;
//alert( 'script (' + i + ',' + j + ') "' + headContent.substr(i,j-i) + '"' ) ;
      scriptTagString += headContent.substr(i,j-i);
      if( i > 0 ) {
         headContent = headContent.substr(0,i-1) + headContent.substr(j);
      } else {
         headContent = headContent.substr(j);
      }
      i = headContent.toLowerCase().indexOf('<script ');
   };

//--- get title tag
   i = headContent.toLowerCase().indexOf('<title>');
   if ( i > -1 ) {
      j = headContent.toLowerCase().indexOf('</title>')+8;
//alert( 'titleString "' + headContent.substr(i,j-i) + '"' ) ;
      titleTagString += headContent.substr(i,j-i);
      if( i > 0 ) { headContent = headContent.substr(0,i-1) + headContent.substr(j); } else { headContent =  headContent.substr(j); }
   }

//--- get base tag
   i = headContent.toLowerCase().indexOf('<base ');
   if ( i > -1 ) {
      j = headContent.toLowerCase().substr(i).indexOf('>');
//alert( 'baseString "' + headContent.substr(i,j) + '"' ) ;
      baseTagString += headContent.substr(i,j);
      if( i > 0 ) { headContent = headContent.substr(0,i-1) + headContent.substr(i+j+1); } else { headContent =  headContent.substr(j+1); }
   }

//--- remove everything down to "<body" tag
   i = textString.toLowerCase().indexOf('<body');
   if( i > 0 ) {
      textString = textString.substr(i);
   }

//--- extract the "<body" tag and the body content
   var bodyTag = '';
   i = textString.toLowerCase().indexOf('</body');
   if( i > -1 ) {
      bodyString = textString.substr(0,i);
//--- we are done with textString
//---      textString = textString.substr(i,textString.length-i);
//--- remove the "<body...>" tag from bodyString and save the <body...> tag as bodyTag
      i = bodyString.indexOf('>');
      if( i > -1 ) {
         bodyTag = bodyString.substr(0,i+1);
         bodyString = bodyString.substr(i+1);
      }
   } else {
      bodyString = textString;
   }
   if( bodyTag === '' ) { bodyTag = '<body>'; }

//--- establish a string value for href BASE tag
   docHref = content_URL;
   if( baseTagString == '' ) {
      var a;
      if( docHref.indexOf('http://') == 0 ) {
         a = (docHref).split('?');
      } else {
         a = (location.href).split('?');
      }

      c = docHref.split('?')[0].split('/');
      if( c.length > 0 ) {
         docHref = c[c.length-1];
         c.length = c.length - 1;
      }

      var b = a[0].split('/');
      b.length = b.length - 1;

      if( c[0] && c[0] != 'http:' ) {
         for ( var d in c ) {
            if( c[d] == '..') {
               b.length = b.length-1;
            } else {
               b.push(c[d]);
            }
         }
      }  
      baseHref =  b.join('/') + '/';

   } else {
//--- using document <base ... > tag ( untested program code )
      var i = baseTagString.toLowerCase.indexOf('href=');
      var j = baseTagString.substr(i+6).indexOf(baseTagString.substr(i+5,1));
      baseHref = baseTagString.substr(i,j);
      var a = ('http://' + location.host + location.pathname + docHref).split('/');
      var b = new Array();
      for ( var i in a ) {
         if( a[i] == '..' ) {
            b.length = b.length - 1;
         } else {
            b.push(a[i]);
         }
      }
      docHref = b.join('/');
//--- keep the search query string except for siteFulcrum parameters 
      var qsArray = location.search.split('?');
      if( qsArray[1] ) {
          var paramArray = qsArray[1].split('&');
          for ( i in paramArray ) {
             var nameValueArray = paramArray[i].split('=');
             if( nameValueArray[1] &&
                 ',menu,title,content_url,href,ss,'.indexOf(nameValueArray[0].toLowerCase()) == -1 ) {
                docHref += '&' + paramArray[i];
             }
          }
       }
   }
//-   headContent = '<base href="' + baseHref + '">' + headContent;
   headContent = '<base href="' + baseHref + '">';
   if( document.getElementsByTagName("head")[0].getElementsByTagName('base')[0]) {
      document.getElementsByTagName("head")[0].getElementsByTagName('base')[0].href=baseHref;
   }

//--   if( documentTitle !== '' ) { document.write('<title>' + documentTitle + '</title>'); }

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

if( ss.get('debug') > '0' ) {alert('headContent="' + headContent + '"')};
   document.write( headContent );
if( ss.get('debug') > '0' ) {alert('scriptTagString="' +  scriptTagString + '"')};
   document.write( scriptTagString );

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

//--- would like to catch <body onEvents... 

//--- <body> content is in variable bodyString
//--- search and replace <a href= > tags so that they use siteFulcrum
//--- result accumulated in siteFulcrumContent

   if( ss.get('href') === '0' ) {
   } else {

//--- substitute href targets with siteFulcrum styled href targets

//--- look for <a href="..."> tags within bodyString
//--- this is very picky about the pattern "<a href=" and case sensitive
//--- if href begins 'http://' + location.host then alter to current host-path?Content_URL= href
//--- if not href="http://
//---		and not href="javascript
//---		and not href="mailto
//---		and not href="../?title=
//---		and not href="../?menu=
//---		and not href contains "+'
//---		and not href ends .gif .jpg .png .doc .pdf
//---	then alter to current host-path?Content_URL= BASE + href
      var editTime = (new Date()).getTime();
      var baseHrefArray = baseHref.split('/');
      if( baseHrefArray.length > 0 ) { baseHrefArray.length = baseHrefArray.length-1; }
      var needBaseHrefArray = 0;
      var i = bodyString.indexOf('<a href=');
      var j = 1;
      while( i > -1 && j > -1 ) {
         var delimiter = bodyString.substr(i+8,1);
         var otherQuote = '"';
         if( delimiter == otherQuote ) { otherQuote = "'"; }
         j = bodyString.substr(i+9,bodyString.length-i-8).indexOf(delimiter);
         if( j > -1 ) {
            if( needBaseHrefArray == 1 ) {
               needBaseHrefArray = 0;
               baseHrefArray = baseHref.split('/');
               if( baseHrefArray.length > 0 ) { baseHrefArray.length = baseHrefArray.length-1; }
            }
            var href = bodyString.substr(i+9,j);
//--- do we want to "edit" the tag?
            if( (href.substr(0,10).toLowerCase() == 'javascript')
                || (href.substr(0,6).toLowerCase() == 'mailto')
                || ( '.gif.jpg.png.doc.pdf'.indexOf(href.substr(href.length-4).toLowerCase()) > -1 )
                || (('"'+"'").indexOf(delimiter)<0)
		|| (href.toLowerCase().indexOf('../?title=')>-1)
		|| (href.toLowerCase().indexOf('../?menu=')>-1)
              ) {
//--- no "edit"; href is altered so as to not be found again by bodyString.indexOf('<a href="')
               href = 'a  HREF=' + delimiter + href;
            } else if(  href.substr(0,5) == 'http:') {
//--- do we need replaceString(href,'&','&amp;') ???
               href = 'a  HREF="#" onClick=' + delimiter
                    + 'JavaScript:jumpContent_URL('
                    + otherQuote + href + otherQuote + ');'
                    + 'return false;';
                
            } else {
//--- this part for back-reference
               while( href.substr(0,3) == '../' ) {
                  if( baseHrefArray.length > 0 ) {
                     baseHrefArray.length = baseHrefArray.length-1;
                     needBaseHrefArray = 1;
                  }
                  href = href.substr(3,href.length-3);
               }
               var contentHref = baseHrefArray.join('/') + '/';
               if( href.substr(0,1) == '/') { contentHref = ''; }
               if( href.substr(0,5) == 'http:') { contentHref = ''; }
//--- href is altered so as to not be found by bodyString.indexOf('<a href="')
               href = 'a  HREF=' + delimiter + 'http://' + location.host + location.pathname
                      + '?Content_URL=' + contentHref + replaceString(href,'?','&')
               if( ss.get('ss') != '1' ) {
                  var menuPointer = '';
                  if( menuString !== '' ) { menuPointer = '?lastMenu=' + menuString + '&'; }
                  else { if( lastMenu !== '' ) { menuPointer = '?lastMenu=' + lastMenu + '&'; }
                         else { menuPointer = '?lastMenu=' + menuTableArray + '&'; }
                  }
                  if( menuPointer != '' ) { href = replaceString(href,'?',menuPointer); }
               }
if( ss.get('debug') > '0' ) {alert('href="' + href + '"')};
//--- "fix" the href tag for ampersand
               href = replaceString(href,'&amp;','&');
               href = replaceString(href,'&','&amp;');
            }
            var bodyStringPart = bodyString.substr(0,i+1);
            bodyString = bodyString.substr(i+j+9,bodyString.length-i-j+1);
            if( typeof sitefulcrum_UnEscape != 'undefined' && sitefulcrum_UnEscape == 1 ) {
               bodyStringPart = unescape(bodyStringPart);
               href = unescape(href);
            }
            siteFulcrumContent += bodyStringPart + href;
         }
         i = bodyString.indexOf('<a href=');
      }
      siteFulcrumEditTime = (new Date()).getTime() - editTime;

if( ss.get('debug') > '0' ) {alert('bodyString="' + bodyString + '"')};

   }

   if( typeof sitefulcrum_UnEscape != 'undefined' && sitefulcrum_UnEscape == 1 ) {  bodyString = unescape(bodyString); }

   siteFulcrumContent += bodyString;

   return;
}




//--- determine path and name for the "index.html"
   var pathnameString = '';
   var indexhtmlString = '';
   if( 1 ) {
      var pathArray = location.pathname.substr(1).split('\/');
      for ( var i in pathArray ) {
          i = parseInt(i); // need this to do i+1
          indexhtmlString = pathArray[i]
          if( typeof pathArray[i+1] != 'undefined' ) {
             pathnameString += '/'+indexhtmlString;
             indexhtmlString = '';
          } 
      }
      if( pathnameString.length>0 ) {
      if( pathnameString.substr(pathnameString.length-1) != '/' ) { pathnameString += '/'; }
      } else { pathnameString = '/'; }
   }

//--- optional function siteFulcrumInitialize can assign global variables such as 
//---    menuTableName and titleTableName
   if( typeof siteFulcrumInitialize == 'function' ) {
      siteFulcrumInitialize();
   }


//------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------
//--- Get tables needed to construct the document.
//--- 4 Synchronus transfer calls are used to get 3 tables and the document to display.

//--- get the first table - Menu Table

//--- optional function siteFulcrumMenuTable may load the arrays.
   if( typeof siteFulcrumMenuTable == 'function' ) {
      textString = siteFulcrumMenuTable();
   } else {
      textString = loadXMLDocText(menuTableName, 'text/plain; charset=x-user-defined').replace(rExp, '');
   }

//--- Menu Table is composed of a line for each sidebar menu item
//--- Each line contains a name for display in the sidebar menu and
//--- each line contains a document title name to be resolved to a URL.

   var navigationArray = textString.split('\n');
   for (var i in navigationArray) {
      var lineArray = (navigationArray[i] + '\t\t').split('\t');
      var column1 = lineArray.shift();
      var column2 = lineArray.shift();
      if( !column1 ) { column1 = ''; }
      if( !column2 ) { column2 = ''; }
      if( column1 !== '' ) {
         menuTableArray.push(column1);
         menuTitleArray.push(column2);
      }
   }

//--- continue by making a second transfer for Title Table associating a title to a URL


//--- optional function siteFulcrumTitleTable may load the arrays.
   if( typeof siteFulcrumTitleTable == 'function' ) {
      textString = siteFulcrumTitleTable();
   } else {
      textString = loadXMLDocText(titleTableName, 'text/plain; charset=x-user-defined').replace(rExp, '');
   }

//--- Title Table is composed of a line for each document.
//--- Each line contains a document title name and a URL to content.
   
   var titleArray = textString.split('\n');
   for (var i in titleArray) {
      var lineArray = (titleArray[i] + '\t\t').split('\t');
      var column1 = lineArray.shift();
      var column2 = lineArray.shift();
      if( !column1 ) { column1 = ''; }
      if( !column2 ) { column2 = ''; }
      if( column1 !== '' ) {
         titleTableArray.push(column1); 
         titleURLArray.push(column2);
      }
   }

//--- continue by making a third transfer for Team Table URLs for a distributed siteFulcrum web site.


//--- optional function siteFulcrumTeamTable may load the arrays.
   if( typeof siteFulcrumTeamTable == 'function' ) {
      textString = siteFulcrumTeamTable();
//textString += '\nhttp://rockbridgehunt.org' + '\t/\n';
   } else {
      textString = loadXMLDocText(teamTableName, 'text/plain; charset=x-user-defined').replace(rExp, '');
   }

//--- Team Table is composed of a line for each collaberative web site.
//--- Each line contains an absolute URL to the path of a Team member's web site.
//--- This URL is used to identify linked document absolute URL that can be
//--- re-formatted into a siteFulcrum link with search string content_URL

//--- add current location
   if( textString.indexOf('http://' + location.host + pathnameString + '\t' + indexhtmlString) < 0 ) {
if( ss.get('debug') > '0') { alert('add teamTable "http://' + location.host + pathnameString + ' --> ' + indexhtmlString + '"' ); }
      textString += '\nhttp://' + location.host + pathnameString + '\t' + indexhtmlString + '\n';
   }

   var teamArray = textString.split('\n');
   for (var i in teamArray) {
      var lineArray = (teamArray[i] + '\t\t').split('\t');
      var column1 = lineArray.shift();
      var column2 = lineArray.shift();
      if( !column1 ) { column1 = ''; }
      if( !column2 ) { column2 = ''; }
      
      if( column1 !== '' ) {
         teamPathArray.push(column1);
         teamHomeArray.push(column2);
      }
   }

//--- expand the arrays with breakdown of each site
   var l = teamPathArray.length-1;
   for (var i=0;i<=l;i++) {
      var home = teamHomeArray[i];
      var urlArray = teamPathArray[i].split('/');
      while( urlArray.length > 3 ) {
         var n = urlArray.length-1;
         if( urlArray[n] !== '' ) {
            home = urlArray[n] + '/' + home;
            urlArray.length = urlArray.length-1;
            teamPathArray.push(urlArray.join('/') + '/');
            teamHomeArray.push(home);
         } else {
            urlArray.length = urlArray.length-1;
         }
      }
   }

//--- continue by getting the URL for the fourth transfer ( document to be written as content )


   var itteration = 0
   content_URL = '';

   while( itteration == 0 ) {
      itteration ++;
//--- check search string for Content_URL when no menu or title
      if( menuString === '' && documentTitle === '' ) {
         content_URL = ss.get('Content_URL');
         if( content_URL == null ) { content_URL = ss.get('content_url');  }
         if( content_URL == null ) { content_URL = ''; }
      }

      textString = getMenuTitleContent_URL();

if( ss.get('debug') > '0') { alert( textString + '  "' + 'http://' + location.host + location.pathname + '?' + '"'); }

//--- check for recursive reference to this

      if( menuString === '' && documentTitle === '' &&
           content_URL.indexOf('http://' + location.host + location.pathname + '?') == 0 ) {
         ss = new SearchString( content_URL.split('?')[1] );
if( ss.get('debug') > '0') { alert( 'new ss "' + content_URL.split('?')[1] + '"'); }
         itteration = 0;
      }
   }

//--- At this point we should have content_URL

   document.title = documentTitle;

   if( typeof siteFulcrumDelayBuildContent == 'undefined' || !siteFulcrumDelayBuildContent ) {
      siteFulcrumBuildContent();
   } else {
alert('content delay');
   }

//--- do not load bodyString at this time.
//--- return document loading to browser.
//----------------------------------------------------------------------------------------------------