function   slideraction(index)
%%  change slider position as scroll bar is clicked

%%  Kriging Software Package  version 1.0 beta,   October 29, 1998
%%  Copyright (c) 1998, property of Dezhang Chu and Woods Hole Oceanographic
%%  Institution.  All Rights Reserved.


global max_nugt max_sill max_lscl max_powr max_osci lag gammah lag

if ~isempty(lag)
   
index=str2num(index);

max_val=[max_nugt max_sill max_lscl max_powr max_osci];
maxval=max_val(index);

para=['nugt';'sill';'lscl';'powr';'osci'];
paraStr=para(index,:);
sldStr=['sld' paraStr];
txtStr=['txt' paraStr];
sliderhdl=findobj(gcf,'Tag',sldStr);
txthdl=findobj(gcf,'Tag',txtStr);
[new_maxval]=value2slider(sliderhdl,txthdl,2,0,maxval);
switch index
  case 1
     max_nugt=new_maxval;
  case 2
     max_sill=new_maxval;
  case 3
     max_lscl=new_maxval;
  case 4
     max_powr=new_maxval;
  case 5
     max_osci=new_maxval;
end     
%axeshdl=findobj(gcf,'Tag','variogramAxes1');
%axes_chdhdl=get(axeshdl,'children');
axes_chdhdl=findobj(gcf,'type','line');
lag=get(axes_chdhdl(1),'XData');
if length(axes_chdhdl) > 1
   set(axes_chdhdl(1),'visible','off');
end
hold on
[model,nugt,sill,L,b,p]=getvariopara;
model_para=[nugt sill L b p];
gammah_theo=variogrammodel(model,lag,model_para);
if model > 0
   hv0=plot(lag,gammah,'o',lag,gammah_theo);
   hy=ylabel('Variogram');
else
   hv0=plot(lag,1-gammah,'o',lag,1-gammah_theo);
   hy=ylabel('Correlogram');
end
%hv0=plot(lag,gammah_theo,'-r');
%set(get(hv0(1),'parent'),'Tag','variogramAxes1')
if ~isempty(hv0)
   set(get(hv0(1),'parent'),'Tag','variogramAxes1')
   status=2;
end
hx=xlabel('Lag (km)');
set([hx hy],'fontsize',12,'fontweight','bold')

hold off
else
   dd=warningtext;
end
