$(document).on('click','form .NextGameElement',function(){
     var Group = $(this).closest('.ChooseElement');
     $( Group ).slideUp();
     $( Group ).next().slideDown();
});

$(document).on('change','.selectionrang',function(){

    var Wartosc = $(this).val();    
    var GameHandler = $(this).closest('.ChooseElement');
    
    // Mobile
    if( $(window).width() < 979 )
    {
        var ElementA_0 = {
            width: '120px'
        };

        var ElementB_0 = {
            width: '60px'
        };


        var ElementA_1 = {
            width: '100px'
        };
        

        var ElementB_1 = { 
            width:'70px'
        };

        var ElementA_2 = { 
            width:'80px'
        };
        
        var ElementB_2 = { 
            width:'80px'
        };
        
        var ElementA_3 = { 
            width:'70px'
        };
        
        var ElementB_3 = { 
            width:'100px'
        };
        
        var ElementA_4 = { 
            width:'60px'
        };
        
        var ElementB_4 = { 
            width:'120px'
        };
    } 
    // Desktop
    else 
    {
        var ElementA_0 = { 
            width:'250px'
        };
        
        var ElementB_0 = { 
            width:'100px'
        };

        var ElementA_1 = { 
            width:'200px'
        };
        
        var ElementB_1 = { 
            width:'125px'
        };  



        var ElementA_2 = { 
            width:'150px'
        };
        
        var ElementB_2 = { 
            width:'150px'
        };   
        
        
        
        var ElementA_3 = { 
            width:'125px'
        };
        
        var ElementB_3 = { 
            width:'200px'
        };
        
        var ElementA_4 = { 
            width:'100px'
        };
        
        var ElementB_4 = { 
            width:'250px'
        };
    }
    
    switch( Wartosc )
    {
        case '0':
            $('.ElementA',GameHandler).animate( ElementA_0 );
            $('.ElementB',GameHandler).animate( ElementB_0 );
            
            $('.ElementA input',GameHandler).val(2);
            $('.ElementB input',GameHandler).val(0);
        break;
        
        case '1':
            $('.ElementA',GameHandler).animate( ElementA_1 );
            $('.ElementB',GameHandler).animate( ElementB_1 );
            
            $('.ElementA input',GameHandler).val(1);
            $('.ElementB input',GameHandler).val(0);
        break;
        
        case '2':
            $('.ElementA',GameHandler).animate( ElementA_2 );
            $('.ElementB',GameHandler).animate( ElementB_2 );
            
            $('.ElementA input',GameHandler).val(0);
            $('.ElementB input',GameHandler).val(0);
        break;
        
        case '3':
            $('.ElementA',GameHandler).animate( ElementA_3 );
            $('.ElementB',GameHandler).animate( ElementB_3 );
            
            $('.ElementA input',GameHandler).val(0);
            $('.ElementB input',GameHandler).val(1);
        break;
        
        case '4':
            $('.ElementA',GameHandler).animate( ElementA_4 );
            $('.ElementB',GameHandler).animate( ElementB_4 );
            
            $('.ElementA input',GameHandler).val(0);
            $('.ElementB input',GameHandler).val(2);
        break;
    }
    
});