function ClockClock(str, timeshift, x, y, scale)
{
   scale = scale?scale:1;
   this.clock_size = 100*scale;

   this.center_x = this.clock_size+10*scale;
   this.center_y = this.clock_size+40*scale;

   this.mark_rad   = 80*scale;
   this.mark_size  = 1*scale;
   this.keymark_size = 2*scale;
   this.arrow_sec  = 80*scale;
   this.arrow_min  = 70*scale;
   this.arrow_hrs  = 60*scale;
   this.arrow_hrs_width = 6*scale;
   this.title_fs   = 20*scale;
   this.time_fs    = 30*scale;
   this.inner_dif  = 8*scale;
   this.cyfer_dif  = 10*scale;

   this.circleOuter = null;
   this.circleInner = null;
   this.circleCyfer = null;
   this.hrs = null;
   this.min = null;
   this.sec = null;

   this.time = null;

   this.seconds = null;
   this.minutes = null;
   this.hours   = null;
   this.c       = Array();

   this.paper = Raphael(x, y, this.clock_size*2+20*scale, this.clock_size*2+this.title_fs+this.time_fs+ 40*scale);

   this.shift = timeshift;

   this.title  = this.paper.text(this.center_x,this.center_y-this.clock_size-20*scale, str).attr({"font-family": "Calibri", "font-size":+this.title_fs+"px"});
   this.time   = this.paper.text(this.center_x,this.center_y+this.clock_size+20*scale, "00:00").attr({"font-family": "Calibri", "font-size":this.time_fs+"px"});

 this.NewTime = function (timeshift)
 {
   this.shift = timeshift;
   this.ReSet();
 }
 this.ReSet = function()
 {
   this.seconds.stop();
   var dt  = new Date();
   if (this.shift != undefined && this.shift != 0)
    {
      dt.setHours(dt.getHours()+toInt(this.shift[0]));
      dt.setMinutes(dt.getMinutes()+toInt(this.shift[1]));
      dt.setSeconds(dt.getSeconds()+toInt(this.shift[2]));
    }
   dt.setHours(dt.getHours()+dt.getTimezoneOffset()/60);

   this.hrs = dt.getHours();

   this.min = dt.getMinutes();
   this.sec = dt.getSeconds();

   this.time.attr("text", (this.hrs<=9?"0":"")+this.hrs+":"+(this.min<=9?"0":"")+this.min+":"+(this.sec<=9?"0":"")+this.sec);


   this.hours.transform("R"+(30*this.hrs+this.min/2)+","+this.center_x+","+this.center_y);
   this.minutes.transform("R"+(6*this.min+this.sec/10)+","+this.center_x+","+this.center_y);
   this.seconds.transform("R"+6*this.sec+","+this.center_x+","+this.center_y);

   this.count = this.sec;
   this.SecondsAnimate();
 }
this.SecondsAnimate = function()
 {
   var dt  = new Date;
   var sectest = this.sec % 60;
   var mintest = this.min % 60;
   var hrstest = this.hrs % 24;
   var ms = 0;

   var sec, sec2;
   sec2 = this.sec;
   if (this.shift != undefined && this.shift != 0)
    {
      sec2 -= this.shift[2];
    }
   sec2 = sec2 % 60;


   if (this.sec % 10 == 0)
    {

      if (this.sec == 60) this.min++;

      this.minutes.transform("R"+(6*this.min+sectest/10)+","+this.center_x+","+this.center_y);

      if (this.min == 60 && sectest == 0) this.hrs++;

      if (this.min % 2)
        this.hours.transform("R"+(30*this.hrs+mintest/2)+","+this.center_x+","+this.center_y);

    }
   this.time.attr("text", (hrstest<=9?"0":"")+hrstest+":"+(mintest<=9?"0":"")+mintest+":"+(sectest<=9?"0":"")+sectest);

   sec = dt.getSeconds();

   if (sec>=sec2)
    { ms = 800; }
   else if (sec<sec2)
    { ms = 1100; }
   else ms = 1000;

   this.sec++;
   var obj = this;
   this.seconds.animate({transform: "R"+6*this.sec+","+this.center_x+","+this.center_y, callback: function()
    {
      obj.SecondsAnimate();
    }}, ms);

 }
this.DrawClock = function()
 {

   this.circleOuter = this.paper.circle(this.center_x, this.center_y, this.clock_size);
   this.circleOuter.attr({fill: "45-#ccc-#eee", stroke: "#bbb"});
   this.circleInner = this.paper.circle(this.center_x, this.center_y, this.clock_size-this.inner_dif);
   this.circleInner.attr({fill: "90-#ccc-#eee", stroke: "#fff"});
   this.circleCyfer = this.paper.circle(this.center_x, this.center_y, this.clock_size - this.cyfer_dif);
   this.circleCyfer.attr({fill: "r#bbe-#aae", "stroke-width": "0"});

   this.c = Array();
   for (i=0; i<60; i++)
    {
      if (i%5 == 0)
       {
         this.c[i] = this.paper.circle(this.center_x-this.mark_rad*Math.sin(30*i*Math.PI/180), this.center_y-this.mark_rad*Math.cos(30*i*Math.PI/180), this.keymark_size);
         if (i%15==0)
          this.c[i].attr({stroke: "#bfb", fill: "#bfb"});
         else
          this.c[i].attr({stroke: "#fff", fill: "#fff"});
       }
      else
       {
         x = this.center_x-this.mark_rad*Math.sin(6*i*Math.PI/180);
         y = this.center_y-this.mark_rad*Math.cos(6*i*Math.PI/180);
         this.c[i] = this.paper.circle(x, y, this.mark_size);
         this.c[i].attr({"stroke-width": "0", stroke: "#fff", fill: "#fff"});
       }
    }

   this.seconds = this.paper.path("M"+this.center_x+","+this.center_y+"L"+this.center_x+","+(this.center_y-this.arrow_sec));
   this.minutes = this.paper.path("M"+this.center_x+","+this.center_y+"L"+this.center_x+","+(this.center_y-this.arrow_min));
   this.hours   = this.paper.rect(this.center_x-this.arrow_hrs_width/2, this.center_y-(this.arrow_hrs-this.arrow_hrs_width/2)/*185*/, this.arrow_hrs_width, this.arrow_hrs);
   this.seconds.attr({stroke: "#dff"});
   this.minutes.attr({stroke: "#dff", "stroke-width": "2"});
   this.hours.attr({stroke: "#dff"});

 }

   this.DrawClock();
   this.ReSet();

}

function toInt(value)
{
  var intVal = +value
  if (isNaN(intVal))
   {
     throw new Error("Неправильный формат данных: "+value);
   }
}
