function buttonselect0123CA4(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesC, AxesA, AxesSOLC, AxesSOLA, uonoff, uonoffC, plotopt, lvSlider, lvText, vers, lcs)
data = get(Empty_Button,'UserData');

if data.afscomputed(1)+data.afscomputed(2) == 0
    set(uonoff(1), 'Value', 1);
    set(uonoffC(1), 'Value', 1);
    return;
end

outscale = 1.5;

if vers == 1
    
    for i=1:4
        vals(i) = get(uonoff(i+1), 'Value');
    end
    
    [ma,id] = max(vals);
    if (data.motion >= 1) && (ma > 0) && (length(data.actx) > 0) && (length(data.lv.lastStart) > 0) && (norm(data.lv.lastStart-data.actx) > 1.E-14)
        buttonlockCA4(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesC, AxesA, AxesSOLC, AxesSOLA, uonoff, uonoffC, 0)
        data = get(Empty_Button,'UserData');
    end
    
    if get(uonoff(1), 'Value')
        data.motion = 0;
        data.motionC = 0;
        set(uonoffC(1), 'Value', 1);
    elseif get(uonoff(2), 'Value')
        data.motion = 1;
        data.motionC = 0;
        set(uonoffC(1), 'Value', 1);
    elseif get(uonoff(3), 'Value')
        data.motion = 2;
        data.motionC = 0;
        set(uonoffC(1), 'Value', 1);
    elseif get(uonoff(4), 'Value')
        data.motion = 3;
        data.motionC = 0;
        set(uonoffC(1), 'Value', 1);
    else
        data.motion = 4;
        data.motionC = 0;
        set(uonoffC(1), 'Value', 1);
    end
    
    if data.motion > 0
        
        set(lvSlider(1), 'Min', outscale*data.afsA.xm(1), 'Max', outscale*data.afsA.xm(2));
        set(lvSlider(2), 'Min', outscale*data.afsA.ym(1), 'Max', outscale*data.afsA.ym(2));
        set(lvSlider(3), 'Min', outscale*data.afsA.zm(1), 'Max', outscale*data.afsA.zm(2));
        
        if data.choosen(data.motion)
            set(lvSlider(1), 'Value', min(max(data.fixA{data.motion}.pt(1), outscale*data.afsA.xm(1)), outscale*data.afsA.xm(2)));
            set(lvSlider(2), 'Value', min(max(data.fixA{data.motion}.pt(2), outscale*data.afsA.ym(1)), outscale*data.afsA.ym(2)));
            set(lvSlider(3), 'Value', min(max(data.fixA{data.motion}.pt(3), outscale*data.afsA.zm(1)), outscale*data.afsA.zm(2)));
            
            data.lv.lastStart = [get(lvSlider(1), 'Value'), get(lvSlider(2), 'Value'), get(lvSlider(3), 'Value')];
            data.actx = data.lv.lastStart;
        else
            
            pts = data.InitT(data.motion,2:4)/data.InitT(data.motion,1);
            set(lvSlider(1), 'Value', pts(1));
            set(lvSlider(2), 'Value', pts(2));
            set(lvSlider(3), 'Value', pts(3));
            
            data.lv.lastStart = [0, 0, 0];
            data.actx = pts;
        end
        
        for i=1:3
            set(lvText(i+3), 'String', num2str(get(lvSlider(i), 'Value')));
        end
        
    end
    
else
    
    for i=1:4
        vals(i) = get(uonoffC(i+1), 'Value');
    end
    
    [ma,id] = max(vals);
    if (data.motionC >= 1) && (ma > 0) && (length(data.actx) > 0) && (length(data.lvC.lastStart) > 0) && (norm(data.lvC.lastStart-data.actx) > 1.E-14)
        buttonlockCA4(hObject, eventdata, Empty_Button, Buttons, Footnote, AxesC, AxesA, AxesSOLC, AxesSOLA, uonoff, uonoffC, 0)
        data = get(Empty_Button,'UserData');
    end
    
    if get(uonoffC(1), 'Value')
        data.motion = 0;
        data.motionC = 0;
        set(uonoff(1), 'Value', 1);
    elseif get(uonoffC(2), 'Value')
        data.motion = 0;
        data.motionC = 1;
        set(uonoff(1), 'Value', 1);
    elseif get(uonoffC(3), 'Value')
        data.motion = 0;
        data.motionC = 2;
        set(uonoff(1), 'Value', 1);
    elseif get(uonoffC(4), 'Value')
        data.motion = 0;
        data.motionC = 3;
        set(uonoff(1), 'Value', 1);
    else
        data.motion = 0;
        data.motionC = 4;
        set(uonoff(1), 'Value', 1);
    end
    
    if data.motionC > 0
        
        set(lvSlider(1), 'Min', outscale*data.afsC.xm(1), 'Max', outscale*data.afsC.xm(2));
        set(lvSlider(2), 'Min', outscale*data.afsC.ym(1), 'Max', outscale*data.afsC.ym(2));
        set(lvSlider(3), 'Min', outscale*data.afsC.zm(1), 'Max', outscale*data.afsC.zm(2));
        
        if data.choosenC(data.motionC)
            
            set(lvSlider(1), 'Value', min(max(data.fixC{data.motionC}.pt(1), outscale*data.afsC.xm(1)), outscale*data.afsC.xm(2)));
            set(lvSlider(2), 'Value', min(max(data.fixC{data.motionC}.pt(2), outscale*data.afsC.ym(1)), outscale*data.afsC.ym(2)));
            set(lvSlider(3), 'Value', min(max(data.fixC{data.motionC}.pt(3), outscale*data.afsC.zm(1)), outscale*data.afsC.zm(2)));
        
            data.lvC.lastStart = [get(lvSlider(1), 'Value'), get(lvSlider(2), 'Value'), get(lvSlider(3), 'Value')];
            data.actx = data.lvC.lastStart;
        else
            
            pT = data.S*pinv(data.InitT);
            
            pts = pT(2:4,data.motionC)/pT(1,data.motionC);
            
            set(lvSlider(1), 'Value', pts(1));
            set(lvSlider(2), 'Value', pts(2));
            set(lvSlider(3), 'Value', pts(3));
            
            data.lvC.lastStart = [0, 0, 0];
            data.actx = pts;
        end
        
        for i=1:3
            set(lvText(i+3), 'String', num2str(get(lvSlider(i), 'Value')));
        end
    end
    
end

set(Buttons(3), 'Enable', 'on');

set(Empty_Button,'UserData',data);

liveviewCA4(hObject, eventdata, Empty_Button, AxesC, AxesA, AxesSOLC, AxesSOLA, uonoff, uonoffC, plotopt, lvText, lvSlider, -1, lcs, [0 0 0])
