tags in // order to take advantage of this feature. // // o Each image named XXX can have a complement grouping: // XXX_normal -- the static image // XXX_active -- the active image // XXX_clicked -- the clicked image // // o Harmless to non-compliant browsers (eg, Win MSIE 3.x). // //-------------------------------------------------------------------- // Bill Houle [while at NCR Corporation] // bhoule(at)siliconexus(dot)com //-------------------------------------------------------------------- //-------------------------------------------------------------------- // First, we build the complement grouping by pre-loading all // the images (if the browser can handle it) // if (document.images) { button_normal = new Image(); button_normal.src = "mc_help_button.gif"; button_active = new Image(); button_active.src = "mc_help_hot.gif"; button_clicked = new Image(); button_clicked.src = "mc_help_clicked.gif"; } //-------------------------------------------------------------------- // img(imgName,imgEvent) // imgName -- string: basename of the image group // imgEvent -- integer: 0=normal, 1=active, 2=clicked // // Usage: // onClick='img(foo,2); return true;' // onMouseOver='img(foo,1); return true;' // onMouseOut='img(foo,0);return true;' // // o Toggle the named image between event-specific values // (normal, mouseOver, and onClick). Uses pre-loaded // images from above. // function img(imgName,imgEvent) { if (document.images) { if (imgEvent == 2) imgVal = 'clicked'; else if (imgEvent == 1) imgVal = 'active'; else if (imgEvent == 0) imgVal = 'normal'; else return; imgObj = eval(imgName + '_' + imgVal + ".src"); // image may not exist in the grouping... if (document.images[imgName]) document.images[imgName].src = imgObj; } } //==================================================================== //-------------------------------------------------------------------- // msg(msgText) // msgText -- string: text to display on browser Status line // // Usage: // onMouseOver='msg("Hit me!"); return true;' // onMouseOut='msg("Maybe next time?"); return true;' // onClick='msg("Ouch!"); return true;' // // o Use null string to clear Status // function msg(msgText) { window.status = msgText; } //==================================================================== //-------------------------------------------------------------------- // Tool Tip/Balloon Help: dynamic mouseOver/mouseOut windowing. // // o Shows/hides text in pop-up window. // // o Delayed open to only pop those who pause for help. // // o mouseOut->mouseOver will re-use open window rather than // than close & reopen. // // o Window closes after timeout. Timeout varies with amount // of text displayed. More text, larger timeout. // // o Harmless to non-compliant browsers. // // Known bugs: // // o No control of window.open() placement. // // o In Win MSIE3.x: if tipWin is closed manually, the object // is still valid but the window is not open. The timeout // of the tip will result in 'scripting error 80010012'. // Luckily, other browsers support onMouseOut, so the problem // is not widespread. // //-------------------------------------------------------------------- // Bill Houle NCR Corporation // bhoule(at)siliconexus(dot)com bill.houle(at)sandiegoca.ncr.com //-------------------------------------------------------------------- // Global settings; tweak as required // tipTitle = "ToolTip"; tipColor= "#FFFF80"; // yellow background tipWidth = 300; tipHeight = 100; tipFactor = 20; // estimate chars read in 1 msec // Null defaults tipWin = null; tipOTime = null; tipOFlag = 0; tipCTime = null; tipCFlag = 0; //-------------------------------------------------------------------- // tip(tipLocation, tipText, tipDelay, tipLife, stealFocus) // tipLocation -- handle: a Window name // tipText -- string: the message to display in tipLocation // null string to close tipLocation // tipDelay -- integer: millisecond pause before action (open,close) // tipLife -- integer: millisecond life of window (open only) // 0 for variable based on text length // stealFocus -- boolean: force openwindow to front by stealing focus // // Usage: // onMouseOver='tip(win,"This isdescriptive.",1500,0,1); return true;' // onMouseOut='tip(win,"",0,0,0); return true;' // onClick='tip(win,"",0,0,0); return true;' // // o stealFocus will prevent pop-ups from hiding behind the // active application. But don'tuse this with onFocus/onBlur // events or your caller will never regainfocus control! // // o Don't forget the onClick(), or else the tipwindow may pop // up while you are off doing whatever the click action was. // function tip(tipLocation, tipText, tipDelay, tipLife,stealFocus) { // // Clear any pending window opens or closes. Please note: // uninitialized "timeout id" in NN3.x is untestable 'opaque' // object, while "timeout id" in MSIE *must* be tested before // clearTimeout(). Therefore, use global integers to bypass // this Catch-22 situation. // if (tipOFlag != 0) { clearTimeout(tipOTime); tipOFlag = 0; } if (tipCFlag != 0) { clearTimeout(tipCTime); tipCFlag =0; } // // Remove the tip from display // if (tipText == '') { if (tipWin == null) return; // already gone // // Close window in the future (extra delay is to // avoid popping down & up if there is a subsequent // mouseOver). // tipCTime = window.setTimeout( "if (tipWin!= null) {tipWin.close(); tipWin=null;}", tipDelay); tipCFlag = 1; } // // Display the tip // else { // // If not yet open and requesting delayed open... // if (tipWin == null && tipDelay > 0) { tipOTime = window.setTimeout("tip('"+tipLocation+"','"+tipText+"',0,"+tipLife+","+stealFocus+");",tipDelay); tipOFlag = 1; return; } // // MSIE requires explicit options on open(). Also, // contrary to appearances, this double open is not // for the known NN2 open() bug (which ignores the // location URL), but rather for an IE3 problem that // creates a window object without avalid document // object within. // The 'dependent' attribute is Netscapism to indicate // a window child appearance. // tipWin = window.open("",tipLocation,"width="+tipWidth+",height="+tipHeight+","+"toolbar=0,menubar=0,scrollbars=0,"+"location=0,status=0,resizable=0,"+ "directories=0,dependent=1"); if (tipWin == null) return; // whoops! // bring window to front (IE3unsupported) if (stealFocus && (parseInt(navigator.appVersion) > 2)) tipWin.focus(); if (tipWin.document) { tipWin.document.open('text/html'); tipWin.document.write(""); tipWin.document.write(""); tipWin.document.write(tipTitle); tipWin.document.write(""); tipWin.document.write(""); tipWin.document.write("