var sound = new function(){
    var _this = this;
    this.dflCat = null;
    this.init = function(){
        _this.dflCat = menu.getCategoryByName('default');
        _this.lastSoundUrl = _this.dflCat.sound;
        var flashvars = {
            appName: "toyota_akcesoria_sound_controler",
            soundURL: _this.dflCat.sound,
            xmlPath:"xml.xml"
        };
        swfobject.embedSWF("new/soundButton.swf", "soundButton", "21", "16", "10.0.0", "expressInstall.swf", flashvars, {wmode: 'transparent'});        
    };
    
    this.lastState = "play";

    this.getMovie = function(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
                return window[movieName];
        } else {
                return document[movieName];
        }
    };			
    this.play = function(fadeTime) {
        _this.lastState = 'play';
        if( typeof fadeTime == "udefined")
                fadeTime = 0;
        try{
            _this.getMovie("soundButton").player_play(fadeTime);
        }catch(e){};
        
    };
    this.pause = function(fadeTime) {
        _this.lastState = 'pause';        
        //console.log('fadeTime: ' + fadeTime)
        if( typeof fadeTime == "udefined")
                fadeTime = 0;
        try{
            _this.getMovie("soundButton").player_pause(fadeTime);
        }catch(e){};
        
    };
    this.stop = function(fadeTime) {
        _this.lastState = 'stop';
        if( typeof fadeTime == "udefined")
                fadeTime = 0;
        try{
            _this.getMovie("soundButton").player_stop(fadeTime);
        }catch(e){};        
    };
    this.lastSoundUrl = null;
    this.load = function(soundURL) {
        if (!soundURL)
            soundURL =  _this.dflCat.sound;
        _this.lastState = 'load';
        if (_this.lastSoundUrl == soundURL)
            return;
        _this.lastSoundUrl = soundURL;
        try{
            _this.getMovie("soundButton").player_loadSound(soundURL);
        }catch(e){};        
    };     
    
}

