var playedsongid = 0;
            // flash version URL switch (for this demo page)
            if (window.location.toString().match(/flash9/i)) {
                soundManager.flashVersion = 9;
            } else if (window.location.toString().match(/flash8/i)) {
                soundManager.flashVersion = 8;
            }

            soundManager.url = 'script/player/swf/'; // path to SoundManager2 SWF files (note trailing slash)
            soundManager.debugMode = false;
            soundManager.consoleOnly = false;

            soundManager.onload = function() {
                // 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();
                }
            }

            function checkRAM() {
                if (soundManager.supported()) {
                    document.getElementById('flash-ram-use').innerHTML = (soundManager.getMemoryUse()/1024/1024).toFixed(2)+' MB';
                }
            }

            var t = null;
            var playedBGMID = 0;
            var imagePlay = "images/play.png";
            var imageStop = "images/stop.png";

            function playBGM(codeBGM, urlBGM) {
                var s = soundManager.createSound({
                    id:codeBGM,
                    url:urlBGM
                });
                //window.alert('played='+playedBGMID+"\n"+"newBGM="+codeBGM);

                if ( playedBGMID == 0) {
                    playedBGMID = codeBGM;
                    s.play({
                        onfinish:
                            function() {
                            this.play();
                        }
                    });
                    switchImage(codeBGM, imageStop);
                } else {
                    if (playedBGMID == codeBGM) {
                        soundManager.stop(playedBGMID);
                        switchImage(playedBGMID, imagePlay);
                        playedBGMID = 0;
                    } else {
                        soundManager.stop(playedBGMID);
                        switchImage(playedBGMID, imagePlay);
                        playedBGMID = codeBGM;
                        s.play({
                            onfinish:
                                function() {
                                this.play();
                            }
                        });
                        switchImage(codeBGM, imageStop);
                    }
                }
            }

            //        imgs[i].style.border='3px dashed #ccc';

            function switchImage(codeBGM, imageType)
            {
                /*          var imgs = document.getElementsByTagName('img');
            var i;
            window.alert(imgs.length);
            for (i in imgs)
            {
                window.alert(imgs[i].getAttribute('name').toString());
                if (imgs[i].getAttribute('name').toString()){
                    imageStr = "imgs["+i+"].i" + codeBGM + ".src=\'"+imageType+"\'";
                 */
                imageStr = "document.images." + codeBGM + ".src=\'"+imageType+"\'";
                eval(imageStr);

                //}
                //}
            }
