text: function CMain(oData){
      var _bUpdate;
      var _iCurResource = 0;
      var RESOURCE_TO_LOAD = 0;
      var _iState = STATE_LOADING;
      var _oData;
      
      var _oPreloader;
      var _oMenu;
      var _oModeMenu;
      var _oHelp;
      var _oGame;
  
      this.initContainer = function(){
          s_oCanvas = document.getElementById("canvas");
          s_oStage = new createjs.Stage(s_oCanvas);
          createjs.Touch.enable(s_oStage);
  		
  	s_bMobile = jQuery.browser.mobile;
          if(s_bMobile === false){
              s_oStage.enableMouseOver(20);  
              $('body').on('contextmenu', '#canvas', function(e){ return false; });
          }
  		
          s_iPrevTime = new Date().getTime();
  
  	createjs.Ticker.addEventListener("tick", this._update);
          createjs.Ticker.setFPS(30);
  
          if(navigator.userAgent.match(/Windows Phone/i)){
                  DISABLE_SOUND_MOBILE = true;
          }
          
          s_oSpriteLibrary  = new CSpriteLibrary();
  
          //ADD PRELOADER
          _oPreloader = new CPreloader();
  		
  	
      };
      
      this.preloaderReady = function(){
          if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
              this._initSounds();
          }
          
          this._loadImages();
          _bUpdate = true;
      };
      
      this.soundLoaded = function(){
          _iCurResource++;
          var iPerc = Math.floor(_iCurResource/RESOURCE_TO_LOAD *100);
          _oPreloader.refreshLoader(iPerc);
           
      };
      
      this._initSounds = function(){
          Howler.mute(!s_bAudioActive);
  
  
          s_aSoundsInfo = new Array();
          s_aSoundsInfo.push({path: './game9/sounds/',filename:'click',loop:false,volume:1, ingamename: 'click'});
          s_aSoundsInfo.push({path: './game9/sounds/',filename:'game_over',loop:false,volume:1, ingamename: 'game_over'});
          s_aSoundsInfo.push({path: './game9/sounds/',filename:'launch_ball',loop:false,volume:1, ingamename: 'launch_ball'});
          s_aSoundsInfo.push({path: './game9/sounds/',filename:'win_row',loop:false,volume:1, ingamename: 'win_row'});
          s_aSoundsInfo.push({path: './game9/sounds/',filename:'win',loop:false,volume:1, ingamename: 'win'});
          s_aSoundsInfo.push({path: './game9/sounds/',filename:'soundtrack',loop:true,volume:1, ingamename: 'soundtrack'});
          
          RESOURCE_TO_LOAD += s_aSoundsInfo.length;
  
          s_aSounds = new Array();
          for(var i=0; i<s_aSoundsInfo.length; i++){
              this.tryToLoadSound(s_aSoundsInfo[i], false);
          }
          
      };
  
      this.tryToLoadSound = function(oSoundInfo, bDelay){
          
         setTimeout(function(){        
              s_aSounds[oSoundInfo.ingamename] = new Howl({ 
                                                              src: [oSoundInfo.path+oSoundInfo.filename+'.mp3'],
                                                              autoplay: false,
                                                              preload: true,
                                                              loop: oSoundInfo.loop, 
                                                              volume: oSoundInfo.volume,
                                                              onload: s_oMain.soundLoaded,
                                                              onloaderror: function(szId,szMsg){
                                                                                  for(var i=0; i < s_aSoundsInfo.length; i++){
                                                                                       if ( szId === s_aSounds[s_aSoundsInfo[i].ingamename]._sounds[0]._id){
                                                                                           s_oMain.tryToLoadSound(s_aSoundsInfo[i], true);
                                                                                           break;
                                                                                       }
                                                                                  }
                                                                          },
                                                              onplayerror: function(szId) {
                                                                  for(var i=0; i < s_aSoundsInfo.length; i++){
                                                                                       if ( szId === s_aSounds[s_aSoundsInfo[i].ingamename]._sounds[0]._id){
                                                                                            s_aSounds[s_aSoundsInfo[i].ingamename].once('unlock', function() {
                                                                                              s_aSounds[s_aSoundsInfo[i].ingamename].play();
                                                                                              if(s_aSoundsInfo[i].ingamename === "soundtrack" && s_oGame !== null){
                                                                                                  setVolume("soundtrack",SOUNDTRACK_VOLUME_IN_GAME);
                                                                                              }
  
                                                                                            });
                                                                                           break;
                                                                                       }
                                                                                   }
                                                                         
                                                              } 
                                                          });
  
              
          }, (bDelay ? 200 : 0) );
          
          
      };
  
  
      this._loadImages = function(){
          s_oSpriteLibrary.init( this._onImagesLoaded,this._onAllImagesLoaded, this );
  
          s_oSpriteLibrary.addSprite("but_play","./game9/sprites/but_play.png");
          s_oSpriteLibrary.addSprite("msg_box","./game9/sprites/msg_box.png");
          
          s_oSpriteLibrary.addSprite("bg_menu","./game9/sprites/bg_menu.jpg");         
          s_oSpriteLibrary.addSprite("bg_game","./game9/sprites/bg_game.jpg");
          s_oSpriteLibrary.addSprite("bg_select_card","./game9/sprites/bg_select_card.jpg");
          
          s_oSpriteLibrary.addSprite("but_exit","./game9/sprites/but_exit.png");
          s_oSpriteLibrary.addSprite("but_paytable","./game9/sprites/but_paytable.png");
          s_oSpriteLibrary.addSprite("audio_icon","./game9/sprites/audio_icon.png");
          s_oSpriteLibrary.addSprite("but_plus","./game9/sprites/but_plus.png");
          s_oSpriteLibrary.addSprite("but_generic","./game9/sprites/but_generic.png");
          s_oSpriteLibrary.addSprite("plus_display","./game9/sprites/plus_display.png");
  
          s_oSpriteLibrary.addSprite("money_panel","./game9/sprites/money_panel.png");
  
          s_oSpriteLibrary.addSprite("tube","./game9/sprites/tube.png");
          s_oSpriteLibrary.addSprite("ball","./game9/sprites/ball.png");
          
          s_oSpriteLibrary.addSprite("card_cell","./game9/sprites/card_cell.png");
          s_oSpriteLibrary.addSprite("but_gui","./game9/sprites/but_gui.png");
          s_oSpriteLibrary.addSprite("but_ball","./game9/sprites/but_ball.png");
          s_oSpriteLibrary.addSprite("board_cell","./game9/sprites/board_cell.png");
          s_oSpriteLibrary.addSprite("number_extract_bg","./game9/sprites/number_extract_bg.png");
          s_oSpriteLibrary.addSprite("ball_preview","./game9/sprites/ball_preview.png");
          s_oSpriteLibrary.addSprite("card_highlight_1","./game9/sprites/card_highlight_1.png");
          s_oSpriteLibrary.addSprite("card_highlight_2","./game9/sprites/card_highlight_2.png");
          s_oSpriteLibrary.addSprite("display_small","./game9/sprites/display_small.png");
          s_oSpriteLibrary.addSprite("but_fullscreen","./game9/sprites/but_fullscreen.png");
          s_oSpriteLibrary.addSprite("logo_credits","./game9/sprites/logo_credits.png");
          
          RESOURCE_TO_LOAD += s_oSpriteLibrary.getNumSprites();
          s_oSpriteLibrary.loadSprites();
      };
      
      this._onImagesLoaded = function(){
          _iCurResource++;
          var iPerc = Math.floor(_iCurResource/RESOURCE_TO_LOAD *100);
          ////console.log("PERC: "+iPerc);
          _oPreloader.refreshLoader(iPerc);
  
      };
      
      this._onAllImagesLoaded = function(){
          
      };
      
      this._onRemovePreloader = function(){
          _oPreloader.unload();
              
          playSound("soundtrack", 1, true);
  
          this.gotoMenu();
      };
      
      this.gotoMenu = function(){
          _oMenu = new CMenu();
          _iState = STATE_MENU;
      };
  
      this.gotoGame = function(){
          _oGame = new CGame(_oData);   						
          _iState = STATE_GAME;
  
          $(s_oMain).trigger("game_start");
      };
      
      this.gotoHelp = function(){
          _oHelp = new CHelp();
          _iState = STATE_HELP;
      };
  	
      this.stopUpdate = function(){
          _bUpdate = false;
          createjs.Ticker.paused = true;
          $("#block_game").css("display","block");
          
          if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
              Howler.mute(true);
          }
          
      };
  
      this.startUpdate = function(){
          s_iPrevTime = new Date().getTime();
          _bUpdate = true;
          createjs.Ticker.paused = false;
          $("#block_game").css("display","none");
          
          if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
              if(s_bAudioActive){
                  Howler.mute(false);
              }
          }
          
      };
      
      this._update = function(event){
          if(_bUpdate === false){
                  return;
          }
          var iCurTime = new Date().getTime();
          s_iTimeElaps = iCurTime - s_iPrevTime;
          s_iCntTime += s_iTimeElaps;
          s_iCntFps++;
          s_iPrevTime = iCurTime;
          
          if ( s_iCntTime >= 1000 ){
              s_iCurFps = s_iCntFps;
              s_iCntTime-=1000;
              s_iCntFps = 0;
          }
                  
          if(_iState === STATE_GAME){
              _oGame.update();
          }
          
          s_oStage.update(event);
  
      };
      
      s_oMain = this;
      
      _oData = oData;
      ENABLE_CHECK_ORIENTATION = oData.check_orientation;
      SHOW_CREDITS = oData.show_credits;
      ENABLE_FULLSCREEN = _oData.fullscreen;
      s_bAudioActive = oData.audio_enable_on_startup;
      
      this.initContainer();
  }
  var s_bMobile;
  var s_bAudioActive = true;
  var s_iCntTime = 0;
  var s_iTimeElaps = 0;
  var s_iPrevTime = 0;
  var s_iCntFps = 0;
  var s_iCurFps = 0;
  
  var s_oDrawLayer;
  var s_oStage;
  var s_oMain;
  var s_oSpriteLibrary;
  var s_oSoundTrack;
  var s_oCanvas;
  var s_bFullscreen = false;