    function Box(inElement)
    {
        this.element = inElement;
        this.position = '0,0';
        this.rotation = 0;
        this.element.addEventListener('touchstart', this, false);
    }
    Box.prototype = {
      handleEvent: function(e) {
        switch(e.type) {
          case 'touchstart': this.onTouchStart(e); break;
          case 'touchmove': this.onTouchMove(e); break;
          case 'touchend': this.onTouchEnd(e); break;
        }
      },
      get position()
      {
          return this._position;
      },
      // position strings are "x,y" with no units
      set position(pos)
      {
          this._position = pos;
       
          var components = pos.split(',')
          var x = components[0];
          var y = components[1];
       
          const kUseTransform = false;
          if (kUseTransform) {
              this.element.style.webkitTransform = 'translate(' + x + 'px, ' + y + 'px)';
          }
          else {
              this.element.style.left = x + 'px';
              this.element.style.top = y + 'px';
          }
      },    
      // position strings are "x,y" with no units
      get x()
      {
          return parseInt(this._position.split(',')[0]);
      },
       
      set x(inX)
      {
          var comps = this._position.split(',');
          comps[0] = inX;
          this.position = comps.join(',');
      },
       
      get y()
      {
          return parseInt(this._position.split(',')[1]);
      },
       
      set y(inY)
      {
          var comps = this._position.split(',');
          comps[1] = inY;
          this.position = comps.join(',');
      },
      onTouchStart: function(e)
      {
          e.preventDefault();
          // Start tracking when the first finger comes down in this element
          if (e.targetTouches.length != 1)
              return false;

          this.startX = e.targetTouches[0].clientX;
          this.startY = e.targetTouches[0].clientY;

          var leftDelta = e.targetTouches[0].clientX - this.startX;
          var topDelta = e.targetTouches[0].clientY - this.startY;
       
          var newLeft = (this.x) + leftDelta;
          var newTop = (this.y) + topDelta;

          this.origX = newLeft;
          this.origY = newTop;
          this.movedX = newLeft;
          this.movedY = newTop;
       
          this.startTime = e.timestamp;

          this.element.addEventListener('touchmove', this, false);
          this.element.addEventListener('touchend', this, false);
       
          return false;
      },
      onTouchMove: function(e)
      {
          // Prevent the browser from doing its default thing (scroll, zoom)
          e.preventDefault();
       
          // Don't track motion when multiple touches are down in this element (that's a gesture)
          if (e.targetTouches.length != 1)
              return false;

          return false;
      },
      onTouchEnd: function(e)
      {
          console.log('onTouchEnd')
          // Prevent the browser from doing its default thing (scroll, zoom)
          e.preventDefault();
       
          // Stop tracking when the last finger is removed from this element
          if (e.targetTouches.length > 0)
              return false;
          if (this.origX == this.movedX && this.origY == this.movedY){
              $('#nominate').hide();
              $('#desc_block').hide();
              $('#info').hide();
              console.log('thumb click');
              $('#wrapper').css('z-index', 1);
              $('#wrapper').css('height', $('body').height() + 10);
              window.scrollTo(0,0);
              $('#wrapper').show();
              var offset = 3;
              var hoverid = $(this.element).attr('data-id');
              gallery.goToPage(hoverid - offset);
              console.log('touch click');
              $(this.element).click();
          } 
          
          this.dropSpot = null;

          this.element.removeEventListener('touchmove', this, false);
          this.element.removeEventListener('touchend', this, false);
       
          return false;
      }
  }

