code: function DocumentScanner(visitor, scanElementsOnly) {
  	this.visitor = visitor;
  	this.scanElementsOnly = scanElementsOnly;
  
  	/**
  	 * Scans the element
  	 */
  	this.scan = function(element) {
  		if (this.visitor.visit(element)) {
  			// visit child elements
  			var children = element.childNodes;
  			for(var i = 0; i < children.length; i++) {
  				if(!this.scanElementsOnly || children[i].nodeType == 1)
  					this.scan(children[i]);
  			}
  		}		
  	}	
  }
docs: **************************************************
  This class is a scanner for the visitor pattern. *
  ************************************************** 
  Constructor, parameters are:
  visitor: the visitor implementation, it must be a class with a visit(element) method.
  scanElementsOnly: a flag telling whether to scan html elements only or all html nodes.