// The audioplayer variable is used as a reference
// to the current AudioPlayer applet.

var audioplayer

// Assigns a reference to the AudioPlayer applet
// to audioplayer.

function initAudioPlayer() {
	audioplayer = document.applets["AudioPlayer"]
}

// Load and play the specified sound file.

function playSound(fileName) {
	if(audioplayer == null) initAudioPlayer()
	if(audioplayer == null) {
		alert("AudioPlayer has not loaded.")
		return
	}
	audioplayer.stopAudioClip()
	audioplayer.playAudioClip(fileName)
}

// Load and play the specified sound file in a
// continuous loop.

function loopSound(fileName) {
	if(audioplayer == null) initAudioPlayer()
	if(audioplayer == null) {
		alert("AudioPlayer has not loaded.")
		return
	}
	audioplayer.stopAudioClip()
	audioplayer.loopAudioClip(fileName)
}

// Stop the playing of the sound file.

function stopSound(fileName) {
	if(audioplayer == null) initAudioPlayer()
	if(audioplayer == null) return
	audioplayer.stopAudioClip()
}