function obj( id ) {
  return document.getElementById( id );
}

function removeObjById( id ) {
  objekt = obj( id );
  objekt.parentNode.removeChild( objekt );
}

function removeObj( objekt ) {
  objekt.parentNode.removeChild( objekt );
}

function addRow( table ) {
  return table.insertRow( table.rows.length );
}

function addCell( tr ) {
  return tr.insertCell( tr.cells.length );
}

function pageLeft( el ) {
  if ( el ) {
    l = el.offsetLeft;
    while ( ( el = el.offsetParent )!= null ) { l += el.offsetLeft; }
    return l;
  } else {
    return 0;
  }
}

function pageTop( el ) {
  if ( el ) {
    t = el.offsetTop;
    while ( ( el = el.offsetParent )!= null ) { t += el.offsetTop; }
    return t;
  } else {
    return 0;
  }
}

function removeCells( tr ) {
  n = tr.cells.length;
  for ( u=0; u < n; u++ )
    tr.deleteCell(0);
}

function clearDiv( div ) {
  if ( div ) {
    childs = div.childNodes;
    for ( i=0; i < childs.length; i++ )
      div.removeChild( childs[i] );
  }
}

function getTableRowById( table, row_id ) {
  row = null;
  rows = table.rows;
  for ( i=0; i < rows.length; i++ ) {
    if ( rows[i].id == row_id ) {
      row = rows[i];
      break;
    }
  }
  
  return row;
}

function XMLDocument( xml_text ) {
  var doc = null;

  if ( window.ActiveXObject ) {
    doc = new ActiveXObject( "Microsoft.XMLDOM" );
    doc.loadXML( xml_text );
  } else if ( DOMParser ) {
    domParser = new DOMParser();
    doc = domParser.parseFromString( xml_text, "text/xml" );
  }
  
  return doc;
}

function clearSelect( select, with_default ) {
  if ( with_default == null ) with_default = true;
  with_default == true ? j = 0 : j = 1;
  count = select.options.length-j;
  for ( i=0; i < count; i++ ) select.remove( j );
}

function generateID() {
  return Math.floor( Math.random() * 10000 ).toString() + Math.floor( Math.random() * 10000 ).toString();
}