function SoundController() {

    var self = this;

    this.url = null;

    this.imagePlayOff   = null;
    this.imagePlayHover = null;
    this.imageStopOff   = null;
    this.imageStopHover = null;

    this.soundManager   = null;

    this.init = function() {
        $('img.sample').attr('src',self.imagePlayOff);
        $('img.sample').imghover({src: self.imagePlayHover});
    }

    this.play = function(pId, pUrl) {

        $('img.sample').attr('src',self.imagePlayOff);
        $('img.sample').imghover({src: self.imagePlayHover});

        // Determine if this track is already playing, if so simply stop playing
        if (self.soundManager.soundIDs.contains(pId)) {
            if (1 == self.soundManager.sounds[pId].playState) {
                self.soundManager.stopAll();
                return;
            }
        }

        // Otherwise the sound is not already playing, so play it already
        self.soundManager.stopAll();
        self.soundManager.createSound({
            id: pId,
            url: pUrl,
            onfinish: function() {
                self.soundManager.stopAll();
            }
        });
        $('#sample_'+pId).attr('src',self.imageStopOff);
        $('#sample_'+pId).imghover({src: self.imageStopHover});
        self.soundManager.play(pId);
    };
}

var soundController = new SoundController();
