    function getObject(_x) {
	// used to locate the Flash asset in the DOM. Works reliably on FF, IE and Safari.
	return document.getElementById(_x);
    }

    window.onunload = function() {
	// stops audio when browser moves to a new page or closes. Helps stop a crash in Safari.
        getObject("fmp_1").playpause(0);
		getObject("fmp_2").playpause(0);
		getObject("fmp_3").playpause(0);
		getObject("fmp_4").playpause(0);
		getObject("fmp_5").playpause(0);
    }

    function setconfig_player(canal) {
	// sends Flash a new config file URL.
	objecte = 'fmp_' + canal;
	fitxer_config = '/lib/minicaster/canal' + canal + '.xml';
	getObject(objecte).setconfig(fitxer_config);
    }

    function toggle(id) {
	// changes between play and pause. To force audio to stop use '0' in the function.
	getObject(id).playpause(1);
    }

	// the following two functions should be removed for a public production website.
    function xtrace(_st) {
	// sends text from Flash to the on-screen debugging display (if used)
  	getObject("xtracef").t.value += _st + '\n';
    }

    function clearTrace() {
	// removes all text from the debugging display (if used)
	getObject("xtracef").t.value = "";
    }
