﻿
function loopSound(soundID) {
    window.setTimeout(function() {
        soundManager.play(soundID, { onfinish: function() { loopSound(soundID); } });
    }, 1);
}

$("document").ready(function() {
    $('#Banner').jqFancyTransitions({ width: 682, height: 255 });

    soundManager.url = '/swf/';
    //soundManager.flashVersion = 9; // optional: shiny features (default = 8)
    soundManager.useFlashBlock = false; // optionally, enable when you're ready to dive in
    // enable HTML5 audio support, if you're feeling adventurous. iPad/iPhone will always get this.
    // soundManager.useHTML5Audio = true;
    soundManager.debugMode = false

    soundManager.onready(function() {
        if (soundManager.supported()) {
            soundManager.createSound({
                id: 'mySound',
                url: '/music/music.mp3',
                autoLoad: true,
                autoPlay: false,
                onload: function() {
                    if ($.cookie("PlaySounds") == null | $.cookie("PlaySounds") == "TRUE") {
                        loopSound("mySound");
                        $("#PlaySound").hide();
                    } else {
                        $("#PauseSound").hide();
                    }
                },
                volume: 50
            });


        } else {
            // unsupported/error case
        }
    });

    $("#PlaySound").click(function() {
        $.cookie("PlaySounds", "TRUE", { expires: 365 });
        loopSound("mySound");
        $("#PlaySound").hide();
        $("#PauseSound").show();
    });
    $("#PauseSound").click(function() {
    $.cookie("PlaySounds", "FALSE", { expires: 365 });
        soundManager.stop("mySound");
        $("#PauseSound").hide();
        $("#PlaySound").show();
    });

});


