//~ pcTMcode01.js - part 1 of core code for Philip Chalmers' tree menu.
//~ (c) Copyright 2002 Philip Chalmers , all rights reserved.
//~      (www.benefit-from-it.co.uk)
function fixPath(sP){var i=sP.indexOf('?',0);if(i>=0){p=p.substring(0,i);}if(sP.substring(0,2)=='/:'){sP=sP.substring(sP.indexOf('/',2),p.length);}i=sP.indexOf('\\',0);while(i>=0){sP=sP.substring(0,i)+'/'+sP.substring(i+1,sP.length);i=sP.indexOf('\\',i);}return sP;}function getParm(sParm,sName,sDelim){if(typeof sDelim=='undefined')var sDelim=',';if(sParm.length==0){return '';}var nSP=sParm.indexOf(sName+"=");if(nSP==-1){return '';}nSP=nSP+sName.length+1;var nEP=sParm.indexOf(sDelim,nSP);if(nEP==-1){nEP=sParm.length;}return unescape(sParm.substring(nSP,nEP));}function pageFromSearch(sDef,oMenu,bSel){if(typeof oMenu=='undefined')oMenu=null;if(typeof bSel=='undefined')bSel=false;var sLS=self.location.search;if((sLS==null)||(sLS.length<=1)){return sDef;}var sPV=getParm(sLS,'page','&');sPV=(sPV !='')?fixPath(sPV):sDef;if(bSel){theFrames.textURL=sPV;if(oMenu !=null){var nEI=oMenu.findEntry(sPV,'URL','exact');if(nEI !=-1){oMenu.setEntry(nEI,true);oMenu.selectEntry(nEI);}}}return sPV;}function TMfsInfo(){this.menuFrName='frTMmenu';this.ctrlFrName='frTMcntl';this.textFrName='frTMtext';this.dynFrName='frTMdyn';this.autoInit=false;this.menuSide='L';this.menuBuildMsg='Building the menu';}function TMfsLoaded(){var tb=theBrowser;tb.checkBodyFacilities();tb.canTM=((tb.canTM)&&tb.innerHTMLtype !='n');var tf=theFrames;tf.menuFrObj=eval('frames["'+tf.menuFrName+'"]');if(tb.canTM){var scA=[tf.cookieScrURL,tf.codeScrURL,tf.initScrURL];for(var i=0;i<scA.length;i++)tb.canTM=(tb.canTM&&tb.loadScript(scA[i],true));if(!tb.canTM)tb.showBadBrowserMsg(null,'Our DHTML menu needs to load  scripts dynamically.  Unfortunately your browser cannot do this.\n\nSo we will show the static menu instead.');}if(tb.canTM)_TMcheckInit();else{if(tf.menuFrObj.location !=tf.statMenuURL)tf.menuFrObj.location=tf.statMenuURL;}}function _TMcheckInit(){if(typeof window.pcCookie !='undefined'&&typeof _TMinitLoaded !='undefined'&&typeof _TMcode05Loaded !='undefined')initialise();else setTimeout('_TMcheckInit()',100);}function _TMaddHTML(oLyr,sText){if(document.all)oLyr.innerHTML+=sText;if(theBrowser.hasW3CDOM){var rng=document.createRange();rng.setStartBefore(oLyr);var frag=rng.createContextualFragment(sText);oLyr.appendChild(frag);}}function _TMclearHTML(oLyr){if(document.all)oLyr.innerHTML='';else{while(oLyr.hasChildNodes())oLyr.removeChild(oLyr.lastChild);}}function _TMgetLyr(sW,sL){if(theBrowser.canTM){var tFrId="frames['"+sW+"']";if(document.all)return eval(tFrId+'.document.all.'+sL);else{return eval(tFrId+".document.getElementById('"+sL+"')");}}else return null;}function _TMhideLyr(oLyr){oLyr.style.visibility="hidden";}function _TMshowLyr(oLyr){oLyr.style.visibility="visible";}function _TMgetFormObj(oDoc,sForm){if(document.all||document.getElementById){return oDoc.forms[sForm]}else return null;}var TMwhenLoadedMsg='You can do this when the menu has finished loading';function TMflipMenu(){var ok=true;if(theBrowser.flipWarn){ok=confirm("You're using an old browser.\nDo not flip the screen more than twice per session - we're pushing your browser to its limits already.\n\nDo you wish to flip the screen?");}if(ok){oFIi=theFrames;hTF=eval('top.'+oFIi.textFrName);var sMS=(typeof oFIi.menuSide=='undefined'||oFIi.menuSide=='L')?'R':'L';var sCP=fixPath(hTF.document.location.pathname);newURL=fixPath(top.location.pathname)+'?menuSide='+sMS+'&page='+sCP;location.href=newURL;}}function TMexpandAll(){if(theMenu.openAll){var ok=true;if(theBrowser.openWarn){ok=confirm("Your browser cannot show a large menu fully expanded - it cuts off the bottom.\n\nDo you wish to expand the menu fully?");}else if(theBrowser.openQry){ok=confirm("You're using using a browser which is not very common.\nWe're not sure whether it can show a large menu fully expanded - it may cut off the bottom.\n\nDo you wish to expand the menu fully?");}if(ok){theMenu.openAll();}}else alert(TMwhenLoadedMsg);}function TMcloseAll(){if(theMenu.closeAll){theMenu.closeAll();}else alert(TMwhenLoadedMsg);}function TMgetProps(oObj,sObj,sDelim){if(typeof sDelim=='undefined')sDelim='<br>';var ret="";for(var i in oObj){result+=sObj+"."+i+" = "+oObj[i]+sDelim;}return ret;}function pcTMwriteFrames(){var oFI=theFrames;var mLR=(oFI.menuSide=='L'||oFI.menuSide=='R')?oFI.menuSide:mLR;mLR=getParm(location.search,'menuSide','&');mLR=(mLR=='L'||mLR=='R')?mLR:'L';oFI.menuSide=mLR;var mW=210;var contFrTag='<frame name="'+oFI.textFrName+'" src="'+oFI.textURL+'" scrolling="auto" marginwidth="0" marginheight="0" framespacing="0" application="yes" title="Content frame">';var s='<frameset border="0" framespacing="0 "frameborder="0" cols="'+((mLR=='L')?mW+',*':'*,'+mW)+'" onLoad="setTimeout(\'TMfsLoaded()\', 0)">';if(mLR=='L'){s+=pcTMwriteMenuFrames();s+=contFrTag;}else{s+=contFrTag;s+=pcTMwriteMenuFrames();}s+='</frameset>';document.write(s);}function pcTMwriteMenuFrames(){var oBI=pcBrowserInfo._o;var oFI=theFrames;var s='<frameset rows="79,*,0,55" cols="100%" framespacing="0" frameborder="0" border="0"><frame name="'+oFI.ctrlFrName+'" src="menucntrl.htm" scrolling="no" marginwidth="0" marginheight="0" framespacing="0" application="yes" title="Menu Control Panel"><frame name="'+oFI.menuFrName+'" src="'+((oBI.canTM)?oFI.treeMenuURL:oFI.statMenuURL)+'" scrolling="auto" marginwidth="0" marginheight="0" application="yes" title="Main Menu"><frame name="'+oFI.dynFrName+'" src="quicksearch.htm" scrolling="no" marginwidth="0" marginheight="0" application="yes" title="Hidden frame for assembling dynamic additions to menu"><frame name="frTMsearch" src="quicksearch.htm" scrolling="no" marginwidth="0" marginheight="0" application="yes" title="Site Search Form"></frameset>';return s;}var theFrames=new TMfsInfo;var theBrowser=new pcBrowserInfo;theBrowser.hasW3CDOM=(theBrowser.modelType=='w3cdom');theBrowser.canTM=((theBrowser.modelType=='msie'||theBrowser.modelType=='w3cdom')&&theBrowser.canDynLoadScripts);theBrowser.innerHTMLtype='';theBrowser.lineByLine=(!document.all);
