
function createPauseScreen(list) {
    //Crafty.audio.stop();

    if(list != undefined ){
        hideImages(list, false);    
    }
    
    var bg = Crafty.e("2D, Canvas, Image, Mouse").attr({x:0, y:0, w:480, h:280}).image("images/menu_bg.png");
    
    var resumeHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/resume2.png");
    resumeHover.x = bg._x+103; resumeHover.y = bg._y+17;
    resumeHover.alpha = 0.01;
    
    var resumeBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/resume1.png");
    resumeBtn.x = bg._x+103; resumeBtn.y = bg._y+17;

	var onBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/soundon.png");
    onBtn.x = bg._x+103; onBtn.y = bg._y+80;
    onBtn.originX = onBtn._x;
    
    var offBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/soundoff.png");
    offBtn.x = bg._x+103; offBtn.y = bg._y+80;
    offBtn.originX = offBtn._x;
    
    var helpBtnHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/help2.png");
    helpBtnHover.x = bg._x+103; helpBtnHover.y = bg._y+143;
    helpBtnHover.alpha = 0.01;
    
    var helpBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/help1.png");
    helpBtn.x = bg._x+103; helpBtn.y = bg._y+143;
    
    var mainMenuHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/mainmenu2.png");
    mainMenuHover.x = bg._x+103; mainMenuHover.y = bg._y+207;
    mainMenuHover.alpha = 0.01;
    
    var mainMenuBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/mainmenu1.png");
    mainMenuBtn.x = bg._x+103; mainMenuBtn.y = bg._y+207;


    bg.bind("MouseUp", function(e) { 
        helpBtn.alpha = 1;
        helpBtnHover.alpha = 0.01;
        resumeBtn.alpha = 1;
        resumeHover.alpha = 0.01;
        mainMenuBtn.alpha = 1;
        mainMenuHover.alpha = 0.01;
    });
    
    mainMenuBtn.bind("MouseDown", function(e) { 
        mainMenuBtn.alpha = 0.01;
        mainMenuHover.alpha = 1;
    });
    mainMenuBtn.bind("MouseUp", function(e) { 
        mainMenuBtn.alpha = 1;
        mainMenuHover.alpha = 0.01;
        playerNo = 0;
        Crafty.scene('GameMenu');
    });
    
	helpBtn.bind("MouseDown", function(e) { 
        helpBtn.alpha = 0.01;
        helpBtnHover.alpha = 1;
    });
    
    helpBtn.bind("MouseUp", function(e) { 
        helpBtn.alpha = 1;
        helpBtnHover.alpha = 0.01;
        createHelpScreen();
    });

    resumeBtn.bind("MouseDown", function(e) { 
        resumeBtn.alpha = 0.01;
        resumeHover.alpha = 1;
    });
    resumeBtn.bind("MouseUp", function(e) { 
        resumeBtn.alpha = 1;
        resumeHover.alpha = 0.01;
        deleteImages([bg,resumeBtn, resumeHover, mainMenuHover, helpBtnHover, onBtn,offBtn,helpBtn, mainMenuBtn]);
        playBgMusic("GameMusic")
    });


    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) {
        console.log("menu off btn clicked");
        soundBtn = 1;
        setAudioIsMuted(false)
        onBtn.visible = true;
        offBtn.visible = false;
        offBtn.x = -1000;
        onBtn.x = onBtn.originX
        playBgMusic("BgmMenu") 
            
	});
    offBtn.bind("MouseUp", function(e) {
        helpBtn.alpha = 1;
        helpBtnHover.alpha = 0.01;
        resumeBtn.alpha = 1;
        resumeHover.alpha = 0.01;
        mainMenuBtn.alpha = 1;
        mainMenuHover.alpha = 0.01;
    });

	onBtn.bind("MouseDown", function(e) {
        console.log("menu on btn clicked");
        soundBtn = 0;
        setAudioIsMuted(true)
        offBtn.visible = true;
        onBtn.visible = false;
        offBtn.x = offBtn.originX
        onBtn.x = -1000;
        Crafty.audio.stop();
        setBgMusicPlaying();
    });
    onBtn.bind("MouseUp", function(e) {
        helpBtn.alpha = 1;
        helpBtnHover.alpha = 0.01;
        resumeBtn.alpha = 1;
        resumeHover.alpha = 0.01;
        mainMenuBtn.alpha = 1;
        mainMenuHover.alpha = 0.01;
    });
    
//playBgMusic("BgmMenu")
}


