var LDMain = new LDMainFunc();
function LDMainFunc()
{

  this.getElements = function(parent, list)
  {
    for (var i in parent.childNodes)
    {
      if (parent.childNodes[i].tagName != null) {list.push(parent.childNodes[i]);}
      if (parent.childNodes[i].hasChildNodes) {list = LDMain.getElements(parent.childNodes[i], list);}
    }
    return list;
  }

  this.utf8_encode = function(plain)
  {
    plain = plain.replace(/\r\n/g,"\n");
    var utftext = "";
    for (var n=0; n<plain.length; n++)
    {
      var c = plain.charCodeAt(n);
      if (c < 128)
      {
        utftext += String.fromCharCode(c);
      } else
      if ((c>127) && (c<2048))
      {
        utftext += String.fromCharCode((c>>6)|192);
        utftext += String.fromCharCode((c&63)|128);
      } else
      {
        utftext += String.fromCharCode((c>>12)|224);
        utftext += String.fromCharCode(((c>>6)&63)|128);
        utftext += String.fromCharCode((c&63)|128);
      }
    }
    return utftext;
  }

  this.maillink = function(obj, name, domain, tld)
  {
    if (typeof(obj) != 'undefined')
    {
      var link = name + '@' + domain + '.' + tld;
      obj.setAttribute('href', 'mailto:'+link);
      obj.setAttribute('title', link);
      return link;
    }
    return '';
  }

  //find absolute position of an element
  Object.prototype.findPos = function(obj)
  {
    if (obj == null)
      obj = this;
    var x = 0;
    var y = 0;
    while (obj)
    {
      x += obj.offsetLeft;
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    return {'x':x, 'y':y};
  }

  //implement the indexOf-Method for Arrays
  Array.prototype.indexOf = function(obj)
  {
    var len = this.length;
    var id = -1;
    for (var i=0; i<len; i++)
    {
      if (this[i] === obj)
      {
        id = i;
        break;
      }
    }
    return id;
  }
}