home *** CD-ROM | disk | FTP | other *** search
- /* Localize the following variables */
- /* Start Localize */
- var sErr_EntryNotFound = "<P STYLE='color:red'><B> Definition not found.</B></P>";
- var sGlossaryPopUpTitle = "Glossary Term";
- /* End Localize */
-
- //----------------------------------------------------------------------------------
-
- // Global variables
- var bDataSetComplete = false; // flag to ensure the user will not access DB before load complete
- var sDBGlossary = "../dbGlossary.csv"; // path to glossary DB file
- var sPopUpBGColor = "lightblue"; // popup background color
- var sPopUpShadowBGColor = "lightblue"; // popup background color
- var oBInfo = GetBrowserInfo(); // browser information
-
- // Call Intialize PopUp Glossary
- Initialize();
-
- // Main popup glossary subroutine, gets called everytime the user clicks on the on a glossary keyword
- function Glossary(oObj)
- {
- // If DB not loaded exit
- // Removing safety check for IE4, under IE4 on WinNT4 TDC.ondatasetcomplete event never fires.
- // Safety will only work for IE5
- if(oBInfo.GB && bDataSetComplete == false) return;
- // Reposition pop-up tray
- PosPopUpTray(idPopUpTray);
-
- // Get keyword definition from glossary database
- idPopUp.innerHTML = GetKeyDef(dbGlossary.recordset, oObj.RID);
-
- // Set shadow
- idPopUpShadow.innerHTML = idPopUp.innerHTML
-
- // Display pop-up glossary
- DspPopUp(1);
- }
-
- // Method reposition glossary popup tray underneath the glossary keyword.
- function PosPopUpTray(oObj)
- {
- var offSetLeft = window.event.clientX + document.body.scrollLeft ;
- var offSetTop = window.event.clientY + document.body.scrollTop ;
- var offSetWidth = document.body.offsetWidth;
-
- // Avoid runing off to the right of the screen
- if (((offSetLeft + 430) > offSetWidth) && (offSetWidth > 430 ))
- {
- offSetLeft = offSetWidth - parseInt(oObj.style.width) - 34 ;
- }
- oObj.style.left = offSetLeft; // set new x coordinate
- oObj.style.top = offSetTop; // set new y coordinate
- }
-
- // Method obtains keyword deffinition
- function GetKeyDef(oRecordSet, sKeyWord)
- {
- var sDef = "";
- oRecordSet.MoveFirst();
-
- for(var i=0; i < oRecordSet.RecordCount; i++) // >
- {
- // If we found our keyword in the record set extract deffinition and exit
- if(sKeyWord == oRecordSet.fields.item('rid').value)
- {
- sDef = "<P><B>" + oRecordSet.fields.item('key').value + "</B><BR>"
- sDef = sDef + oRecordSet.fields.item('def').value + "</P>"
- return sDef;
- }
- // Advance to next element
- oRecordSet.MoveNext();
- }
-
- sDef = sErr_EntryNotFound ;
- return sDef;
- }
-
- // Method turns pop-up tray display on/off
- function DspPopUp(nState)
- {
- if(nState == 0)
- {
- idPopUpTray.style.display = "none";
- }
- else if(nState == 1)
- {
- idPopUpTray.style.display = "";
- fadeIn(idPopUp);
- idPopUpShadow.focus();
- }
- }
-
- // Method hides pop-up glossary
- function HidePopUp()
- {
- if(window.event.srcElement == null)
- {
- DspPopUp(0);
- }
- else if (window.event.srcElement.id != "idGlossary")
- {
- DspPopUp(0);
- }
- }
-
- // Method fades in the pop-up
- function fadeIn(oObj)
- {
- if(!oBInfo.GB) return ;
- oObj.style.filter="blendTrans(duration=.30";
- // make sure filter is not already playing
- if (oObj.filters.blendTrans.status != 2)
- {
- oObj.style.visibility="hidden";
- oObj.filters.blendTrans.apply();
- oObj.style.visibility="visible";
- oObj.filters.blendTrans.play();
- }
- }
-
- // Set all objects required for the pop-up glossary
- function Initialize()
- {
- // Create style string
- var sStyle = '' +
- '<STYLE> #idGlossary{cursor: hand; color: green; text-decoration: underline;}</STYLE>';
-
- // Create Glossary onclick event handler
- var sOnClickEvent = '' +
- '<SCR' + 'IPT LANGUAGE="JScript" FOR="idGlossary" EVENT="onclick">' +
- ' Glossary(this);' +
- '</SCR' + 'IPT>' ;
-
- // Create Glossary onmouseover event handler
- var sOnMouseOverEvent = '' +
- '<SCR' + 'IPT LANGUAGE="JScript" FOR="idGlossary" EVENT="onmouseover">' +
- ' this.title = "' + sGlossaryPopUpTitle + '";' +
- '</SCR' + 'IPT>' ;
-
- // Create TBDCtl string
- var sObj = '' +
- '<OBJECT ID="dbGlossary" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" STYLE="height: 0; width: 0;" ondatasetcomplete="bDataSetComplete = true">' +
- ' <PARAM NAME="DataURL" VALUE="' + sDBGlossary + '">' +
- ' <PARAM NAME="UseHeader" VALUE="True">' +
- ' <PARAM NAME="TextQualifier" VALUE="|">' +
- '</OBJECT>' ;
-
- // Create event handlers string
- var sEvtHandle = '' +
- '<SCR' + 'IPT LANGUAGE="JScript">' +
- ' document.onmousedown = HidePopUp;' +
- ' window.onresize = HidePopUp;' +
- '</SCR' + 'IPT >';
-
- // Create popup string , lemonchiffon
- var sPopUp = '' +
- '<DIV ID="idPopUpTray" STYLE="display: none; z-index:1; width:400; height:10; position:absolute; padding: 0; border-style: inset; border-width:0;">' +
- ' <DIV ID="idPopUp" STYLE="z-index:3; width:400; height: 10; position:absolute; font:8pt Tahoma; line-height: 8pt; background-color:' + sPopUpBGColor + '; top: 0; left: 0; padding: 7; margin: 6; border-style: inset; border-left-width: 1; border-top-width: 1; border-right-width: 2; border-bottom-width: 2; border-right-color: black; border-bottom-color: black; "> </DIV>' +
- ' <DIV ID="idPopUpShadow" STYLE="z-index:2; width:400; height: 10; position:absolute; font:8pt Tahoma; line-height: 8pt; background-color:' + sPopUpShadowBGColor + '; color:' + sPopUpShadowBGColor + ';top: 6; left:-6; padding: 7; margin: 6; border-style: solid; border-left-width: 1; border-top-width: 1; border-right-width: 2; border-bottom-width: 2; border-right-color: black; border-color:' + sPopUpShadowBGColor + '; filter:alpha(opacity=50, style=0);"> </DIV>' +
- '</DIV>' ;
-
- // Write objects to document
- window.self.document.write(sStyle);
- window.self.document.write(sOnClickEvent);
- window.self.document.write(sOnMouseOverEvent);
- window.self.document.write(sObj);
- window.self.document.write(sPopUp);
- window.self.document.write(sEvtHandle);
- }
-
- // Container for browser/os information
- function BrowserInfo()
- {
- this.Type = "";
- this.Ver = 0;
- this.Plat = "";
- this.GB = false;
- }
-
- // Determines browser/os platforms
- // Question: Will this code work with localized versions of the browser ??
- // ToDo: Test the code to see if it works under Netscape. On mac OS.
- function GetBrowserInfo()
- {
- var brw = new BrowserInfo;
- sUA = window.navigator.appVersion;
-
- if (parseInt(sUA.indexOf("MSIE ")) >= 0) // Check if IE
- {
- brw.Type = "IE";
- brw.Ver = parseInt(sUA.substring(sUA.indexOf("MSIE ")+5,sUA.indexOf (".",sUA.indexOf("MSIE "))));
- if (sUA.lastIndexOf("Win") >= 0)
- brw.Plat = "Win";
- }
- else if(parseInt(navigator.appName.lastIndexOf("Netscape"))>=0)
- {
- brw.Type = "Nav";
- brw.Ver = parseInt(sUA.substring(0, sUA.indexOf('.')));
- }
-
- if (sUA.indexOf("Mac") != -1) {brw.Plat = "Mac"};
-
- brw.GB = (brw.Type == "IE" && brw.Ver >= 5 && brw.Plat == "Win");
- return brw;
- }
-