home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 October / tst.iso / multimed / IDN / web / mixup / beatnik-actionset.js < prev    next >
Encoding:
Text File  |  1999-07-15  |  46.5 KB  |  1,303 lines

  1. mo_delayPlayerCheck = true;
  2.  
  3. /***************************************
  4. Music Object - Version 3.0.8
  5. written by Chris van Rensburg
  6.  
  7. ⌐ Copyright 1996-1999 Beatnik, Inc.
  8. All  Rights Reserved
  9. ***************************************/
  10.  
  11. function mo_indexOf (sourceStr,searchStr,startPos) {
  12.     var result = sourceStr.indexOf (searchStr,startPos);
  13.     return (result != -1) ? result : sourceStr.length;
  14. }
  15.  
  16. function mo_stringHasAny (sourceStr) {
  17.     for (var argNo = 1; argNo < mo_stringHasAny.arguments.length; argNo++) {
  18.         if (sourceStr.indexOf (mo_stringHasAny.arguments [argNo]) != -1) return true;
  19.     }
  20.     return false;
  21. }
  22.  
  23. function mo_null () {
  24.     if (this.ready)
  25.         mo_debug ('Attempted to use a method not supported in this version of the Beatnik Player.',window.location.href,'unknown');
  26.         else if (!Music.ignoreNotReady) mo_debug ('Music Object instance "' + this.objectName + '" is not yet ready for scripting control.',window.location.href,'unknown');
  27. }
  28.  
  29. function mo_execHandler (callbackHandler) {
  30.     if (typeof (callbackHandler) == 'string') eval (callbackHandler);
  31.         else if (typeof (callbackHandler) == 'function') callbackHandler ();
  32. }
  33.  
  34. function mo_play (p1,p2) {
  35.     with (this) {
  36.         endVolumeFade ();
  37.         if (typeof (p2) == 'string') {
  38.             if (p2.indexOf ('.') == -1 && p2.indexOf ('groovoid://') != 0) p2 = 'groovoid://' + p2;
  39.             if (typeof (p1) == 'string') p1 = (p1 == 'auto') ? (p2.indexOf ('groovoid://Background-') == 0) : (p1 == 'yes');
  40.             playerID.play (p1,p2);
  41.         } else if (typeof (p1) == 'boolean' || typeof (p1) == 'number') {
  42.             playerID.play (p1);
  43.         } else if (typeof (p1) == 'string') {
  44.             play ('auto',p1);
  45.         } else {
  46.             if (!playerID.isPlaying ()) playerID.play ();
  47.         }
  48.     }
  49. }
  50.  
  51. function mo_stop (fade) {
  52.     with (this) {
  53.         if (typeof (fade) == 'undefined') {
  54.             endVolumeFade ();
  55.             playerID.stop ();
  56.         } else {
  57.             if (isPaused ()) {
  58.                 endVolumeFade ();
  59.                 playerID.stop ();
  60.             } else {
  61.                 fadeVolume (null,0,fade,objectName + '.stop ()');
  62.             }
  63.         }
  64.     }
  65. }
  66.  
  67. function mo_stopAll () {
  68.     with (this) {
  69.         endVolumeFade ();
  70.         playerID.stopAll ();
  71.     }
  72. }
  73.  
  74. function mo_pause (fade) {
  75.     with (this) {
  76.         endVolumeFade ();
  77.         if (isPaused ()) {
  78.             playerID.pause ();
  79.             if (typeof (fade) == 'number') fadeVolume (0,100,fade);
  80.         } else {
  81.             if (typeof (fade) != 'number') playerID.pause ();
  82.                 else fadeVolume (null,0,fade,objectName + '.pause ()');
  83.         }
  84.     }
  85. }
  86.  
  87. function mo_endVolumeFade () {
  88.     with (this) {
  89.         if (volFade_inProgress) {
  90.             clearTimeout (volFade_timeout);
  91.             volFade_inProgress = false;
  92.             Music.execHandler (volFade_endCallback);
  93.             if (volFade_restoreVolume) setVolume (volFade_fromVolume);
  94.         }
  95.     }
  96. }
  97.  
  98. function mo_execVolumeFade () {
  99.     with (this) {
  100.         volFade_volume += volFade_step;
  101.         setVolume (Math.round (volFade_volume));
  102.         volFade_timeElapsed += volFade_interval;
  103.         Music.execHandler (volFade_advanceCallback);
  104.         if (volFade_timeElapsed >= volFade_time) {
  105.             setVolume (volFade_toVolume);
  106.             endVolumeFade ();
  107.         } else {
  108.             volFade_timeout = setTimeout (objectName + '.execVolumeFade ()',volFade_interval);
  109.         }
  110.     }
  111. }
  112.  
  113. function mo_fadeVolume (fromVolume,toVolume,fadeTime,fadeEndCallback,fadeAdvanceCallback) {
  114.     with (this) {
  115.         if (typeof (fromVolume) != 'number') fromVolume = getVolume ();
  116.         if (typeof (toVolume) != 'number') toVolume = 0;
  117.         if (typeof (fadeTime) == 'boolean') fadeTime = fadeTime ? 1000:0;
  118.         if (typeof (fadeTime) != 'number') fadeTime = 1000;
  119.         if (
  120.             volFade_inProgress &&
  121.             toVolume == volFade_toVolume &&
  122.             fadeTime == volFade_time
  123.         ) {
  124.             volFade_endCallback = fadeEndCallback;
  125.             volFade_advanceCallback = fadeAdvanceCallback;
  126.         } else {
  127.             volFade_restoreVolume = typeof (fadeEndCallback) == 'string' && (fadeEndCallback.indexOf ('.stop ()') != -1 || fadeEndCallback.indexOf ('.pause ()') != -1);
  128.             endVolumeFade ();
  129.             if (fadeTime != 0 && fadeTime < Music.minFadeInterval)
  130.                 fadeTime = Math.round (fadeTime / Music.minFadeInterval) * Music.minFadeInterval
  131.             ;
  132.             if (fadeTime == 0 || toVolume == fromVolume) {
  133.                 if (!volFade_restoreVolume)    setVolume (toVolume);
  134.                 Music.execHandler (fadeEndCallback);
  135.             } else {
  136.                 volFade_fromVolume = fromVolume;
  137.                 volFade_toVolume = toVolume;
  138.                 volFade_time = fadeTime;
  139.                 volFade_endCallback = fadeEndCallback;
  140.                 volFade_advanceCallback = fadeAdvanceCallback;
  141.                 volFade_timeElapsed = 0;
  142.                 volFade_volume = fromVolume;
  143.                 volFade_inProgress = true;
  144.                 volFade_interval = Math.max (Math.ceil (volFade_time / Math.abs (toVolume - fromVolume)),Music.minFadeInterval);
  145.                 volFade_step = (toVolume - fromVolume) / (volFade_time / volFade_interval);
  146.                 setVolume (fromVolume);
  147.                 volFade_timeout = setTimeout (objectName + '.execVolumeFade ()',volFade_interval);
  148.             }
  149.         }
  150.     }
  151. }
  152.  
  153. function mo_fadeTo (toValue,fadeTime,fadeEndCallback,fadeAdvanceCallback) {
  154.     this.fadeVolume (null,toValue,fadeTime,fadeEndCallback,fadeAdvanceCallback);
  155. }
  156.  
  157. function mo_enable () {
  158.     with (this) {
  159.         if (typeof (window [playerName]) == 'object') {
  160.             playerID = window [playerName];
  161.         } else if (typeof (document [playerName]) == 'object') {
  162.             playerID = document [playerName];
  163.         } else {
  164.             for (var formNo = 0; formNo < document.forms.length; formNo++) {
  165.                 formHandle = document.forms [formNo];
  166.                 if (typeof (formHandle [playerName]) == 'object') {
  167.                     playerID = formHandle [playerName];
  168.                     break;
  169.                 }
  170.             }
  171.         }
  172.         if (playerID != null) {
  173.             defineMethodsMO ('getAutostart','getChannelMute','getChannelSolo','getController','getInfo','getLoop','getPanelDisplay','getPanelMode','getProgram','getReverbType','getTempo','getTranspose','getTrackMute','getTrackSolo','getVolume','isPaused','isPlaying','setAutostart','setChannelSolo','setController','setGlobalMute','setLoop','setPanelDisplay','setPanelMode','setReverbType','setTempo','setTrackMute','setTrackSolo','setTranspose','setVolume','fadeTo','noteOff','noteOn','pause','play','setChannelMute','setProgram','stop','fadeVolume');
  174.             fadeFromTo = fadeVolume;
  175.             playGroovoid = play;
  176.             playNote = noteOn;
  177.             if (Music.playerVersion == '') Music.playerVersion = mo_retrieveVersion (playerID.getVersion () + '');
  178.             if (Music.hasMinVersion ('1.3'))
  179.                 defineMethodsMO ('doMenuItem','engageAudio','getFileSize','getPlayLength','getPosition','getTransposable','setEndTime','setPosition','setStartTime','setTransposable','stopAll')
  180.             ;
  181.             if (typeof (onMetaEventHandler) == 'function') playerID.enableMetaEvents (true);
  182.             if (Music.hasCallbackIssue) {
  183.                 playerID.enableCallbacks (true);
  184.             } else {
  185.                 execOnReady ();
  186.             }
  187.         } else {
  188.             setTimeout (objectName + '.enable ()',500);
  189.         }
  190.     }
  191. }
  192.  
  193. function mo_execOnReady () {
  194.     with (this) {
  195.         if (ready) {
  196.             if (Music.playerType == 'ActiveX') playerID.receivedReady (true);
  197.         } else {
  198.             ready = playerID != null;
  199.             if (ready) {
  200.                 if (Music.playerType == 'ActiveX') playerID.receivedReady (true);
  201.                 if (delayAutostart) {
  202.                     setAutostart (true);
  203.                     play ();
  204.                 }
  205.                 Music.execHandler (onReadyHandler);
  206.             } else {
  207.                 enable ();
  208.             }
  209.         }
  210.         if (ready) Music.execHandler (onLoadHandler);
  211.     }
  212. }
  213.  
  214. function mo_setMonophonic (channelNo,state) {
  215.     with (this) {
  216.         if (channelNo == 0)
  217.             for (var channelCount = 0; channelCount < 16; channelCount++) monophonic [channelCount] = state;
  218.             else monophonic [channelNo - 1] = state;
  219.     }
  220. }
  221.  
  222. function mo_getMonophonic (channelNo) {return this.monophonic [channelNo - 1]}
  223.  
  224. function mo_noteOn (_channelNo,p2,p3,p4,p5,p6) {
  225.     var voiceNo;
  226.     with (this) {
  227.         if (mo_noteOn.arguments.length >= 5) {
  228.             if (monophonic [_channelNo - 1]) noteOff (_channelNo);
  229.             if (typeof (p4) == 'string') p4 = getNoteNumber (p4);
  230.             Music.globalNoteNo++;
  231.             with (Music.newVoice) {
  232.                 musicID = this;
  233.                 timeStamp = Music.globalNoteNo;
  234.                 channelNo = _channelNo;
  235.                 noteNo = p4;
  236.             }
  237.             var assignToVoiceNo = -1;
  238.             for (voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
  239.                 with (Music.voices [voiceNo]) {
  240.                     if (channelNo == 0) {
  241.                         assignToVoiceNo = voiceNo;
  242.                         break;
  243.                     }
  244.                 }
  245.             }
  246.             if (assignToVoiceNo == -1) {
  247.                 assignToVoiceNo = 0;
  248.                 for (voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
  249.                     if (Music.voices [voiceNo].timeStamp < Music.voices [assignToVoiceNo].timeStamp)
  250.                         assignToVoiceNo = voiceNo
  251.                     ;
  252.                 }
  253.             }
  254.             with (Music.voices [assignToVoiceNo]) {
  255.                 musicID = Music.newVoice.musicID;
  256.                 timeStamp = Music.newVoice.timeStamp;
  257.                 channelNo = Music.newVoice.channelNo;
  258.                 noteNo = Music.newVoice.noteNo;
  259.                 if (p2 >= 0 && p3 >= 0) playerID.noteOn (channelNo,p2,p3,p4,p5);
  260.                     else playerID.noteOn (channelNo,p4,p5);
  261.                 if (typeof (p6) == 'number') noteOffTimeout = setTimeout ('Music.voices [' + assignToVoiceNo + '].free ()',p6);
  262.             }
  263.         } else {
  264.             noteOn (_channelNo,-1,-1,p2,p3,(typeof (p4) != 'number') ? null : p4);
  265.         }
  266.     }
  267. }
  268.  
  269. function mo_noteOff (_channelNo,_noteNo) {
  270.     with (this) {
  271.         if (typeof (_noteNo) == 'undefined') {
  272.             for (var voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
  273.                 with (Music.voices [voiceNo])
  274.                     if (musicID == this && channelNo == _channelNo) free ()
  275.                 ;
  276.             }
  277.         } else {
  278.             if (typeof (_noteNo) == 'string') _noteNo = getNoteNumber (_noteNo);
  279.             for (var voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
  280.                 with (Music.voices [voiceNo]) {
  281.                     if (musicID == this && channelNo == _channelNo && noteNo == _noteNo) {
  282.                         free ();
  283.                         break;
  284.                     }
  285.                 }
  286.             }
  287.         }
  288.     }
  289. }
  290.  
  291. function mo_setProgram (channelNo,p2,p3) {
  292.     with (this) {
  293.         if (typeof (p3) == 'number') playerID.setProgram (channelNo,p2,p3);
  294.             else playerID.setProgram (channelNo,p2);
  295.     }
  296. }
  297.  
  298. function mo_setChannelMute (channelNo,state) {
  299.     with (this) {
  300.         if (channelNo == 0) {
  301.             for (var channelCount = 1; channelCount <= 16; channelCount++)
  302.                 playerID.setChannelMute (channelCount,state)
  303.             ;
  304.         } else {
  305.             playerID.setChannelMute (channelNo,state)
  306.         }
  307.     }
  308. }
  309.  
  310. function mo_isReady () {return this.ready}
  311.  
  312. function mo_onLoad (onLoadHandler) {this.onLoadHandler = onLoadHandler}
  313. function mo_onPause (onPauseHandler) {this.onPauseHandler = onPauseHandler}
  314. function mo_onPlay (onPlayHandler) {this.onPlayHandler = onPlayHandler}
  315. function mo_onReady (onReadyHandler) {this.onReadyHandler = onReadyHandler}
  316. function mo_onStop (onStopHandler) {this.onStopHandler = onStopHandler}
  317.  
  318. function mo_onMetaEvent (_onMetaEventHandler) {
  319.     with (this) {
  320.         onMetaEventHandler = _onMetaEventHandler;
  321.         if (ready) playerID.enableMetaEvents (typeof (onMetaEventHandler) == 'function');
  322.     }
  323. }
  324.  
  325. function mo_execOnPause () {
  326.     with (this) {
  327.         endVolumeFade ();
  328.         Music.execHandler (this.onPauseHandler);
  329.     }
  330. }
  331.  
  332. function mo_execOnPlay () {
  333.     with (this) {
  334.         setVolume (VOLUME);
  335.         Music.execHandler (onPlayHandler);
  336.     }
  337. }
  338.  
  339. function mo_execOnStop () {
  340.     with (this) {
  341.         endVolumeFade ();
  342.         Music.execHandler (onStopHandler);
  343.     }
  344. }
  345.  
  346. function mo_execOnMetaEvent (eventType,eventValue) {
  347.     with (this)
  348.         if (onMetaEventHandler != null) onMetaEventHandler (eventType,eventValue,this)
  349.     ;
  350. }
  351.  
  352. function mo_setVolume (_volume) {
  353.     with (this) {
  354.         VOLUME = _volume;
  355.         playerID.setVolume (_volume);
  356.     }
  357. }
  358.  
  359. function mo_getVersion () {return Music.playerVersion}
  360. function mo_getVolume () {return this.VOLUME}
  361.  
  362. function mo_isPaused () {return this.playerID.IsPaused ()}
  363. function mo_isPlaying () {return this.playerID.IsPlaying ()}
  364.  
  365. function mo_promptClose () {
  366.     if (typeof (Music.promptWindow) == 'object') Music.promptWindow.close ();
  367.     window.focus ();
  368. }
  369.  
  370. function mo_promptUser (heading,message,okText,okAction,cancelText,cancelAction,showStatus) {
  371.     Music.promptWindow = window.open ('','mo_promptWindow','toolbar=no,location=no,directories=no,status=' + ((showStatus || navigator.appName == 'Microsoft Internet Explorer') ? 'yes' : 'no') + ',menubar=no,scrollbars=no,resizable=yes,width=400,height=300');
  372.     if (typeof (okAction) != 'string' || okAction == '') okAction = 'Music.promptClose ()';
  373.     if (typeof (cancelAction) != 'string' || cancelAction == '') cancelAction = 'Music.promptClose ()';
  374.     if (typeof (heading) != 'string') heading = '';
  375.     with (Music.promptWindow.document) {
  376.         open ('text/html');
  377.         writeln (
  378.             '<HTML><HEAD><TITLE>' + heading + '</TITLE></HEAD><BODY BGCOLOR=002244 TEXT=CCCCCC>' +
  379.             '<FORM><TABLE WIDTH=100% HEIGHT=100% BORDER=1 CELLSPACING=10 CELLPADDING=6 BGCOLOR=000000>'
  380.         );
  381.         if (heading != '') writeln ('<TR><TD ALIGN=CENTER BGCOLOR=0088AA><FONT FACE="ARIAL,HELVETICA,VERDANA" COLOR=000000 SIZE=5>' + heading + '</FONT></U><BR></TD></TR>');
  382.         writeln (
  383.             '<TR><TD VALIGN=TOP><FONT FACE="ARIAL,HELVETICA,VERDANA" SIZE=3>' + message + '<P></FONT>' +
  384.             '<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=LEFT>'
  385.         );
  386.         if (typeof (cancelText) == 'string' && cancelText != '')
  387.             writeln ('<INPUT TYPE=button VALUE="' + cancelText + '" ONCLICK="with (window.opener) {' + cancelAction + '}">')
  388.         ;
  389.         writeln ('</TD><TD ALIGN=RIGHT>');
  390.         if (typeof (okText) == 'string' && okText != '')
  391.             writeln ('<INPUT TYPE=button VALUE="' + okText + '" ONCLICK="with (window.opener) {' + okAction + '}">')
  392.         ;
  393.         writeln ('</TD></TR></TABLE></TD></TR></TABLE></FORM></BODY></HTML>');
  394.         close ();
  395.         if (typeof (Event) != 'undefined') {
  396.             Music.promptWindow.captureEvents (Event.KEYUP);
  397.             Music.promptWindow.onKeyUp = new Function ('event','if (event.which == 13) {' + okAction + '} else if (event.which == 27) {' + cancelAction + '}; return false');
  398.             Music.promptWindow.focus ();
  399.         }
  400.     }
  401. }
  402.  
  403. function mo_installBeatnik () {
  404.     Music.promptWindow = window.open ('http://www.beatnik.com/to/install-player.html','mo_promptWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=400,height=300');
  405. }
  406.  
  407. function mo_retrieveVersion (appName) {
  408.     var
  409.         versionStr = '',
  410.         numerals = '0123456789',
  411.         charNo = appName.length - 1,
  412.         currentChar,
  413.         inVersion = false,
  414.         parensLevel = 0
  415.     ;
  416.     while (charNo >= 0) {
  417.         currentChar = appName.charAt (charNo);
  418.         if (currentChar == ')') {
  419.             parensLevel++;
  420.         } else if (currentChar == '(') {
  421.             parensLevel--;
  422.         } else if (parensLevel == 0) {
  423.             if (inVersion || numerals.indexOf (currentChar) != -1) {
  424.                 inVersion = true;
  425.                 if (currentChar == ' ') charNo = 0;
  426.                     else if (currentChar == '.' || numerals.indexOf (currentChar) != -1) versionStr = currentChar + versionStr;
  427.             }
  428.         }
  429.         charNo--;
  430.     }
  431.     return versionStr;
  432. }
  433.  
  434. function mo_meetsMinVersion (versionToTest,minRequiredVersion) {
  435.     var
  436.         versionA = mo_retrieveVersion (versionToTest),
  437.         versionB = mo_retrieveVersion (minRequiredVersion)
  438.     ;
  439.     if (versionA.length < versionB.length) versionA += '.0.0.0.0.0.0.0.0.0.0.0.0'.substring (0,versionB.length - versionA.length);
  440.     return versionA >= versionB;
  441. }
  442.  
  443. function mo_hasMinVersion (minRequiredVersion) {
  444.     return mo_meetsMinVersion (Music.playerVersion,minRequiredVersion);
  445. }
  446.  
  447. function mo_isPlayerCompatible (minVersion,silentIfInadequate,showCompatibilityPrompt) {
  448.     if (Music.clientSupported) {
  449.         if (typeof (silentIfInadequate) == 'boolean') Music.silentIfInadequate = silentIfInadequate;
  450.         if (typeof (showCompatibilityPrompt) == 'boolean') Music.showCompatibilityPrompt = showCompatibilityPrompt;
  451.         if (typeof (minVersion) == 'string') Music.requiredMinVersion = minVersion;
  452.         if (Music.hasPlayer) {
  453.             if (Music.hasMinVersion (Music.requiredMinVersion)) {
  454.                 return true;
  455.             } else {
  456.                 if (Music.client.upgradable && Music.showCompatibilityPrompt) Music.promptUser ('Please Upgrade Beatnik','This page has been optimized for the features of version <FONT COLOR=FFFFFF><B>' + Music.requiredMinVersion + ' (or higher)</B></FONT> of the Beatnik Player. The currently installed version in your browser is ' + Music.playerVersion + '.<P>If you choose to IGNORE this message, the page will continue to load normally, but may not function properly as designed by the author.','UPGRADE BEATNIK >>>','Music.installPlayer ()','IGNORE','Music.promptClose ()');
  457.                 return false;
  458.             }
  459.         } else {
  460.             if (Music.client.upgradable && Music.showCompatibilityPrompt) Music.promptUser ('Beatnik Enhanced Content !!','This page has been optimized for the audio features of the <FONT COLOR=FFFFFF><B>Beatnik Player</B></FONT>. It appears you do not have the Beatnik Player installed.<P>If you choose to IGNORE this message, the page will continue to load normally, except there will be no Beatnik audio.','INSTALL BEATNIK >>>','Music.installPlayer ()','IGNORE','Music.promptClose ()');
  461.             return false;
  462.         }
  463.     } else return false;
  464. }
  465.  
  466. function mo_requireJava () {
  467.     Music.ignoreJavaDisabled = true;
  468.     if (Music.clientSupported && Music.client.name == 'Netscape' && !navigator.javaEnabled ()) {
  469.         Music.promptUser ('Please Enable Java','This page makes use of the interactive audio features of the Beatnik Player. Java is currently not enabled in your browser. In order for the page to function correctly with Beatnik, <FONT COLOR=FFFFFF><B>you must have Java enabled</B></FONT>.<P>This page will continue to load normally, but some interactive audio functionality may be absent.','    OK    ','Music.promptClose ()');
  470.     }
  471. }
  472.  
  473. function mo_magicEmbed (attrList) {
  474.     if (typeof (Music.playerCompatible) != 'boolean') Music.playerCompatible = Music.isPlayerCompatible (Music.requiredMinVersion,null,Music.showCompatibilityPrompt);
  475.     var
  476.         subChar,
  477.         isMethod = typeof (this.playerID) != 'undefined',
  478.         attribs = isMethod ? this : Music,
  479.         attrNames = new Array ('SRC','WIDTH','HEIGHT','AUTOSTART','LOOP','VOLUME','ALIGN','HSPACE','VSPACE','BGCOLOR','HIDDEN','DISPLAY','MODE','GROOVOID','ONREADY','ONPLAY','ONPAUSE','ONSTOP','ONMETAEVENT','CALLBACKS','METAEVENTS')
  480.     ;
  481.     if (typeof (this.playerName) != 'string' || !isMethod) {
  482.         for (var attrNo = 0; attrNo < attrNames.length; attrNo++) attribs [attrNames [attrNo]] = null;
  483.         with (this) {
  484.             if (isMethod) {
  485.                 this.playerName = objectName + 'Player';
  486.                 var prefix = objectName + '.execOn';
  487.                 attribs.ONREADY = prefix + 'Ready()';
  488.                 attribs.ONPLAY = prefix + 'Play()';
  489.                 attribs.ONPAUSE = prefix + 'Pause()';
  490.                 attribs.ONSTOP = prefix + 'Stop()';
  491.                 attribs.ONMETAEVENT = prefix + 'MetaEvent()';
  492.                 attribs.METAEVENTS = 'FALSE';
  493.             }
  494.             attribs.AUTOSTART = 'TRUE';
  495.             attribs.WIDTH = '144';
  496.             attribs.HEIGHT = '60';
  497.             attribs.HSPACE = '0';
  498.             attribs.VSPACE = '0';
  499.             attribs.BGCOLOR = document.bgColor;
  500.             attribs.VOLUME = '100';
  501.  
  502.             var
  503.                 tagEndFound = false,
  504.                 attrStartPos = 0
  505.             ;
  506.             while (!tagEndFound && attrStartPos < attrList.length) {
  507.                 var attrFound = false;
  508.                 while (!attrFound && attrStartPos < attrList.length) {
  509.                     attrFound = attrList.charAt (attrStartPos) != ' ';
  510.                     if (!attrFound) attrStartPos++;
  511.                 }
  512.                 if (attrFound) {
  513.                     var
  514.                         equalPos = mo_indexOf (attrList,'=',attrStartPos),
  515.                         spacePos = mo_indexOf (attrList,' ',attrStartPos),
  516.                         closePos = mo_indexOf (attrList,'>',attrStartPos),
  517.                         attrNameEndPos = Math.min (Math.min (spacePos,equalPos),closePos),
  518.                         hasValue = attrNameEndPos != spacePos && attrNameEndPos != closePos,
  519.                         attrName = attrList.substring (attrStartPos,attrNameEndPos).toUpperCase (),
  520.                         attrValueEndPos = attrNameEndPos,
  521.                         attrValue = ''
  522.                     ;
  523.                     tagEndFound = closePos == attrNameEndPos;
  524.                     if (hasValue) {
  525.                         var
  526.                             attrValuePos = attrNameEndPos + 1,
  527.                             quoteChar = attrList.charAt (attrValuePos)
  528.                         ;
  529.                         if (quoteChar == '"' || quoteChar == "'") {
  530.                             attrValuePos++;
  531.                             attrValueEndPos = attrValuePos;
  532.                             var attrValueEndFound = false;
  533.                             while (!attrValueEndFound && attrValueEndPos < attrList.length - 1) {
  534.                                 attrValueEndPos = mo_indexOf (attrList,quoteChar,attrValueEndPos + 1);
  535.                                 attrValueEndFound = true;
  536.                                 var
  537.                                     checkingEscape = true,
  538.                                     charPos = attrValueEndPos
  539.                                 ;
  540.                                 while (checkingEscape) {
  541.                                     charPos--;
  542.                                     checkingEscape = attrList.charAt (charPos) == '\\';
  543.                                     if (checkingEscape) attrValueEndFound = !attrValueEndFound;
  544.                                 }
  545.                             }
  546.                         } else {
  547.                             attrValueEndPos = Math.min (mo_indexOf (attrList,' ',attrValuePos),mo_indexOf (attrList,'>',attrValuePos));
  548.                         }
  549.                         attrValue = attrList.substring (attrValuePos,attrValueEndPos);
  550.                     }
  551.                     attrStartPos = attrValueEndPos + 1;
  552.                     attribs [attrName] = attrValue;
  553.                 }
  554.             }
  555.  
  556.             if (attribs.SRC == '') attribs.SRC = null;
  557.             if (attribs.HIDDEN == '') attribs.HIDDEN = 'TRUE';
  558.  
  559.             if (isMethod) {
  560.                 if (Music.hasCallbackIssue) {
  561.                     attribs.CALLBACKS = 'FALSE';
  562.                     delayAutostart = attribs.AUTOSTART.toUpperCase () == 'TRUE';
  563.                     attribs.AUTOSTART = 'FALSE';
  564.                     if (!Music.bodyEventsAdded) {
  565.                         Music.windowOnloadStr = '';
  566.                         Music.bodyEventsAdded = true;
  567.                         if (Music.playerType == 'ActiveX') mo_addEventHandler (window,window,'onunload','for (var instanceNo = Music.instances.length - 1; instanceNo >= 0; instanceNo--) Music.instances [instanceNo].playerID = null;');
  568.                         mo_addEventHandler (window,window,'onload','eval (Music.windowOnloadStr)');
  569.                     }
  570.                     Music.windowOnloadStr += objectName + '.enable ();';
  571.                 }
  572.             }
  573.             attribs.VOLUME = attribs.VOLUME - 0;
  574.  
  575.             with (document) {
  576.                 var
  577.                     panelW = attribs.WIDTH - 0,
  578.                     panelH = attribs.HEIGHT - 0,
  579.                     embedOutput = ''
  580.                 ;
  581.                 if (Music.enabled && Music.clientSupported && Music.hasPlayer && (Music.playerCompatible || !Music.silentIfInadequate)) {
  582.                     if (Music.playerType == 'Plug-in') {
  583.                         embedOutput = '<EMBED TYPE="audio/rmf" ' + (isMethod ? ('NAME="' + playerName + '" ') : '');
  584.                         for (var attrNo = 0; attrNo < attrNames.length; attrNo++) {
  585.                             if (attribs [attrNames [attrNo]] != null) {
  586.                                 embedOutput += ' ' + attrNames [attrNo];
  587.                                 if (attribs [attrNames [attrNo]] != '')
  588.                                     embedOutput += '="' + attribs [attrNames [attrNo]] + '"'
  589.                                 ;
  590.                             }
  591.                         }
  592.                         embedOutput += '>';
  593.                         if (isMethod && !Music.ignoreJavaDisabled) mo_requireJava ();
  594.                     } else if (Music.playerType == 'ActiveX') {
  595.                         if (isMethod) {
  596.                             var callbacks = new Array ('OnReady','OnPlay','OnPause','OnStop','OnMetaEvent');
  597.                             for (var callbackNo = 0; callbackNo < callbacks.length; callbackNo++) {
  598.                                 var
  599.                                     callbackParams = '(' + (callbacks [callbackNo] == 'OnMetaEvent' ? 'eventType,eventValue' : '') + ')',
  600.                                     callbackHandler = attribs [callbacks [callbackNo].toUpperCase ()]
  601.                                 ;
  602.                                 embedOutput += '<SCRIPT LANGUAGE=JavaScript FOR="' + playerName + '" EVENT="' + callbacks [callbackNo] + callbackParams + '">' + callbackHandler.substring (0,callbackHandler.indexOf ('(')) + callbackParams + '</SCRIPT>\n';
  603.                             }
  604.                         }
  605.                         embedOutput += '<OBJECT' + (isMethod ? (' ID="' + playerName + '"') : '') + ' WIDTH=' + panelW + ' HEIGHT=' + panelH + ' CLASSID="CLSID:B384F118-18EE-11D1-95C8-00A024330339">\n';
  606.                         for (var attrNo = 0; attrNo < attrNames.length; attrNo++) {
  607.                             if (attribs [attrNames [attrNo]] != null)
  608.                                 embedOutput += '<PARAM NAME="' + attrNames [attrNo] + '" VALUE="' + attribs [attrNames [attrNo]] + '">\n'
  609.                             ;
  610.                         }
  611.                         embedOutput += '</OBJECT>';
  612.                     }
  613. 0                } else {
  614.                     var tableDims = ' WIDTH=' + panelW + ' HEIGHT=' + panelH + ' HSPACE=' + attribs.HSPACE + ' VSPACE=' + attribs.VSPACE + ((attribs.ALIGN != null) ? (' ALIGN=' + attribs.ALIGN) : 'LEFT');
  615.                     if (Music.enabled && Music.clientSupported && Music.client.upgradable && (attribs.HIDDEN == null || attribs.HIDDEN.toUpperCase () != 'TRUE')) {
  616.                         var
  617.                             getPlayerText = (Music.hasPlayer ? 'Upgrade' : 'Get') + ' Beatnik!',
  618.                             getPlayerLink = '<A HREF="javascript://" ONCLICK="Music.installPlayer (); return false">'
  619.                         ;
  620.                         if (typeof (Music.getPlayerImagesPath) == 'string' && panelW == 144 && (panelH == 60 || panelH == 45 || panelH == 15)) {
  621.                             embedOutput = getPlayerLink + '<IMG SRC="' + Music.getPlayerImagesPath + 'get-player-' + panelW + 'x' + panelH + '.gif"' + tableDims + ' ALT="' + getPlayerText + '" BORDER=0></A>';
  622.                         } else {
  623.                             if (panelW >= 90 && panelH >= 15) embedOutput = '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR=FFFFFF' + tableDims + '><TR ALIGN=CENTER VALIGN=CENTER><TD>' + getPlayerLink + '<FONT FACE="ARIAL,HELVETICA,VERDANA" COLOR=000000 SIZE=' + ((panelH >= 30) ? '3' : '1')  + '>' + getPlayerText + '</FONT></A></TD></TR></TABLE>';
  624.                         }
  625.                     }
  626.                     if (embedOutput == '')
  627.                         embedOutput = '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0' + tableDims + '><TR><TD></TD></TR></TABLE>'
  628.                     ;
  629.                 }
  630.                 writeln (embedOutput);
  631.             }
  632.         }
  633.     }
  634. }
  635.  
  636. function mo_stubEmbed (stubURL) {
  637.     this.magicEmbed (((typeof (stubURL) != 'string') ? '' : ('SRC="' + stubURL + '" ')) + 'WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=TRUE LOOP=TRUE');
  638. }
  639.  
  640. function mo_preloadEmbed (fileURL,extraAttr) {
  641.     if (typeof (extraAttr) != 'string') extraAttr = '';
  642.     this.magicEmbed ('SRC="' + fileURL + '" WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=FALSE LOOP=FALSE VOLUME=100 ' + extraAttr);
  643. }
  644.  
  645. function mo_getNoteName (noteNumber) {
  646.     var noteNames = new Array ('C','C#','D','D#','E','F','F#','G','G#','A','A#','B');
  647.     return noteNames [noteNumber % 12] + (Math.floor (noteNumber / 12) - 1) + '';
  648. }
  649.  
  650. function mo_getNoteNumber (noteName) {
  651.     var
  652.         noteOffset = 'c-d-ef-g-a-b'.indexOf (noteName.charAt (0).toLowerCase ()),
  653.         result = 0,
  654.         sharpFlatOffset = 0
  655.     ;
  656.     if (noteOffset != -1) {
  657.         var sharpFlatPos = noteName.indexOf ('b',1);
  658.         if (sharpFlatPos == -1) {
  659.             sharpFlatPos = noteName.indexOf ('#',1);
  660.             if (sharpFlatPos == -1) sharpFlatPos = 0; else sharpFlatOffset = 1;
  661.         } else {
  662.             sharpFlatOffset = -1;
  663.         }
  664.         var octaveNo = noteName.substring (sharpFlatPos + 1) - 0;
  665.         result =  12 + octaveNo * 12 + noteOffset + sharpFlatOffset;
  666.     }
  667.     return Math.floor (result);
  668. }
  669.  
  670. function mo_Voice_free () {
  671.     with (this) {
  672.         clearTimeout (noteOffTimeout);
  673.         musicID.playerID.noteOff (channelNo,noteNo,127);
  674.         channelNo = 0;
  675.     }
  676. }
  677.  
  678. function mo_Voice (musicID,channelNo,noteNo) {
  679.     /*** Constructor Variables ***/
  680.     this.musicID = musicID;
  681.     this.channelNo = channelNo;
  682.     this.noteNo = noteNo;
  683.  
  684.     /*** Instance State Variables ***/
  685.     this.timeStamp = 0;
  686.     this.noteOffTimeout = setTimeout ('',0);
  687.  
  688.     /*** Object's Exposed Methods ***/
  689.     this.free = mo_Voice_free;
  690. }
  691.  
  692. function mo_defineMethodsNull () {
  693.     for (var argNo = 0; argNo < mo_defineMethodsNull.arguments.length; argNo++)
  694.         this [mo_defineMethodsNull.arguments [argNo]] = mo_null
  695.     ;
  696. }
  697.  
  698. function mo_defineMethodsMO () {
  699.     for (var argNo = 0; argNo < mo_defineMethodsMO.arguments.length; argNo++)
  700.         this [mo_defineMethodsMO.arguments [argNo]] = window ['mo_' + mo_defineMethodsMO.arguments [argNo]]
  701.     ;
  702. }
  703.  
  704. /*** Functions Mapped Directly to the Player ***/
  705.  
  706. function mo_doMenuItem (menuItemName) {this.playerID.doMenuItem (menuItemName)}
  707. function mo_engageAudio (audioState) {this.playerID.engageAudio (audioState)}
  708. function mo_getAutostart () {return this.playerID.getAutostart ()}
  709. function mo_getChannelMute (channelNo) {return this.playerID.getChannelMute (channelNo)}
  710. function mo_getChannelSolo (channelNo) {return this.playerID.getChannelSolo (channelNo)}
  711. function mo_getController (channelNo,controllerNo) {return this.playerID.getController (channelNo,controllerNo)}
  712. function mo_getFileSize () {return this.playerID.getFileSize ()}
  713. function mo_getInfo (infoField) {return this.playerID.getInfo (infoField)}
  714. function mo_getLoop () {return this.playerID.getLoop ()}
  715. function mo_getPanelDisplay () {return this.playerID.getPanelDisplay ()}
  716. function mo_getPanelMode () {return this.playerID.getPanelMode ()}
  717. function mo_getPlayLength () {return this.playerID.getPlayLength ()}
  718. function mo_getPosition () {return this.playerID.getPosition ()}
  719. function mo_getProgram (channelNo) {return this.playerID.getProgram (channelNo)}
  720. function mo_getReverbType () {return this.playerID.getReverbType ()}
  721. function mo_getTempo () {return this.playerID.getTempo ()}
  722. function mo_getTrackMute (trackNo) {return this.playerID.getTrackMute (trackNo)}
  723. function mo_getTrackSolo (trackNo) {return this.playerID.getTrackSolo (trackNo)}
  724. function mo_getTranspose () {return this.playerID.getTranspose ()}
  725. function mo_getTransposable (channelNo) {return this.playerID.getTransposable (channelNo)}
  726. function mo_setAutostart (state) {this.playerID.setAutostart (state)}
  727. function mo_setChannelSolo (channelNo,state) {this.playerID.setChannelSolo (channelNo,state)}
  728. function mo_setController (channelNo,controllerNo,controllerValue) {this.playerID.setController (channelNo,controllerNo,controllerValue)}
  729. function mo_setEndTime (endTime) {this.playerID.setEndTime (endTime)}
  730. function mo_setGlobalMute (muteState) {this.playerID.setGlobalMute (muteState)}
  731. function mo_setLoop (state) {this.playerID.setLoop (state)}
  732. function mo_setPanelDisplay (displayType) {this.playerID.setPanelDisplay (displayType)}
  733. function mo_setPanelMode (panelMode) {this.playerID.setPanelMode (panelMode)}
  734. function mo_setPosition (position) {this.playerID.setPosition (position)}
  735. function mo_setReverbType (reverbType) {this.playerID.setReverbType (reverbType)}
  736. function mo_setStartTime (startTime) {this.playerID.setStartTime (startTime)}
  737. function mo_setTempo (tempo) {this.playerID.setTempo (tempo)}
  738. function mo_setTrackMute (trackNo,state) {this.playerID.setTrackMute (trackNo,state)}
  739. function mo_setTrackSolo (trackNo,state) {this.playerID.setTrackSolo (trackNo,state)}
  740. function mo_setTranspose (transpose) {this.playerID.setTranspose (transpose)}
  741. function mo_setTransposable (channelNo,state) {this.playerID.setTransposable (channelNo,state)}
  742.  
  743. /*** Music Object Class Definition ***/
  744.  
  745. function Music (objectName) {
  746.     this.objectName = objectName;
  747.  
  748.     /*** Instance State Variables ***/
  749.     this.delayAutostart = false;
  750.     this.volFade_timeout = setTimeout ('',0);
  751.     this.volFade_step = 0;
  752.     this.volFade_time = 0;
  753.     this.volFade_timeElapsed = 0;
  754.     this.volFade_interval = 0;
  755.     this.volFade_fromVolume = 0;
  756.     this.volFade_volume = 0;
  757.     this.volFade_toVolume = 0;
  758.     this.volFade_endCallback = null;
  759.     this.volFade_inProgress = false;
  760.     this.volFade_restoreVolume = false;
  761.     this.monophonic = new Array (false,false,false,false,false,false,false,false,false,false,false,false,false,false,false);
  762.     this.ready = false;
  763.     this.playerID = null;
  764.     this.onLoadHandler = null;
  765.     this.onMetaEventHandler = null;
  766.     this.onPauseHandler = null;
  767.     this.onPlayHandler = null;
  768.     this.onStopHandler = null;
  769.     this.onReadyHandler = null;
  770.  
  771.     /*** Method Configuration Methods ***/
  772.     this.defineMethodsNull = mo_defineMethodsNull;
  773.     this.defineMethodsMO = mo_defineMethodsMO;
  774.  
  775.     /*** Initialisation ***/
  776.     this.defineMethodsNull ('doMenuItem','engageAudio','fadeTo','fadeFromTo','fadeVolume','getAutostart','getChannelMute','getChannelSolo','getController','getFileSize','getInfo','getLoop','getPanelDisplay','getPanelMode','getPlayLength','getPosition','getProgram','getReverbType','getTempo','getTrackMute','getTrackSolo','getTranspose','getTransposable','getVolume','isPaused','isPlaying','noteOff','noteOn','pause','play','playGroovoid','playNote','setAutostart','setChannelMute','setChannelSolo','setController','setEndTime','setGlobalMute','setLoop','setPanelDisplay','setPanelMode','setPosition','setProgram','setReverbType','setStartTime','setTempo','setTrackMute','setTrackSolo','setTranspose','setTransposable','setVolume','stop','stopAll');
  777.  
  778.     this.defineMethodsMO ('enable','endVolumeFade','execOnMetaEvent','execOnPause','execOnPlay','execOnReady','execOnStop','execVolumeFade','getMonophonic','getNoteName','getNoteNumber','getVersion','isReady','magicEmbed','onLoad','onMetaEvent','onPause','onPlay','onStop','preloadEmbed','onReady','setMonophonic','stubEmbed');
  779.  
  780.     window [objectName] = this;
  781.     Music.instances [Music.instances.length] = this;
  782. }
  783.  
  784. /*** Static Methods ***/
  785.  
  786. Music.execHandler = mo_execHandler;
  787. Music.getNoteName = mo_getNoteName;
  788. Music.getNoteNumber = mo_getNoteNumber;
  789. Music.magicEmbed = mo_magicEmbed;
  790. Music.installPlayer = mo_installBeatnik;
  791. Music.isPlayerCompatible = mo_isPlayerCompatible;
  792. Music.hasMinVersion = mo_hasMinVersion;
  793. Music.promptClose = mo_promptClose;
  794. Music.promptUser = mo_promptUser;
  795. musicObject = Music;
  796.  
  797. /*** Static Properties ***/
  798.  
  799. Music.enabled = true;
  800.  
  801. Music.requiredMinVersion = '';
  802. Music.silentIfInadequate = false;
  803. Music.showCompatibilityPrompt = true;
  804. Music.ignoreJavaDisabled = false;
  805.  
  806. Music.debugToJavaConsole = true;
  807. Music.debugToAlert = false;
  808. Music.debugToStatus = true;
  809. Music.ignoreNotReady = true;
  810.  
  811. /*** Static Read-only Properties ***/
  812.  
  813. Music.hasPlayer = false;
  814. Music.playerType = '';
  815. Music.playerVersion = '';
  816.  
  817. /*** Private Properties ***/
  818.  
  819. Music.absoluteMinVersion = '';
  820. Music.bodyEventsAdded = false;
  821. Music.globalNoteNo = 0;
  822. Music.minFadeInterval = 100;
  823. Music.storedHandlers = 0;
  824. Music.hasCallbackIssue = false;
  825. Music.instances = new Array ();
  826. Music.polyphony = 32;
  827. Music.voices = new Array ();
  828. Music.newVoice = new mo_Voice (null,0,0);
  829.  
  830. for (mo_voiceNo = 0; mo_voiceNo < Music.polyphony; mo_voiceNo++)
  831.     Music.voices [mo_voiceNo] = new mo_Voice (null,0,0)
  832. ;
  833.  
  834. /*** Debug Handling ***/
  835.  
  836. function mo_debug (errorMessage,errorURL,errorLineNo) {
  837.     var errorStr = '\n**** JAVASCRIPT ERROR ****\n    TYPE: ' + errorMessage + '\n    LINE# ' + errorLineNo + '\n    FILE: ' + errorURL + '\n';
  838.     if (Music.debugToJavaConsole && typeof (java) != 'undefined') java.lang.System.out.println (errorStr);
  839.     if (Music.debugToAlert) alert (errorStr);
  840.     if (Music.debugToStatus) window.defaultStatus = errorStr;
  841.     return true;
  842. }
  843.  
  844. function mo_enableDebug (windowHandle) {
  845.     windowHandle.onerror = mo_debug;
  846.     for (var frameNo = 0; frameNo < windowHandle.frames.length; frameNo++)
  847.         mo_enableDebug (windowHandle.frames [frameNo])
  848.     ;
  849. }
  850.  
  851. mo_enableDebug (top);
  852.  
  853. function mo_addEventHandler (windowHandle,objectID,eventType,handler) {
  854.     var storedHandlerStr = '';
  855.     if (typeof (objectID [eventType]) == 'function') {
  856.         if (typeof (windowHandle.mo_storedHandlers) == 'undefined') windowHandle.mo_storedHandlers = 0;
  857.         windowHandle.mo_storedHandlers++;
  858.         var storedHandler = 'mo_storedEventHandler' + mo_storedHandlers;
  859.         windowHandle [storedHandler] = objectID [eventType];
  860.         storedHandlerStr = '; return ' + storedHandler + ' (event)';
  861.     }
  862.     objectID [eventType] = windowHandle.eval ('new Function (\'event\',\'' + handler + storedHandlerStr + '\')');
  863. }
  864.  
  865. function mo_SupportedClient (_name,_platform,_minVersion,_upgradable) {
  866.     this.name = _name;
  867.     this.platform = _platform;
  868.     this.minVersion = _minVersion;
  869.     this.upgradable = _upgradable;
  870. }
  871.  
  872. Music.supportedClients = new Array (
  873.     new mo_SupportedClient ('Netscape','Win32','3.01',true),
  874.     new mo_SupportedClient ('Netscape','MacPPC','3.01',true),
  875.     new mo_SupportedClient ('Microsoft Internet Explorer','Win32','4.0',true),
  876.     new mo_SupportedClient ('WebTV Plus Receiver','WebTV','3.0',false),
  877.     new mo_SupportedClient ('WebTV Satellite Receiver','WebTV','3.0',false)
  878. );
  879.  
  880. with (navigator) {
  881.     if (mo_stringHasAny (userAgent,'Win95','Windows 95','WinNT','Windows NT','Win98','Windows 98')) {
  882.         Music.platform = 'Win32';
  883.     } else if (userAgent.indexOf ('PPC') != -1) {
  884.         Music.platform = 'MacPPC';
  885.     } else if (userAgent.indexOf ('WebTV') != -1) {
  886.         Music.platform = 'WebTV';
  887.     } else {
  888.         Music.platform = (typeof (platform) == 'undefined') ? 'Unknown' : platform;
  889.     }
  890.     Music.clientVersion = mo_retrieveVersion (appVersion);
  891.     Music.clientSupported = false;
  892.     for (mo_clientNo = 0; mo_clientNo < Music.supportedClients.length; mo_clientNo++) {
  893.         Music.client = Music.supportedClients [mo_clientNo];
  894.         if (Music.client.name == appName && Music.client.platform == Music.platform && mo_meetsMinVersion (Music.clientVersion,Music.client.minVersion)) {
  895.             Music.clientSupported = true;
  896.             break;
  897.         }
  898.     }
  899. }
  900.  
  901. function mo_checkForPlayer () {
  902.     if (Music.clientSupported) {
  903.         with (navigator) {
  904.             if (appName == 'Netscape' || appName == 'WebTV Internet Terminal') {
  905.                 Music.playerType = 'Plug-in';
  906.                 for (var pluginNo = 0; pluginNo < plugins.length; pluginNo++) {
  907.                     if (plugins [pluginNo].name.indexOf ('Beatnik') != -1 && plugins [pluginNo].name.indexOf ('Stub') == -1) {
  908.                         Music.playerVersion = mo_retrieveVersion (plugins [pluginNo].name);
  909.                         if (Music.playerVersion == '') {
  910.                             if (Music.platform == 'Mac') {
  911.                                 Music.playerVersion = '1.1.7';
  912.                             } else if (Music.platform == 'WebTV') {
  913.                                 Music.playerVersion = '0.9.0';
  914.                             }
  915.                         }
  916.                         Music.hasPlayer = true;
  917.                         break;
  918.                     }
  919.                 }
  920.                 Music.hasCallbackIssue = appName == 'Netscape' && Music.hasMinVersion ('1.3') && navigator.javaEnabled ();
  921.             } else if (appName == 'Microsoft Internet Explorer') {
  922.                 Music.playerType = 'ActiveX';
  923.                 document.writeln (
  924.                     '<OBJECT ID="mo_testInstance" CLASSID="CLSID:B384F118-18EE-11D1-95C8-00A024330339" WIDTH=1 HEIGHT=1>' +
  925.                     '<PARAM NAME="WIDTH" VALUE="1">' + 
  926.                     '<PARAM NAME="HEIGHT" VALUE="1">' + 
  927.                     '<PARAM NAME="AUTOSTART" VALUE="FALSE">' +
  928.                     '</OBJECT>'
  929.                 );
  930.                 Music.hasPlayer = typeof (document.mo_testInstance.getVersion) != 'undefined';
  931.                 if (Music.hasPlayer) Music.playerVersion = mo_retrieveVersion (document.mo_testInstance.getVersion ());
  932.                 Music.hasCallbackIssue = true;
  933.             }
  934.         }
  935.     }
  936. }
  937.  
  938. if (typeof (mo_delayPlayerCheck) == 'undefined') mo_checkForPlayer ();
  939.  
  940. /************************************
  941. Beatnik ActionSet - version 1.2.0
  942. written by C. van Rensburg
  943.  
  944. ⌐ Copyright 1997-1999 Beatnik, Inc.
  945. All  Rights Reserved
  946. *************************************/
  947.  
  948. Music.ignoreJavaDisabled = true;
  949. Music.debugToJavaConsole = false;
  950. Music.debugToStatus = false;
  951. B_enabled = false;
  952.  
  953. /*** Implementation section ***/
  954.  
  955. var
  956.     B_targetID = null,
  957.     B_bankNo,
  958.     B_programNo
  959. ;
  960.  
  961. function B_stripComment (paramToStrip) {
  962.     if (typeof (paramToStrip) == 'number') {
  963.         return paramToStrip;
  964.     } else {
  965.         if (paramToStrip == '' || '0123456789-'.indexOf (paramToStrip.charAt (0)) == -1) {
  966.             return paramToStrip;
  967.         } else {
  968.             var spacePos = paramToStrip.indexOf (' ');
  969.             return ((spacePos == -1) ? paramToStrip : paramToStrip.substring (0,spacePos)) - 0;
  970.         }
  971.     }
  972. }
  973.  
  974. function B_mapTo127 (value) {return Math.round (value / 100 * 127)}
  975.  
  976. function B_findTarget (_target,_fileURL) {
  977.     if (B_enabled) {
  978.         var playerNo;
  979.         if (_target != '' && (_target.charAt (0) != '[' || _target == '[reserved player]')) {
  980.             if (B_targetID == null || B_targetID.targetName != _target) {
  981.                 B_targetID = null;
  982.                 for (playerNo = 0; playerNo < Music.instances.length; playerNo++) {
  983.                     if (Music.instances [playerNo].targetName == _target) {
  984.                         B_targetID = Music.instances [playerNo];
  985.                         break;
  986.                     }
  987.                 }
  988.             }
  989.         } else {
  990.             B_targetID = null;
  991.         }
  992.         if (B_targetID == null) {
  993.             if (typeof (_fileURL) != 'string') _fileURL = _target;
  994.             for (playerNo = 0; playerNo < Music.instances.length; playerNo++) {
  995.                 if (Music.instances [playerNo].fileURL == _fileURL) {
  996.                     B_targetID = Music.instances [playerNo];
  997.                     break;
  998.                 }
  999.             }
  1000.         }
  1001.         return (B_targetID != null);
  1002.     } else return false;
  1003. }
  1004.  
  1005. function B_findAvailable () {
  1006.     for (var playerNo = 0; playerNo < Music.instances.length; playerNo++) {
  1007.         with (Music.instances [playerNo]) {
  1008.             if (targetName == '' && !isPlaying () && !isPaused ()) {
  1009.                 B_targetID = Music.instances [playerNo];
  1010.                 onPlay ();
  1011.                 onPause ();
  1012.                 onStop ();
  1013.                 onLoad ();
  1014.                 if (typeof (B_targetID.metaEventMap) != 'undefined') {
  1015.                     onMetaEvent ();
  1016.                     for (var eventNo = 0; eventNo < metaEventMap.length; eventNo++)
  1017.                         metaEventMap [eventNo].active = false
  1018.                     ;
  1019.                 }
  1020.                 break;
  1021.             }
  1022.         }
  1023.     }
  1024. }
  1025.  
  1026. function B_evalPanStr (panStr) {
  1027.     panStr = B_stripComment (panStr);
  1028.     if (typeof (panStr) == 'number') {
  1029.         return panStr;
  1030.     } else {
  1031.         if (panStr == ')- CENTER -(') {
  1032.             return 64;
  1033.         } else if (panStr.indexOf ('+') != -1) {
  1034.             return Math.round (((panStr.indexOf ('+') - 2) / (panStr.length - 5)) * 127);
  1035.         }
  1036.     }
  1037. }
  1038.  
  1039. function B_constrain (newValue,minValue,maxValue) {
  1040.     return (newValue < minValue) ? minValue : ((newValue > maxValue) ? maxValue : newValue);
  1041. }
  1042.  
  1043. function B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial) {
  1044.     if (_iGM + '' > ' ') {
  1045.         B_bankNo = 0;
  1046.         B_programNo = B_stripComment (_iGM);
  1047.     } else if (_iSpecial + '' > ' ') {
  1048.         B_bankNo = 1;
  1049.         B_programNo = B_stripComment (_iSpecial);
  1050.     } else if (_iUser + '' > ' ') {
  1051.         B_bankNo = 2;
  1052.         B_programNo = _iUser - 0;
  1053.     } else if (_pGM + '' > ' ') {
  1054.         B_bankNo = 0;
  1055.         B_programNo = 128 + B_stripComment (_pGM);
  1056.     } else if (_pSpecial + '' > ' ') {
  1057.         B_bankNo = 1;
  1058.         B_programNo = 128 + B_stripComment (_pSpecial);
  1059.     } else {
  1060.         B_bankNo = -1;
  1061.     }
  1062. }
  1063.  
  1064. function B_channelNo (_channelNo) {
  1065.     with (B_targetID) {
  1066.         if (_channelNo == '[auto]') {
  1067.             autoChannelNo = (autoChannelNo % 16) + 1;
  1068.             if (autoChannelNo == 10) autoChannelNo = 11;
  1069.             B_channelNumber = autoChannelNo;
  1070.         } else {
  1071.             B_channelNumber = B_stripComment (_channelNo);
  1072.         }
  1073.     }
  1074. }
  1075.  
  1076. function B_playFile (_targetName,_looping,_fileURL,_volume) {
  1077.     if (B_enabled) {
  1078.         if (!B_findTarget (_targetName,_fileURL)) B_findAvailable ();
  1079.         if (B_targetID != null) {
  1080.             with (B_targetID) {
  1081.                 if (_targetName != '' && _targetName.charAt (0) != '[') targetName = _targetName;
  1082.                 setAutostart (true);
  1083.                 setVolume (B_stripComment (_volume));
  1084.                 if (fileURL == _fileURL || _fileURL == '') {
  1085.                     stop ();
  1086.                     play (_looping == 'yes' || (_looping == 'auto' && fileURL.indexOf ('Background-') == 0));
  1087.                 } else {
  1088.                     fileURL = _fileURL;
  1089.                     play (_looping,fileURL);
  1090.                 }
  1091.             }
  1092.         }
  1093.     }
  1094. }
  1095.  
  1096. function B_pauseFile (_targetName,_fileURL,_fadeTime) {
  1097.     if (B_findTarget (_targetName,_fileURL)) B_targetID.pause (_fadeTime);
  1098. }
  1099.  
  1100. function B_stopFile (_targetName,_fileURL,_fadeTime) {
  1101.     if (B_findTarget (_targetName,_fileURL)) B_targetID.stop (_fadeTime);
  1102. }
  1103.  
  1104. b_playGroovoid = B_playFile;
  1105. b_pauseGroovoid = B_pauseFile;
  1106. b_stopGroovoid = B_stopFile;
  1107.  
  1108. b_playMusicFile = B_playFile;
  1109. b_pauseMusicFile = B_pauseFile;
  1110. b_stopMusicFile = B_stopFile;
  1111.  
  1112. function b_preloadMusicFile (_target,_fileURL) {
  1113.     if (B_enabled && _fileURL != '') {
  1114.         if (!B_findTarget (_target,_fileURL)) B_findAvailable ();
  1115.         if (B_targetID != null) {
  1116.             with (B_targetID) {
  1117.                 if (_target != '' && _target.charAt (0) != '[') targetName = _target;
  1118.                 if (fileURL != _fileURL) {
  1119.                     fileURL = _fileURL;
  1120.                     setAutostart (false);
  1121.                     play (false,_fileURL);
  1122.                 }
  1123.             }
  1124.         }
  1125.     }
  1126. }
  1127.  
  1128. function b_playMusicalNote (_target,_channelNo,_iGM,_iSpecial,_iUser,_pGM,_pSpecial,_note,_velocity,_duration,_volume,_pan) {
  1129.     if (B_findTarget (_target)) {
  1130.         B_channelNo (_channelNo);
  1131.         B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial);
  1132.         with (B_targetID) {
  1133.             setController (B_channelNumber,7,B_mapTo127 (B_stripComment (_volume)));
  1134.             setController (B_channelNumber,10,B_evalPanStr (_pan));
  1135.             if (B_bankNo == -1)
  1136.                 playNote (B_channelNumber,B_stripComment (_note),B_mapTo127 (B_stripComment (_velocity)),_duration);
  1137.                 else playNote (B_channelNumber,B_bankNo,B_programNo,B_stripComment (_note),B_mapTo127 (B_stripComment (_velocity)),_duration);
  1138.         }
  1139.     }
  1140. }
  1141.  
  1142. function b_stopMusicalNote (_target,_channelNo,_note) {
  1143.     if (B_findTarget (_target)) B_targetID.noteOff (B_stripComment (_channelNo),B_stripComment (_note));
  1144. }
  1145.  
  1146. function b_setGlobalMute (_status) {
  1147.     if (B_enabled) Music.instances [0].setGlobalMute (_status == 'Mute');
  1148. }
  1149.  
  1150. function b_setReverbType (_reverbType) {
  1151.     if (B_enabled) Music.instances [0].setReverbType (B_stripComment (_reverbType));
  1152. }
  1153.  
  1154. function b_setVolume (_target,_volume,_fadeTime) {
  1155.     if (B_findTarget (_target)) B_targetID.fadeVolume (null,B_stripComment (_volume),_fadeTime);
  1156. }
  1157.  
  1158. function b_adjustVolume (_target,_adjustBy,_fadeTime) {
  1159.     if (B_findTarget (_target)) {
  1160.         with (B_targetID) fadeVolume (null,B_constrain (getVolume () + _adjustBy,0,100),_fadeTime);
  1161.     }
  1162. }
  1163.  
  1164. function b_setTransposition (_target,_transposition) {
  1165.     if (B_findTarget (_target)) B_targetID.setTranspose (B_stripComment (_transposition));
  1166. }
  1167.  
  1168. function b_adjustTransposition (_target,_adjustBy) {
  1169.     if (B_findTarget (_target)) {
  1170.         with (B_targetID) setTranspose (B_constrain (getTranspose () + B_stripComment (_adjustBy),-48,48));
  1171.     }
  1172. }
  1173.  
  1174. function b_setTempo (_target,_tempo) {
  1175.     if (B_findTarget (_target)) B_targetID.setTempo (_tempo);
  1176. }
  1177.  
  1178. function b_adjustTempo (_target,_adjustBy) {
  1179.     if (B_findTarget (_target)) {
  1180.         with (B_targetID) setTempo (B_constrain (getTempo () + _adjustBy,10,250));
  1181.     }
  1182. }
  1183.  
  1184. function b_setPosition (_target,_position) {
  1185.     if (B_findTarget (_target)) B_targetID.setPosition (_position);
  1186. }
  1187.  
  1188. function b_adjustPosition (_target,_adjustBy) {
  1189.     if (B_findTarget (_target)) {
  1190.         with (B_targetID) setPosition (B_constrain (getPosition () + (_adjustBy),0,10000000));
  1191.     }
  1192. }
  1193.  
  1194. function b_showCopyrightInfo (_target) {
  1195.     if (B_findTarget (_target)) B_targetID.doMenuItem ('Copyright');
  1196. }
  1197.  
  1198. function b_releasePlayer (_target) {
  1199.     if (B_findTarget (_target)) B_targetID.targetName = '';
  1200. }
  1201.  
  1202. function b_setChannelInstrument (_target,_channelNo,_iGM,_iSpecial,_iUser,_pGM,_pSpecial) {
  1203.     if (B_enabled) {
  1204.         B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial);
  1205.         if (B_findTarget (_target) && B_bankNo != -1)
  1206.             B_targetID.setProgram (B_stripComment (_channelNo),B_bankNo,B_programNo)
  1207.         ;
  1208.     }
  1209. }
  1210.  
  1211. function b_setChannelVolume (_target,_channelNo,_volume) {
  1212.     if (B_findTarget (_target))
  1213.         B_targetID.setController (B_stripComment (_channelNo),7,B_mapTo127 (B_stripComment (_volume)))
  1214.     ;
  1215. }
  1216.  
  1217. function b_adjustChannelVolume (_target,_channelNo,_adjustBy) {
  1218.     if (B_findTarget (_target)) {
  1219.         with (B_targetID)
  1220.             B_channelNo (_channelNo);
  1221.             setController (B_channelNumber,7,B_constrain (getController (B_channelNumber,7) + B_mapTo127 (_adjustBy),0,127));
  1222.     }
  1223. }
  1224.  
  1225. function b_setChannelPan (_target,_channelNo,_pan) {
  1226.     if (B_findTarget (_target))
  1227.         B_targetID.setController (B_stripComment (_channelNo),10,B_evalPanStr (_pan))
  1228.     ;
  1229. }
  1230.  
  1231. function b_adjustChannelPan (_target,_channelNo,_adjustBy) {
  1232.     if (B_findTarget (_target)) {
  1233.         with (B_targetID)
  1234.             B_channelNo (_channelNo);
  1235.             setController (B_channelNumber,10,B_constrain (getController (B_channelNumber,10) + Math.round (_adjustBy / 200 * 127),0,127));
  1236.     }
  1237. }
  1238.  
  1239. function b_setChannelMute (_target,_channelNo,_status) {
  1240.     if (B_findTarget (_target)) {
  1241.         _channelNo = B_stripComment (_channelNo);
  1242.         if (_status == 'Toggle')
  1243.             B_targetID.setChannelMute (_channelNo,!B_targetID.getChannelMute (_channelNo));
  1244.             else B_targetID.setChannelMute (_channelNo,_status == 'Mute');
  1245.     }
  1246. }
  1247.  
  1248. function b_setChannelSolo (_target,_channelNo,_status) {
  1249.     if (B_findTarget (_target)) {
  1250.         _channelNo = B_stripComment (_channelNo);
  1251.         if (_status == 'Toggle')
  1252.             B_targetID.setChannelSolo (_channelNo,!B_targetID.getChannelSolo (_channelNo));
  1253.             else B_targetID.setChannelSolo (_channelNo,_status == 'Solo');
  1254.     }
  1255. }
  1256.  
  1257. function b_setChannelMonophonic (_target,_channelNo,_status) {
  1258.     if (B_findTarget (_target)) {
  1259.         _channelNo = B_stripComment (_channelNo);
  1260.         if (_status == 'Toggle')
  1261.             B_targetID.setMonophonic (_channelNo,!B_targetID.getMonophonic (_channelNo));
  1262.             else B_targetID.setMonophonic (_channelNo,_status == 'Monophonic');
  1263.     }
  1264. }
  1265.  
  1266. function b_setTrackMute (_target,_trackNo,_status) {
  1267.     if (B_findTarget (_target)) {
  1268.         if (_status == 'Toggle')
  1269.             B_targetID.setTrackMute (_trackNo,!B_targetID.getTrackMute (_trackNo));
  1270.             else B_targetID.setTrackMute (_trackNo,_status == 'Mute');
  1271.     }
  1272. }
  1273.  
  1274. function b_setTrackSolo (_target,_trackNo,_status) {
  1275.     if (B_findTarget (_target)) {
  1276.         if (_status == 'Toggle')
  1277.             B_targetID.setTrackSolo (_trackNo,!B_targetID.getTrackSolo (_trackNo));
  1278.             else B_targetID.setTrackSolo (_trackNo,_status == 'Solo');
  1279.     }
  1280. }
  1281.  
  1282. /*** Initialisation Section ***/
  1283.  
  1284. function b_initialize (stubFileURL,totalPlayers) {
  1285.     mo_checkForPlayer ();
  1286.     B_enabled = Music.isPlayerCompatible ('1.3',true,false);
  1287.     if (B_enabled) {
  1288.         if (typeof (totalPlayers) != 'number') totalPlayers = 8;
  1289.         var stubSrc = (typeof (stubFileURL) == 'string' && stubFileURL != '') ? (' SRC="' + stubFileURL + '"') : '';
  1290.         for (var playerNo = 0; playerNo < totalPlayers; playerNo++) {
  1291.             var player = new Music ('B_playerMO' + Music.instances.length);
  1292.             player.fileURL = stubFileURL;
  1293.             player.autoChannelNo = 0;
  1294.             player.targetName = (playerNo == 0) ? '[reserved player]' : '';
  1295.             player.magicEmbed (stubSrc + ' WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=' + (playerNo == 0) + ' VOLUME=100');
  1296.         }
  1297.     }
  1298. }
  1299.  
  1300. /*** Frameset Authoring for Dreamweaver ***/
  1301.  
  1302. function b_enablePeer () {}
  1303.