procedure ChangeColor;
var 
	inifn:TIniFile; 
	s:string;
begin
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    s:=ReadString('Item0','BitmapName','');
    if s='top.png' then 
    begin
      WriteString('Item0','BitmapName','Olive_top.png');
      WriteString('Item1','BitmapName','Olive_middle.png');
      WriteString('Item2','BitmapName','Olive_bottom.png');
      WriteString('Item4','DayXItem2Font','Arial/12/#8B9E52/1/0/0/0/0/255/1/0/1/clBlack/200');
    end
    else if s='Olive_top.png' then
    begin
      WriteString('Item0','BitmapName','Mauve_top.png');
      WriteString('Item1','BitmapName','Mauve_middle.png');
      WriteString('Item2','BitmapName','Mauve_bottom.png');
      WriteString('Item4','DayXItem2Font','Arial/12/#6C5B68/1/0/0/0/0/255/1/0/1/clBlack/200');
    end
    else
    begin
      WriteString('Item0','BitmapName','top.png');
      WriteString('Item1','BitmapName','middle.png');
      WriteString('Item2','BitmapName','bottom.png');
      WriteString('Item4','DayXItem2Font','Arial/12/#7696C1/1/0/0/0/0/255/1/0/1/clBlack/200');
    end;
    
    InitSkin; 
    RefreshSkin(true); 
  finally 
    free; 
  end; 
end;

procedure CollapseSkin;
begin
  SetSkin(false);
end;

procedure ExpandSkin;
begin
  SetSkin(true);
end;

procedure SetSkin(isShow:boolean);
var 
	inifn:TIniFile; 
	s:string;
	iTop,l,t,w,h,i:integer; 
begin
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    WriteBool('Item3','Enable',isShow); //grid
    if isShow then
    	WriteInteger('Item4','ShowDays',7)
    else
    	WriteInteger('Item4','ShowDays',1);
    WriteBool('Item5','Enable',isShow); //Button:CollapseSkin
    WriteBool('Item6','Enable',not isShow); //Button:ExpandSkin
  	s:=ReadString('Item7','Rect','');
    GetRectProperty(s,l,t,w,h);
	    if isShow then
  	  	t:=203
    	else
    	  t:=91;
    SetRectProperty(s,l,t,w,h);
	  WriteString('Item7','Rect',s);

    iTop:=82;
    //Middle
    if ReadBool('Item1','Enable',false) then
    begin
    	s:=ReadString('Item1','Rect','');
    	GetRectProperty(s,l,t,w,h);
    	t:=iTop;
	    if isShow then
  	  	h:=125
    	else
    	  h:=15;
    	SetRectProperty(s,l,t,w,h);
	  	WriteString('Item1','Rect',s);
    	iTop:=iTop+h;
    end;
    //Bottom
    if ReadBool('Item2','Enable',false) then
    begin
      s:=ReadString('Item2','Rect','');
      GetRectProperty(s,l,t,w,h);
      t:=iTop;
    	SetRectProperty(s,l,t,w,h);
	  	WriteString('Item2','Rect',s);
    	iTop:=iTop+h;
    end;

    //Height
    if isShow then
    	WriteInteger('system','Height',240)
    else
    	WriteInteger('system','Height',121);
    InitSkin; 
    RefreshSkin(true); 
  finally 
    free; 
  end; 
end;

procedure GetRectProperty(value:string; var aLeft:integer; var aTop:Integer; var aWidth:integer; var aHeight:Integer);
var
  lst:TStrings;
begin
  if Trim(value)='' then exit;
  lst:=TStringList.Create;
  try
    StrToStrings(value,lst,'/');
    if lst.Count>3 then
    try
      aLeft:=StrToInt(lst[0]);
      aTop:=StrToInt(lst[1]);
      aWidth:=StrToInt(lst[2]);
      aHeight:=StrToInt(lst[3]);
    except
    
    end;
  finally
    lst.Free;
  end;
end;

procedure SetRectProperty(var value:string; aLeft:integer; aTop:Integer; aWidth:integer; aHeight:Integer);
var
  lst:TStrings;
begin
  if Trim(value)='' then exit;
  lst:=TStringList.Create;
  try
    StrToStrings(value,lst,'/');
    if lst.Count>3 then
    try
      lst[0]:=IntToStr(aLeft);
      lst[1]:=IntToStr(aTop);
      lst[2]:=IntToStr(aWidth);
      lst[3]:=IntToStr(aHeight);
      value:=StringsToStr(lst,'/');
    except
    
    end;
  finally
    lst.Free;
  end;
end;

var
  inifn:TIniFile; 
  s:string;
  iTop,t,h:integer; 
begin
  //
  RefreshNetWeather;
end.