
function CreatePauseScreen(){
  console.log("GAME MEGamePauseNU SCREEN");

    fromPause = true;
    Crafty.audio.stop('GameMusic');
    
    var bg = Crafty.e("2D, Canvas, Image, Mouse").attr({x:0, y:0, w:480, h:280}).image("images/menuBg.png");
    
    var resumeHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/resume_button1.png");
    resumeHover.x = bg._x+182; resumeHover.y = bg._y+45;
    
    var resumeGameBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/resume_button.png");
    resumeGameBtn.x = bg._x+182; resumeGameBtn.y = bg._y+45;
    
    var helpBtnHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/help1.png");
    helpBtnHover.x = bg._x+182; helpBtnHover.y = bg._y+154;
    
    var helpBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/help.png");
    helpBtn.x = bg._x+182; helpBtn.y = bg._y+154;
    
    var onBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/on.png");
    onBtn.x = bg._x+182; onBtn.y = bg._y+100;
    onBtn.originX = onBtn._x;
    
    var offBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/off.png");
    offBtn.x = bg._x+182; offBtn.y = bg._y+100;
    offBtn.originX = offBtn._x;    

    var exitBtnHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/quit_button1.png");
    exitBtnHover.x = bg._x+182; exitBtnHover.y = bg._y+210;
    
    var exitUsBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/quit_button.png");
    exitUsBtn.x = bg._x+182; exitUsBtn.y = bg._y+210;


    if(getAudioIsMuted()) {
        offBtn.visible = true;
        onBtn.visible = false;
        onBtn.x = -1000;
    }
    else {
        offBtn.visible = false;
        onBtn.visible = true;
        offBtn.x = -1000;
    }
            
    offBtn.bind("MouseDown", function(e) {
        setAudioIsMuted(false)
        onBtn.visible = true;
        offBtn.visible = false;
        offBtn.x = -1000;
        onBtn.x = onBtn.originX
        playBgMusic("BgmMenu")
        soundBtn = 1;
  });
    
    onBtn.bind("MouseDown", function(e) {
        setAudioIsMuted(true)
        offBtn.visible = true;
        onBtn.visible = false;
        offBtn.x = offBtn.originX
        onBtn.x = -1000;
        Crafty.audio.stop();
        playSfxAudio("BtnClick");
        setBgMusicPlaying();
        soundBtn = 0;
    });
    
    
    helpBtn.bind("MouseDown", function(e) { 
        helpBtn.alpha = 0.01;
    });
    
    helpBtn.bind("MouseUp", function(e) {
        helpBtn.alpha = 1;
        playSfxAudio("BtnClick");
        createHelpScreen();
    });
     

    exitUsBtn.bind("MouseDown", function(e) { 
        exitUsBtn.alpha = 0.01;
    });
    
    exitUsBtn.bind("MouseUp", function(e) { 
        exitUsBtn.alpha = 1;
        playSfxAudio("BtnClick");
        createExitScreen();
    });
     
    resumeGameBtn.bind("MouseDown", function(e) { 
        resumeGameBtn.alpha = 0.01;
    });
    
    resumeGameBtn.bind("MouseUp", function(e) { 
        resumeGameBtn.alpha = 1;
        playSfxAudio("BtnClick");
        deleteImages([bg,resumeGameBtn, resumeHover, helpBtnHover, exitBtnHover, helpBtn, onBtn, offBtn, exitUsBtn]);
        beginRaceFunction();
        bgMovement();
        changeHorsePosition();
        playBgMusic("GameMusic")
    });
    
    
    bg.bind("MouseUp", function(e) { 
        exitUsBtn.alpha = 1;
        resumeGameBtn.alpha = 1;
        helpBtn.alpha = 1;
    });
    
    offBtn.bind("MouseUp", function(e) { 
        exitUsBtn.alpha = 1;
        resumeGameBtn.alpha = 1;
        helpBtn.alpha = 1;
    });
    
    onBtn.bind("MouseUp", function(e) { 
        exitUsBtn.alpha = 1;
        resumeGameBtn.alpha = 1;
        helpBtn.alpha = 1;
    });

    playBgMusic("BgmMenu");


}
 