//<object type="application/x-shockwave-flash" data="/include/audio_player.swf" id="audioplayer2" height="24" width="290">
//                    <param name="movie" value="/include/audio_player.swf">
//                    <param name="FlashVars" value="playerID=2&amp;autostart=no&amp;soundFile=location.mp3">
//                    <param name="quality" value="high">
//                    <param name="menu" value="false">
//                    <param name="wmode" value="transparent">
//                </object>
//
//the  id of the object needs to start with audioplayer and is followed by a number, that number is also for the FlashVars playerID, in the above example, it is 2

var ap_instances = new Array();

function ap_stopAll(playerID) {
	for(var i = 0;i<ap_instances.length;i++) {
		try {
			if(ap_instances[i] != playerID) document.getElementById("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 1);
			else document.getElementById("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 0);
		} catch( errorObject ) {
			// stop any errors
		}
	}
}

function ap_registerPlayers() {
	var objectID;
	var objectTags = document.getElementsByTagName("object");
	for(var i=0;i<objectTags.length;i++) {
		objectID = objectTags[i].id;
		if(objectID.indexOf("audioplayer") == 0) {
			ap_instances[i] = objectID.substring(11, objectID.length);
		}
	}
}

var ap_clearID = setInterval( ap_registerPlayers, 100 );