var res:string;
	i:byte;
	osX,osY,prX,prY:integer;
begin
   res:='';	
   osX:=round(intpower(2,GetZ-1)) div 2;
   osY:=round(intpower(2,GetZ-1)) div 2;
   prX:=osX; prY:=osY;
   for i:=2 to GetZ do
    begin
    prX:=prX div 2;
    prY:=prY div 2;
    if GetX<osX
     then begin
           osX:=osX-prX;
           if GetY<osY then begin
                            osY:=osY-prY;
                            res:=res+'1';
                           end
                      else begin
                            osY:=osY+prY;
                            res:=res+'3';
                           end;
          end
     else begin
           osX:=osX+prX;
           if Gety<osy then begin
                             osY:=osY-prY;
                             res:=res+'2';
                            end
                     else begin
                           osY:=osY+prY;
                           res:=res+'4';
                          end;
         end;
     end;

    res := Copy(res, 4, 99);
    ResultURL:=GetURLBase + inttostr(GetZ-1)+ '/' + res + '.jpg';

    RequestHead:='User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0' + #13#10 +
      'Accept: image/png,image/*;q=0.8,*/*;q=0.5' + #13#10 +
      'Accept-Language: en-us,en;q=0.5' + #13#10 +
      'Accept-Encoding: gzip, deflate' + #13#10 +
      'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' + #13#10 +
      'DNT: 1' + #13#10 +
      'Proxy-Connection: keep-alive' + #13#10 +
      'Referer: http://mosday.ru/map/?ll=55.806312,37.512119&z=16&t=h' + #13#10;
end.

