var gaHSLoad=new Array(); var gnMinIdx=0; var gnInsIdx=-1; var gsLoadingDivID="LoadingDiv"; var gsLoadingMsg="Loading, click here to cancel..."; var gaProj=null; var gaTocs=new Array(); var goChunk=null; var gbReady=false; var gbLoadToc=false; var gbXML=false; var gaRoot=new Array(); var gnCC=-1; var gsTP=""; var gaBTPs=""; var gsCTPath=""; var gnLT=-1; var gsPathSplit="\n"; var gsBgColor="#ffffff"; var gsBgImage=""; var goFont=null; var goHFont=null; var gsMargin="0pt"; var gsIndent="15pt"; var gsABgColor="#cccccc"; var giBookClose=""; var giBookOpen=""; var giBookItem=""; var giURLItem=""; var giNewBookClose=""; var giNewBookOpen=""; var giNewBookItem=""; var giNewURLItem=""; var gnImages=0; var gnLoadedImages=0; var gaImgs=new Array(); var gbLoadData=false; var gobj=null; var gaTocsNs61Fix=null; var gbWhTHost=false; var gBookItems=new Array(); var gInSync=false; function setBackground(sBgImage) { gsBgImage=sBgImage; } function setBackgroundcolor(sBgColor) { gsBgColor=sBgColor; } function setFont(sType,sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration) { var vFont=new whFont(sFontName,sFontSize,sFontColor,sFontStyle,sFontWeight,sFontDecoration); if(sType=="Normal") goFont=vFont; else if(sType=="Hover") goHFont=vFont; } function setActiveBgColor(sBgColor){gsABgColor=sBgColor;} function setMargin(sMargin){gsMargin=sMargin;} function setIndent(sIndent){gsIndent=sIndent;} function setIcon(sType,sURL) { if(sType=="BookOpen") giBookOpen=sURL; else if(sType=="BookClose") giBookClose=sURL; else if(sType=="Item") giBookItem=sURL; else if(sType=="RemoteItem") giURLItem=sURL; else if(sType=="NewBookClose") giNewBookClose=sURL; else if(sType=="NewBookOpen") giNewBookOpen=sURL; else if(sType=="NewItem") giNewBookItem=sURL; else if(sType=="NewRemoteItem") giNewURLItem=sURL; } function bookItem(sTarget, sURL) { if (sTarget) this.sTarget=sTarget; else this.sTarget="bsscright"; this.sURL=sURL; } function addBookItem(sBookId, sTarget, sURL) { gBookItems[sBookId] = new bookItem(sTarget, sURL); } function tocChunk(sPPath,sDPath) { this.sPPath=sPPath; this.sDPath=sDPath; this.nMI=-1; this.aTocs=null; } function addTocChunk(sPPath,sDPath) { var oChunk=new tocChunk(sPPath,sDPath); gaTocs[gaTocs.length]=oChunk; return oChunk; } function isHSLoad(nIdx) { for(var i=0;i"; sHTML+="

\"Book\""; var sURL=_textToHtml_nonbsp(getItemURL(nIdx)); if(sURL!="") addBookItem(getBookId(nIdx),_textToHtml_nonbsp(getTopicTarget(nIdx)),sURL); sHTML+=" "+sName+"

"; return sHTML; } function getBookId(nIdx){return "B_"+nIdx;} function getItemId(nIdx){return "I_"+nIdx;} function markBook(nIdx) { var obj=getElement(getItemId(nIdx)); if(obj==null) obj=getElement(getBookId(nIdx)); if(gbNav6) { gobj=obj; setTimeout("delayMarkObj();",1); } else markObj(obj); } function delayMarkObj() { if(gobj) { markObj(gobj); gobj=null; } } function markObj(obj) { if(obj!=null) { HighLightElement(obj,gsABgColor,"transparent"); var sPath=calTocPath(obj); if(gsCTPath!=sPath) gsCTPath=sPath; } } function markItem(nIdx) { var obj=getElement(getItemId(nIdx)); if(gbNav6) { gobj=obj; setTimeout("delayMarkObj();",1); } else markObj(getElement(getItemId(nIdx))); } function calTocPath(obj) { var sPath=getInnerText(obj).substring(1); var pObj=getParentNode(obj); do { while(pObj!=null&&!isCBId(pObj.id)) pObj=getParentNode(pObj); if(pObj!=null) { var nId=getIdByCBId(pObj.id); var sObj=getElement(getPBId(nId)); if(sObj!=null) { var objs=getItemsByBook(sObj); for(var i=0;i\""+sAltString+"\" "+sName+"

"; return sHTML; } function writeBookItems(nIdx,num) { var sHTML=""; if(num>0){ var nCIdx=0; do{ nCIdx++; var i=nIdx+nCIdx; var nItemType=getItemType(i); if(nItemType==1){ sHTML+=writeBook(i); nCIdx+=getItemContentsNum(i); } else if(nItemType==2||nItemType==16){ sHTML+=writeAnItem(i); }else if(nItemType==4){ sHTML+=writeBook(i,false); }else if(nItemType==8){ sHTML+=writeBook(i,true); } } while(nCIdx"+gsLoadingMsg+""; } function getItemName(nIdx) { var oChunk=getChunk(nIdx); if(oChunk) return oChunk.aTocs[nIdx-oChunk.nMI].sItemName; else return null; } function getItemContentsNum(nIdx) { var oChunk=getChunk(nIdx); if(oChunk) return oChunk.aTocs[nIdx-oChunk.nMI].nContents; else return null; } function getItemType(nIdx) { var oChunk=getChunk(nIdx); if(oChunk) return oChunk.aTocs[nIdx-oChunk.nMI].nType; else return 0; } function getItemURL(nIdx) { var oChunk=getChunk(nIdx); if(oChunk) { var sPath=oChunk.aTocs[nIdx-oChunk.nMI].sItemURL; if(!(sPath==null||sPath=="")) { return _getFullPath(oChunk.sPPath,sPath); } } return ""; } function getRefURL(nIdx) { var oChunk=getChunk(nIdx); if(oChunk) { var sPath=oChunk.aTocs[nIdx-oChunk.nMI].sRefURL; if(!(sPath==null||sPath=="")) { return _getFullPath(oChunk.sPPath,sPath) } } return ""; } function getTopicTarget(nIdx) { var oChunk=getChunk(nIdx); if(oChunk) { if(typeof(oChunk.aTocs[nIdx-oChunk.nMI].sTarget)!="undefined") return oChunk.aTocs[nIdx-oChunk.nMI].sTarget; } return ""; } function getItemIcon(nIdx,nIconIdx) { var oChunk=getChunk(nIdx); if(oChunk) { if(typeof(oChunk.aTocs[nIdx-oChunk.nMI].sIconRef)!="undefined") { var sIconRef=oChunk.aTocs[nIdx-oChunk.nMI].sIconRef; var nIndex=sIconRef.indexOf(";"); while(nIconIdx-->0&&nIndex!=-1) { sIconRef=sIconRef.substring(nIndex+1); nIndex=sIconRef.indexOf(";"); } if(nIconIdx<0) { if(nIndex!=-1) sIconRef=sIconRef.substring(0,nIndex); return _getFullPath(oChunk.sPPath,sIconRef) } } } return ""; } function TocWriteClassStyle() { var sStyle=""; document.write(sStyle); } function TocWriteFixedWidth(bBegin,nWidth) { if((gbIE4)&&(gbMac)&&(!gbIE5)){ if(bBegin) document.write("
"); else document.write("
"); } } function TocInitPage() { var tempColl=getItemsByBook(document.body); if(tempColl.length>0) tempColl[0].focus(); } function getItemsFromObj(obj) { var aAnchor=new Array(); var tempColl=getChildrenByTag(obj,"P"); if(tempColl&&tempColl.length>0) { var anobr=new Array(); for(var i=0;i0) { for(var j=0;j0) { for(var u=0;u0) { for(var j=0;jdocument.body.clientHeight){ nNewScroll=nTop-20; } } document.body.scrollTop=nNewScroll; } } function TocExpand(nId,bChangeImg,bForceOpen) { var oDiv=getElement(getCBId(nId)); if(oDiv==null) return null; var whichIm=document.images[getBId(nId)]; if((oDiv.style.display!="block")||bForceOpen){ oDiv.style.display="block"; if(bChangeImg){ var sPath=getPath(whichIm.src); sPath=_getFullPath(sPath,getBookImage(nId,false)); whichIm.src=sPath; } }else{ oDiv.style.display="none"; if(bChangeImg){ var sPath=getPath(whichIm.src); sPath=_getFullPath(sPath,getBookImage(nId,true)); whichIm.src=sPath; } if(gbMac&&gbIE5){ this.parent.document.getElementById("tocIFrame").style.width="101%"; this.parent.document.getElementById("tocIFrame").style.width="100%"; } } return oDiv; } function getChunkId(n) { var nCandidate=-1; for(var i=0;in)) { return gaTocs[gnCC]; } else{ gnCC=getChunkId(n); if(gnCC!=-1) return gaTocs[gnCC]; else return null; } } function getBookImage(nIdx,bClosed) { var nIdx=bClosed?0:1; var sIcon=getItemIcon(nIdx,nIdx); if(sIcon=="") if(bClosed) sIcon=giBookClose; else sIcon=giBookOpen; return _getFullPath(gaProj[0].sPPath,sIcon); } function getItemImage(nIdx,bRemote) { var sIcon=getItemIcon(nIdx,0); if(sIcon=="") if(bRemote) sIcon=giURLItem; else sIcon=giBookItem; return _getFullPath(gaProj[0].sPPath,sIcon); } function expandToc(oObj,sRest,aIdList) { var len=aIdList.length; var nPos=sRest.indexOf(gsPathSplit); if(nPos!=-1) { sPart=sRest.substring(0,nPos); sRest=sRest.substring(nPos+1); } else { sPart=sRest; var aTagAs=getItemsByBook(oObj); for(var s=0;s0) sText=sText.substring(1); if(sText==sPart) { aIdList[len]=aTagAs[s]; return 1; } } return 0; } var aChildren=getChildrenByTag(oObj,"DIV"); for(var i=0;i0) { if(gbNav6) { var sCommand=obj[0].getAttribute("onClick"); var nCommand=sCommand.indexOf(";"); sCommand=sCommand.substring(0,nCommand); setTimeout(sCommand,1); } else obj[0].click(); } return -1; } var nRet=expandToc(oCObj,sRest,aIdList); if(nRet) return nRet; } } aIdList.length=len; return 0; } function getIdByPBId(sPId) { return parseInt(sPId.substring(5,sPId.length-6)); } function getIdByCBId(sCId) { return parseInt(sCId.substring(5,sCId.length-5)); } function isPBId(sId) { return (sId&&sId.indexOf("Book_")==0&&sId.lastIndexOf("Parent")==sId.length-6); } function isCBId(sId) { return (sId&&sId.indexOf("Book_")==0&&sId.lastIndexOf("Child")==sId.length-5); } function getBId(nIdx) { return "Book_"+nIdx; } function getPBId(nIdx) { return getBId(nIdx)+"Parent"; } function getCBId(nIdx) { return getBId(nIdx)+"Child"; } function getClosestTocPath(aPaths) { var nMaxSimilarity=0; var nThatIndex=-1; var sPath=null; if(aPaths.length==0) return sPath; for(var i=0;inMaxSimilarity) { nMaxSimilarity=nSimilarity; nThatIndex=i; } } if(nThatIndex!=-1) { sPath=aPaths[nThatIndex]; } else { sPath=aPaths[0]; } return sPath; } function comparePath(sPath1,sPath2) { var nMaxSimilarity=0; var nStartPos1=0; var nPos1=-1; var nStartPos2=0; var nPos2=-1; do{ var sCheck1=null; var sCheck2=null; nPos1=sPath1.indexOf(gsPathSplit,nStartPos1); if(nPos1!=-1) { sCheck1=sPath1.substring(nStartPos1,nPos1); nStartPos1=nPos1+1; } else { sCheck1=sPath1.substring(nStartPos1); nStartPos1=-1; } nPos2=sPath2.indexOf(gsPathSplit,nStartPos2); if(nPos1!=-1) { sCheck2=sPath2.substring(nStartPos2,nPos2); nStartPos2=nPos2+1; } else { sCheck2=sPath2.substring(nStartPos2); nStartPos2=-1; } if(sCheck1==sCheck2) nMaxSimilarity++; else break; }while(nStartPos1!=-1&&nStartPos2!=-1); return nMaxSimilarity; } function getTocPaths(oTopicParam) { var aRelTocPaths=oTopicParam.aPaths; var aPaths=new Array(); for(var i=0;i0) { for(var i=0;i0) { document.body.background=gsBgImage; } if(gsBgColor&&gsBgColor.length>0) { document.body.bgColor=gsBgColor; } loadToc(); var oMsg=new whMessage(WH_MSG_SHOWTOC,this,1,null) SendMessage(oMsg); } function loadImages() { if(giBookClose) { gaImgs[gnImages]=giBookClose; gnImages++; } if(giBookOpen) { gaImgs[gnImages]=giBookOpen; gnImages++; } if(giBookItem) { gaImgs[gnImages]=giBookItem; gnImages++; } if(giURLItem) { gaImgs[gnImages]=giURLItem; gnImages++; } if(giNewBookClose) { gaImgs[gnImages]=giNewBookClose; gnImages++; } if(giNewBookOpen) { gaImgs[gnImages]=giNewBookOpen; gnImages++; } if(giNewBookItem) { gaImgs[gnImages]=giNewBookItem; gnImages++; } if(giNewURLItem) { gaImgs[gnImages]=giNewURLItem; gnImages++; } if(gnImages>0) { setTimeout("loadDataAfter();",1000); loadImage(gaImgs[0]); } else loadDataAfter(); } function loadImage(sURL) { var oImg=new Image(); oImg.onload=checkImageLoading; oImg.onerror=errorImageLoading; oImg.src=_getFullPath(gaProj[0].sPPath,sURL); } function loadDataAfter() { if(!gbLoadData) { gbLoadData=true; loadTData(); } } function errorImageLoading() { gnLoadedImages++; if(gnImages==gnLoadedImages) loadDataAfter(); else loadImage(gaImgs[gnLoadedImages]); } function checkImageLoading() { gnLoadedImages++; if(gnImages==gnLoadedImages) loadDataAfter(); else loadImage(gaImgs[gnLoadedImages]); } function window_unload() { UnRegisterListener2(this,WH_MSG_PROJECTREADY); UnRegisterListener2(this,WH_MSG_SYNCTOC); UnRegisterListener2(this,WH_MSG_SHOWTOC); } function onSendMessage(oMsg) { if(oMsg) { var nMsgId=oMsg.nMessageId; if(nMsgId==WH_MSG_PROJECTREADY) { loadToc(); } else if(nMsgId==WH_MSG_SYNCTOC) { if(gbReady) { syncWithPaths(oMsg.oParam); } } else if(nMsgId==WH_MSG_SHOWTOC) { if(!gbNav6) document.body.focus(); } } return true; } if (window.gbWhUtil&&window.gbWhVer&&window.gbWhMsg&&window.gbWhProxy) { RegisterListener2(this,WH_MSG_PROJECTREADY); RegisterListener2(this,WH_MSG_SYNCTOC); RegisterListener2(this,WH_MSG_SHOWTOC); goFont=new whFont("Verdana","8pt","#000000","normal","normal","none"); goHFont=new whFont("Verdana","8pt","#007f00","normal","normal","underline"); window.onload=window_OnLoad; window.onbeforeunload=window_BUnload; window.onunload=window_unload; gbWhTHost=true; } else document.location.reload();