mo_delayPlayerCheck = true;

/***************************************
Music Object - Version 3.0.8
written by Chris van Rensburg

© Copyright 1996-1999 Beatnik, Inc.
All  Rights Reserved
***************************************/

function mo_indexOf (sourceStr,searchStr,startPos) {
	var result = sourceStr.indexOf (searchStr,startPos);
	return (result != -1) ? result : sourceStr.length;
}

function mo_stringHasAny (sourceStr) {
	for (var argNo = 1; argNo < mo_stringHasAny.arguments.length; argNo++) {
		if (sourceStr.indexOf (mo_stringHasAny.arguments [argNo]) != -1) return true;
	}
	return false;
}

function mo_null () {
	if (this.ready)
		mo_debug ('Attempted to use a method not supported in this version of the Beatnik Player.',window.location.href,'unknown');
		else if (!Music.ignoreNotReady) mo_debug ('Music Object instance "' + this.objectName + '" is not yet ready for scripting control.',window.location.href,'unknown');
}

function mo_execHandler (callbackHandler) {
	if (typeof (callbackHandler) == 'string') eval (callbackHandler);
		else if (typeof (callbackHandler) == 'function') callbackHandler ();
}

function mo_play (p1,p2) {
	with (this) {
		endVolumeFade ();
		if (typeof (p2) == 'string') {
			if (p2.indexOf ('.') == -1 && p2.indexOf ('groovoid://') != 0) p2 = 'groovoid://' + p2;
			if (typeof (p1) == 'string') p1 = (p1 == 'auto') ? (p2.indexOf ('groovoid://Background-') == 0) : (p1 == 'yes');
			playerID.play (p1,p2);
		} else if (typeof (p1) == 'boolean' || typeof (p1) == 'number') {
			playerID.play (p1);
		} else if (typeof (p1) == 'string') {
			play ('auto',p1);
		} else {
			if (!playerID.isPlaying ()) playerID.play ();
		}
	}
}

function mo_stop (fade) {
	with (this) {
		if (typeof (fade) == 'undefined') {
			endVolumeFade ();
			playerID.stop ();
		} else {
			if (isPaused ()) {
				endVolumeFade ();
				playerID.stop ();
			} else {
				fadeVolume (null,0,fade,objectName + '.stop ()');
			}
		}
	}
}

function mo_stopAll () {
	with (this) {
		endVolumeFade ();
		playerID.stopAll ();
	}
}

function mo_pause (fade) {
	with (this) {
		endVolumeFade ();
		if (isPaused ()) {
			playerID.pause ();
			if (typeof (fade) == 'number') fadeVolume (0,100,fade);
		} else {
			if (typeof (fade) != 'number') playerID.pause ();
				else fadeVolume (null,0,fade,objectName + '.pause ()');
		}
	}
}

function mo_endVolumeFade () {
	with (this) {
		if (volFade_inProgress) {
			clearTimeout (volFade_timeout);
			volFade_inProgress = false;
			Music.execHandler (volFade_endCallback);
			if (volFade_restoreVolume) setVolume (volFade_fromVolume);
		}
	}
}

function mo_execVolumeFade () {
	with (this) {
		volFade_volume += volFade_step;
		setVolume (Math.round (volFade_volume));
		volFade_timeElapsed += volFade_interval;
		Music.execHandler (volFade_advanceCallback);
		if (volFade_timeElapsed >= volFade_time) {
			setVolume (volFade_toVolume);
			endVolumeFade ();
		} else {
			volFade_timeout = setTimeout (objectName + '.execVolumeFade ()',volFade_interval);
		}
	}
}

function mo_fadeVolume (fromVolume,toVolume,fadeTime,fadeEndCallback,fadeAdvanceCallback) {
	with (this) {
		if (typeof (fromVolume) != 'number') fromVolume = getVolume ();
		if (typeof (toVolume) != 'number') toVolume = 0;
		if (typeof (fadeTime) == 'boolean') fadeTime = fadeTime ? 1000:0;
		if (typeof (fadeTime) != 'number') fadeTime = 1000;
		if (
			volFade_inProgress &&
			toVolume == volFade_toVolume &&
			fadeTime == volFade_time
		) {
			volFade_endCallback = fadeEndCallback;
			volFade_advanceCallback = fadeAdvanceCallback;
		} else {
			volFade_restoreVolume = typeof (fadeEndCallback) == 'string' && (fadeEndCallback.indexOf ('.stop ()') != -1 || fadeEndCallback.indexOf ('.pause ()') != -1);
			endVolumeFade ();
			if (fadeTime != 0 && fadeTime < Music.minFadeInterval)
				fadeTime = Math.round (fadeTime / Music.minFadeInterval) * Music.minFadeInterval
			;
			if (fadeTime == 0 || toVolume == fromVolume) {
				if (!volFade_restoreVolume)	setVolume (toVolume);
				Music.execHandler (fadeEndCallback);
			} else {
				volFade_fromVolume = fromVolume;
				volFade_toVolume = toVolume;
				volFade_time = fadeTime;
				volFade_endCallback = fadeEndCallback;
				volFade_advanceCallback = fadeAdvanceCallback;
				volFade_timeElapsed = 0;
				volFade_volume = fromVolume;
				volFade_inProgress = true;
				volFade_interval = Math.max (Math.ceil (volFade_time / Math.abs (toVolume - fromVolume)),Music.minFadeInterval);
				volFade_step = (toVolume - fromVolume) / (volFade_time / volFade_interval);
				setVolume (fromVolume);
				volFade_timeout = setTimeout (objectName + '.execVolumeFade ()',volFade_interval);
			}
		}
	}
}

function mo_fadeTo (toValue,fadeTime,fadeEndCallback,fadeAdvanceCallback) {
	this.fadeVolume (null,toValue,fadeTime,fadeEndCallback,fadeAdvanceCallback);
}

function mo_enable () {
	with (this) {
		if (typeof (window [playerName]) == 'object') {
			playerID = window [playerName];
		} else if (typeof (document [playerName]) == 'object') {
			playerID = document [playerName];
		} else {
			for (var formNo = 0; formNo < document.forms.length; formNo++) {
				formHandle = document.forms [formNo];
				if (typeof (formHandle [playerName]) == 'object') {
					playerID = formHandle [playerName];
					break;
				}
			}
		}
		if (playerID != null) {
			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');
			fadeFromTo = fadeVolume;
			playGroovoid = play;
			playNote = noteOn;
			if (Music.playerVersion == '') Music.playerVersion = mo_retrieveVersion (playerID.getVersion () + '');
			if (Music.hasMinVersion ('1.3'))
				defineMethodsMO ('doMenuItem','engageAudio','getFileSize','getPlayLength','getPosition','getTransposable','setEndTime','setPosition','setStartTime','setTransposable','stopAll')
			;
			if (typeof (onMetaEventHandler) == 'function') playerID.enableMetaEvents (true);
			if (Music.hasCallbackIssue) {
				playerID.enableCallbacks (true);
			} else {
				execOnReady ();
			}
		} else {
			setTimeout (objectName + '.enable ()',500);
		}
	}
}

function mo_execOnReady () {
	with (this) {
		if (ready) {
			if (Music.playerType == 'ActiveX') playerID.receivedReady (true);
		} else {
			ready = playerID != null;
			if (ready) {
				if (Music.playerType == 'ActiveX') playerID.receivedReady (true);
				if (delayAutostart) {
					setAutostart (true);
					play ();
				}
				Music.execHandler (onReadyHandler);
			} else {
				enable ();
			}
		}
		if (ready) Music.execHandler (onLoadHandler);
	}
}

function mo_setMonophonic (channelNo,state) {
	with (this) {
		if (channelNo == 0)
			for (var channelCount = 0; channelCount < 16; channelCount++) monophonic [channelCount] = state;
			else monophonic [channelNo - 1] = state;
	}
}

function mo_getMonophonic (channelNo) {return this.monophonic [channelNo - 1]}

function mo_noteOn (_channelNo,p2,p3,p4,p5,p6) {
	var voiceNo;
	with (this) {
		if (mo_noteOn.arguments.length >= 5) {
			if (monophonic [_channelNo - 1]) noteOff (_channelNo);
			if (typeof (p4) == 'string') p4 = getNoteNumber (p4);
			Music.globalNoteNo++;
			with (Music.newVoice) {
				musicID = this;
				timeStamp = Music.globalNoteNo;
				channelNo = _channelNo;
				noteNo = p4;
			}
			var assignToVoiceNo = -1;
			for (voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
				with (Music.voices [voiceNo]) {
					if (channelNo == 0) {
						assignToVoiceNo = voiceNo;
						break;
					}
				}
			}
			if (assignToVoiceNo == -1) {
				assignToVoiceNo = 0;
				for (voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
					if (Music.voices [voiceNo].timeStamp < Music.voices [assignToVoiceNo].timeStamp)
						assignToVoiceNo = voiceNo
					;
				}
			}
			with (Music.voices [assignToVoiceNo]) {
				musicID = Music.newVoice.musicID;
				timeStamp = Music.newVoice.timeStamp;
				channelNo = Music.newVoice.channelNo;
				noteNo = Music.newVoice.noteNo;
				if (p2 >= 0 && p3 >= 0) playerID.noteOn (channelNo,p2,p3,p4,p5);
					else playerID.noteOn (channelNo,p4,p5);
				if (typeof (p6) == 'number') noteOffTimeout = setTimeout ('Music.voices [' + assignToVoiceNo + '].free ()',p6);
			}
		} else {
			noteOn (_channelNo,-1,-1,p2,p3,(typeof (p4) != 'number') ? null : p4);
		}
	}
}

function mo_noteOff (_channelNo,_noteNo) {
	with (this) {
		if (typeof (_noteNo) == 'undefined') {
			for (var voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
				with (Music.voices [voiceNo])
					if (musicID == this && channelNo == _channelNo) free ()
				;
			}
		} else {
			if (typeof (_noteNo) == 'string') _noteNo = getNoteNumber (_noteNo);
			for (var voiceNo = 0; voiceNo < Music.polyphony; voiceNo++) {
				with (Music.voices [voiceNo]) {
					if (musicID == this && channelNo == _channelNo && noteNo == _noteNo) {
						free ();
						break;
					}
				}
			}
		}
	}
}

function mo_setProgram (channelNo,p2,p3) {
	with (this) {
		if (typeof (p3) == 'number') playerID.setProgram (channelNo,p2,p3);
			else playerID.setProgram (channelNo,p2);
	}
}

function mo_setChannelMute (channelNo,state) {
	with (this) {
		if (channelNo == 0) {
			for (var channelCount = 1; channelCount <= 16; channelCount++)
				playerID.setChannelMute (channelCount,state)
			;
		} else {
			playerID.setChannelMute (channelNo,state)
		}
	}
}

function mo_isReady () {return this.ready}

function mo_onLoad (onLoadHandler) {this.onLoadHandler = onLoadHandler}
function mo_onPause (onPauseHandler) {this.onPauseHandler = onPauseHandler}
function mo_onPlay (onPlayHandler) {this.onPlayHandler = onPlayHandler}
function mo_onReady (onReadyHandler) {this.onReadyHandler = onReadyHandler}
function mo_onStop (onStopHandler) {this.onStopHandler = onStopHandler}

function mo_onMetaEvent (_onMetaEventHandler) {
	with (this) {
		onMetaEventHandler = _onMetaEventHandler;
		if (ready) playerID.enableMetaEvents (typeof (onMetaEventHandler) == 'function');
	}
}

function mo_execOnPause () {
	with (this) {
		endVolumeFade ();
		Music.execHandler (this.onPauseHandler);
	}
}

function mo_execOnPlay () {
	with (this) {
		setVolume (VOLUME);
		Music.execHandler (onPlayHandler);
	}
}

function mo_execOnStop () {
	with (this) {
		endVolumeFade ();
		Music.execHandler (onStopHandler);
	}
}

function mo_execOnMetaEvent (eventType,eventValue) {
	with (this)
		if (onMetaEventHandler != null) onMetaEventHandler (eventType,eventValue,this)
	;
}

function mo_setVolume (_volume) {
	with (this) {
		VOLUME = _volume;
		playerID.setVolume (_volume);
	}
}

function mo_getVersion () {return Music.playerVersion}
function mo_getVolume () {return this.VOLUME}

function mo_isPaused () {return this.playerID.IsPaused ()}
function mo_isPlaying () {return this.playerID.IsPlaying ()}

function mo_promptClose () {
	if (typeof (Music.promptWindow) == 'object') Music.promptWindow.close ();
	window.focus ();
}

function mo_promptUser (heading,message,okText,okAction,cancelText,cancelAction,showStatus) {
	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');
	if (typeof (okAction) != 'string' || okAction == '') okAction = 'Music.promptClose ()';
	if (typeof (cancelAction) != 'string' || cancelAction == '') cancelAction = 'Music.promptClose ()';
	if (typeof (heading) != 'string') heading = '';
	with (Music.promptWindow.document) {
		open ('text/html');
		writeln (
			'<HTML><HEAD><TITLE>' + heading + '</TITLE></HEAD><BODY BGCOLOR=002244 TEXT=CCCCCC>' +
			'<FORM><TABLE WIDTH=100% HEIGHT=100% BORDER=1 CELLSPACING=10 CELLPADDING=6 BGCOLOR=000000>'
		);
		if (heading != '') writeln ('<TR><TD ALIGN=CENTER BGCOLOR=0088AA><FONT FACE="ARIAL,HELVETICA,VERDANA" COLOR=000000 SIZE=5>' + heading + '</FONT></U><BR></TD></TR>');
		writeln (
			'<TR><TD VALIGN=TOP><FONT FACE="ARIAL,HELVETICA,VERDANA" SIZE=3>' + message + '<P></FONT>' +
			'<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=LEFT>'
		);
		if (typeof (cancelText) == 'string' && cancelText != '')
			writeln ('<INPUT TYPE=button VALUE="' + cancelText + '" ONCLICK="with (window.opener) {' + cancelAction + '}">')
		;
		writeln ('</TD><TD ALIGN=RIGHT>');
		if (typeof (okText) == 'string' && okText != '')
			writeln ('<INPUT TYPE=button VALUE="' + okText + '" ONCLICK="with (window.opener) {' + okAction + '}">')
		;
		writeln ('</TD></TR></TABLE></TD></TR></TABLE></FORM></BODY></HTML>');
		close ();
		if (typeof (Event) != 'undefined') {
			Music.promptWindow.captureEvents (Event.KEYUP);
			Music.promptWindow.onKeyUp = new Function ('event','if (event.which == 13) {' + okAction + '} else if (event.which == 27) {' + cancelAction + '}; return false');
			Music.promptWindow.focus ();
		}
	}
}

function mo_installBeatnik () {
	Music.promptWindow = window.open ('http://www.headspace.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');
}

function mo_retrieveVersion (appName) {
	var
		versionStr = '',
		numerals = '0123456789',
		charNo = appName.length - 1,
		currentChar,
		inVersion = false,
		parensLevel = 0
	;
	while (charNo >= 0) {
		currentChar = appName.charAt (charNo);
		if (currentChar == ')') {
			parensLevel++;
		} else if (currentChar == '(') {
			parensLevel--;
		} else if (parensLevel == 0) {
			if (inVersion || numerals.indexOf (currentChar) != -1) {
				inVersion = true;
				if (currentChar == ' ') charNo = 0;
					else if (currentChar == '.' || numerals.indexOf (currentChar) != -1) versionStr = currentChar + versionStr;
			}
		}
		charNo--;
	}
	return versionStr;
}

function mo_meetsMinVersion (versionToTest,minRequiredVersion) {
	var
		versionA = mo_retrieveVersion (versionToTest),
		versionB = mo_retrieveVersion (minRequiredVersion)
	;
	if (versionA.length < versionB.length) versionA += '.0.0.0.0.0.0.0.0.0.0.0.0'.substring (0,versionB.length - versionA.length);
	return versionA >= versionB;
}

function mo_hasMinVersion (minRequiredVersion) {
	return mo_meetsMinVersion (Music.playerVersion,minRequiredVersion);
}

function mo_isPlayerCompatible (minVersion,silentIfInadequate,showCompatibilityPrompt) {
	if (Music.clientSupported) {
		if (typeof (silentIfInadequate) == 'boolean') Music.silentIfInadequate = silentIfInadequate;
		if (typeof (showCompatibilityPrompt) == 'boolean') Music.showCompatibilityPrompt = showCompatibilityPrompt;
		if (typeof (minVersion) == 'string') Music.requiredMinVersion = minVersion;
		if (Music.hasPlayer) {
			if (Music.hasMinVersion (Music.requiredMinVersion)) {
				return true;
			} else {
				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 ()');
				return false;
			}
		} else {
			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 ()');
			return false;
		}
	} else return false;
}

function mo_requireJava () {
	Music.ignoreJavaDisabled = true;
	if (Music.clientSupported && Music.client.name == 'Netscape' && !navigator.javaEnabled ()) {
		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 ()');
	}
}

function mo_magicEmbed (attrList) {
	if (typeof (Music.playerCompatible) != 'boolean') Music.playerCompatible = Music.isPlayerCompatible (Music.requiredMinVersion,null,Music.showCompatibilityPrompt);
	var
		subChar,
		isMethod = typeof (this.playerID) != 'undefined',
		attribs = isMethod ? this : Music,
		attrNames = new Array ('SRC','WIDTH','HEIGHT','AUTOSTART','LOOP','VOLUME','ALIGN','HSPACE','VSPACE','BGCOLOR','HIDDEN','DISPLAY','MODE','GROOVOID','ONREADY','ONPLAY','ONPAUSE','ONSTOP','ONMETAEVENT','CALLBACKS','METAEVENTS')
	;
	if (typeof (this.playerName) != 'string' || !isMethod) {
		for (var attrNo = 0; attrNo < attrNames.length; attrNo++) attribs [attrNames [attrNo]] = null;
		with (this) {
			if (isMethod) {
				this.playerName = objectName + 'Player';
				var prefix = objectName + '.execOn';
				attribs.ONREADY = prefix + 'Ready()';
				attribs.ONPLAY = prefix + 'Play()';
				attribs.ONPAUSE = prefix + 'Pause()';
				attribs.ONSTOP = prefix + 'Stop()';
				attribs.ONMETAEVENT = prefix + 'MetaEvent()';
				attribs.METAEVENTS = 'FALSE';
			}
			attribs.AUTOSTART = 'TRUE';
			attribs.WIDTH = '144';
			attribs.HEIGHT = '60';
			attribs.HSPACE = '0';
			attribs.VSPACE = '0';
			attribs.BGCOLOR = document.bgColor;
			attribs.VOLUME = '100';

			var
				tagEndFound = false,
				attrStartPos = 0
			;
			while (!tagEndFound && attrStartPos < attrList.length) {
				var attrFound = false;
				while (!attrFound && attrStartPos < attrList.length) {
					attrFound = attrList.charAt (attrStartPos) != ' ';
					if (!attrFound) attrStartPos++;
				}
				if (attrFound) {
					var
						equalPos = mo_indexOf (attrList,'=',attrStartPos),
						spacePos = mo_indexOf (attrList,' ',attrStartPos),
						closePos = mo_indexOf (attrList,'>',attrStartPos),
						attrNameEndPos = Math.min (Math.min (spacePos,equalPos),closePos),
						hasValue = attrNameEndPos != spacePos && attrNameEndPos != closePos,
						attrName = attrList.substring (attrStartPos,attrNameEndPos).toUpperCase (),
						attrValueEndPos = attrNameEndPos,
						attrValue = ''
					;
					tagEndFound = closePos == attrNameEndPos;
					if (hasValue) {
						var
							attrValuePos = attrNameEndPos + 1,
							quoteChar = attrList.charAt (attrValuePos)
						;
						if (quoteChar == '"' || quoteChar == "'") {
							attrValuePos++;
							attrValueEndPos = attrValuePos;
							var attrValueEndFound = false;
							while (!attrValueEndFound && attrValueEndPos < attrList.length - 1) {
								attrValueEndPos = mo_indexOf (attrList,quoteChar,attrValueEndPos + 1);
								attrValueEndFound = true;
								var
									checkingEscape = true,
									charPos = attrValueEndPos
								;
								while (checkingEscape) {
									charPos--;
									checkingEscape = attrList.charAt (charPos) == '\\';
									if (checkingEscape) attrValueEndFound = !attrValueEndFound;
								}
							}
						} else {
							attrValueEndPos = Math.min (mo_indexOf (attrList,' ',attrValuePos),mo_indexOf (attrList,'>',attrValuePos));
						}
						attrValue = attrList.substring (attrValuePos,attrValueEndPos);
					}
					attrStartPos = attrValueEndPos + 1;
					attribs [attrName] = attrValue;
				}
			}

			if (attribs.SRC == '') attribs.SRC = null;
			if (attribs.HIDDEN == '') attribs.HIDDEN = 'TRUE';

			if (isMethod) {
				if (Music.hasCallbackIssue) {
					attribs.CALLBACKS = 'FALSE';
					delayAutostart = attribs.AUTOSTART.toUpperCase () == 'TRUE';
					attribs.AUTOSTART = 'FALSE';
					if (!Music.bodyEventsAdded) {
						Music.windowOnloadStr = '';
						Music.bodyEventsAdded = true;
						if (Music.playerType == 'ActiveX') mo_addEventHandler (window,window,'onunload','for (var instanceNo = Music.instances.length - 1; instanceNo >= 0; instanceNo--) Music.instances [instanceNo].playerID = null;');
						mo_addEventHandler (window,window,'onload','eval (Music.windowOnloadStr)');
					}
					Music.windowOnloadStr += objectName + '.enable ();';
				}
			}
			attribs.VOLUME = attribs.VOLUME - 0;

			with (document) {
				var
					panelW = attribs.WIDTH - 0,
					panelH = attribs.HEIGHT - 0,
					embedOutput = ''
				;
				if (Music.enabled && Music.clientSupported && Music.hasPlayer && (Music.playerCompatible || !Music.silentIfInadequate)) {
					if (Music.playerType == 'Plug-in') {
						embedOutput = '<EMBED TYPE="audio/rmf" ' + (isMethod ? ('NAME="' + playerName + '" ') : '');
						for (var attrNo = 0; attrNo < attrNames.length; attrNo++) {
							if (attribs [attrNames [attrNo]] != null) {
								embedOutput += ' ' + attrNames [attrNo];
								if (attribs [attrNames [attrNo]] != '')
									embedOutput += '="' + attribs [attrNames [attrNo]] + '"'
								;
							}
						}
						embedOutput += '>';
						if (isMethod && !Music.ignoreJavaDisabled) mo_requireJava ();
					} else if (Music.playerType == 'ActiveX') {
						if (isMethod) {
							var callbacks = new Array ('OnReady','OnPlay','OnPause','OnStop','OnMetaEvent');
							for (var callbackNo = 0; callbackNo < callbacks.length; callbackNo++) {
								var
									callbackParams = '(' + (callbacks [callbackNo] == 'OnMetaEvent' ? 'eventType,eventValue' : '') + ')',
									callbackHandler = attribs [callbacks [callbackNo].toUpperCase ()]
								;
								embedOutput += '<SCRIPT LANGUAGE=JavaScript FOR="' + playerName + '" EVENT="' + callbacks [callbackNo] + callbackParams + '">' + callbackHandler.substring (0,callbackHandler.indexOf ('(')) + callbackParams + '</SCRIPT>\n';
							}
						}
						embedOutput += '<OBJECT' + (isMethod ? (' ID="' + playerName + '"') : '') + ' WIDTH=' + panelW + ' HEIGHT=' + panelH + ' CLASSID="CLSID:B384F118-18EE-11D1-95C8-00A024330339">\n';
						for (var attrNo = 0; attrNo < attrNames.length; attrNo++) {
							if (attribs [attrNames [attrNo]] != null)
								embedOutput += '<PARAM NAME="' + attrNames [attrNo] + '" VALUE="' + attribs [attrNames [attrNo]] + '">\n'
							;
						}
						embedOutput += '</OBJECT>';
					}
0				} else {
					var tableDims = ' WIDTH=' + panelW + ' HEIGHT=' + panelH + ' HSPACE=' + attribs.HSPACE + ' VSPACE=' + attribs.VSPACE + ((attribs.ALIGN != null) ? (' ALIGN=' + attribs.ALIGN) : 'LEFT');
					if (Music.enabled && Music.clientSupported && Music.client.upgradable && (attribs.HIDDEN == null || attribs.HIDDEN.toUpperCase () != 'TRUE')) {
						var
							getPlayerText = (Music.hasPlayer ? 'Upgrade' : 'Get') + ' Beatnik!',
							getPlayerLink = '<A HREF="javascript://" ONCLICK="Music.installPlayer (); return false">'
						;
						if (typeof (Music.getPlayerImagesPath) == 'string' && panelW == 144 && (panelH == 60 || panelH == 45 || panelH == 15)) {
							embedOutput = getPlayerLink + '<IMG SRC="' + Music.getPlayerImagesPath + 'get-player-' + panelW + 'x' + panelH + '.gif"' + tableDims + ' ALT="' + getPlayerText + '" BORDER=0></A>';
						} else {
							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>';
						}
					}
					if (embedOutput == '')
						embedOutput = '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0' + tableDims + '><TR><TD></TD></TR></TABLE>'
					;
				}
				writeln (embedOutput);
			}
		}
	}
}

function mo_stubEmbed (stubURL) {
	this.magicEmbed (((typeof (stubURL) != 'string') ? '' : ('SRC="' + stubURL + '" ')) + 'WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=TRUE LOOP=TRUE');
}

function mo_preloadEmbed (fileURL,extraAttr) {
	if (typeof (extraAttr) != 'string') extraAttr = '';
	this.magicEmbed ('SRC="' + fileURL + '" WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=FALSE LOOP=FALSE VOLUME=100 ' + extraAttr);
}

function mo_getNoteName (noteNumber) {
	var noteNames = new Array ('C','C#','D','D#','E','F','F#','G','G#','A','A#','B');
	return noteNames [noteNumber % 12] + (Math.floor (noteNumber / 12) - 1) + '';
}

function mo_getNoteNumber (noteName) {
	var
		noteOffset = 'c-d-ef-g-a-b'.indexOf (noteName.charAt (0).toLowerCase ()),
		result = 0,
		sharpFlatOffset = 0
	;
	if (noteOffset != -1) {
		var sharpFlatPos = noteName.indexOf ('b',1);
		if (sharpFlatPos == -1) {
			sharpFlatPos = noteName.indexOf ('#',1);
			if (sharpFlatPos == -1) sharpFlatPos = 0; else sharpFlatOffset = 1;
		} else {
			sharpFlatOffset = -1;
		}
		var octaveNo = noteName.substring (sharpFlatPos + 1) - 0;
		result =  12 + octaveNo * 12 + noteOffset + sharpFlatOffset;
	}
	return Math.floor (result);
}

function mo_Voice_free () {
	with (this) {
		clearTimeout (noteOffTimeout);
		musicID.playerID.noteOff (channelNo,noteNo,127);
		channelNo = 0;
	}
}

function mo_Voice (musicID,channelNo,noteNo) {
	/*** Constructor Variables ***/
	this.musicID = musicID;
	this.channelNo = channelNo;
	this.noteNo = noteNo;

	/*** Instance State Variables ***/
	this.timeStamp = 0;
	this.noteOffTimeout = setTimeout ('',0);

	/*** Object's Exposed Methods ***/
	this.free = mo_Voice_free;
}

function mo_defineMethodsNull () {
	for (var argNo = 0; argNo < mo_defineMethodsNull.arguments.length; argNo++)
		this [mo_defineMethodsNull.arguments [argNo]] = mo_null
	;
}

function mo_defineMethodsMO () {
	for (var argNo = 0; argNo < mo_defineMethodsMO.arguments.length; argNo++)
		this [mo_defineMethodsMO.arguments [argNo]] = window ['mo_' + mo_defineMethodsMO.arguments [argNo]]
	;
}

/*** Functions Mapped Directly to the Player ***/

function mo_doMenuItem (menuItemName) {this.playerID.doMenuItem (menuItemName)}
function mo_engageAudio (audioState) {this.playerID.engageAudio (audioState)}
function mo_getAutostart () {return this.playerID.getAutostart ()}
function mo_getChannelMute (channelNo) {return this.playerID.getChannelMute (channelNo)}
function mo_getChannelSolo (channelNo) {return this.playerID.getChannelSolo (channelNo)}
function mo_getController (channelNo,controllerNo) {return this.playerID.getController (channelNo,controllerNo)}
function mo_getFileSize () {return this.playerID.getFileSize ()}
function mo_getInfo (infoField) {return this.playerID.getInfo (infoField)}
function mo_getLoop () {return this.playerID.getLoop ()}
function mo_getPanelDisplay () {return this.playerID.getPanelDisplay ()}
function mo_getPanelMode () {return this.playerID.getPanelMode ()}
function mo_getPlayLength () {return this.playerID.getPlayLength ()}
function mo_getPosition () {return this.playerID.getPosition ()}
function mo_getProgram (channelNo) {return this.playerID.getProgram (channelNo)}
function mo_getReverbType () {return this.playerID.getReverbType ()}
function mo_getTempo () {return this.playerID.getTempo ()}
function mo_getTrackMute (trackNo) {return this.playerID.getTrackMute (trackNo)}
function mo_getTrackSolo (trackNo) {return this.playerID.getTrackSolo (trackNo)}
function mo_getTranspose () {return this.playerID.getTranspose ()}
function mo_getTransposable (channelNo) {return this.playerID.getTransposable (channelNo)}
function mo_setAutostart (state) {this.playerID.setAutostart (state)}
function mo_setChannelSolo (channelNo,state) {this.playerID.setChannelSolo (channelNo,state)}
function mo_setController (channelNo,controllerNo,controllerValue) {this.playerID.setController (channelNo,controllerNo,controllerValue)}
function mo_setEndTime (endTime) {this.playerID.setEndTime (endTime)}
function mo_setGlobalMute (muteState) {this.playerID.setGlobalMute (muteState)}
function mo_setLoop (state) {this.playerID.setLoop (state)}
function mo_setPanelDisplay (displayType) {this.playerID.setPanelDisplay (displayType)}
function mo_setPanelMode (panelMode) {this.playerID.setPanelMode (panelMode)}
function mo_setPosition (position) {this.playerID.setPosition (position)}
function mo_setReverbType (reverbType) {this.playerID.setReverbType (reverbType)}
function mo_setStartTime (startTime) {this.playerID.setStartTime (startTime)}
function mo_setTempo (tempo) {this.playerID.setTempo (tempo)}
function mo_setTrackMute (trackNo,state) {this.playerID.setTrackMute (trackNo,state)}
function mo_setTrackSolo (trackNo,state) {this.playerID.setTrackSolo (trackNo,state)}
function mo_setTranspose (transpose) {this.playerID.setTranspose (transpose)}
function mo_setTransposable (channelNo,state) {this.playerID.setTransposable (channelNo,state)}

/*** Music Object Class Definition ***/

function Music (objectName) {
	this.objectName = objectName;

	/*** Instance State Variables ***/
	this.delayAutostart = false;
	this.volFade_timeout = setTimeout ('',0);
	this.volFade_step = 0;
	this.volFade_time = 0;
	this.volFade_timeElapsed = 0;
	this.volFade_interval = 0;
	this.volFade_fromVolume = 0;
	this.volFade_volume = 0;
	this.volFade_toVolume = 0;
	this.volFade_endCallback = null;
	this.volFade_inProgress = false;
	this.volFade_restoreVolume = false;
	this.monophonic = new Array (false,false,false,false,false,false,false,false,false,false,false,false,false,false,false);
	this.ready = false;
	this.playerID = null;
	this.onLoadHandler = null;
	this.onMetaEventHandler = null;
	this.onPauseHandler = null;
	this.onPlayHandler = null;
	this.onStopHandler = null;
	this.onReadyHandler = null;

	/*** Method Configuration Methods ***/
	this.defineMethodsNull = mo_defineMethodsNull;
	this.defineMethodsMO = mo_defineMethodsMO;

	/*** Initialisation ***/
	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');

	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');

	window [objectName] = this;
	Music.instances [Music.instances.length] = this;
}

/*** Static Methods ***/

Music.execHandler = mo_execHandler;
Music.getNoteName = mo_getNoteName;
Music.getNoteNumber = mo_getNoteNumber;
Music.magicEmbed = mo_magicEmbed;
Music.installPlayer = mo_installBeatnik;
Music.isPlayerCompatible = mo_isPlayerCompatible;
Music.hasMinVersion = mo_hasMinVersion;
Music.promptClose = mo_promptClose;
Music.promptUser = mo_promptUser;
musicObject = Music;

/*** Static Properties ***/

Music.enabled = true;

Music.requiredMinVersion = '';
Music.silentIfInadequate = false;
Music.showCompatibilityPrompt = true;
Music.ignoreJavaDisabled = false;

Music.debugToJavaConsole = true;
Music.debugToAlert = false;
Music.debugToStatus = true;
Music.ignoreNotReady = true;

/*** Static Read-only Properties ***/

Music.hasPlayer = false;
Music.playerType = '';
Music.playerVersion = '';

/*** Private Properties ***/

Music.absoluteMinVersion = '';
Music.bodyEventsAdded = false;
Music.globalNoteNo = 0;
Music.minFadeInterval = 100;
Music.storedHandlers = 0;
Music.hasCallbackIssue = false;
Music.instances = new Array ();
Music.polyphony = 32;
Music.voices = new Array ();
Music.newVoice = new mo_Voice (null,0,0);

for (mo_voiceNo = 0; mo_voiceNo < Music.polyphony; mo_voiceNo++)
	Music.voices [mo_voiceNo] = new mo_Voice (null,0,0)
;

/*** Debug Handling ***/

function mo_debug (errorMessage,errorURL,errorLineNo) {
	var errorStr = '\n**** JAVASCRIPT ERROR ****\n    TYPE: ' + errorMessage + '\n    LINE# ' + errorLineNo + '\n    FILE: ' + errorURL + '\n';
	if (Music.debugToJavaConsole && typeof (java) != 'undefined') java.lang.System.out.println (errorStr);
	if (Music.debugToAlert) alert (errorStr);
	if (Music.debugToStatus) window.defaultStatus = errorStr;
	return true;
}

function mo_enableDebug (windowHandle) {
	windowHandle.onerror = mo_debug;
	for (var frameNo = 0; frameNo < windowHandle.frames.length; frameNo++)
		mo_enableDebug (windowHandle.frames [frameNo])
	;
}

mo_enableDebug (top);

function mo_addEventHandler (windowHandle,objectID,eventType,handler) {
	var storedHandlerStr = '';
	if (typeof (objectID [eventType]) == 'function') {
		if (typeof (windowHandle.mo_storedHandlers) == 'undefined') windowHandle.mo_storedHandlers = 0;
		windowHandle.mo_storedHandlers++;
		var storedHandler = 'mo_storedEventHandler' + mo_storedHandlers;
		windowHandle [storedHandler] = objectID [eventType];
		storedHandlerStr = '; return ' + storedHandler + ' (event)';
	}
	objectID [eventType] = windowHandle.eval ('new Function (\'event\',\'' + handler + storedHandlerStr + '\')');
}

function mo_SupportedClient (_name,_platform,_minVersion,_upgradable) {
	this.name = _name;
	this.platform = _platform;
	this.minVersion = _minVersion;
	this.upgradable = _upgradable;
}

Music.supportedClients = new Array (
	new mo_SupportedClient ('Netscape','Win32','3.01',true),
	new mo_SupportedClient ('Netscape','MacPPC','3.01',true),
	new mo_SupportedClient ('Microsoft Internet Explorer','Win32','4.0',true),
	new mo_SupportedClient ('WebTV Plus Receiver','WebTV','3.0',false),
	new mo_SupportedClient ('WebTV Satellite Receiver','WebTV','3.0',false)
);

with (navigator) {
	if (mo_stringHasAny (userAgent,'Win95','Windows 95','WinNT','Windows NT','Win98','Windows 98')) {
		Music.platform = 'Win32';
	} else if (userAgent.indexOf ('PPC') != -1) {
		Music.platform = 'MacPPC';
	} else if (userAgent.indexOf ('WebTV') != -1) {
		Music.platform = 'WebTV';
	} else {
		Music.platform = (typeof (platform) == 'undefined') ? 'Unknown' : platform;
	}
	Music.clientVersion = mo_retrieveVersion (appVersion);
	Music.clientSupported = false;
	for (mo_clientNo = 0; mo_clientNo < Music.supportedClients.length; mo_clientNo++) {
		Music.client = Music.supportedClients [mo_clientNo];
		if (Music.client.name == appName && Music.client.platform == Music.platform && mo_meetsMinVersion (Music.clientVersion,Music.client.minVersion)) {
			Music.clientSupported = true;
			break;
		}
	}
}

function mo_checkForPlayer () {
	if (Music.clientSupported) {
		with (navigator) {
			if (appName == 'Netscape' || appName == 'WebTV Internet Terminal') {
				Music.playerType = 'Plug-in';
				for (var pluginNo = 0; pluginNo < plugins.length; pluginNo++) {
					if (plugins [pluginNo].name.indexOf ('Beatnik') != -1 && plugins [pluginNo].name.indexOf ('Stub') == -1) {
						Music.playerVersion = mo_retrieveVersion (plugins [pluginNo].name);
						if (Music.playerVersion == '') {
							if (Music.platform == 'Mac') {
								Music.playerVersion = '1.1.7';
							} else if (Music.platform == 'WebTV') {
								Music.playerVersion = '0.9.0';
							}
						}
						Music.hasPlayer = true;
						break;
					}
				}
				Music.hasCallbackIssue = appName == 'Netscape' && Music.hasMinVersion ('1.3') && navigator.javaEnabled ();
			} else if (appName == 'Microsoft Internet Explorer') {
				Music.playerType = 'ActiveX';
				document.writeln (
					'<OBJECT ID="mo_testInstance" CLASSID="CLSID:B384F118-18EE-11D1-95C8-00A024330339" WIDTH=1 HEIGHT=1>' +
					'<PARAM NAME="WIDTH" VALUE="1">' + 
					'<PARAM NAME="HEIGHT" VALUE="1">' + 
					'<PARAM NAME="AUTOSTART" VALUE="FALSE">' +
					'</OBJECT>'
				);
				Music.hasPlayer = typeof (document.mo_testInstance.getVersion) != 'undefined';
				if (Music.hasPlayer) Music.playerVersion = mo_retrieveVersion (document.mo_testInstance.getVersion ());
				Music.hasCallbackIssue = true;
			}
		}
	}
}

if (typeof (mo_delayPlayerCheck) == 'undefined') mo_checkForPlayer ();

/************************************
Beatnik ActionSet - version 1.2.0
written by C. van Rensburg

© Copyright 1997-1999 Beatnik, Inc.
All  Rights Reserved
*************************************/

Music.ignoreJavaDisabled = true;
Music.debugToJavaConsole = false;
Music.debugToStatus = false;
B_enabled = false;

/*** Implementation section ***/

var
	B_targetID = null,
	B_bankNo,
	B_programNo
;

function B_stripComment (paramToStrip) {
	if (typeof (paramToStrip) == 'number') {
		return paramToStrip;
	} else {
		if (paramToStrip == '' || '0123456789-'.indexOf (paramToStrip.charAt (0)) == -1) {
			return paramToStrip;
		} else {
			var spacePos = paramToStrip.indexOf (' ');
			return ((spacePos == -1) ? paramToStrip : paramToStrip.substring (0,spacePos)) - 0;
		}
	}
}

function B_mapTo127 (value) {return Math.round (value / 100 * 127)}

function B_findTarget (_target,_fileURL) {
	if (B_enabled) {
		var playerNo;
		if (_target != '' && (_target.charAt (0) != '[' || _target == '[reserved player]')) {
			if (B_targetID == null || B_targetID.targetName != _target) {
				B_targetID = null;
				for (playerNo = 0; playerNo < Music.instances.length; playerNo++) {
					if (Music.instances [playerNo].targetName == _target) {
						B_targetID = Music.instances [playerNo];
						break;
					}
				}
			}
		} else {
			B_targetID = null;
		}
		if (B_targetID == null) {
			if (typeof (_fileURL) != 'string') _fileURL = _target;
			for (playerNo = 0; playerNo < Music.instances.length; playerNo++) {
				if (Music.instances [playerNo].fileURL == _fileURL) {
					B_targetID = Music.instances [playerNo];
					break;
				}
			}
		}
		return (B_targetID != null);
	} else return false;
}

function B_findAvailable () {
	for (var playerNo = 0; playerNo < Music.instances.length; playerNo++) {
		with (Music.instances [playerNo]) {
			if (targetName == '' && !isPlaying () && !isPaused ()) {
				B_targetID = Music.instances [playerNo];
				onPlay ();
				onPause ();
				onStop ();
				onLoad ();
				if (typeof (B_targetID.metaEventMap) != 'undefined') {
					onMetaEvent ();
					for (var eventNo = 0; eventNo < metaEventMap.length; eventNo++)
						metaEventMap [eventNo].active = false
					;
				}
				break;
			}
		}
	}
}

function B_evalPanStr (panStr) {
	panStr = B_stripComment (panStr);
	if (typeof (panStr) == 'number') {
		return panStr;
	} else {
		if (panStr == ')- CENTER -(') {
			return 64;
		} else if (panStr.indexOf ('+') != -1) {
			return Math.round (((panStr.indexOf ('+') - 2) / (panStr.length - 5)) * 127);
		}
	}
}

function B_constrain (newValue,minValue,maxValue) {
	return (newValue < minValue) ? minValue : ((newValue > maxValue) ? maxValue : newValue);
}

function B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial) {
	if (_iGM + '' > ' ') {
		B_bankNo = 0;
		B_programNo = B_stripComment (_iGM);
	} else if (_iSpecial + '' > ' ') {
		B_bankNo = 1;
		B_programNo = B_stripComment (_iSpecial);
	} else if (_iUser + '' > ' ') {
		B_bankNo = 2;
		B_programNo = _iUser - 0;
	} else if (_pGM + '' > ' ') {
		B_bankNo = 0;
		B_programNo = 128 + B_stripComment (_pGM);
	} else if (_pSpecial + '' > ' ') {
		B_bankNo = 1;
		B_programNo = 128 + B_stripComment (_pSpecial);
	} else {
		B_bankNo = -1;
	}
}

function B_channelNo (_channelNo) {
	with (B_targetID) {
		if (_channelNo == '[auto]') {
			autoChannelNo = (autoChannelNo % 16) + 1;
			if (autoChannelNo == 10) autoChannelNo = 11;
			B_channelNumber = autoChannelNo;
		} else {
			B_channelNumber = B_stripComment (_channelNo);
		}
	}
}

function B_playFile (_targetName,_looping,_fileURL,_volume) {
	if (B_enabled) {
		if (!B_findTarget (_targetName,_fileURL)) B_findAvailable ();
		if (B_targetID != null) {
			with (B_targetID) {
				if (_targetName != '' && _targetName.charAt (0) != '[') targetName = _targetName;
				setAutostart (true);
				setVolume (B_stripComment (_volume));
				if (fileURL == _fileURL || _fileURL == '') {
					stop ();
					play (_looping == 'yes' || (_looping == 'auto' && fileURL.indexOf ('Background-') == 0));
				} else {
					fileURL = _fileURL;
					play (_looping,fileURL);
				}
			}
		}
	}
}

function B_pauseFile (_targetName,_fileURL,_fadeTime) {
	if (B_findTarget (_targetName,_fileURL)) B_targetID.pause (_fadeTime);
}

function B_stopFile (_targetName,_fileURL,_fadeTime) {
	if (B_findTarget (_targetName,_fileURL)) B_targetID.stop (_fadeTime);
}

b_playGroovoid = B_playFile;
b_pauseGroovoid = B_pauseFile;
b_stopGroovoid = B_stopFile;

b_playMusicFile = B_playFile;
b_pauseMusicFile = B_pauseFile;
b_stopMusicFile = B_stopFile;

function b_preloadMusicFile (_target,_fileURL) {
	if (B_enabled && _fileURL != '') {
		if (!B_findTarget (_target,_fileURL)) B_findAvailable ();
		if (B_targetID != null) {
			with (B_targetID) {
				if (_target != '' && _target.charAt (0) != '[') targetName = _target;
				if (fileURL != _fileURL) {
					fileURL = _fileURL;
					setAutostart (false);
					play (false,_fileURL);
				}
			}
		}
	}
}

function b_playMusicalNote (_target,_channelNo,_iGM,_iSpecial,_iUser,_pGM,_pSpecial,_note,_velocity,_duration,_volume,_pan) {
	if (B_findTarget (_target)) {
		B_channelNo (_channelNo);
		B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial);
		with (B_targetID) {
			setController (B_channelNumber,7,B_mapTo127 (B_stripComment (_volume)));
			setController (B_channelNumber,10,B_evalPanStr (_pan));
			if (B_bankNo == -1)
				playNote (B_channelNumber,B_stripComment (_note),B_mapTo127 (B_stripComment (_velocity)),_duration);
				else playNote (B_channelNumber,B_bankNo,B_programNo,B_stripComment (_note),B_mapTo127 (B_stripComment (_velocity)),_duration);
		}
	}
}

function b_stopMusicalNote (_target,_channelNo,_note) {
	if (B_findTarget (_target)) B_targetID.noteOff (B_stripComment (_channelNo),B_stripComment (_note));
}

function b_setGlobalMute (_status) {
	if (B_enabled) Music.instances [0].setGlobalMute (_status == 'Mute');
}

function b_setReverbType (_reverbType) {
	if (B_enabled) Music.instances [0].setReverbType (B_stripComment (_reverbType));
}

function b_setVolume (_target,_volume,_fadeTime) {
	if (B_findTarget (_target)) B_targetID.fadeVolume (null,B_stripComment (_volume),_fadeTime);
}

function b_adjustVolume (_target,_adjustBy,_fadeTime) {
	if (B_findTarget (_target)) {
		with (B_targetID) fadeVolume (null,B_constrain (getVolume () + _adjustBy,0,100),_fadeTime);
	}
}

function b_setTransposition (_target,_transposition) {
	if (B_findTarget (_target)) B_targetID.setTranspose (B_stripComment (_transposition));
}

function b_adjustTransposition (_target,_adjustBy) {
	if (B_findTarget (_target)) {
		with (B_targetID) setTranspose (B_constrain (getTranspose () + B_stripComment (_adjustBy),-48,48));
	}
}

function b_setTempo (_target,_tempo) {
	if (B_findTarget (_target)) B_targetID.setTempo (_tempo);
}

function b_adjustTempo (_target,_adjustBy) {
	if (B_findTarget (_target)) {
		with (B_targetID) setTempo (B_constrain (getTempo () + _adjustBy,10,250));
	}
}

function b_setPosition (_target,_position) {
	if (B_findTarget (_target)) B_targetID.setPosition (_position);
}

function b_adjustPosition (_target,_adjustBy) {
	if (B_findTarget (_target)) {
		with (B_targetID) setPosition (B_constrain (getPosition () + (_adjustBy),0,10000000));
	}
}

function b_showCopyrightInfo (_target) {
	if (B_findTarget (_target)) B_targetID.doMenuItem ('Copyright');
}

function b_releasePlayer (_target) {
	if (B_findTarget (_target)) B_targetID.targetName = '';
}

function b_setChannelInstrument (_target,_channelNo,_iGM,_iSpecial,_iUser,_pGM,_pSpecial) {
	if (B_enabled) {
		B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial);
		if (B_findTarget (_target) && B_bankNo != -1)
			B_targetID.setProgram (B_stripComment (_channelNo),B_bankNo,B_programNo)
		;
	}
}

function b_setChannelVolume (_target,_channelNo,_volume) {
	if (B_findTarget (_target))
		B_targetID.setController (B_stripComment (_channelNo),7,B_mapTo127 (B_stripComment (_volume)))
	;
}

function b_adjustChannelVolume (_target,_channelNo,_adjustBy) {
	if (B_findTarget (_target)) {
		with (B_targetID)
			B_channelNo (_channelNo);
			setController (B_channelNumber,7,B_constrain (getController (B_channelNumber,7) + B_mapTo127 (_adjustBy),0,127));
	}
}

function b_setChannelPan (_target,_channelNo,_pan) {
	if (B_findTarget (_target))
		B_targetID.setController (B_stripComment (_channelNo),10,B_evalPanStr (_pan))
	;
}

function b_adjustChannelPan (_target,_channelNo,_adjustBy) {
	if (B_findTarget (_target)) {
		with (B_targetID)
			B_channelNo (_channelNo);
			setController (B_channelNumber,10,B_constrain (getController (B_channelNumber,10) + Math.round (_adjustBy / 200 * 127),0,127));
	}
}

function b_setChannelMute (_target,_channelNo,_status) {
	if (B_findTarget (_target)) {
		_channelNo = B_stripComment (_channelNo);
		if (_status == 'Toggle')
			B_targetID.setChannelMute (_channelNo,!B_targetID.getChannelMute (_channelNo));
			else B_targetID.setChannelMute (_channelNo,_status == 'Mute');
	}
}

function b_setChannelSolo (_target,_channelNo,_status) {
	if (B_findTarget (_target)) {
		_channelNo = B_stripComment (_channelNo);
		if (_status == 'Toggle')
			B_targetID.setChannelSolo (_channelNo,!B_targetID.getChannelSolo (_channelNo));
			else B_targetID.setChannelSolo (_channelNo,_status == 'Solo');
	}
}

function b_setChannelMonophonic (_target,_channelNo,_status) {
	if (B_findTarget (_target)) {
		_channelNo = B_stripComment (_channelNo);
		if (_status == 'Toggle')
			B_targetID.setMonophonic (_channelNo,!B_targetID.getMonophonic (_channelNo));
			else B_targetID.setMonophonic (_channelNo,_status == 'Monophonic');
	}
}

function b_setTrackMute (_target,_trackNo,_status) {
	if (B_findTarget (_target)) {
		if (_status == 'Toggle')
			B_targetID.setTrackMute (_trackNo,!B_targetID.getTrackMute (_trackNo));
			else B_targetID.setTrackMute (_trackNo,_status == 'Mute');
	}
}

function b_setTrackSolo (_target,_trackNo,_status) {
	if (B_findTarget (_target)) {
		if (_status == 'Toggle')
			B_targetID.setTrackSolo (_trackNo,!B_targetID.getTrackSolo (_trackNo));
			else B_targetID.setTrackSolo (_trackNo,_status == 'Solo');
	}
}

/*** Initialisation Section ***/

function b_initialize (stubFileURL,totalPlayers) {
	mo_checkForPlayer ();
	B_enabled = Music.isPlayerCompatible ('1.3',true,false);
	if (B_enabled) {
		if (typeof (totalPlayers) != 'number') totalPlayers = 8;
		var stubSrc = (typeof (stubFileURL) == 'string' && stubFileURL != '') ? (' SRC="' + stubFileURL + '"') : '';
		for (var playerNo = 0; playerNo < totalPlayers; playerNo++) {
			var player = new Music ('B_playerMO' + Music.instances.length);
			player.fileURL = stubFileURL;
			player.autoChannelNo = 0;
			player.targetName = (playerNo == 0) ? '[reserved player]' : '';
			player.magicEmbed (stubSrc + ' WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=' + (playerNo == 0) + ' VOLUME=100');
		}
	}
}

/************************************
Beatnik ActionSet PRO - version 1.2.0
written by C. van Rensburg

© Copyright 1997-1999 Beatnik, Inc.
All  Rights Reserved
*************************************/

/*** Implementation section ***/

function B_getCookie (_name) {
	var
		arg = _name + '=',
		alen = arg.length,
		i = 0,
		j,
		cookieEnd
	;
	with (document) {
		while (i < cookie.length) {
			j = i + alen;
			if (cookie.substring (i,j) == arg) {
				cookieEnd = cookie.indexOf (';',j);
				if (cookieEnd == -1) cookieEnd = cookie.length;
				return unescape (cookie.substring (j,cookieEnd));
			}
			i = cookie.indexOf (' ',i) + 1;
			if (i == 0) break;
		}
		return null;
	}
}

function B_setCookie (_name,_value,_expires,_path,_domain,_secure) {
	if (_expires != null) {
		var
			base = new Date (0),
			skew = base.getTime ()
		;
		if (skew > 0) _expires.setTime (_expires.getTime () - skew);
	}
	document.cookie =
		_name + "=" + escape (_value) +
		((typeof (_expires) == 'undefined') ? '' : ('; expires=' + _expires.toGMTString ())) +
		((typeof (_path) == 'undefined') ? '' : ('; path=' + _path)) +
		((typeof (_domain) == 'undefined') ? '' : ('; domain=' + _domain)) +
		((typeof (_secure) == 'boolean' && _secure) ? '; secure' : '')
	;
}

function B_lastIndexOfSlash (argStr) {
	var
		returnVal1 = argStr.lastIndexOf ('/'),
		returnVal2 = argStr.lastIndexOf ('\\')
	;
	return (returnVal1 > returnVal2) ? returnVal1 : returnVal2;
}

function B_filesMatch (fileA,fileB,matchType) {
	if (matchType == 'Full Path') {
		return fileA == fileB;
	} else if (matchType == 'Filename Only') {
		return fileA.substr (B_lastIndexOfSlash (fileA) + 1) == fileB.substr (B_lastIndexOfSlash (fileB) + 1);
	}
}

function B_Playlist_readMemory () {
	with (this) {
		var cookieVal = B_getCookie (objectName);
		if (cookieVal != null) {
			var cookieFields = cookieVal.split (',');
			selectionScheme = unescape (cookieFields [0]);
			updateSelection = unescape (cookieFields [1]);
			startDateYear = unescape (cookieFields [2]);
			startDateMonth = unescape (cookieFields [3]);
			startDateDay = unescape (cookieFields [4]);
			startDateHour = unescape (cookieFields [5]);
			startDateMinute = unescape (cookieFields [6]);
			creationDate.setTime (Date.parse (unescape (cookieFields [7])));
			lastSelection = unescape (cookieFields [8]);
			lastSelectionDate = new Date (unescape (cookieFields [9]));
			totalFiles = unescape (cookieFields [10]) - 0;
			itemList = cookieFields [11].split ('|');
			itemsPlayed = new Array ();
			for (var fileNo = 0; fileNo < totalFiles; fileNo++) {
				itemList [fileNo] = unescape (itemList [fileNo]);
				itemsPlayed [fileNo] = cookieFields [12].charAt (fileNo) == '1';
			}
			initialized = true;
		}
	}
}

function B_Playlist_writeMemory () {
	with (this) {
		var
			cookieVal =
				escape (selectionScheme) + ',' +
				escape (updateSelection) + ',' +
				escape (startDateYear) + ',' +
				escape (startDateMonth) + ',' +
				escape (startDateDay) + ',' +
				escape (startDateHour) + ',' +
				escape (startDateMinute) + ',' +
				escape (creationDate.toLocaleString ()) + ',' +
				escape (lastSelection) + ',' +
				escape (lastSelectionDate.toLocaleString ()) + ',' +
				escape (totalFiles) + ','
			,
			cookieExpiration = new Date (),
			fileNo
		;
		for (fileNo = 0; fileNo < totalFiles; fileNo++)
			cookieVal += ((fileNo > 0) ? '|' : '') + escape (itemList [fileNo])
		;
		cookieVal += ',';
		for (fileNo = 0; fileNo < totalFiles; fileNo++)
			cookieVal += itemsPlayed [fileNo] ? '1' : '0'
		;
		cookieExpiration.setTime (cookieExpiration.getTime () + memoryLife * 24 * 60 * 60 * 1000);
		B_setCookie (objectName,cookieVal,cookieExpiration);
	}
}

function B_Playlist_reset () {
	with (this) {
		for (var fileNo = 0; fileNo < totalFiles; fileNo++)
			itemsPlayed [fileNo] = false
		;
	}
}

function B_Playlist_itemPlayed (fileNo) {
	var selectionDate = new Date ();
	with (this) {
		itemsPlayed [fileNo] = true;
		lastSelection = itemList [fileNo];
		lastSelectionDate.setTime (selectionDate.getTime ());
		writeMemory ();
		return this.lastSelection;
	}
}

function B_Playlist_selectNext () {
	with (this) {
		var
			selectionDate = new Date (),
			makeNewSelection = lastSelection == '' || updateSelection  == 0,
			fileNo
		;
		if (!makeNewSelection) {
			with (Math) {
				makeNewSelection =
					floor ((selectionDate.getTime () - startDate.getTime ()) / 60000 / updateSelection) !=
					floor ((lastSelectionDate.getTime () - startDate.getTime ()) / 60000 / updateSelection);
			}
		}
		if (makeNewSelection) {
			if (selectionScheme == 'Step-through') {
				if (updateSelection == 0) {
					for (fileNo = 0; fileNo < totalFiles; fileNo++)
						if (!itemsPlayed [fileNo]) return this.itemPlayed (fileNo)
					;
					resetPlaylist ();
					return this.itemPlayed (0);
				} else {
					return this.itemPlayed (Math.floor (((selectionDate.getTime () - startDate.getTime ()) / 60000) / updateSelection) % totalFiles);
				}
			} else if (selectionScheme == 'Random') {
				var totalUnplayed = 0;
				for (fileNo = 0; fileNo < totalFiles; fileNo++)
					if (!itemsPlayed [fileNo]) totalUnplayed++
				;
				if (totalUnplayed == 0) {
					resetPlaylist ();
					totalUnplayed = totalFiles;
				}
				with (Math) var fileToPlay = round (random () * (totalUnplayed - 1));
				var unplayedFileNo = 0;
				for (fileNo = 0; fileNo < totalFiles; fileNo++) {
					if (!itemsPlayed [fileNo]) {
						unplayedFileNo++;
						if (unplayedFileNo == fileToPlay) return this.itemPlayed (fileNo);
					}
				}
			}
		} else {
			return this.lastSelection;
		}
	}
}

function B_Playlist_update (_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList) {
	_updateSelection = B_stripComment (_updateSelection);
	var fileNo;
	with (this) {
		if (initialized) {
			var
				settingsChanged =
					selectionScheme != _selectionScheme ||
					updateSelection != _updateSelection ||
					startDateYear != _startDateYear ||
					startDateDay != _startDateDay ||
					startDateHour != _startDateHour ||
					startDateMinute != _startDateMinute
				,
				itemListChanged = totalFiles != _itemList.length
			;
		}
		if (initialized && !itemListChanged) {
			for (fileNo = 0; fileNo < totalFiles; fileNo++) {
				if (itemList [fileNo] != _itemList [fileNo]) {
					if (B_filesMatch (itemList [fileNo],_itemList [fileNo],_matchFilesBy)) {
						itemList [fileNo] = _itemList [fileNo];
					} else {
						itemListChanged = true;
						break;
					}
				}
			}
		}
		if (!initialized || settingsChanged) {
			selectionScheme = _selectionScheme;
			updateSelection = _updateSelection;
			startDateYear = _startDateYear;
			startDateMonth = _startDateMonth;
			startDateDay = _startDateDay;
			startDateHour = _startDateHour;
			startDateMinute = _startDateMinute;
			if (_ifSettingsChange == 'Reset Memory') this.creationDate = new Date ();
		}
		if (!initialized || itemListChanged) {
			if (initialized && _ifSettingsChange == 'Adapt Memory') {
				var newItemsPlayed = new Array ();
				for (var fileNoA = 0; fileNoA < _itemList.length; fileNoA++) {
					newItemsPlayed [fileNoA] = false;
					for (var fileNoB = 0; fileNoB < totalFiles; fileNoB++) {
						if (B_filesMatch (itemList [fileNoB],_itemList [fileNoA],_matchFilesBy)) {
							newItemsPlayed [fileNoA] = true;
							break;
						}
					}
				}
				totalFiles = _itemList.length;
				for (fileNo = 0; fileNo < _itemList.length; fileNo++) {
					itemList [fileNo] = _itemList [fileNo];
					itemsPlayed [fileNo] = newItemsPlayed [fileNo];
				}
			} else {
				totalFiles = _itemList.length;
				for (fileNo = 0; fileNo < totalFiles; fileNo++) {
					itemList [fileNo] = _itemList [fileNo];
					itemsPlayed [fileNo] = false;
				}
			}
		} else {
			if (settingsChanged && _ifSettingsChange == 'Reset Memory') resetPlaylist ();
		}
		memoryLife = B_stripComment (_memoryLife);
		if (memoryLife > 0) writeMemory ();
		startDate.setTime (creationDate.getTime ());
		if (startDateYear != '[first visit]') startDate.setYear (B_stripComment (startDateYear));
		if (startDateMonth != '[first visit]') startDate.setMonth (B_stripComment (startDateMonth) - 1);
		if (startDateDay != '[first visit]') startDate.setDate (B_stripComment (startDateDay));
		if (startDateHour != '[first visit]') startDate.setHours (B_stripComment (startDateHour) - 1);
		if (startDateMinute != '[first visit]') startDate.setMinutes (B_stripComment (startDateMinute) - 1);
		initialized = true;
	}
}

function B_Playlist (_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,B_memoryName,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList) {
	/*** Constructor Variables ***/
	this.objectName = B_memoryName;

	/*** Instance State Variables ***/
	this.totalFiles = 0;
	this.itemList = new Array ();
	this.itemsPlayed = new Array ();
	this.lastSelection = '';
	this.lastSelectionDate = new Date ();
	this.creationDate = new Date ();
	this.initialized = false;
	this.startDate = new Date ();

	/*** Object's Exposed Methods ***/
	this.selectNext = B_Playlist_selectNext;
	this.readMemory = B_Playlist_readMemory;
	this.writeMemory = B_Playlist_writeMemory;
	this.update = B_Playlist_update;
	this.resetPlaylist = B_Playlist_reset;
	this.itemPlayed = B_Playlist_itemPlayed;

	/*** Initialisation ***/
	window [this.objectName] = this;
	this.readMemory ();
	this.update (_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList);
	return this;
}

function B_playRandomFile (_target,_looping,_volume,_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryName,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList) {
	if (_memoryName == '[use player name]') {_memoryName = 'B_' + _target} else {_memoryName = 'B_' + _memoryName}
	if (typeof (window [_memoryName]) == 'object') {
		window [_memoryName].update (_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList);
	} else {
		new B_Playlist (_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryName,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList);
	}
	var fileToPlay = window [_memoryName].selectNext ();
	B_playFile (_target,_looping,fileToPlay,B_stripComment (_volume));
}

function b_playRandomGroovoid (_target,_looping,_volume,_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryName,_memoryLife,_ifSettingsChange,_groovoidGroup) {
	if (B_enabled) {
		var
			groovoidNames = new Array (
				'UI-BeepClick1','UI-Chimes','UI-Choice1','UI-Click1','UI-Click2',
				'UI-Click3','UI-Click4','UI-Click5','UI-Click6','UI-Click7',
				'UI-Click8','UI-Click9','UI-Click10','UI-Click11','UI-Click12',
				'UI-Click13','UI-Click14','UI-Click15','UI-Click16','UI-Click17',
				'UI-Click18','UI-CarriageReturn','UI-FunnyBeep','UI-Load1',
				'UI-MouseOver1','UI-MouseOver2','UI-MouseOverDrone1',
				'UI-Notification1','UI-Notification2','UI-Notification3',
				'UI-OpenOrClose1','UI-OpenOrClose2','UI-OpenOrClose3',
				'UI-Question','UI-SimpleClick1','UI-SimpleClick2','UI-SystemBeep',
				'UI-TeletypeBurst2','UI-TypeOneKey','Hits-BlastOff','Hits-Kicker1',
				'Hits-Kicker2','Hits-Kicker5','Hits-LudwigVan','Hits-Magic',
				'Hits-MysteryChime','Hits-SportsOrganCharge','Hits-ZoomAndHit',
				'Fanfare-Arrival','Fanfare-Cascade','Fanfare-CorpSting1',
				'Fanfare-Finished','Fanfare-Horserace','Fanfare-Mars',
				'Fanfare-Majesty','Fanfare-Presenting','Fanfare-Sports',
				'Background-Beeps','Background-Clock','Background-Dubby',
				'Background-Funky','Background-Groove2','Background-InfoPulse',
				'Background-Latin','Background-News','Background-Piano',
				'Background-SimpleTyping','Background-Smooth',
				'Background-StillWaiting','Background-Teletype',
				'Misc-CashRegister','Misc-ThruPhoneRing'
			),
			_itemList = new Array (),
			totalFiles = 0
		;
		for (var groovoidNo = 0; groovoidNo < groovoidNames.length; groovoidNo++) {
			if (_groovoidGroup == '[all Groovoids]' || groovoidNames [groovoidNo].indexOf (_groovoidGroup) == 0) {
				_itemList [totalFiles] = groovoidNames [groovoidNo];
				totalFiles++;
			}
		}
		B_playRandomFile (_target,_looping,_volume,_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryName,_memoryLife,'Full Path',_ifSettingsChange,_itemList);
	}
}

function B_randomInRange (rangeLimitA,rangeLimitB) {
	return rangeLimitA + Math.round (Math.random () * (rangeLimitB - rangeLimitA));
}

function b_playRandomMusicFile (_target,_looping,_volume,_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryName,_memoryLife,_matchFilesBy,_ifSettingsChange) {
	if (B_enabled) {
		var
			_itemList = new Array (),
			totalFiles = 0
		;
		for (var argNo = 14; argNo < b_playRandomMusicFile.arguments.length; argNo++) {
			var fileName = b_playRandomMusicFile.arguments [argNo];
			if (fileName != '') {
				_itemList [totalFiles] = fileName;
				totalFiles++;
			}
		}
		B_playRandomFile (_target,_looping,_volume,_selectionScheme,_updateSelection,_startDateYear,_startDateMonth,_startDateDay,_startDateHour,_startDateMinute,_memoryName,_memoryLife,_matchFilesBy,_ifSettingsChange,_itemList);
	}
}

function b_playRandomMusicalNote (_target,_channelNo,_iGM,_iSpecial,_iUser,_pGM,_pSpecial,_noteMin,_noteMax,_velocityMin,_velocityMax,_durationMin,_durationMax,_volumeMin,_volumeMax,_panA,_panB) {
	if (B_findTarget (_target)) {
		B_channelNo (_channelNo);
		B_bankAndProgram (_iGM,_iSpecial,_iUser,_pGM,_pSpecial);
		with (B_targetID) {
			setController (B_channelNumber,7,B_mapTo127 (B_randomInRange (B_stripComment (_volumeMin),B_stripComment (_volumeMax))));
			setController (B_channelNumber,10,B_randomInRange (B_evalPanStr (_panA),B_evalPanStr (_panB)));
			playNote (
				B_channelNumber,
				B_bankNo,
				B_programNo,
				B_randomInRange (B_stripComment (_noteMin),B_stripComment (_noteMax)),
				B_mapTo127 (B_randomInRange (B_stripComment (_velocityMin),B_stripComment (_velocityMax))),
				B_randomInRange (_durationMin,_durationMax)
			);
		}
	}
}

function B_handlerStr (handler) {
	if (handler == '') {
		return '';
	} else {
		if (typeof (F_sendMessage) == 'function')
			return 'F_sendMessage ("' + params.id + '","' + handler + '","",true)';
			else return handler;
	}
}

function B_sonifyForm (windowHandle,formHandle) {
	with (formHandle) {
		for (var elementNo = 0; elementNo < elements.length; elementNo++) {
			var element = elements [elementNo];
			if (element.type == 'checkbox') {
				mo_addEventHandler (windowHandle,element,'onclick','eval (this.checked ? B_checkboxCheck : B_checkboxUncheck)');
			} else if (element.type == 'radio') {
				mo_addEventHandler (windowHandle,element,'onclick','eval (B_radioButton)');
			} else if (element.type == 'select-one') {
				mo_addEventHandler (windowHandle,element,'onfocus','eval (B_listboxFocus)');
				mo_addEventHandler (windowHandle,element,'onchange','eval (B_listboxChoose)');
				mo_addEventHandler (windowHandle,element,'onblur','eval (B_listboxBlur)');
			} else if (element.type == 'select-multiple') {
				mo_addEventHandler (windowHandle,element,'onfocus','eval (B_selectMultipleFocus)');
				mo_addEventHandler (windowHandle,element,'onchange','eval (B_selectMultipleChoose)');
				mo_addEventHandler (windowHandle,element,'onblur','eval (B_selectMultipleBlur)');
			} else if (element.type == 'text') {
				mo_addEventHandler (windowHandle,element,'onfocus','eval (B_textboxFocus)');
				mo_addEventHandler (windowHandle,element,'onblur','eval (B_textboxBlur)');
			} else if (element.type == 'textarea') {
				mo_addEventHandler (windowHandle,element,'onfocus','eval (B_textboxFocus)');
				mo_addEventHandler (windowHandle,element,'onblur','eval (B_textboxBlur)');
			} else if (element.type == 'button') {
				mo_addEventHandler (windowHandle,element,'onclick','eval (B_buttonClick)');
			} else if (element.type == 'reset') {
				mo_addEventHandler (windowHandle,element,'onclick','eval (B_formReset)');
			} else if (element.type == 'submit') {
				mo_addEventHandler (windowHandle,element,'onclick','eval (B_formSubmit)');
			}
		}
	}
}

function B_joinStatements () {
	var result = '';
	for (var argNo = 0; argNo < B_joinStatements.arguments.length; argNo++) {
		if (B_joinStatements.arguments [argNo] != '')
			result += ((result != '') ? '; ' : '') + B_joinStatements.arguments [argNo];
		;
	}
	return result;
}

function B_updateHandler (oldValue,newValue,updateType) {
	if (updateType == 'replace') {
		return newValue;
	} else if (updateType == 'merge with') {
		if (newValue != '') return newValue; else return oldValue;
	} else if (updateType == 'add to') {
		return B_joinStatements (oldValue,newValue);
	} else return oldValue;
}

function B_sonifyForms (_checkboxCheck,_checkboxUncheck,_radioButton,_listboxFocus,_listboxChoose,_listboxBlur,_selectMultipleFocus,_selectMultipleChoose,_selectMultipleBlur,_textboxFocus,_textboxBlur,_buttonClick,_formReset,_formSubmit,windowHandle,updateType) {
	if (typeof (updateType) != 'string') updateType = 'add to'; 
	if (typeof (windowHandle.B_formsSonified) == 'undefined') {
		windowHandle.B_formsSonified = true;
		windowHandle.B_checkboxCheck = '';
		windowHandle.B_checkboxUncheck = '';
		windowHandle.B_radioButton = '';
		windowHandle.B_listboxFocus = '';
		windowHandle.B_listboxChoose = '';
		windowHandle.B_listboxBlur = '';
		windowHandle.B_selectMultipleFocus = '';
		windowHandle.B_selectMultipleChoose = '';
		windowHandle.B_selectMultipleBlur = '';
		windowHandle.B_textboxFocus = '';
		windowHandle.B_textboxBlur = '';
		windowHandle.B_buttonClick = '';
		windowHandle.B_formReset = '';
		windowHandle.B_formSubmit = '';
		with (windowHandle) {
			for (var formNo = 0; formNo < document.forms.length; formNo++)
				B_sonifyForm (windowHandle,document.forms [formNo])
			;
			if (typeof (document.layers) != 'undefined') {
				for (var layerNo = 0; layerNo < document.layers.length; layerNo++) {
					docHandle = document.layers [layerNo].document;
					for (var formNo = 0; formNo < docHandle.forms.length; formNo++)
						B_sonifyForm (windowHandle,docHandle.forms [formNo])
					;
				}
			}
		}
	}
	with (windowHandle) {
		B_checkboxCheck = B_updateHandler (B_checkboxCheck,_checkboxCheck,updateType);
		B_checkboxUncheck = B_updateHandler (B_checkboxUncheck,_checkboxUncheck,updateType);
		B_radioButton = B_updateHandler (B_radioButton,_radioButton,updateType);
		B_listboxFocus = B_updateHandler (B_listboxFocus,_listboxFocus,updateType);
		B_listboxChoose = B_updateHandler (B_listboxChoose,_listboxChoose,updateType);
		B_listboxBlur = B_updateHandler (B_listboxBlur,_listboxBlur,updateType);
		B_selectMultipleFocus = B_updateHandler (B_selectMultipleFocus,_selectMultipleFocus,updateType);
		B_selectMultipleChoose = B_updateHandler (B_selectMultipleChoose,_selectMultipleChoose,updateType);
		B_selectMultipleBlur = B_updateHandler (B_selectMultipleBlur,_selectMultipleBlur,updateType);
		B_textboxFocus = B_updateHandler (B_textboxFocus,_textboxFocus,updateType);
		B_textboxBlur = B_updateHandler (B_textboxBlur,_textboxBlur,updateType);
		B_buttonClick = B_updateHandler (B_buttonClick,_buttonClick,updateType);
		B_formReset = B_updateHandler (B_formReset,_formReset,updateType);
		B_formSubmit = B_updateHandler (B_formSubmit,_formSubmit,updateType);
	}
}

function B_formSound (_groovoidName) {
	return (_groovoidName > ' ') ? ('B_playFile (\'' + B_formTarget + '\',\'auto\',\'' + _groovoidName + '\',100)') : '';
}

function B_formSoundStop (_groovoidName) {
	return (_groovoidName > ' ') ? ('B_stopFile (\'' + B_formTarget + '\',\'' + _groovoidName + '\',150)') : '';
}

function b_sonifyFormsWithGroovoids (_target,_checkboxCheck,_checkboxUncheck,_radioButton,_listboxFocus,_listboxChoose,_listboxBlur,_selectMultipleFocus,_selectMultipleChoose,_selectMultipleBlur,_textboxFocus,_textboxBlur,_buttonClick,_formReset,_formSubmit,windowHandle) {
	if (B_enabled) {
		B_formTarget = _target;
		B_sonifyForms (
			B_formSound (_checkboxCheck),
			B_formSound (_checkboxUncheck),
			B_formSound (_radioButton),
			B_formSound (_listboxFocus),
			B_joinStatements (B_formSoundStop (_listboxFocus),B_formSound (_listboxChoose)),
			B_joinStatements (B_formSoundStop (_listboxFocus),B_formSound (_listboxBlur)),
			B_formSound (_selectMultipleFocus),
			B_joinStatements (B_formSoundStop (_selectMultipleFocus),B_formSound (_selectMultipleChoose)),
			B_joinStatements (B_formSoundStop (_selectMultipleFocus),B_formSound (_selectMultipleBlur)),
			B_formSound (_textboxFocus),
			B_joinStatements (B_formSoundStop (_textboxFocus),B_formSound (_textboxBlur)),
			B_formSound (_buttonClick),
			B_formSound (_formReset),
			B_formSound (_formSubmit),
			(typeof (windowHandle) != 'undefined') ? windowHandle : ((typeof (this.document) != 'undefined') ? this : window)
		);
	}
}

function b_sonifyFormsWithHandlers (_checkboxCheck,_checkboxUncheck,_radioButton,_listboxFocus,_listboxChoose,_listboxBlur,_selectMultipleFocus,_selectMultipleChoose,_selectMultipleBlur,_textboxFocus,_textboxBlur,_buttonClick,_formReset,_formSubmit,windowHandle) {
	if (B_enabled)
		B_sonifyForms (
			B_handlerStr (_checkboxCheck),
			B_handlerStr (_checkboxUncheck),
			B_handlerStr (_radioButton),
			B_handlerStr (_listboxFocus),
			B_handlerStr (_listboxChoose),
			B_handlerStr (_listboxBlur),
			B_handlerStr (_selectMultipleFocus),
			B_handlerStr (_selectMultipleChoose),
			B_handlerStr (_selectMultipleBlur),
			B_handlerStr (_textboxFocus),
			B_handlerStr (_textboxBlur),
			B_handlerStr (_buttonClick),
			B_handlerStr (_formReset),
			B_handlerStr (_formSubmit),
			(typeof (windowHandle) != 'undefined') ? windowHandle : ((typeof (this.document) != 'undefined') ? this : window)
		)
	;
}

function b_setPlayEventHandler (_target,_handler) {
	if (B_findTarget (_target)) B_targetID.onPlay (B_handlerStr (_handler));
}

function b_clearPlayEventHandler (_target) {
	if (B_findTarget (_target)) B_targetID.onPlay ();
}

function b_setPauseEventHandler (_target,_handler) {
	if (B_findTarget (_target)) B_targetID.onPause (B_handlerStr (_handler));
}

function b_clearPauseEventHandler (_target) {
	if (B_findTarget (_target)) B_targetID.onPause ();
}

function b_setStopEventHandler (_target,_handler) {
	if (B_findTarget (_target)) B_targetID.onStop (B_handlerStr (_handler));
}

function b_clearStopEventHandler (_target) {
	if (B_findTarget (_target)) B_targetID.onStop ();
}

function b_setLoadEventHandler (_target,_handler) {
	if (B_findTarget (_target)) B_targetID.onLoad (B_handlerStr (_handler));
}

function b_clearLoadEventHandler (_target) {
	if (B_findTarget (_target)) B_targetID.onLoad ();
}

function B_metaEvent (_type,_value,_handler) {
	this.type = _type;
	this.value = _value;
	this.handler = _handler;
	this.active = true;
}

function B_onMetaEvent (_type,_value,instanceID) {
	with (instanceID) {
		var eventFound = false;
		for (var eventNo = 0; eventNo < metaEventMap.length; eventNo++) {
			with (metaEventMap [eventNo]) {
				if (active && type == _type && value == _value) {
					eval (handler);
					break;
				}
			}
		}
	}
}

function b_addMusicEventHandler (_target,_type,_value,_handler) {
	if (B_findTarget (_target)) {
		with (B_targetID) {
			if (typeof (B_targetID.metaEventMap) == 'undefined') B_targetID.metaEventMap = new Array ();
			var eventFound = false;
			for (var eventNo = 0; eventNo < metaEventMap.length && !eventFound; eventNo++) {
				with (metaEventMap [eventNo]) {
					if (!active) {
						type = _type;
						value = _value;
						handler = B_handlerStr (_handler);
						active = true;
						eventFound = true;
					} else {
						if (type == _type && value == _value) {
							handler = B_handlerStr (_handler);
							eventFound = true;
						}
					}
				}
			}
			if (!eventFound) metaEventMap [metaEventMap.length] = new B_metaEvent (_type,__value,B_handlerStr (_handler));
			onMetaEvent (B_onMetaEvent);
		}
	}
}

function b_removeMusicEventHandler (_target,_type,_value) {
	if (B_findTarget (_target)) {
		with (B_targetID) {
			if (typeof (B_targetID.metaEventMap) != 'undefined') {
				var
					eventFound = false,
					activeEventFound = false
				;
				for (var eventNo = 0; eventNo < metaEventMap.length; eventNo++) {
					with (metaEventMap [eventNo]) {
						if (active) {
							if (!eventFound && type == _type && value == _value) {
								active = false;
								eventFound = true;
								if (activeEventFound) break;
							} else {
								activeEventFound = true;
								if (eventFound) break;
							}
						}
					}
				}
				if (!activeEventFound) onMetaEvent ();
			}
		}
	}
}

function b_clearMusicEventHandlers (_target,_type) {
	if (B_findTarget (_target)) {
		with (B_targetID) {
			if (typeof (B_targetID.metaEventMap) != 'undefined') {
				var activeEventFound = false;
				for (var eventNo = 0; eventNo < metaEventMap.length; eventNo++) {
					with (metaEventMap [eventNo]) {
						if (active) {
							if (_type == '[all]' || type == _type)
								active = false;
								else activeEventFound = true;
						}
					}
				}
				if (!activeEventFound) onMetaEvent ();
			}
		}
	}
}

function b_requirePlayerVersion (minVersion) {
	if (mo_isPlayerCompatible (minVersion,true,true)) mo_requireJava ();
}

/*** Frameset Authoring for Dreamweaver ***/

function b_enablePeer (peerHandle) {
	var actionNames = new Array (
		/*** Standard Actions ***/
		'pauseGroovoid','playGroovoid','stopGroovoid','pauseMusicFile','playMusicFile','preloadMusicFile','stopMusicFile','playMusicalNote','stopMusicalNote','adjustChannelPan','adjustChannelVolume','setChannelInstrument','setChannelMonophonic','setChannelMute','setChannelPan','setChannelSolo','setChannelVolume','setGlobalMute','setReverbType','adjustPosition','adjustTempo','adjustTransposition','adjustVolume','releasePlayer','setPosition','setTempo','setTransposition','setVolume','showCopyrightInfo','setTrackMute','setTrackSolo'
		/*** PRO Actions ***/,
		'requirePlayerVersion','playRandomGroovoid','playRandomMusicFile','playRandomMusicalNote','sonifyFormsWithGroovoids','sonifyFormsWithHandlers','addMusicEventHandler','clearLoadEventHandler','clearMusicEventHandlers','clearPauseEventHandler','clearPlayEventHandler','clearStopEventHandler','removeMusicEventHandler','setLoadEventHandler','setPauseEventHandler','setPlayEventHandler','setStopEventHandler'
	);
	mo_enableDebug (peerHandle);
	for (var actionNo in actionNames)
		peerHandle ['b_' + actionNames [actionNo]] = window ['b_' + actionNames [actionNo]]
	;
}
