
// flash version URL switch (for this demo page)
var winLoc = window.location.toString();
soundManager.preferFlash = (winLoc.match(/usehtml5audio=1/i) ? false : true);
if (winLoc.match(/flash9/i)) {
    soundManager.flashVersion = 9;
    if (winLoc.match(/highperformance/i)) {
        soundManager.useHighPerformance = true;
        soundManager.useFastPolling = true;
    }
} else if (winLoc.match(/flash8/i)) {
    soundManager.flashVersion = 8;
}

soundManager.useFlashBlock = false;
soundManager.url = 'http://www.sistema.net.br/swf/'; // path to SoundManager2 SWF files (note trailing slash)
soundManager.debugMode = false;
soundManager.consoleOnly = false;

soundManager.onready(function(oStatus) {
    if (!oStatus.success) {
        return false;	
    }
    // soundManager is initialised, ready to use. Create a sound for this demo page.

    if (soundManager.flashVersion > 8) {
        t = window.setInterval(checkRAM,500);
        document.getElementById('flash-ram-use').style.display = 'inline';
        checkRAM();
    }

    soundManager.createSound({
        id: 'chatBeep',
        url: 'http://www.sistema.net.br/sounds/chat.mp3'
    });


});

function checkRAM() {
    if (soundManager.supported()) {
        var ram = (soundManager.getMemoryUse()/1024/1024).toFixed(2);
        if (!isNaN(ram)) {
            document.getElementById('flash-ram-use').innerHTML = ram+' MB';
        } else {
            document.getElementById('flash-ram-use').style.display = 'none';
        }
    }
}

var t = null;

function doEval(sHTML) {
    var html = sHTML.replace(/\<(span|code)\>/gi,'');
    html = html.replace(/\<[\/](span|code)\>/gi,'');
    html = html.replace(/&gt;/gi,'>');
    eval(html);
    return false;
}
