/**
 *  Abstract Control Object
 *
 *  the idea for this suite was originally taken from Serge Dolgov, http://qlib.quazzle.com
 */

/**
 *  initialized the THControl object
 */
function THControl_init(parent, name)
{
  this.parent = parent || self;
  this.window = (parent && parent.window) || self;
  this.document = (parent && parent.document) || self.document;
  this.name = (parent && parent.name) ? (parent.name + "." + name) : ("self." + name);
  this.id = "H";
  var h = this.hash(this.name);
  for (var j=0; j<8; j++)
  {
    this.id += THControl.HEXTABLE.charAt(h & 15);
    h >>>= 4;
  }
}

/**
 *  creates a hash value from the given string
 */
function THControl_hash(str)
{
  var h = 0;
  if (str)
  {
    for (var j=str.length-1; j>=0; j--)
    {
      h ^= THControl.ANTABLE.indexOf(str.charAt(j)) + 1;
      for (var i=0; i<3; i++)
      {
        var m = (h = h<<7 | h>>>25) & 150994944;
        h ^= m ? (m == 150994944 ? 1 : 0) : 1;
      }
    }
  }
  return h;
}

function THControl_nop()
{
}

function THControl()
{
  this.init = THControl_init;
  this.hash = THControl_hash;
  this.window = self;
  this.document = self.document;
  this.tag = null;
}

THControl.ANTABLE  = "w5Q2KkFts3deLIPg8Nynu_JAUBZ9YxmH1XW47oDpa6lcjMRfi0CrhbGSOTvqzEV";
THControl.HEXTABLE = "0123456789ABCDEF";
THControl.nop = THControl_nop;
THControl.event = THControl_nop;
