// JavaScript Document
function get_position(o) {
	var x = y = 0;
	if (o.offsetParent) {
		x = o.offsetLeft;
		y = o.offsetTop;
		while (o = o.offsetParent) {
			x += o.offsetLeft;
			y += o.offsetTop;
		}
	}
	return [x,y];
}

// Determine whether a node's text content is entirely whitespace.
function is_all_ws( nod ) {
  return !(/[^\t\n\r ]/.test(nod.data));
}

// Version of |firstChild| that skips nodes that are entirely whitespace and comments.
function first_child( par ) {
  var res=par.firstChild;
  while (res) {
    if (!is_ignorable(res)) return res;
    res = res.nextSibling;
  }
  return null;
}

// Determine if a node should be ignored by the iterator functions. 
function is_ignorable( nod ) {
  return ( nod.nodeType == 8) || // A comment node
         ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
}

function child_nodes( nod ) {
	var cNod = nod.childNodes;
	var rNod = [];
	for (i=0; i<cNod.length; i++) {
		if (!is_ignorable(cNod[i])) rNod.push(cNod[i]);
	}
	return rNod;
}