// filename = synchro.js
// Sets the TOC entry selection to the selected page.
// Use this javascript at the top of every page that can be
// loaded by a link other than the Joust TOC.
//Load the page inside the frameset if linked from outside.
//This is in the Joust documentation.function synchro(levelsup){
if(self==top){
  var navPrinting = false;
  if((navigator.appName+navigator.appVersion.substring(0,1))=="Netscape4"){
    navPrinting = (self.innerHeight == 0) && (self.innerWidth == 0);
  }
  if((self.name != "text")  && (self.location.protocol != "file:") &&
    (document.cookie.indexOf('mode=NoFrames')< 0) && !navPrinting) {
    //This transforms something 
    //like: htjp://192.168.0.3/downeast/000004/home.htm
    //into: htjp://192.168.0.3/downeast/main.htm?page=/downeast/000004/home.htm    //where the parameter, levelsup, is the count of directories to go    //up from the current document to the directory where main.htm is found.
    //In the example, levelsup=2.
    if(arguments.length<1) levelsup=2;
    var dirup="../"
    var newURL="";    for(i=0;i<levelsup;i++){
      newURL+=dirup    }
    newURL+="main.htm?page=";
    newURL+=self.location.pathname;
    if(parseInt(navigator.appVersion,10) >= 3){
      self.location.replace(newURL);
    }else{
      self.location.href = newURL;
    }
  }
}
//Expand the menu to the appropriate spot when the page is
// not called from the menu. This is in the Joust documentation.
if (parent.theMenu){
	var entryID=parent.theMenu.findEntry(location.pathname,"url","right",0);
	if (entryID>=0){
		parent.theMenu.selectEntry(entryID);
		if (parent.theMenu.setEntry(entryID,true)){
			parent.theMenu.refresh();
		}
	}else{
		//If this page is not in the menu, (e.g. home.htm)
		//de-select the last clicked item and collapse the menu.
		parent.theMenu.selectEntry(-1);
		parent.theMenu.closeAll();
	}
}
} //end function.
//end of js.	
