
Crafty.scene('GamePlay', function() {
    console.log("GAME PLAY SCREEN");
    
    Crafty.audio.stop();
    setBgMusicPlaying();
    
    var lNumberValue;           //  numeric value of star & shell images
    var lBoxValue1, lBoxValue2, lBoxValue3;     //  variables holds lNumberValue at rect1, rect2, rect3
    var lBoxValue4, lBoxValue5, lBoxValue6;     //  variables holds lNumberValue at rect4, rect5, rect6
    var lBoxValue7, lBoxValue8, lBoxValue9;     //  variables holds lNumberValue at rect7, rect8, rect9
    var lTurn = 1;  
    var lWinTurn;
    var lTotalMove = 0; 
    var rect11 = 0;     //  numeric value for rect1
    var rect22 = 0;     //  numeric value for rect2
    var rect33 = 0;     //  numeric value for rect3
    var rect44 = 0;     //  numeric value for rect4
    var rect55 = 0;     //  numeric value for rect5
    var rect66 = 0;     //  numeric value for rect6
    var rect77 = 0;     //  numeric value for rect7
    var rect88 = 0;     //  numeric value for rect8
    var rect99 = 0;     //  numeric value for rect9
    var lValue1,lValue2;
    var imgValue1, imgValue2;
    var randomNumber;
    var lSpeed = 50;        // speed for move the image      
    var playerNo;
    var img1,img2;
    var playerTurn;
    var playerText, botText, player1Text, player2Text;
    var winLine;        //  winning line for winning combination
    var i;
    var lHoverClick = true;
    var gameBegin = true;       //  used for start dragging
    var moveNo;
    var gameMove = false;
    
    //  ingame background
    var bg = Crafty.e("2D, Canvas, Image, Mouse").attr({x:0, y:0, w:480, h:280}).image("images/ingame_bg2.png");
   
    var maskingBg = Crafty.e("2D, Canvas, Image, Mouse").image("images/masking1.png");
    maskingBg.x = bg.x;   maskingBg.y = bg.y;
    
    maskingBg.bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    
    maskingBg.bind('MouseUp',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    
    
    
    
    //  mousemove event on ingame background
    bg.bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    //  mouseup event on ingame background
    bg.bind('MouseUp',function(e){
        pauseBtn.alpha = 1;
        pauseBtnHover.alpha = 0.01;
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    
    
    //    selection background for selected box
    var selectBg = Crafty.e("2D, Canvas, TileBg");
    selectBg.alpha = 0.01;
    
    //  mouseup event on selection background
    selectBg.bind('MouseUp',function(e){
        pauseBtn.alpha = 1;
        pauseBtnHover.alpha = 0.01;
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = -1000;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = -1000;
            }
        }
    });
    
    
    //  canvas on each box
    var rect1 = Crafty.e("2D, Canvas, touchBox");
    rect1.x=bg._x+110;  rect1.y=bg._y+45;
    rect1.alpha = 0.01;
        
    var rect2 = Crafty.e("2D, Canvas, touchBox");
    rect2.x=bg._x+203;  rect2.y=bg._y+45;
    rect2.alpha = 0.01;
   
    var rect3 = Crafty.e("2D, Canvas, touchBox");
    rect3.x=bg._x+295;  rect3.y=bg._y+45;
    rect3.alpha = 0.01;
    
    var rect4 = Crafty.e("2D, Canvas, touchBox");
    rect4.x=bg._x+108;  rect4.y=bg._y+106;
    rect4.alpha = 0.01;
    
    var rect5 = Crafty.e("2D, Canvas, touchBox");
    rect5.x=bg._x+200;  rect5.y=bg._y+106;
    rect5.alpha = 0.01;
    
    var rect6 = Crafty.e("2D, Canvas, touchBox");
    rect6.x=bg._x+300;  rect6.y=bg._y+106;
    rect6.alpha = 0.01;
    
    var rect7 = Crafty.e("2D, Canvas, touchBox");
    rect7.x=bg._x+95;  rect7.y=bg._y+178;
    rect7.alpha = 0.01;
    
    var rect8 = Crafty.e("2D, Canvas, touchBox");
    rect8.x=bg._x+200;  rect8.y=bg._y+178;
    rect8.alpha = 0.01;
    
    var rect9 = Crafty.e("2D, Canvas, touchBox");
    rect9.x=bg._x+305;  rect9.y=bg._y+178;
    rect9.alpha = 0.01;
    
    //  Array for star images
    var star1 = new Array(Crafty.e("2D, Canvas, Img0"), Crafty.e("2D, Canvas, Img0"), Crafty.e("2D, Canvas, Img0"),
                          Crafty.e("2D, Canvas, Img0"), Crafty.e("2D, Canvas, Img0"), Crafty.e("2D, Canvas, Img0"),
                          Crafty.e("2D, Canvas, Img0"));
    
    star1[0].alpha = 0.01;
    star1[0].x = -1000;
    
    star1[1].alpha = 0.01;
    star1[1].x = -1000;
    
    star1[2].alpha = 0.01;
    star1[2].x = -1000;
    
    star1[3].alpha = 0.01;
    star1[3].x = -1000;
    
    star1[4].alpha = 0.01;
    star1[4].x = -1000;
    
    star1[5].alpha = 0.01;
    star1[5].x = -1000;
    
    star1[6].alpha = 0.01;
    star1[6].x = -1000;
    
    //  Array for shell images    
    var shell1 = new Array(Crafty.e("2D, Canvas, Img1"), Crafty.e("2D, Canvas, Img1"), Crafty.e("2D, Canvas, Img1"),
                           Crafty.e("2D, Canvas, Img1"), Crafty.e("2D, Canvas, Img1"), Crafty.e("2D, Canvas, Img1"),
                           Crafty.e("2D, Canvas, Img1"));

    shell1[0].alpha = 0.01;
    shell1[0].x = -1000;
    
    shell1[1].alpha = 0.01;
    shell1[1].x = -1000;
    
    shell1[2].alpha = 0.01;
    shell1[2].x = -1000;
    
    shell1[3].alpha = 0.01;
    shell1[3].x = -1000;
    
    shell1[4].alpha = 0.01;
    shell1[4].x = -1000;
    
    shell1[5].alpha = 0.01;
    shell1[5].x = -1000;
    
    shell1[6].alpha = 0.01;
    shell1[6].x = -1000;
    
    
    //  mousemove event on shell1 array images
    shell1[0].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    shell1[1].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    shell1[2].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    shell1[3].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    shell1[4].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    shell1[5].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    star1[0].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    //  mousemove event on star1 array images
    star1[1].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    star1[2].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    star1[3].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    star1[4].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    star1[5].bind('MouseMove',function(e){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
   

    //  mouseup event on star1 array images    
    star1[0].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    star1[1].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    star1[2].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    star1[3].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    star1[4].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    star1[5].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    
    
    //  mouseup event on shell1 array images
    shell1[0].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    shell1[1].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    shell1[2].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    shell1[3].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    shell1[4].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    shell1[5].bind("MouseUp", function(e) {
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    
    
    //  function for delete the array elements
    function stopOverride(){
        if(noOfPlayer == 1){
            if(lTurn == 1){
                img1.x = -1000;
            }
            else{
                img2.x = -1000;
            }
        }
        else{
            if(playerTurn == true){
                if(lTurn == 1){
                    img1.x = -1000;
                }
                else{
                    img2.x = -1000;
                }
            }
            else{
                if(lTurn == 1){
                    img1.x = -1000;
                }
                else{
                    img2.x = -1000; 
                }
            }
        }
    }
    
    
    //  object for star image
    var player1Select = Crafty.e("2D, Canvas, Img0, Mouse");
    player1Select.x = bg._x+15;           player1Select.y = bg._y+40;
    
    //  object for shell image
    var player2Select = Crafty.e("2D, Canvas, Img1, Mouse");
    player2Select.x = bg._x+395;       player2Select.y = bg._y+40;
    
    player1Select.alpha = 0.01;
    player2Select.alpha = 0.01;
    
    //  select player background
    var blackBg = Crafty.e("2D, Canvas, Image, Mouse").image('images/selectingscreem.png');
    blackBg.x = bg._x+65; blackBg.y = bg._y+35;
    
    //  select player image
    if(noOfPlayer == 1){
        var selectTag = Crafty.e("2D, Canvas, Image").image("images/selectobject.png");
        selectTag.x = bg._x+135; selectTag.y = blackBg._y+20;
    }
    else{
        var selectTag = Crafty.e("2D, Canvas, Image").image("images/selectobject1.png");
        selectTag.x = bg._x+73; selectTag.y = blackBg._y+20;
    }
    
    //  star highlight image
    var starBtnHover = Crafty.e("2D, Canvas, Star1");
    starBtnHover.x = bg._x+125; starBtnHover.y = bg._y+98;
    starBtnHover.alpha = 0.01;
    
    //  star image for select player
    var starBtn = Crafty.e("2D, Canvas, Img0");
    starBtn.x = bg._x+125; starBtn.y = bg._y+98;
    
    //  shell highlight image
    var shellBtnHover = Crafty.e("2D, Canvas, Shell1");
    shellBtnHover.x = bg._x+265; shellBtnHover.y = bg._y+98;
    shellBtnHover.alpha = 0.01;
    
    //  shell image for select player
    var shellBtn = Crafty.e("2D, Canvas, Img1");
    shellBtn.x = bg._x+265; shellBtn.y = bg._y+98;
    
    
    
    starBtn.bind("MouseDown", function(e) { 
        playSfxAudio("Fix");
        i = 0;
        playerNo = 1;
        playerTurn = true;
        if(noOfPlayer == 1){
            playerText = Crafty.e('2D, Canvas, Image').image('images/player.png');
            playerText.x = bg._x+12;  playerText.y = bg._y+100;
                
            botText = Crafty.e('2D, Canvas, Image').image('images/bot.png');
            botText.x = bg._x+415;  botText.y = bg._y+100
        }
        else{
            player1Text = Crafty.e('2D, Canvas, Image').image('images/player1.png');
            player1Text.x = bg._x+12;  player1Text.y = bg._y+100;
            
            player2Text = Crafty.e('2D, Canvas, Image').image('images/player2.png');
            player2Text.x = bg._x+401;  player2Text.y = bg._y+100;
        
//            var player1turn = Crafty.e('2D, Canvas, Image').image('images/player1turn.png');
//            player1turn.x = bg._x+145;   player1turn.y = bg._y+115;
//            
//             setTimeout(function(){
//                 player1turn.destroy();
//                 gameMove = true;
//             }, 1000);
        
        }
        selectTag.destroy();
        blackBg.destroy();
        
        starBtnHover.tween({x:player1Select.x, y:player1Select.y},30);
        starBtn.tween({x:player1Select.x, y:player1Select.y},30);
        shellBtnHover.tween({x:player2Select.x, y:player2Select.y},30);
        shellBtn.tween({x:player2Select.x, y:player2Select.y},30);
        
        starBtn.unbind('MouseDown', this.starBtn);
        shellBtn.unbind('MouseDown', this.shellBtn);
        
        setTimeout(function(){
            if(noOfPlayer == 1){
                moveNo = Crafty.math.randomInt(1,2);
                randomMove();
            }else{
                moveNo = Crafty.math.randomInt(1,2);
                randomTwoMove();         
            }
        },800);
        
    });
    
   
    
   
    
    
    shellBtn.bind("MouseDown", function(e) { 
        playSfxAudio("Fix");
        i = 0;
        playerNo = 2;
        playerTurn = false;
        selectTag.destroy();
        blackBg.destroy();
        if(noOfPlayer == 1){
            playerText = Crafty.e('2D, Canvas, Image').image('images/player.png');
            playerText.x = bg._x+407;  playerText.y = bg._y+100
            botText = Crafty.e('2D, Canvas, Image').image('images/bot.png');
            botText.x = bg._x+25;  botText.y = bg._y+100
        }
        else{
            player1Text = Crafty.e('2D, Canvas, Image').image('images/player1.png');
            player1Text.x = bg._x+401;  player1Text.y = bg._y+97;
            
            player2Text = Crafty.e('2D, Canvas, Image').image('images/player2.png');
            player2Text.x = bg._x+12;  player2Text.y = bg._y+100;
        
//            var player1turn = Crafty.e('2D, Canvas, Image').image('images/player1turn.png');
//            player1turn.x = bg._x+145;   player1turn.y = bg._y+115;
            
//            setTimeout(function(){
//                 player1turn.destroy();
//                 gameMove = true;
//             }, 1000);
        
        }
               
        starBtnHover.tween({x:player1Select.x, y:player1Select.y},30);
        starBtn.tween({x:player1Select.x, y:player1Select.y},30);
        shellBtnHover.tween({x:player2Select.x, y:player2Select.y},30);
        shellBtn.tween({x:player2Select.x, y:player2Select.y},30);
        
        starBtn.unbind('MouseDown', this.starBtn);
        shellBtn.unbind('MouseDown', this.shellBtn);
        
        setTimeout(function(){
            if(noOfPlayer == 1){
                moveNo = Crafty.math.randomInt(1,2);
                randomMove();
            }
            else{
                moveNo = Crafty.math.randomInt(1,2);
                randomTwoMove();         
            }
        },800);
        
    });
        
    
    
     // function used for choose first move randomly in two player mode
    function randomTwoMove(){
        if(moveNo == 2){
            lTurn = 0;
            var player2turn = Crafty.e('2D, Canvas, Image').image('images/player2turn.png');
            player2turn.x = bg._x+145;   player2turn.y = bg._y+115;
            if(playerNo == 1){
                starBtnHover.alpha = 0.01;
                starBtn.alpha = 1;
                shellBtnHover.alpha = 1;
                shellBtn.alpha = 0.01;
                player2Select.alpha = 1;
                    player1Select.alpha = 1;
                    starBtn.destroy();
                    shellBtn.destroy();
                        playerTurn = false;  
              setTimeout(function(){
                    player2turn.destroy();
                    
                    gameMove = true;
              },1000);  
            }
            else{
                starBtnHover.alpha = 1;
                starBtn.alpha = 0.01;
                shellBtnHover.alpha = 0.01;
                shellBtn.alpha = 1;
                player2Select.alpha = 1;
                    player1Select.alpha = 1;
                    starBtn.destroy();
                    shellBtn.destroy();
          setTimeout(function(){
                   player2turn.destroy();
                    playerTurn = true;
                    gameMove = true;
              },1000);  
            }

        }
        else{
            var player1turn = Crafty.e('2D, Canvas, Image').image('images/player1turn.png');
            player1turn.x = bg._x+145;   player1turn.y = bg._y+115;
            
            
            if(playerNo == 1){
                starBtnHover.alpha = 1;
                starBtn.alpha = 0.01;
                shellBtnHover.alpha = 0.01;
                shellBtn.alpha = 1;
                starBtn.destroy();
                player2Select.alpha = 1;
                shellBtn.destroy();
                
                setTimeout(function(){
                    
                    player1turn.destroy();
                   
                    gameMove = true;
            },800);
            }
            else{
                starBtnHover.alpha = 0.01;
                starBtn.alpha = 1;
                shellBtnHover.alpha = 1;
                shellBtn.alpha = 0.01;
                starBtn.destroy();
                shellBtn.destroy();
                player1Select.alpha = 1;
                setTimeout(function(){
                  
                    player1turn.destroy();
                    
                    gameMove = true;
              },800);
            
            }
        }
    }
    
    
    
    
     // function used for choose first move randomly in single player mode 
    function randomMove(){
        if(moveNo == 2){
            var compTurn = Crafty.e('2D, Canvas, Image').image('images/botturn.png');
            compTurn.x = bg._x+165;   compTurn.y = bg._y+115;
            if(playerNo == 1){
                starBtnHover.alpha = 0.01;
                starBtn.alpha = 1;
                shellBtnHover.alpha = 1;
                shellBtn.alpha = 0.01;
                
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = bg._x+395;   img2.y = bg._y+40;
                i +=1;
                
                setTimeout(function(){
                    compTurn.destroy();
                    img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
                    starBtnHover.alpha = 1;
                    shellBtnHover.alpha = 0.01;
                    player2Select.alpha = 1;
                    starBtn.destroy();
                    shellBtn.destroy();
                    gameMove = true;
                },1000);  
            }
            else{
                starBtnHover.alpha = 1;
                starBtn.alpha = 0.01;
                shellBtnHover.alpha = 0.01;
                shellBtn.alpha = 1;
                
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = bg._x+15;   img2.y = bg._y+40;
                i +=1;
            
                setTimeout(function(){
                    compTurn.destroy();
                    img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
                    starBtnHover.alpha = 0.01;
                    shellBtnHover.alpha = 1;
                    player1Select.alpha = 1;
                    starBtn.destroy();
                    shellBtn.destroy();
                    gameMove = true;
                },1000);  
            }
            rect3.unbind('MouseDown', this.rect3);
            rect3.unbind('MouseUp', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else{
            var playerTurn = Crafty.e('2D, Canvas, Image').image('images/playerturn.png');
            playerTurn.x = bg._x+145;   playerTurn.y = bg._y+115;
            
            if(playerNo == 1){
                starBtnHover.alpha = 1;
                starBtn.alpha = 0.01;
                shellBtnHover.alpha = 0.01;
                shellBtn.alpha = 1;
        
                setTimeout(function(){
                    starBtn.destroy();
                    shellBtn.destroy();
                    player2Select.alpha = 1;
                    playerTurn.destroy();
                    gameMove = true;
                },800);
            }
            else{
                starBtnHover.alpha = 0.01;
                starBtn.alpha = 1;
                shellBtnHover.alpha = 1;
                shellBtn.alpha = 0.01;
        
                setTimeout(function(){
                    starBtn.destroy();
                    shellBtn.destroy();
                    player1Select.alpha = 1;
                    playerTurn.destroy();
                    gameMove = true;
                },800);
            
            }
        }
    }
    
    
    starBtnHover.bind('MouseDown',function(){
        if(gameMove == true){
        if(noOfPlayer == 1){
            if(playerNo == 1){
                imgValue1 = 0;
                imgValue2 = 1;
                gameBegin = false;
                if(lHoverClick == false){
                    i += 1;
                    starBtnHover.unbind('MouseDown', this.starBtnHover);
                }
                img1 = star1[i];
                img1.alpha = 1;
                img1.x = starBtnHover.x;   img1.y = starBtnHover.y;
                shellBtnHover.unbind('MouseDown', this.shellBtnHover);
            }
        }
        else if(noOfPlayer == 2){
            if(playerTurn == true){
                imgValue1 = 0;
                imgValue2 = 1;
                if(lTurn == 0){
                    gameBegin = false;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                }
                else{
                    gameBegin = false;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = starBtnHover.x;   img1.y = starBtnHover.y;
                }
            }
        }}
    });
    
    
    shellBtnHover.bind('MouseDown',function(){
        if(gameMove == true){
        if(noOfPlayer == 1){
            if(playerNo == 2){
                imgValue1 = 1;
                imgValue2 = 0;
                gameBegin = false;
                if(lHoverClick == false){
                    i += 1;
                   shellBtnHover.unbind('MouseDown', this.shellBtnHover);
                }
                
                img1 = shell1[i];
                img1.alpha = 1;
                img1.x = shellBtnHover.x;   img1.y = shellBtnHover.y;
                starBtnHover.unbind('MouseDown', this.starBtnHover);
            }
        }
        else if(noOfPlayer == 2){
            if(playerTurn == false){
                imgValue1 = 1;
                imgValue2 = 0;
                if(lTurn == 0){
                    gameBegin = false;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                }
                else{
                    gameBegin = false;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = shellBtnHover.x;   img1.y = shellBtnHover.y;
                }
               
            }
        }}
    });
    
    
    starBtnHover.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
         if(gameBegin == false){
            stopOverride();
             gameBegin = true;
        }
    });
    shellBtnHover.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
            gameBegin = true;
        }
    });
 
  
    
    
    //  mouse event on  rect1 canvas
    rect1.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect1);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect1._x-6;  img1.y = rect1._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect1._x-6, y:rect1._y-5}, 30);
            }
            gameBegin = true;
            rect11 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue1 = img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2 && lTurn == 0){
            playSfxAudio("Fix");
            rect11 = 1;
            if(gameBegin == false){
                img2.x = rect1._x-6;  img2.y = rect1._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect1._x-6, y:rect1._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            lBoxValue1 = img2.lNumberValue;
            i +=1;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            checkForWinner();  
        }   
        }
    });
    
    //  mouse event on  rect2 canvas
    rect2.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect2);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect2._x-6;  img1.y = rect2._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect2._x-6, y:rect2._y-5}, 30);
            }
            gameBegin = true;
            rect22 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue2 = img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect22 = 1;
            if(gameBegin == false){
                img2.x = rect2._x-6;  img2.y = rect2._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect2._x-6, y:rect2._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            lBoxValue2 = img2.lNumberValue;
            i +=1;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect3 canvas
    rect3.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect3);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect3._x-6;  img1.y = rect3._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect3._x-6, y:rect3._y-5}, 30);
            }
            gameBegin = true;
            rect33 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue3 = img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect33 = 1;
            if(gameBegin == false){
                img2.x = rect3._x-6;  img2.y = rect3._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect3._x-6, y:rect3._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            lBoxValue3 = img2.lNumberValue;
            i +=1;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect4 canvas
    rect4.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect4);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect4._x-6;  img1.y = rect4._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect4._x-6, y:rect4._y-5}, 30);
            }
            gameBegin = true;
            rect44 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue4= img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect44 = 1;
            if(gameBegin == false){
                img2.x = rect4._x-6;  img2.y = rect4._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect4._x-6, y:rect4._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            lBoxValue4 = img2.lNumberValue;
            i +=1;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect5 canvas
    rect5.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect5);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect5._x-6;  img1.y = rect5._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect5._x-6, y:rect5._y-5}, 30);
            }
            gameBegin = true;
            rect55=1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue5= img1.lNumberValue;
            if(noOfPlayer == 1){
                randomNumber = Crafty.math.randomInt(1,4);
                if(randomNumber == 2){randomNumber = 7;}
                if(randomNumber == 4){randomNumber = 9;}
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect55 = 1;
            if(gameBegin == false){
                img2.x = rect5._x-6;  img2.y = rect5._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect5._x-6, y:rect5._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            lBoxValue5 = img2.lNumberValue;
            i +=1;
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect6 canvas
    rect6.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect6);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect6._x-6;  img1.y = rect6._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect6._x-6, y:rect6._y-5}, 30);
            }
            gameBegin = true;
            rect66 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue6 = img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect66 = 1;
            if(gameBegin == false){
                img2.x = rect6._x-6;  img2.y = rect6._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect6._x-6, y:rect6._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            lBoxValue6 = img2.lNumberValue;
            i +=1;
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect7 canvas
    rect7.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect7);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect7._x-6;  img1.y = rect7._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect7._x-6, y:rect7._y-5}, 30);
            }
            gameBegin = true;
            rect77 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue7= img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect77 = 1;
            if( playerNo == 1){
                img2 = shell1[i];
                img2.alpha = 1;
                img2.x = bg._x+395;  img2.y = bg._y+40;
            }
            else{
                img2 = star1[i];
                img2.alpha = 1;
                img2.x = bg._x+15;  img2.y = bg._y+40;
            }
            img2.tween({x: rect7._x-6, y:rect7._y-5}, 30);
            lTurn = 1;
            lWinTurn = lTurn;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            lBoxValue7 = img2.lNumberValue;
            i +=1;
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect8 canvas
    rect8.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect8);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect8._x-6;  img1.y = rect8._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect8._x-6, y:rect8._y-5}, 30);
            }
            gameBegin = true;
            rect88 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue8= img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            rect88 = 1;
            selectBg.alpha = 0.01;
            playSfxAudio("Fix");
            if(gameBegin == false){
                img2.x = rect8._x-6;  img2.y = rect8._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect8._x-6, y:rect8._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            lBoxValue8 = img2.lNumberValue;
            i +=1;
            checkForWinner();
        }
        }
    });
    
    //  mouse event on  rect9 canvas
    rect9.bind('MouseUp',function(){
        selectBg.alpha = 0.01;
        if(gameMove == true){
        this.unbind('MouseUp', this.rect9);
        if(lTurn == 1){
            playSfxAudio("Fix");
            if(gameBegin == false){
                img1.x = rect9._x-6;  img1.y = rect9._y-5;               
            }
            else{
                if( playerNo == 2){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img1 = shell1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+395;  img1.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img1 = star1[i];
                    img1.alpha = 1;
                    img1.x = bg._x+15;  img1.y = bg._y+40;
                }
                img1.tween({x: rect9._x-6, y:rect9._y-5}, 30);
            }
            gameBegin = true;
            rect99 = 1;
            lTurn = 0;
            lWinTurn = lTurn;
            lBoxValue9= img1.lNumberValue;
            if(noOfPlayer == 1){
                if(playerNo == 2){
                    shellHighlight();
                }
                else{
                    starHighlight();
                }
                playerWinCheck();
            }
            else{
                if(playerTurn == false){
                    shellHighlight();
                    playerTurn = true;
                }
                else{
                    starHighlight();
                    playerTurn = false;
                }
                checkForWinner();            
            }
        }
        else if(noOfPlayer == 2  && lTurn == 0){
            playSfxAudio("Fix");
            rect99 = 1;    
            if(gameBegin == false){
                img2.x = rect9._x-6;  img2.y = rect9._y-5;               
            }
            else{
                if( playerNo == 1){
                    imgValue1 = 1;
                    imgValue2 = 0;
                    img2 = shell1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+395;  img2.y = bg._y+40;
                }
                else{
                    imgValue1 = 0;
                    imgValue2 = 1;
                    img2 = star1[i];
                    img2.alpha = 1;
                    img2.x = bg._x+15;  img2.y = bg._y+40;
                }
                img2.tween({x: rect9._x-6, y:rect9._y-5}, 30);
            }
            gameBegin = true;
            lTurn = 1;
            lWinTurn = lTurn;
            if(playerTurn == false){
                shellHighlight();
                playerTurn = true;
            }
            else{
                starHighlight();
                playerTurn = false;
            }
            lBoxValue9 = img2.lNumberValue;
            i +=1;
            checkForWinner();
        }
        }
    });
    
    
    
    
    rect1.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect1._x-20;  selectBg.y=rect1._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect2.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect2._x-20;     selectBg.y=rect2._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect3.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect3._x-20;      selectBg.y=rect3._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect4.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect4._x-20;      selectBg.y=rect4._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect5.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect5._x-20;  selectBg.y=rect5._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect6.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect6._x-20;  selectBg.y=rect6._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect7.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect7._x-18;  selectBg.y=rect7._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect8.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect8._x-18;  selectBg.y=rect8._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    rect9.bind('MouseMove',function(e){
        if(gameBegin == false){
            selectBg.alpha = 1;
            selectBg.x=rect9._x-18;  selectBg.y=rect9._y-20;
            if(lTurn == 1){
                img1.x = e.clientX-25;   img1.y = e.clientY-25;
            }
            if(noOfPlayer == 2 && lTurn ==0){
                img2.x = e.clientX-25;   img2.y = e.clientY-25;
            }
        }
    });
    
    
    
    var pauseBtnHover = Crafty.e("2D, Canvas, Image, Mouse").image("images/pause2.png");
    pauseBtnHover.x = bg._x+10; pauseBtnHover.y = bg._y+225;    
    pauseBtnHover.alpha = 0.01;
    
    var pauseBtn = Crafty.e("2D, Canvas, Image, Mouse").image("images/pause1.png");
    pauseBtn.x = bg._x+10; pauseBtn.y = bg._y+225;  
   
    pauseBtn.bind("MouseDown", function(e) {
        pauseBtn.alpha = 0.01;
        pauseBtnHover.alpha = 1;
    });
    pauseBtn.bind("MouseUp", function(e) {
        pauseBtn.alpha = 1;
        pauseBtnHover.alpha = 0.01;
        if(gameBegin == false){
            stopOverride();
        }
        gameBegin = true;
        console.log('soundBtn = '+soundBtn);
        if(soundBtn == 1){
            Crafty.audio.stop();
            Crafty.audio.play("BgmMenu", -1)
        }
        createPauseScreen();
    });
    
    //  function for highlight star 
    function starHighlight(){
        starBtnHover.alpha = 0.01;
        shellBtnHover.alpha = 1;
        player2Select.alpha = 0.01;
        player1Select.alpha = 1;
        if(noOfPlayer == 1){
            setTimeout(function(){
                shellBtnHover.alpha = 0.01;
                starBtnHover.alpha = 1;
                player2Select.alpha = 1;
                player1Select.alpha = 0.01;
            },700); 
        }
    }
    
    //  function for highlight shell
    function shellHighlight(){
        starBtnHover.alpha = 1;
        shellBtnHover.alpha = 0.01;
        player2Select.alpha = 1;
        player1Select.alpha = 0.01;
        if(noOfPlayer == 1){
            setTimeout(function(){
                shellBtnHover.alpha = 1;
                starBtnHover.alpha = 0.01;
                player2Select.alpha = 0.01;
                player1Select.alpha = 1;
            },700);
        }
    }
    
    
    rect1.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect1._x-20;  selectBg.y = rect1._y-20;
    });
    rect2.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect2._x-20;  selectBg.y = rect2._y-20;
    });
    rect3.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect3._x-20;  selectBg.y = rect3._y-20;
    });
    rect4.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect4._x-20;  selectBg.y = rect4._y-20;
    });
    rect5.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect5._x-20;  selectBg.y = rect5._y-20;
    });
    rect6.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect6._x-20;  selectBg.y = rect6._y-20;
    });
    rect7.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect7._x-18;  selectBg.y = rect7._y-20;
    });
    rect8.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect8._x-18;  selectBg.y = rect8._y-20;
    });
    rect9.bind('MouseDown',function(){
        selectBg.alpha = 1;
        selectBg.x = rect9._x-18;  selectBg.y = rect9._y-20;
    });
    
    
    
    
    //  function for determine winner in two player mode
    function checkForWinner() {
		// Check horizontal wins
        if (lBoxValue1 == 1 && lBoxValue2 == 1 && lBoxValue3 == 1  ||  
            lBoxValue1 == 0 && lBoxValue2 == 0 && lBoxValue3 == 0){
            lTurn = 2;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+65;
            },700);
            setTimeout(function(){
                displayWin();
            },1500); 
        }
        else if (lBoxValue4 == 1 && lBoxValue5 == 1 && lBoxValue6 == 1  ||  
            lBoxValue4 == 0 && lBoxValue5 == 0 && lBoxValue6 == 0){
            lTurn = 2;
             gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+125;
            },700);
            setTimeout(function(){
                displayWin();
            },1500);
        }
        else if (lBoxValue7 == 1 && lBoxValue8 == 1 && lBoxValue9 == 1  ||  
            lBoxValue7 == 0 && lBoxValue8 == 0 && lBoxValue9 == 0){
            lTurn = 2;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+195;
            },700);
            setTimeout(function(){
                displayWin();
            },1500);
        }
        
        //  Check for vertical wins
        else if (lBoxValue1 == 1 && lBoxValue4 == 1 && lBoxValue7 == 1  ||  
            lBoxValue1 == 0 && lBoxValue4 == 0 && lBoxValue7 == 0){
            lTurn = 2;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line4");
                winLine.x = bg._x+120; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                displayWin();
            },1500);
        }
        else if (lBoxValue2 == 1 && lBoxValue5 == 1 && lBoxValue8 == 1  ||  
            lBoxValue2 == 0 && lBoxValue5 == 0 && lBoxValue8 == 0){
            lTurn = 2;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line3");
                winLine.x = bg._x+230; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                displayWin();
            },1500);  
        }
        else if (lBoxValue3 == 1 && lBoxValue6 == 1 && lBoxValue9 == 1  ||  
            lBoxValue3 == 0 && lBoxValue6 == 0 && lBoxValue9 == 0){
            lTurn = 2;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line2");
                winLine.x = bg._x+320; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                displayWin();
            },1500);
        }
        
        // Check diagonal win
        else if (lBoxValue1 == 1 && lBoxValue5 == 1 && lBoxValue9 == 1  ||  
            lBoxValue1 == 0 && lBoxValue5 == 0 && lBoxValue9 == 0){
            lTurn = 2;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line6");
                winLine.x = bg._x+102; winLine.y = bg._y+35;
            },700);
            setTimeout(function(){
                displayWin();
            },1500); 
        }
        else if (lBoxValue3 == 1 && lBoxValue5 == 1 && lBoxValue7 == 1  ||  
            lBoxValue3 == 0 && lBoxValue5 == 0 && lBoxValue7 == 0){
            lTurn = 2;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line5");
                winLine.x = bg._x+85; winLine.y = bg._y+35;
            },700);
            setTimeout(function(){
                displayWin();
            },1500);  
        }
        else {
            drawCheck();
        }
    }
	
    
    //   function for display winning screen in two player mode
    function displayWin(){
        lTotalMove = 0;
        if(lWinTurn == 1){
            Crafty.scene("Player2Won");
        }
        else{
            Crafty.scene("Player1Won");
        }
    }
    
    
    //  function for check player win in single player mode
    function playerWinCheck(){
        if(lBoxValue1 == imgValue1 && lBoxValue2 == imgValue1 && lBoxValue3 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;             
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+65;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        } 
        else if(lBoxValue4 == imgValue1 && lBoxValue5 == imgValue1 && lBoxValue6 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+125;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        } 
        else if(lBoxValue7 == imgValue1 && lBoxValue8 == imgValue1 && lBoxValue9 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+195;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue4 == imgValue1 && lBoxValue7 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line4");
                winLine.x = bg._x+120; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        }
        else if(lBoxValue2 == imgValue1 && lBoxValue5 == imgValue1 && lBoxValue8 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true; 
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line3");
                winLine.x = bg._x+230; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        }
        else if(lBoxValue3 == imgValue1 && lBoxValue6 == imgValue1 && lBoxValue9 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line2");
                winLine.x = bg._x+320; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue5 == imgValue1 && lBoxValue9 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line6");
                winLine.x = bg._x+102; winLine.y = bg._y+35;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        }
        else if(lBoxValue3 == imgValue1 && lBoxValue5 == imgValue1 && lBoxValue7 == imgValue1){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line5");
                winLine.x = bg._x+85; winLine.y = bg._y+35;
            },700);
            setTimeout(function(){
                Crafty.scene("UserWin");
            },1500);
        }
        else{
            winCheck()
        }
    
    }
    
    
    //  function for check computer win in single player mode
    function compWinCheck(){
        drawCheck();
        if(lBoxValue1 == imgValue2 && lBoxValue2 == imgValue2 && lBoxValue3 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+65;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);
        } 
        else if(lBoxValue4 == imgValue2 && lBoxValue5 == imgValue2 && lBoxValue6 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;  
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+125;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);
        } 
        else if(lBoxValue7 == imgValue2 && lBoxValue8 == imgValue2 && lBoxValue9 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line1");
                winLine.x = bg._x+70; winLine.y = bg._y+195;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue4 == imgValue2 && lBoxValue7 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line4");
                winLine.x = bg._x+120; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);
        }
        else if(lBoxValue2 == imgValue2 && lBoxValue5 == imgValue2 && lBoxValue8 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line3");
                winLine.x = bg._x+230; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);  
        }
        else if(lBoxValue3 == imgValue2 && lBoxValue6 == imgValue2 && lBoxValue9 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line2");
                winLine.x = bg._x+320; winLine.y = bg._y+25;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue5 == imgValue2 && lBoxValue9 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line6");
                winLine.x = bg._x+102; winLine.y = bg._y+35;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500); 
        }
        else if(lBoxValue3 == imgValue2 && lBoxValue5 == imgValue2 && lBoxValue7 == imgValue2){
            lTurn = 2;
            lHoverClick = false;
            gameBegin = true; 
            setTimeout(function(){
                winLine = Crafty.e("2D, Canvas, Line5");
                winLine.x = bg._x+85; winLine.y = bg._y+35;
            },700);
            setTimeout(function(){
                Crafty.scene("LostScreen");
            },1500);  
        }

    }


    //  function for check draw game in all mode
    function drawCheck(){
        lTotalMove = rect11 + rect22 + rect33 + rect44 + rect55 + rect66 + rect77 + rect88 + rect99; 
        if(lTotalMove == 9){
            lHoverClick = false;
            gameBegin = true;
            setTimeout(function(){
                Crafty.scene("GameDraw");
            }, 1000);
        }
    }

    
    //  function for stop player winning by conputer in single player mode
    function winCheck(){
        compWinCheck()
        if(lBoxValue1 == imgValue2 && lBoxValue2 == imgValue2 && rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
            
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(lBoxValue2 == imgValue2 && lBoxValue3 == imgValue2 && rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
            
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
        else if(lBoxValue4 == imgValue2 && lBoxValue5 == imgValue2 && rect66 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect6._x-6, y: rect6._y-5}, lSpeed);
            
            rect6.unbind('MouseDown', this.rect6);
            lBoxValue6 = img2.lNumberValue;
            lTurn = 1;
            rect66 = 1;
        }
        else if(lBoxValue5 == imgValue2 && lBoxValue6 == imgValue2 && rect44 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect4._x-6, y: rect4._y-5}, lSpeed);
            
            rect4.unbind('MouseDown', this.rect4);
            lBoxValue4 = img2.lNumberValue;
            lTurn = 1;
            rect44 = 1;
        }
        else if(lBoxValue7 == imgValue2 && lBoxValue8 == imgValue2 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
            
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(lBoxValue8 == imgValue2 && lBoxValue9 == imgValue2 && rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
           
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue5 == imgValue2 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
            
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(lBoxValue5 == imgValue2 && lBoxValue9 == imgValue2 && rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
           
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
        else if(lBoxValue3 == imgValue2 && lBoxValue5 == imgValue2 && rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
            
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(lBoxValue7 == imgValue2 && lBoxValue5 == imgValue2 && rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
            
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue3 == imgValue2 && rect22 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect2._x-6, y: rect2._y-5}, lSpeed);
            
            rect2.unbind('MouseDown', this.rect2);
            lBoxValue2 = img2.lNumberValue;
            lTurn = 1;
            rect22 = 1;
        }
        else if(lBoxValue4 == imgValue2 && lBoxValue6 == imgValue2 && rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
            
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        else if(lBoxValue7 == imgValue2 && lBoxValue9 == imgValue2 && rect88 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect8._x-6, y: rect8._y-5}, lSpeed);
            
            rect8.unbind('MouseDown', this.rect8);
            lBoxValue8 = img2.lNumberValue;
            lTurn = 1;
            rect88 = 1;
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue7 == imgValue2 && rect44 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect4._x-6, y: rect4._y-5}, lSpeed);
            
            rect4.unbind('MouseDown', this.rect4);
            lBoxValue4 = img2.lNumberValue;
            lTurn = 1;
            rect44 = 1;
        }
        else if(lBoxValue2 == imgValue2 && lBoxValue8 == imgValue2 && rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
            
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        else if(lBoxValue3 == imgValue2 && lBoxValue9 == imgValue2 && rect66 == 0 && lTurn == 0){
           if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect6._x-6, y: rect6._y-5}, lSpeed);
            
            rect6.unbind('MouseDown', this.rect6);
            lBoxValue6 = img2.lNumberValue;
            lTurn = 1;
            rect66 = 1;
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue5 == imgValue2 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
            
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(lBoxValue4 == imgValue2 && lBoxValue7 == imgValue2 && rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
            
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
        else if(lBoxValue5 == imgValue2 && lBoxValue8 == imgValue2 && rect22 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect2._x-6, y: rect2._y-5}, lSpeed);
            
            rect2.unbind('MouseDown', this.rect2);
            lBoxValue2 = img2.lNumberValue;
            lTurn = 1;
            rect22 = 1;
        }
        else if(lBoxValue6 == imgValue2 && lBoxValue9 == imgValue2 && rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
           
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue4 == imgValue2 && rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
           
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(lBoxValue2 == imgValue2 && lBoxValue5 == imgValue2 && rect88 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect8._x-6, y: rect8._y-5}, lSpeed);
           
            rect8.unbind('MouseDown', this.rect8);
            lBoxValue8 = img2.lNumberValue;
            lTurn = 1;
            rect88 = 1;
        }
        else if(lBoxValue3 == imgValue2 && lBoxValue6 == imgValue2 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
          
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(lBoxValue1 == imgValue2 && lBoxValue9 == imgValue2 && rect55 == 0 && lTurn == 0){   
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
          
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        else if(lBoxValue3 == imgValue2 && lBoxValue7 == imgValue2 && rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
          
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        else{
            computer()
        }
        compWinCheck()
    
    }
    
    
    
    function computer(){
        compWinCheck()
        if(lBoxValue1 == imgValue1 && lBoxValue2 == imgValue1 && rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
          
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(lBoxValue2 == imgValue1 && lBoxValue3 == imgValue1 && rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
         
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
        else if(lBoxValue4 == imgValue1 && lBoxValue5 == imgValue1 && rect66 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect6._x-6, y: rect6._y-5}, lSpeed);
            
            rect6.unbind('MouseDown', this.rect6);
            lBoxValue6 = img2.lNumberValue;
            lTurn = 1;
            rect66 = 1;
        }
        else if(lBoxValue5 == imgValue1 && lBoxValue6 == imgValue1 && rect44 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect4._x-6, y: rect4._y-5}, lSpeed);
         
            rect4.unbind('MouseDown', this.rect4);
            lBoxValue4 = img2.lNumberValue;
            lTurn = 1;
            rect44 = 1;
        }
        else if(lBoxValue7 == imgValue1 && lBoxValue8 == imgValue1 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
        
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }

        else if(lBoxValue8 == imgValue1 && lBoxValue9 == imgValue1 && rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
           
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue5 == imgValue1 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
        
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        
        else if(lBoxValue5 == imgValue1 && lBoxValue9 == imgValue1 && rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
          
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }

        else if(lBoxValue7 == imgValue1 && lBoxValue5 == imgValue1 && rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
           
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }

        else if(lBoxValue1 == imgValue1 && lBoxValue3 == imgValue1 && rect22 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect2._x-6, y: rect2._y-5}, lSpeed);
        
            rect2.unbind('MouseDown', this.rect2);
            lBoxValue2 = img2.lNumberValue;
            lTurn = 1;
            rect22 = 1;
        }
        else if(lBoxValue4 == imgValue1 && lBoxValue6 == imgValue1 && rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
           
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        else if(lBoxValue7 == imgValue1 && lBoxValue9 == imgValue1 && rect88 == 0 && lTurn == 0){
           if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect8._x-6, y: rect8._y-5}, lSpeed);
           
            rect8.unbind('MouseDown', this.rect8);
            lBoxValue8 = img2.lNumberValue;
            lTurn = 1;
            rect88 = 1;
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue7 == imgValue1 && rect44 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect4._x-6, y: rect4._y-5}, lSpeed);
         
            rect4.unbind('MouseDown', this.rect4);
            lBoxValue4 = img2.lNumberValue;
            lTurn = 1;
            rect44 = 1;
        }

        else if(lBoxValue2 == imgValue1 && lBoxValue8 == imgValue1 && rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
          
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }

        else if(lBoxValue3 == imgValue1 && lBoxValue9 == imgValue1 && rect66 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect6._x-6, y: rect6._y-5}, lSpeed);
           
            rect6.unbind('MouseDown', this.rect6);
            lBoxValue6 = img2.lNumberValue;
            lTurn = 1;
            rect66 = 1;
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue5 == imgValue1 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
          
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }

        else if(lBoxValue4 == imgValue1 && lBoxValue7 == imgValue1 && rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
         
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
        else if(lBoxValue5 == imgValue1 && lBoxValue8 == imgValue1 && rect22 == 0 && lTurn == 0){
           if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect2._x-6, y: rect2._y-5}, lSpeed);
         
            rect2.unbind('MouseDown', this.rect2);
            lBoxValue2 = img2.lNumberValue;
            lTurn = 1;
            rect22 = 1;
        }
        else if(lBoxValue6 == imgValue1 && lBoxValue9 == imgValue1 && rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
          
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue4 == imgValue1 && rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
           
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(lBoxValue2 == imgValue1 && lBoxValue5 == imgValue1 && rect88 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect8._x-6, y: rect8._y-5}, lSpeed);
         
            rect8.unbind('MouseDown', this.rect8);
            lBoxValue8 = img2.lNumberValue;
            lTurn = 1;
            rect88 = 1;
        }
        else if(lBoxValue3 == imgValue1 && lBoxValue6 == imgValue1 && rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
           
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(lBoxValue3 == imgValue1 && lBoxValue5 == imgValue1 && rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
          
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(lBoxValue1 == imgValue1 && lBoxValue9 == imgValue1 && rect55 == 0 && lTurn == 0){
           if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
           
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        else if(lBoxValue3 == imgValue1 && lBoxValue7 == imgValue1 && rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
          
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }

        else{
            AI()
        }
        compWinCheck()
    
    }

    
    
    function AI(){
        if(rect55 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
         
            img2.tween({x: rect5._x-6, y: rect5._y-5}, lSpeed);
            
            rect5.unbind('MouseDown', this.rect5);
            lBoxValue5 = img2.lNumberValue;
            lTurn = 1;
            rect55 = 1;
        }
        
        else if(rect99 == 0 && lTurn == 0 && randomNumber == 9){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
           
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(rect77 == 0 && lTurn == 0 && randomNumber == 7){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
           
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        else if(rect33 == 0 && lTurn == 0 && randomNumber == 3){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
           
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(rect11 == 0 && lTurn == 0 && randomNumber == 1){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
            
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
//        else if(lBoxValue1 == imgValue1 && lBoxValue5 == imgValue1 && rect33 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
//          
//            rect3.unbind('MouseDown', this.rect3);
//            lBoxValue3 = img2.lNumberValue;
//            lTurn = 1;
//            rect33 = 1;
//        }
//        else if(lBoxValue7 == imgValue1 && lBoxValue5 == imgValue1 && rect11 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
//           
//            rect1.unbind('MouseDown', this.rect1);
//            lBoxValue1 = img2.lNumberValue;
//            lTurn = 1;
//            rect11 = 1;
//        }
//        else if(lBoxValue3 == imgValue1 && lBoxValue5 == imgValue1 && rect11 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
//            
//            rect1.unbind('MouseDown', this.rect1);
//            lBoxValue1 = img2.lNumberValue;
//            lTurn = 1;
//            rect11 = 1;
//        }
//        else if(lBoxValue9 == imgValue1 && lBoxValue5 == imgValue1 && rect33 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
//            
//            rect3.unbind('MouseDown', this.rect3);
//            lBoxValue3 = img2.lNumberValue;
//            lTurn = 1;
//            rect33 = 1;
//        }
//        else if(lBoxValue4 == imgValue1 && lBoxValue8 == imgValue1 && rect77 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
//           
//            rect7.unbind('MouseDown', this.rect7);
//            lBoxValue7 = img2.lNumberValue;
//            lTurn = 1;
//            rect77 = 1;
//        }
//        else if(lBoxValue6 == imgValue1 && lBoxValue8 == imgValue1 && rect99 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
//      
//            rect9.unbind('MouseDown', this.rect9);
//            lBoxValue9 = img2.lNumberValue;
//            lTurn = 1;
//            rect99 = 1;
//        }
//        else if(lBoxValue2 == imgValue1 && lBoxValue6 == imgValue1 && rect33 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
//           
//            rect3.unbind('MouseDown', this.rect3);
//            lBoxValue3 = img2.lNumberValue;
//            lTurn = 1;
//            rect33 = 1;
//        }
//        else if(lBoxValue2 == imgValue1 && lBoxValue4 == imgValue1 && rect11 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
//           
//            rect1.unbind('MouseDown', this.rect1);
//            lBoxValue1 = img2.lNumberValue;
//            lTurn = 1;
//            rect11 = 1;
//        }
//        else if(lBoxValue1 == imgValue1 && lBoxValue9 == imgValue1 && rect44 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect4._x-6, y: rect4._y-5}, lSpeed);
//          
//            rect4.unbind('MouseDown', this.rect4);
//            lBoxValue4 = img2.lNumberValue;
//            lTurn = 1;
//            rect44 = 1;
//        }
//        else if(lBoxValue1 == imgValue1 && lBoxValue6 == imgValue1 && rect22 == 0 && lTurn == 0){
//            if(playerNo == 1){
//                var img2 = shell1[i];
//                shell1[i].alpha = 1;
//                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
//                i +=1;
//            }
//            else{
//                var img2 = star1[i];
//                star1[i].alpha = 1;
//                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
//                i +=1;
//            }
//            img2.tween({x: rect2._x-6, y: rect2._y-5}, lSpeed);
//           
//            rect2.unbind('MouseDown', this.rect2);
//            lBoxValue2 = img2.lNumberValue;
//            lTurn = 1;
//            rect22 = 1;
//        }
        
        
        
        else if(rect77 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect7._x-6, y: rect7._y-5}, lSpeed);
           
            rect7.unbind('MouseDown', this.rect7);
            lBoxValue7 = img2.lNumberValue;
            lTurn = 1;
            rect77 = 1;
        }
        
        else if(rect22 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect2._x-6, y: rect2._y-5}, lSpeed);
           
            rect2.unbind('MouseDown', this.rect2);
            lBoxValue2 = img2.lNumberValue;
            lTurn = 1;
            rect22 = 1;
        }
        else if(rect66 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect6._x-6, y: rect6._y-5}, lSpeed);
           
            rect6.unbind('MouseDown', this.rect6);
            lBoxValue6 = img2.lNumberValue;
            lTurn = 1;
            rect66 = 1;
        }   
        else if(rect88 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect8._x-6, y: rect8._y-5}, lSpeed);
          
            rect8.unbind('MouseDown', this.rect8);
            lBoxValue8 = img2.lNumberValue;
            lTurn = 1;
            rect88 = 1;
        }
        else if(rect44 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect4._x-6, y: rect4._y-5}, lSpeed);
            
            rect4.unbind('MouseDown', this.rect4);
            lBoxValue4 = img2.lNumberValue;
            lTurn = 1;
            rect44 = 1;
        }
        
        else if(rect99 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
            img2.tween({x: rect9._x-6, y: rect9._y-5}, lSpeed);
          
            rect9.unbind('MouseDown', this.rect9);
            lBoxValue9 = img2.lNumberValue;
            lTurn = 1;
            rect99 = 1;
        }
        else if(rect33 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
          
            img2.tween({x: rect3._x-6, y: rect3._y-5}, lSpeed);
            
            rect3.unbind('MouseDown', this.rect3);
            lBoxValue3 = img2.lNumberValue;
            lTurn = 1;
            rect33 = 1;
        }
        else if(rect11 == 0 && lTurn == 0){
            if(playerNo == 1){
                var img2 = shell1[i];
                shell1[i].alpha = 1;
                img2.x = shellBtnHover.x;   img2.y = shellBtnHover.y;
                i +=1;
            }
            else{
                var img2 = star1[i];
                star1[i].alpha = 1;
                img2.x = starBtnHover.x;   img2.y = starBtnHover.y;
                i +=1;
            }
           
            img2.tween({x: rect1._x-6, y: rect1._y-5}, lSpeed);
            rect1.unbind('MouseDown', this.rect1);
            lBoxValue1 = img2.lNumberValue;
            lTurn = 1;
            rect11 = 1;
        }
        compWinCheck()

    }
                
      playBgMusic("GameMusic")          
});

