function GClock (el, images, format, offset)
{
   this.el = get_by_id(el);
   this.imgs = imgs;
   this.format = format;
   this.offset = offset;

   this.id = ++GClock.prototype.ids;
   this.display();

   return this;
}


GClock.prototype = {

   ids : 0,
   id : 0,
   el : null,
   format : '',
   local : true,
   offset : 0,
   imgs : [],

   display : function ()
   {
      make_el('IMG', {src : this.imgs[0], id : this.id + '-h1'}, this.el);
      make_el('IMG', {src : this.imgs[0], id : this.id + '-h2'}, this.el);
      make_el('IMG', {src : this.imgs['s']}, this.el);
      make_el('IMG', {src : this.imgs[0], id : this.id + '-m1'}, this.el);
      make_el('IMG', {src : this.imgs[0], id : this.id + '-m2'}, this.el);

      if (this.format == 1 || this.format == 3)
      {
         make_el('IMG', {src : this.imgs['s']}, this.el);
         make_el('IMG', {src : this.imgs[0], id : this.id + '-s1'}, this.el);
         make_el('IMG', {src : this.imgs[0], id : this.id + '-s2'}, this.el);
      }

      if (this.format == 3 || this.format == 4)
      {
         make_text(' ', this.el);
         make_el('IMG', {src : this.imgs['am'], id : this.id + '-a'}, this.el);
      }

      this.getTime();
   },

   tick : function ()
   {
      this.getTime();
   },

   getTime : function ()
   {
      if (this.offset == false)
      {
         var time = new Date();
      }
      else
      {
         var now = new Date();
         var now_z = now.getTime();
         var time = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds())
         var time_z = time.getTime();
             time.setTime(time_z + (this.offset * 60 * 60 * 1000));
      }

      if (this.format == 1 || this.format == 2)
      {
         var hrs = time.getHours() > 9 ? time.getHours() + '' : '0' + time.getHours();
      }
      else if (this.format == 3 || this.format == 4)
      {
         var hrs = time.getHours() > 12 ? time.getHours() - 12 : time.getHours();
         var hrs = hrs > 9 ? hrs + '' : '0' + hrs;
      }

      var h1 = parseInt(hrs.substr(0, 1));
      var h2 = parseInt(hrs.substr(1, 2));

      get_by_id(this.id + '-h1').src = this.imgs[h1];
      get_by_id(this.id + '-h2').src = this.imgs[h2];


      var min = time.getMinutes() > 9 ? time.getMinutes() + '' : '0' + time.getMinutes();
      var m1 = parseInt(min.substr(0, 1));
      var m2 = parseInt(min.substr(1, 2));

      get_by_id(this.id + '-m1').src = this.imgs[m1];
      get_by_id(this.id + '-m2').src = this.imgs[m2];

      if (this.format == 1 || this.format == 3)
      {
         var sec = time.getSeconds() > 9 ? time.getSeconds() + '' : '0' + time.getSeconds();
         var s1 = parseInt(sec.substr(0, 1));
         var s2 = parseInt(sec.substr(1, 2));

         get_by_id(this.id + '-s1').src = this.imgs[s1];
         get_by_id(this.id + '-s2').src = this.imgs[s2];
      }

      if (this.format == 3 || this.format == 4)
      {
         var a = time.getHours() > 11 ? "pm" : "am";
         get_by_id(this.id + '-a').src = this.imgs[a];
      }
   }
}