<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>DTD/xhtml-lat1.ent</filename>
    </added>
    <added>
      <filename>DTD/xhtml-special.ent</filename>
    </added>
    <added>
      <filename>DTD/xhtml-symbol.ent</filename>
    </added>
    <added>
      <filename>DTD/xhtml.soc</filename>
    </added>
    <added>
      <filename>DTD/xhtml1-frameset.dtd</filename>
    </added>
    <added>
      <filename>DTD/xhtml1-strict.dtd</filename>
    </added>
    <added>
      <filename>DTD/xhtml1-transitional.dtd</filename>
    </added>
    <added>
      <filename>DTD/xhtml1.dcl</filename>
    </added>
    <added>
      <filename>src/css/properties.js</filename>
    </added>
    <added>
      <filename>src/css/rule.js</filename>
    </added>
    <added>
      <filename>src/css/sizzle.js</filename>
    </added>
    <added>
      <filename>src/css/stylesheet.js</filename>
    </added>
    <added>
      <filename>src/dom/attr.js</filename>
    </added>
    <added>
      <filename>src/dom/cdatasection.js</filename>
    </added>
    <added>
      <filename>src/dom/characterdata.js</filename>
    </added>
    <added>
      <filename>src/dom/comment.js</filename>
    </added>
    <added>
      <filename>src/dom/doctype.js</filename>
    </added>
    <added>
      <filename>src/dom/document.js</filename>
    </added>
    <added>
      <filename>src/dom/dom.js</filename>
    </added>
    <added>
      <filename>src/dom/element.js</filename>
    </added>
    <added>
      <filename>src/dom/exception.js</filename>
    </added>
    <added>
      <filename>src/dom/fragment.js</filename>
    </added>
    <added>
      <filename>src/dom/implementation.js</filename>
    </added>
    <added>
      <filename>src/dom/instruction.js</filename>
    </added>
    <added>
      <filename>src/dom/node.js</filename>
    </added>
    <added>
      <filename>src/dom/nodelist.js</filename>
    </added>
    <added>
      <filename>src/dom/parser.js</filename>
    </added>
    <added>
      <filename>src/dom/text.js</filename>
    </added>
    <added>
      <filename>src/event/event.js</filename>
    </added>
    <added>
      <filename>src/event/mouseevent.js</filename>
    </added>
    <added>
      <filename>src/event/uievent.js</filename>
    </added>
    <added>
      <filename>src/html/anchor.js</filename>
    </added>
    <added>
      <filename>src/html/canvas.js</filename>
    </added>
    <added>
      <filename>src/html/collection.js</filename>
    </added>
    <added>
      <filename>src/html/cookie.js</filename>
    </added>
    <added>
      <filename>src/html/document.js</filename>
    </added>
    <added>
      <filename>src/html/element.js</filename>
    </added>
    <added>
      <filename>src/html/form.js</filename>
    </added>
    <added>
      <filename>src/html/frame.js</filename>
    </added>
    <added>
      <filename>src/html/html.js</filename>
    </added>
    <added>
      <filename>src/html/htmlparser.js</filename>
    </added>
    <added>
      <filename>src/html/iframe.js</filename>
    </added>
    <added>
      <filename>src/html/image.js</filename>
    </added>
    <added>
      <filename>src/html/input.js</filename>
    </added>
    <added>
      <filename>src/html/link.js</filename>
    </added>
    <added>
      <filename>src/html/select.js</filename>
    </added>
    <added>
      <filename>src/html/table.js</filename>
    </added>
    <added>
      <filename>src/html/textarea.js</filename>
    </added>
    <added>
      <filename>src/platform/xmlsax.js</filename>
    </added>
    <added>
      <filename>src/platform/xmlw3cdom.js</filename>
    </added>
    <added>
      <filename>src/window/css.js</filename>
    </added>
    <added>
      <filename>src/window/dialog.js</filename>
    </added>
    <added>
      <filename>src/window/document.js</filename>
    </added>
    <added>
      <filename>src/window/event.js</filename>
    </added>
    <added>
      <filename>src/window/history.js</filename>
    </added>
    <added>
      <filename>src/window/location.js</filename>
    </added>
    <added>
      <filename>src/window/navigator.js</filename>
    </added>
    <added>
      <filename>src/window/screen.js</filename>
    </added>
    <added>
      <filename>src/window/timer.js</filename>
    </added>
    <added>
      <filename>src/window/window.js</filename>
    </added>
    <added>
      <filename>src/window/xhr.js</filename>
    </added>
    <added>
      <filename>test/unit/dom.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -40,22 +40,47 @@
         &lt;echo message=&quot;Building ${ENV_DIST}&quot; /&gt;
         &lt;concat destfile=&quot;${ENV_DIST}&quot;&gt;
             &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;intro.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;location.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;history.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;navigator.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;timer.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;event.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;document.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;xhr.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;css.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;cookie.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;screen.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;uievent.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dialog.js&quot; /&gt;
-            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;htmlparser.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/window.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/dom.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/document.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/attr.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/cdatasection.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/characterdata.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/comment.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/doctype.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/element.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/exception.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/fragment.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/implementation.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/instruction.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/node.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/nodelist.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/parser.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;dom/text.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/html.js&quot; /&gt;
+            &lt;!--fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/htmlparser.js&quot; /--&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/document.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/element.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/form.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/collection.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;html/anchor.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;event/event.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;event/mouseevent.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;event/uievent.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;css/properties.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;css/rule.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;css/stylesheet.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/location.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/history.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/navigator.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/timer.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/event.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/xhr.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/css.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/screen.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/dialog.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/document.js&quot; /&gt;
+            &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;window/cookie.js&quot; /&gt;
             &lt;fileset dir=&quot;${SRC_DIR}&quot; includes=&quot;outro.js&quot; /&gt;
         &lt;/concat&gt;
         &lt;echo message=&quot;${ENV_DIST} built.&quot; /&gt;</diff>
      <filename>build.xml</filename>
    </modified>
    <modified>
      <diff>@@ -6,14 +6,18 @@
  
 
 // The Window Object
-var window = this;
+var __this__ = this;
+this.__defineGetter__('window', function(){
+  return __this__;
+});
 (function($w, $env){/*
 *	window.js
 *   - this file will be wrapped in a closure providing the window object as $w
 */
 // a logger or empty function available to all modules.
-var $log = $env.log;
-var $error = $env.error;
+var $log = $env.log,
+    $error = $env.error,
+    $debug = $env.debug;
 //The version of this application
 var $version = &quot;0.1&quot;;
 //This should be hooked to git or svn or whatever
@@ -95,6 +99,7 @@ var $top;
 // the window property is identical to the self property.
 var $window = $w;
 
+$log(&quot;Initializing Window.&quot;);
 __extend__($w,{
   get closed(){return $closed;},
   get defaultStatus(){return $defaultStatus;},
@@ -116,7 +121,7 @@ __extend__($w,{
   get pageXOffest(){return $pageXOffset;},
   get pageYOffset(){return $pageYOffset;},
   get parent(){return $parent;},
-  get screen(){return $w.screen;},
+  //get screen(){return $screen;}, see screen.js
   get screenLeft(){return $screenLeft;},
   get screenTop(){return $screenTop;},
   get screenX(){return $screenX;},
@@ -203,114 +208,1504 @@ function __extend__(a,b) {
 function trim( str ){
  var start = -1,
   end = str.length;
-/*jsl:ignore*/
+ /*jsl:ignore*/
  while( str.charCodeAt(--end) &lt; 33 );
  while( str.charCodeAt(++start) &lt; 33 );
-/*jsl:end*/
+ /*jsl:end*/
  return str.slice( start, end + 1 );
-};/*
-*	location.js
-*   - requires env
+};
+
+//from jQuery
+function setArray( target, array ) {
+	// Resetting the length to 0, then using the native Array push
+	// is a super-fast way to populate an object with array-like properties
+	target.length = 0;
+	Array.prototype.push.apply( target, array );
+};
+/*
+*	dom.js
+*
+*	DOM Level 2 /DOM level 3 (partial)
+*	
+*	The Document Object is now private in scope but you can create new
+*	Documents via document.implementation.createDocument which
+*	now also exposes the DOM Level 3 function 'load(uri)'.
+*
+*/
+	// Helper method for generating the right
+	// DOM objects based upon the type
+	
+	var $nodeCache = {};//caches a reference to our implementation of the node
+	var $nodeImplCache = {};//reverse look-up : caches a reference to the env supplied implementors dom node
+	var $guid = (-1)*Math.pow(2,31);
+  function createGUID(){
+    /*jsl:ignore*/
+    return String(++$guid);
+    /*jsl:end*/
+  };
+	
+  // A handy utility method to convert the env supplied DOM Level 2 implementation
+  // into our window externalized implementaion.
+  // Its kept here since Node is the base class of all the DOM window level classes
+	function makeNode(node, doc ){
+		if ( node !== null &amp;&amp; node !== undefined) {
+			if ( !$nodeCache[ $env.hashCode(node) ] ){
+        if( (document.__html__)&amp;&amp;(node.getNodeType()===$w.Node.ELEMENT_NODE)){
+          //$log(&quot;Caching HTML Node: &quot; + node);
+          makeHTMLElement(node.getTagName().toUpperCase(), node);
+        }else if( (document.__html__)&amp;&amp;(node.getNodeType()===$w.Node.DOCUMENT_NODE)){
+          //$log(&quot;Caching HTML Document: &quot; + node);
+          cacheNode( node, HTMLDocument );
+        }else{
+          $debug(&quot;Caching Node: &quot; + node);
+          if(     node.getNodeType() === $w.Node.ELEMENT_NODE){cacheNode(node, Element);}
+          else if(node.getNodeType() === $w.Node.ATTRIBUTE_NODE){cacheNode(node, Attr);}
+          else if(node.getNodeType() === $w.Node.TEXT_NODE){cacheNode(node, Text);}
+          else if(node.getNodeType() === $w.Node.CDATA_SECTION_NODE){cacheNode(node, CDATASection);}
+          else if(node.getNodeType() === $w.Node.PROCESSING_INSTRUCTION_NODE){cacheNode(node, ProcessingInstruction);}
+          else if(node.getNodeType() === $w.Node.COMMENT_NODE){cacheNode(node, Comment);}
+          else if(node.getNodeType() === $w.Node.DOCUMENT_NODE){cacheNode( node, Document );}
+          else if(node.getNodeType() === $w.Node.DOCUMENT_TYPE_NODE){cacheNode(node, DocumentType);}
+          else if(node.getNodeType() === $w.Node.DOCUMENT_FRAGMENT_NODE){cacheNode(node, DocumentFragment);}
+          else{cacheNode(node, Node);}
+        }
+			}
+			//$log(&quot;Retreived Node from cache: &quot; + $env.hashCode(node ) + &quot; =&gt; &quot;+ $nodeCache[$env.hashCode(node)]);
+			return $nodeCache[$env.hashCode(node)];
+		} else{ 
+		  //$log(&quot;makeNode =&gt; Node is null!&quot;);
+		  return null;
+	  }
+	};
+	
+
+  function cacheNode(node, constructor){
+    if(node &amp;&amp; constructor){
+      var cachednode = new constructor( node );
+      $debug(&quot;Caching node &quot;+ cachednode);
+      $nodeCache[$env.hashCode(node)] = cachednode;
+      $debug(&quot;Reversing lookup for node &quot;+ cachednode.__$__);
+      $nodeImplCache[cachednode.__$__] = node;
+    }
+  };$log(&quot;Defining Document&quot;);
+/*
+* Document - DOM Level 2
+*  The Document object is not directly 
+*/
+$w.__defineGetter__('Document', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Document = function(node){
+  var $dom = node, 
+      $id = createGUID(), 
+      $url; 
+  $debug(&quot;Document &quot; +$id);
+  return __extend__(this,{
+		get defaultView(){ //TODO: why isnt this just 'return $w;'?
+			return { getComputedStyle: function(elem){
+				return { getPropertyValue: function(prop){
+					prop = prop.replace(/\-(\w)/g,function(m,c){ return c.toUpperCase(); });
+					var val = elem.style[prop];
+					if ( prop === &quot;opacity&quot; &amp;&amp; val === &quot;&quot; ){ val = &quot;1&quot;; }return val;
+				}};
+			}};
+		},
+		get doctype(){return makeNode( $dom.getDoctype() );},
+		get documentElement(){ return makeNode( $dom.getDocumentElement() ); },
+	  get implementation(){ return $implementation; },
+		get nodeName() { return &quot;#document&quot;; },
+	  get styleSheets(){ return [];/*TODO*/ },
+		addEventListener        : $w.addEventListener,
+	  attachEvent             : $w.addEventListener,/*IE only subject to random, frustrating, obscure deprecation*/
+	  createAttribute         : function(name){return makeNode( $dom.createAttribute(name) );},
+	  createAttributeNS       : function(nsuri, qname){return makeNode($dom.createAttribute(nsuri, qname) );},
+	  createCDATASection      : function(data){return makeNode( $dom.createCDATASection(data) );},
+	  createComment           : function(data){return makeNode( $dom.createComment(data) );},
+	  createDocumentFragment  : function(){return $dom.createDocumentFragment();},
+	  createElement           : function(tagname){ return makeNode( $dom.createElement(tagname) );},
+	  createElementNS         : function(nsuri, qname){ return makeNode( $dom.createElementNS(nsuri, qname) );},
+		createEvent             : function(eventType){ 
+		  var event;
+		  if(eventType === &quot;UIEvents&quot;){ event = new UIEvent();}
+		  else if(eventType === &quot;MouseEvents&quot;){ event = new MouseEvent();}
+		  else{ event = new Event(); } 
+		  return event;
+	  },
+	  createExpression        : function(xpath, nsuriMap){ return null;/*TODO*/},
+	  createProcessingInstruction: function(target,data){ return makeNode( $dom.createProcessingInstruction(target, data) );},
+	  createTextNode          : function(data){ return makeNode( $dom.createTextNode(data) );},
+	  detachEvent             : window.detachEvent,/*IE only subject to random, frustrating, obscure deprecation*/
+		dispatchEvent           : window.dispatchEvent,
+	  evaluate                : function(xpath, context, nsuriMap, resulttype, result){ 
+		  $log(&quot;document.evaluate(&quot;+xpath+&quot;)&quot;);
+		  var nodelist = new NodeList($env.xpath(xpath, context?context:$dom));
+		  $log(&quot;length :=&gt; &quot;+nodelist.length);
+	    return nodelist;
+    },
+		getElementById          : function(id){
+      $debug(&quot;document.getElementById( &quot;+id+&quot; )&quot;);
+      var elem = makeNode( $dom.getElementById(id) );
+			return elem;
+		},
+		getElementsByTagName    : function(name){ 
+		  $debug(&quot;document.getElementsByTagName(&quot;+name+&quot;)&quot;);
+			return new NodeList( $dom.getElementsByTagName(name) );
+	  },
+		getElementsByTagNameNS  : function(nsuri,qname){ 
+		  $debug(&quot;document.getElementsByTagNameNS(&quot;+nsuri+&quot;, &quot;+qname+&quot;)&quot;);
+		  return  new NodeList( $dom.getElementsByTagNameNS( nsuri,qname ) );
+	  },
+		importNode              : function(node, deep){
+		  return makeNode($dom.importNode($nodeImplCache[node.__$__], deep));
+	  },
+		adoptNode              : function(node){
+		  return makeNode($dom.adoptNode($nodeImplCache[node.__$__]));
+	  },
+		load: function(url){
+		  $log(&quot;Loading url into DOM Document: &quot;+ url + &quot; - (Asynch? &quot;+$w.document.async+&quot;)&quot;);
+			var _this = this;
+			var xhr = new XMLHttpRequest();
+			xhr.open(&quot;GET&quot;, url, $w.document.async);
+			xhr.onreadystatechange = function(){
+			  try{
+				  _this.loadXML(xhr.responseText);
+			  }catch(e){
+			    $error(&quot;Error Parsing XML - &quot;,e);
+          _this.loadXML(
+            &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&quot;+
+              &quot;&lt;h1&gt;Parse Error&lt;/h1&gt;&quot;+
+              &quot;&lt;p&gt;&quot;+e.toString()+&quot;&lt;/p&gt;&quot;+  
+            &quot;&lt;/body&gt;&lt;/html&gt;&quot;);
+		    }
+			  $url = url;
+				$log(&quot;Sucessfully loaded document.&quot;);
+				var event = document.createEvent();
+				event.initEvent(&quot;load&quot;);
+				$w.dispatchEvent( event );
+			};
+			xhr.send();
+		},
+		//This is actually IE specific but still convenient
+		loadXML                 : function(xmlString){ 
+		  $debug(&quot;Parsing document into internal dom&quot;);
+		  $dom = $env.parseHTML(xmlString);
+		  $nodeCache[$env.hashCode($dom)] = this;
+		  $nodeImplCache[$id] = $dom;
+		  $url = $url?$url:xmlString;
+		  $debug(&quot;Finished Parsing Document (&quot;+$id+&quot;), Internal DOM is set. =&gt; &quot; + $dom);
+		  return this; 
+	  },
+	  normalizeDocument: function(){
+	    $log(&quot;Normalizing Document&quot;);
+	    $dom.normalizeDocument();
+	    $log(&quot;Finished Normalizing Document&quot;);
+    },
+	  get xml(){return this.doctype.xml + &quot;\n&quot; +this.documentElement.xml;},
+		removeEventListener     : window.removeEventListener,
+		toString: function(){ return &quot;Document&quot; +  (typeof $url == &quot;string&quot; ? &quot;: &quot; + $url : &quot;&quot;); },
+		get __$__(){return $id;}
+  });
+};$log(&quot;Defining Attr&quot;);
+/*
+* Attr - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Attr&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Attr = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Attr &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get name(){return String($dom.getName()); },
+    get ownerElement(){ return makeNode( $dom.getOwnerElement() );},
+    get specified(){ return makeNode( $dom.getSpecified() );},
+    get value(){return String($dom.getValue()); },
+    set value(value){return $dom.setValue(value); },
+    get xml(){return this.nodeName + &quot;='&quot; + this.nodeValue + &quot;' &quot;;}
+  });
+};$log(&quot;Defining CDATASection&quot;);
+/*
+* CDATASection - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CDATASection&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CDATASection = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;CDATASection &quot;+$id);
+  __extend__(this, new Text($dom, $id));
+  return __extend__(this,{
+    get xml(){return &quot;&lt;![CDATA[&quot; + this.nodeValue + &quot;]]&gt;&quot;;}
+  });
+};
+$debug(&quot;Defining CharacterData&quot;);
+/*
+* CharacterData - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CharacterData&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CharacterData = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;CharacterData &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get data(){return $dom.getData();},
+    set data(data){return $dom.setData(data);},
+    get length(){return $dom.getLength();},
+    appendData: function(arg){return $dom.appendData(arg);},
+    deleteData: function(offset, count){ return $dom.deleteData(offset, count);},
+    insertData: function(offset, arg){return $dom.insertData(offset, arg);},
+    replaceData: function(offset, count, arg){return $dom.replaceData(offset, count, arg);},
+    substringData: function(offset, count){return $dom.substringData(offset, count);}
+  });
+};$log(&quot;Defining Comment&quot;);
+/* 
+* Comment - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Comment&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Comment = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Comment &quot;+$id);
+  __extend__(this, new CharacterData($dom, $id));
+  return __extend__(this,{
+    get xml(){return &quot;&lt;!-- &quot; + this.nodeValue + &quot; --&gt;&quot;;}
+  });
+};
+
+	$log(&quot;Defining DocumentType&quot;);
+;/*
+* DocumentType - DOM Level 2
+*/
+$w.__defineGetter__('DocumentType', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var DocumentType = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;DocumentType &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get internalSubset(){return $dom.getInternalSubset();},
+    get name(){return $dom.getName();},
+    get publicId(){return $dom.getPublicId();},
+    get systemId(){return $dom.getSystemId();},
+    get xml(){return '&lt;!DOCTYPE ' +this.name+ ' PUBLIC &quot;'+this.publicId+'&quot; &quot;'+this.systemId+'&quot;&gt;';}
+  });
+};
+
+var __DocumentType__ = function(doctype){
+  $domparser.parseString('&lt;!DOCTYPE ' +doctype.name||''+ 
+    ' PUBLIC &quot;'+doctype.publicId||''+' '+'&quot;'+
+    doctype.systemId||''+'&quot;&gt;&lt;asdf&gt;&lt;/asdf&gt;').doctype;
+};$log(&quot;Defining Element&quot;);
+/*
+* Element - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Element&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Element = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  
+  $debug(&quot;Element &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+  	get tagName(){ return $dom.getTagName(); },
+  	get attributes(){
+  	  //Simple way to emulate NamedNodeMap which is only
+  	  //ever used here
+  		var attrs = new NodeList($dom.getAttributes());
+  		if(!attrs||(attrs.length === undefined)){setArray(attrs,[]);}
+  		for ( var i = 0; i &lt; attrs.length; i++ ){
+  		  attrs[attrs[i].nodeName] = attrs[i];
+  		}return attrs;
+  	},
+  	addEventListener: window.addEventListener,
+  	removeEventListener: window.removeEventListener,
+  	dispatchEvent: window.dispatchEvent,
+  	getAttribute: function(name){ return String($dom.getAttribute(name));},
+  	getAttributeNode: function(name){ return makeNode( $dom.getAttributeNode(name) ); },
+  	getAttributeNodeNS: function(nsuri,localname){ return makeNode( $dom.getAttributeNodeNS(nsuri,localname) ); },
+  	getElementsByTagName: function(name){ 
+  	  //$debug(&quot;element.getElementsByTagName(&quot;+name+&quot;)&quot;);
+  	  return new NodeList($dom.getElementsByTagName(name));
+	  },
+  	getElementsByTagNameNS: function(nsuri, localname){ return new NodeList( $dom.getElementsByTagNameNS(nsuri, localname) );},
+  	hasAttribute: function(name){return $dom.hasAttribute(name);},
+  	hasAttributeNS: function(nsuri,localname){return $dom.hasAttributeNS(nsuri,localname);},
+  	removeAttribute: function(name){ $dom.removeAttribute(name); },
+  	removeAttributeNode: function(node){ return makeNode($dom.removeAttributeNode($nodeImplCache[node.__$__])); },
+  	removeAttributeNS: function(nsuri,localname){ $dom.removeAttributeNS(nsuri, localname); },
+  	setAttribute: function(name,value){
+  	  $dom.setAttribute(name,value);
+  	  if(name === 'id' &amp;&amp; this.ownerDocument.__html__){this.setIdAttribute(name,true);} 
+	  },
+  	setIdAttribute: function(name,bool){ $dom.setIdAttribute(name,bool); },
+  	setAttributeNode: function(node){ return makeNode($dom.setAttributeNode($nodeImplCache[node.__$__])); },
+  	setAttributeNodeNS: function(node){ return makeNode($dom.setAttributeNodeNS($nodeImplCache[node.__$__])); },
+  	setAttributeNS: function(nsuri,qname,value){ $dom.setAttributeNS(nsuri,qname,value); },
+  	toString: function(){ return &quot;&lt;&quot; + this.tagName + (this.id ? &quot;#&quot; + this.id : &quot;&quot; ) + &quot;&gt;&quot;; },
+  	get xml(){
+			var ret = &quot;&lt;&quot; + this.tagName, attrs = this.attributes;
+			for ( var i = 0; i&lt; attrs.length;i++ ){ ret += &quot; &quot; + attrs[i].xml; }
+			if ( this.childNodes.length || this.nodeName == &quot;SCRIPT&quot; ){
+			  ret += &quot;&gt;&quot; + this.childNodes.xml + &quot;&lt;/&quot; + this.tagName + &quot;&gt;&quot;;
+			}else{
+				ret += &quot;/&gt;&quot;;
+			} return ret;
+		}
+  });
+};
+
+	/*
+* DOMException - DOM Level 2
+*/	
+
+// For now I'm passing on this since DOMExceptions can simply flow 
+// through the underlying env supplied dom implementation
+
+$log(&quot;Defining DocumentFragment&quot;);
+/* 
+* DocumentFragment - DOM Level 2
+*/
+$w.__defineGetter__(&quot;DocumentFragment&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var DocumentFragment = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;DocumentFragment &quot; +$id);
+  __extend__(this, new Node($dom, $id));
+  // Nothing to extend as far as I know.  This and several other
+  // classes need to be moved off of window as the constructor, though available
+  // (by this I mean it wont throw a 'no such method') are not meant
+  // to be used directly. Instead the document.create* is meant to be used.
+  // Not perfectly sure how to implement this.  perhaps we have to examine
+  // the context inside the constructor
+};
+//DOMImplementation
+$log(&quot;Defining DOMImplementation&quot;);
+$w.__defineGetter__(&quot;DOMImplementation&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var DOMImplementation = function(){
+	return {
+		hasFeature: function(feature, version){
+			//TODO
+			return false;
+		},
+		createDocumentType: function(qname, publicid, systemid){
+			return new __DocumentType__({
+			  name:qname, publicId:publicid, systemId:systemid
+			});
+		},
+		createDocument:function(nsuri, qname, doctype){
+		  //TODO - this currently returns an empty doc
+		  //but needs to handle the args
+			return new HTMLDocument();
+		},
+		getFeature:function(feature, version){
+			//TODO or TODONT?
+		}
+	};
+};
+
+
+$log(&quot;Initializing document.implementation&quot;);
+var $implementation =  new DOMImplementation();$log(&quot;Defining ProcessingInstruction&quot;);
+/*
+* ProcessingInstruction - DOM Level 2
+*/
+$w.__defineGetter__('ProcessingInstruction', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var ProcessingInstruction = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;ProcessingInstruction &quot; +$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get data(){return $dom.getData();},
+    set data(data){return $dom.setData(data);},
+    get target(){return $dom.getTarget();}
+  });
+};$log(&quot;Defining Node&quot;);
+/*
+* Node - DOM Level 2
+*/	
+$w.__defineGetter__('Node', function(){
+  return __extend__(function(){
+        throw new Error(&quot;Object cannot be created in this context&quot;);
+      } , {
+  		ELEMENT_NODE    :1,
+  		ATTRIBUTE_NODE  :2,
+  		TEXT_NODE       :3,
+  		CDATA_SECTION_NODE: 4,
+  		PROCESSING_INSTRUCTION_NODE: 7,
+  		COMMENT_NODE: 8,
+  		DOCUMENT_NODE: 9,
+  		DOCUMENT_TYPE_NODE: 10,
+  		DOCUMENT_FRAGMENT_NODE: 11
+	});
+});
+
+var Node = function(node, id){
+  __extend__(this, {
+  		ELEMENT_NODE    :1,
+  		ATTRIBUTE_NODE  :2,
+  		TEXT_NODE       :3,
+  		CDATA_SECTION_NODE: 4,
+  		PROCESSING_INSTRUCTION_NODE: 7,
+  		COMMENT_NODE: 8,
+  		DOCUMENT_NODE: 9,
+  		DOCUMENT_TYPE_NODE: 10,
+  		DOCUMENT_FRAGMENT_NODE: 11
+	});
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Node  &quot;+$id);
+  return __extend__(this, {
+    get attributes(){ return null;},
+		get childNodes(){ return new NodeList( $dom.getChildNodes() ); },
+		get firstChild(){ return makeNode( $dom.getFirstChild() ); },
+		get lastChild(){ return makeNode( $dom.getLastChild() ); },
+		get localName(){ return  String($dom.getLocalName()); },
+		get namespaceURI(){ return  String($dom.getNamespaceURI()); },
+		get nextSibling() { return makeNode( $dom.getNextSibling() ); },
+		get nodeName() {return String($dom.getNodeName()); },
+		get nodeType(){ return Number($dom.getNodeType()); },
+		get nodeValue(){ return $dom.getNodeValue(); },
+		set nodeValue(value){ return $dom.setNodeValue(value); },
+		get ownerDocument(){ return makeNode(  $dom.getOwnerDocument() ); },
+		get parentNode() { return makeNode( $dom.getParentNode() ); },
+		get prefix() { return $dom.getPrefix(); },
+		set prefix(prefix) { return $dom.setPrefix(prefix); },
+		get previousSibling() { return makeNode( $dom.getPreviousSibling() ); },
+		get xml() { return this.nodeValue; },
+		appendChild: function(node){ $dom.appendChild( $nodeImplCache[node.__$__] ); },
+		cloneNode: function(deep){ return makeNode( $dom.cloneNode(deep) ); },
+		hasAttributes: function(){ return $dom.hasAttributes(); },
+		hasChildNodes: function(){ return $dom.hasChildNodes(); },
+		insertBefore: function(node,before){
+			$dom.insertBefore( $nodeImplCache[node.__$__], before ? $nodeImplCache[before.__$__] : before );
+		},
+		isSupported: function(feature,version){return $dom.isSupported(feature,version);},
+		normalize: function(){return $dom.normalize();},
+		removeChild: function(node){ 
+		  $dom.removeChild( $nodeImplCache[node.__$__] ); 
+		  $nodeCache[$nodeImplCache[node.__$__]]=null;
+		  delete $nodeCache[$nodeImplCache[node.__$__]];
+		  delete $nodeImplCache[node.__$__];
+		  node = null;
+		  delete node;
+	  },
+		replaceChild: function(newNode, oldNode){ 
+		  $dom.replaceChild( $nodeImplCache[newNode.__$__],$nodeImplCache[oldNode.__$__] ); 
+		  $nodeCache[$nodeImplCache[oldNode.__$__]]=null;
+		  delete $nodeCache[$nodeImplCache[oldNode.__$__]];
+		  delete $nodeImplCache[oldNode.__$__];
+		  oldNode = null;
+		  delete oldNode;
+	  },
+		toString: function(){ return '&quot;' + this.nodeValue + '&quot;'; },
+		get __$__(){return String($id);}
+  });
+};
+
+
+__extend__(Node, {
+		ELEMENT_NODE    :1,
+		ATTRIBUTE_NODE  :2,
+		TEXT_NODE       :3,
+		CDATA_SECTION_NODE: 4,
+		PROCESSING_INSTRUCTION_NODE: 7,
+		COMMENT_NODE: 8,
+		DOCUMENT_NODE: 9,
+		DOCUMENT_TYPE_NODE: 10,
+		DOCUMENT_FRAGMENT_NODE: 11
+});$log(&quot;Defining NodeList&quot;);
+/*
+* NodeList - DOM Level 2
+*/
+$w.__defineGetter__('NodeList', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var NodeList = function(nodes){
+  function toArray(nodelist){
+    if(nodelist&amp;&amp;nodelist.getLength){
+      var node, nodeArray = [];
+  		for ( var i = 0; i &lt; nodelist.getLength(); i++ ) {
+  		  node = makeNode( nodelist.item(i) );
+  		  if(node === null){$log(node + &quot; = makeNode(&quot;+nodelist.item(i)+&quot;); : NodeList&quot;);}
+  			nodeArray.push(node);
+  		}return nodeArray;
+	  }else{return [];}
+  };
+	setArray(this,toArray(nodes));
+	__extend__(this,{
+		toString: function(){ return &quot;[ &quot; + Array.prototype.join.apply(this,[&quot;,&quot;]) + &quot; ]&quot;; },
+  	item: function(index){return  this[index] ;},
+  	get xml(){
+  	  var xml = &quot;&quot;;
+		  for(var i=0;i&lt;this.length;i++){ xml +=  this[i].xml; }
+		  return xml;
+		}
+	});
+	return this;
+};$log(&quot;Defining DOMParser&quot;);
+/*
+* DOMParser
+*/
+$w.__defineGetter__('DOMParser', function(){
+  return function(){
+    return __extend__(this, {
+      parseFromString: function(xmlString){
+        $debug(&quot;Parsing XML String: &quot; +xmlString);
+        return document.implementation.createDocument().loadXML(xmlString);
+      }
+    });
+  };
+});
+
+$log(&quot;Initializing Internal DOMParser.&quot;);
+//keep one around for internal use
+$domparser = new DOMParser();
+$log(&quot;Defining Text&quot;);
+/*
+* Text - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Text&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Text = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Text &quot; +$id);
+  __extend__(this, new CharacterData($dom, $id));
+  return __extend__(this, {
+    splitText: function(offset){return makeNode($dom.splitText(offset));}
+  });
+};
+/*
+*	html.js
+*
+*	DOM Level 2 HTML
 */
-	//the current location
-	var $location = $env.location('./');
+
+var correctHTMLIds = function (node){
+  var children;
+  try{
+    if(node.nodeType === Node.ELEMENT_NODE){
+        //$log(&quot;Setting ID Attribute &quot; + node);
+        if(node.hasAttribute('id'))
+          node.setIdAttribute('id',true);
+      children = node.childNodes;
+      for(var i=0;i&lt;children.length;i++){
+        correctHTMLIds(children.item(i));
+      }
+    }
+  }catch(e){$log(e);}
+};
+			
+//This extends makeNode by allowing HTML&lt;T&gt;Elements to be defined
+function makeHTMLElement(name, node){
+  //This is an html document so we need to use explicit interfaces per the 
+  if(     name.match(/A/)){cacheNode(node, HTMLAnchorElement);}
+  else if(name.match(/AREA/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BASE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BLOCKQUOTE|Q/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BODY/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BR/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BUTTON/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/CAPTION/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/COL|COLGROUP/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/DEL|INS/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/DIV/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/DL/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/FIELDSET/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/FORM/)){cacheNode(node, HTMLFormElement);}
+  else if(name.match(/FRAME/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/FRAMESET/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/H1|H2|H3|H4|H5|H6/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/HEAD/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/HR/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/HTML/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/IFRAME/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/IMG/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/INPUT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LABEL/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LEGEND/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LI/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LINK/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/MAP/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/META/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OBJECT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OL/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OPTGROUP/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OPTION/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/P/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/PARAM/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/PRE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/SCRIPT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/SELECT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/STYLE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TABLE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TBODY|TFOOT|THEAD/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TD|TH/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TEXTAREA/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TITLE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TR/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/UL/)){cacheNode(node, HTMLElement);}
+  else{
+    $debug(&quot;Caching HTML Element &quot; + name);
+    cacheNode(node, HTMLElement);
+  }
+};
 	
-	$w.__defineSetter__(&quot;location&quot;, function(url){
-	  //$w.onunload();
-		$w.document.load(url);
-		$location = url;
-		setHistory($location);
+$log(&quot;Defining HTMLDocument&quot;);
+/*
+* HTMLDocument - DOM Level 2
+*  The Document object is not directly 
+*/
+$w.__defineGetter__(&quot;HTMLDocument&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+var HTMLDocument = function(node){
+  var $url, 
+      $domain, 
+      $title = &quot;&quot;, 
+      $lastModified = &quot;&quot;,
+      $refferer = &quot;&quot;,
+      $open = false;
+  __extend__(this, new Document(node));
+  return __extend__(this, {
+    get anchors(){return new HTMLCollection(this.getElementsByName('a'), 'Anchor');},
+    get applets(){return new HTMLCollection(this.getElementsByName('applet'), 'Applet');},
+    get body(){ return this.getElementsByName('body')[0];},
+    set body(html){return this.replaceNode(this.body,html);},
+    //set/get cookie see cookie.js
+    get domain(){return $domain||$w.location.domain;},
+    set domain(){return; /* TODO - requires a bit of thought to enforce domain restrictions */ },
+    get forms(){
+      $log(&quot;document.forms&quot;);
+      return new HTMLCollection(this.getElementsByName('form'), 'Form');
+    },
+    get images(){return new HTMLCollection(this.getElementsByName('img'), 'Image');},
+    get lastModified(){ return $lastModified; /* TODO */},
+    get links(){return new HTMLCollection(this.getElementsByName('link'), 'Link');},
+    get referrer(){return $refferer; /* TODO */},
+    get title(){return $title; /* TODO */},
+    set title(title){$title = title;},
+    get URL(){return $url; /* TODO*/},
+		close : function(){ $open = false;/* TODO */ },
+		getElementsByName : function(name){
+		  $debug(&quot;document.getElementsByName ( &quot;+name+&quot; )&quot;);
+		  return this.getElementsByTagName(name);
+	  },
+	  open : function(){ $open = true; /* TODO */ },
+	  write: function(htmlstring){ return;/* TODO */ },
+	  writeln: function(htmlstring){ this.write(htmlstring+'\n'); },
+		toString: function(){ return &quot;Document&quot; +  (typeof $url == &quot;string&quot; ? &quot;: &quot; + $url : &quot;&quot;); },
+		get innerHTML(){ return this.documentElement.outerHTML; },
+		get __html__(){return true;}
+  });
+};
+
+//This is useful as html elements that modify the dom must also run through the new 
+//nodes and determine if they are javascript tags and load it.  This is really the fun 
+//parts! ;)
+function execScripts( node ) {
+	if ( node.nodeName == &quot;SCRIPT&quot; ) {
+		if ( !node.getAttribute(&quot;src&quot;) ) {
+			eval.call( window, node.textContent );
+		}
+	} else {
+		var scripts = node.getElementsByTagName(&quot;script&quot;);
+		for ( var i = 0; i &lt; scripts.length; i++ ) {
+			execScripts( node );
+		}
+	}
+};$log(&quot;Defining HTMLElement&quot;);
+/*
+* HTMLElement - DOM Level 2
+*/
+$w.__defineGetter__(&quot;HTMLElement&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLElement = function(node){
+  __extend__(this, new Element(node));  
+	registerEventAttrs(this);
+	return __extend__(this, {
+		get className() { return this.getAttribute(&quot;class&quot;) || &quot;&quot;; },
+		set className(val) { return this.setAttribute(&quot;class&quot;,trim(val)); },
+		get dir() { return this.getAttribute(&quot;dir&quot;) || &quot;&quot;; },
+		set dir(val) { return this.setAttribute(&quot;dir&quot;,val); },
+		get id() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set id(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get innerHTML(){  return this.childNodes.xml; },
+		set innerHTML(html){
+		  //$debug(&quot;htmlElement.innerHTML(&quot;+html+&quot;)&quot;);
+		  //Should be replaced with HTMLPARSER usage
+			html = (html?html:&quot;&quot;).replace(/&lt;\/?([A-Z]+)/g, function(m){
+				return m.toLowerCase();
+			}).replace(/&amp;nbsp;/g, &quot; &quot;);
+			var doc = new DOMParser().
+			  parseFromString('&lt;div&gt;'+html+'&lt;/div&gt;');
+      var elements, nodes = this.ownerDocument.importNode(doc.documentElement, true).childNodes;
+			while (this.firstChild){ this.removeChild( this.firstChild );}
+			for(var i = 0; i&lt;nodes.length; i++ ){
+			  this.appendChild( nodes.item(i) );
+        correctHTMLIds(nodes.item(i));
+		  }
+		  delete doc;
+		},
+		get lang() { return this.getAttribute(&quot;lang&quot;) || &quot;&quot;; },
+		set lang(val) { return this.setAttribute(&quot;lang&quot;,val); },
+		offsetHeight: 0,
+		offsetWidth: 0,
+		offsetLeft: 0,
+		offsetRight: 0,
+		get offsetParent(){return;/* TODO */},
+		set offsetParent(element){return;/*TODO*/},
+		scrollHeight: 0,
+		scrollWidth: 0,
+		scrollLeft: 0, 
+		scrollRight: 0,
+		get style(){return null;},//new CSS2Properties(trim(this.getAttribute(&quot;style&quot;) || &quot;&quot;));},
+		get title() { return this.getAttribute(&quot;title&quot;) || &quot;&quot;; },
+		set title(val) { return this.setAttribute(&quot;title&quot;,val); },
+		//Not in the specs but I'll leave it here for now.
+		get outerHTML(){ return this.xml; },
+	  scrollIntoView: function(){/*TODO*/},
+		onclick: function(event){try{eval(this.getAttribute('onclick'));}catch(e){$error(e);}},
+		ondblclick: function(event){try{eval(this.getAttribute('ondblclick'));}catch(e){$error(e);}},
+		onkeydown: function(event){try{eval(this.getAttribute('onkeydown'));}catch(e){$error(e);}},
+		onkeypress: function(event){try{eval(this.getAttribute('onkeypress'));}catch(e){$error(e);}},
+		onkeyup: function(event){try{eval(this.getAttribute('onkeyup'));}catch(e){$error(e);}},
+		onmousedown: function(event){try{eval(this.getAttribute('onmousedown'));}catch(e){$error(e);}},
+		onmousemove: function(event){try{eval(this.getAttribute('onmousemove'));}catch(e){$error(e);}},
+		onmouseout: function(event){try{eval(this.getAttribute('onmouseout'));}catch(e){$error(e);}},
+		onmouseover: function(event){try{eval(this.getAttribute('onmouseover'));}catch(e){$error(e);}},
+		onmouseup: function(event){try{eval(this.getAttribute('onmouseup'));}catch(e){$error(e);}}
 	});
+};
+
+
+	var registerEventAttrs = function(elm){
+    if(elm.hasAttribute('onclick')){ elm.addEventListener('click', elm.onclick ); }
+    if(elm.hasAttribute('ondblclick')){ elm.addEventListener('dblclick', elm.onclick ); }
+    if(elm.hasAttribute('onkeydown')){ elm.addEventListener('keydown', elm.onclick ); }
+    if(elm.hasAttribute('onkeypress')){ elm.addEventListener('keypress', elm.onclick ); }
+    if(elm.hasAttribute('onkeyup')){ elm.addEventListener('keyup', elm.onclick ); }
+    if(elm.hasAttribute('onmousedown')){ elm.addEventListener('mousedown', elm.onclick ); }
+    if(elm.hasAttribute('onmousemove')){ elm.addEventListener('mousemove', elm.onclick ); }
+    if(elm.hasAttribute('onmouseout')){ elm.addEventListener('mouseout', elm.onclick ); }
+    if(elm.hasAttribute('onmouseover')){ elm.addEventListener('mouseover', elm.onclick ); }
+    if(elm.hasAttribute('onmouseup')){ elm.addEventListener('mouseup', elm.onclick ); }
+    return elm;
+	};
 	
-	$w.__defineGetter__(&quot;location&quot;, function(url){
-		var hash 	 = new RegExp('(\\#.*)'),
+	var click = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;click&quot;);
+		element.dispatchEvent(event);
+	};
+	var submit = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;submit&quot;);
+		element.dispatchEvent(event);
+	};
+	var focus = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;focus&quot;);
+		element.dispatchEvent(event);
+	};
+	var blur = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;blur&quot;);
+		element.dispatchEvent(event);
+	};$log(&quot;Defining HTMLFormElement&quot;);
+/* 
+* HTMLAnchorElement - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Form&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+$w.__defineGetter__(&quot;HTMLFormElement&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLFormElement = function(node){
+  __extend__(this, new HTMLElement(node));
+  return __extend__(this,{
+    get acceptCharset(){ return this.getAttribute('acceptCharset');},
+    set acceptCharset(acceptCharset){this.setAttribute('acceptCharset', acceptCharset);},
+    get action(){return this.getAttribute('action');},
+    set action(action){this.setAttribute('action', action);},
+    get elements() {return this.getElementsByTagName(&quot;*&quot;);},
+    get enctype(){return this.getAttribute('enctype');},
+    set enctype(enctype){this.setAttribute('enctype', enctype);},
+    get length() {return this.elements.length;},
+    get method(){return this.getAttribute('method');},
+    set method(action){this.setAttribute('method', method);},
+		get name() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set name(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get target() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set target(val) { return this.setAttribute(&quot;id&quot;,val); },
+		submit:function(){submit(this);},
+		reset:function(){reset(this);}
+  });
+};
+
+
+			$log(&quot;Defining HTMLCollection&quot;);
+/*
+* HTMLCollection - DOM Level 2
+*/
+$w.__defineGetter__(&quot;HTMLCollection&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLCollection = function(nodelist, type){
+  var $items = [], 
+      $item, i;
+  if(type === &quot;Anchor&quot; ){
+    for(i=0;i&lt;nodelist.length;i++){ 
+      //The name property is required to be add to the collection
+      if(nodelist.item(i).name){
+        item = new nodelist.item(i);
+        $items.push(item);
+        this[nodelist.item(i).name] = item;
+      }
+    }
+  }else if(type === &quot;Link&quot;){
+    for(i=0;i&lt;nodelist.length;i++){ 
+      //The name property is required to be add to the collection
+      if(nodelist.item(i).href){
+        item = new nodelist.item(i);
+        $items.push(item);
+        this[nodelist.item(i).name] = item;
+      }
+    }
+  }else if(type === &quot;Form&quot;){
+    for(i=0;i&lt;nodelist.length;i++){ 
+      //The name property is required to be add to the collection
+      if(nodelist.item(i).href){
+        item = new nodelist.item(i);
+        $items.push(item);
+        this[nodelist.item(i).name] = item;
+      }
+    }
+  }
+  setArray(this, $items);
+  return __extend__(this, {
+    item : function(i){return this[i];},
+    namedItem : function(name){return this[name];}
+  });
+};
+
+	$log(&quot;Defining HTMLAnchorElement&quot;);
+/* 
+* HTMLAnchorElement - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Anchor&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+$w.__defineGetter__(&quot;HTMLAnchorElement&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLAnchorElement = function(node){
+	var hash 	 = new RegExp('(\\#.*)'),
 			hostname = new RegExp('\/\/([^\:\/]+)'),
 			pathname = new RegExp('(\/[^\\?\\#]*)'),
 			port 	 = new RegExp('\:(\\d+)\/'),
 			protocol = new RegExp('(^\\w*\:)'),
 			search 	 = new RegExp('(\\?[^\\#]*)');
-		return {
-			get hash(){
-				var m = hash.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set hash(_hash){
-				//setting the hash is the only property of the location object
-				//that doesn't cause the window to reload
-				_hash = _hash.indexOf('#')===0?_hash:&quot;#&quot;+_hash;	
-				$location = this.protocol + this.host + this.pathname + 
-					this.search + _hash;
-				setHistory(_hash, &quot;hash&quot;);
-			},
-			get host(){
-				return this.hostname + (this.port !== &quot;&quot;)?&quot;:&quot;+this.port:&quot;&quot;;
-			},
-			set host(_host){
-				$w.location = this.protocol + _host + this.pathname + 
-					this.search + this.hash;
-			},
-			get hostname(){
-				var m = hostname.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set hostname(_hostname){
-				$w.location = this.protocol + _hostname + ((this.port===&quot;&quot;)?&quot;&quot;:(&quot;:&quot;+this.port)) +
-				 	 this.pathname + this.search + this.hash;
-			},
-			get href(){
-				//This is the only env specific function
-				return $location;
-			},
-			set href(url){
-				$w.location = url;	
-			},
-			get pathname(){
-				var m = this.href;
-				m = pathname.exec(m.substring(m.indexOf(this.hostname)));
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;/&quot;;
-			},
-			set pathname(_pathname){
-				$w.location = this.protocol + this.host + _pathname + 
-					this.search + this.hash;
-			},
-			get port(){
-				var m = port.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set port(_port){
-				$w.location = this.protocol + this.hostname + &quot;:&quot;+_port + this.pathname + 
-					this.search + this.hash;
-			},
-			get protocol(){
-				return protocol.exec(this.href)[0];
-			},
-			set protocol(_protocol){
-				$w.location = _protocol + this.host + this.pathname + 
-					this.search + this.hash;
-			},
-			get search(){
-				var m = search.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set search(_search){
-				$w.location = this.protocol + this.host + this.pathname + 
-					_search + this.hash;
-			},
-			toString: function(){
-				return this.href;
-			},
-			reload: function(force){
-				//TODO
-			},
-			replace: function(url){
-				//TODO
-			}
-		};
-	});
+  __extend__(this, new HTMLElement(node));
+  return __extend__(this,{
+		get accessKey() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set accessKey(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get charset() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set charset(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get coords() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set coords(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get href() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set href(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get hreflang() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set hreflang(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get name() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set name(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get rel() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set rel(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get rev() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set rev(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get shape() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set shape(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get tabIndex() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set tabIndex(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get target() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set target(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get type() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set type(val) { return this.setAttribute(&quot;id&quot;,val); },
+		blur:function(){blur(this);},
+		focus:function(){focus(this);},
+		get hash(){
+			var m = hash.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hash(_hash){
+			//setting the hash is the only property of the location object
+			//that doesn't cause the window to reload
+			_hash = _hash.indexOf('#')===0?_hash:&quot;#&quot;+_hash;	
+			this.href = this.protocol + this.host + this.pathname + this.search + _hash;
+		},
+		get host(){
+			return this.hostname + (this.port !== &quot;&quot;)?&quot;:&quot;+this.port:&quot;&quot;;
+		},
+		set host(_host){
+			this.href = this.protocol + _host + this.pathname + this.search + this.hash;
+		},
+		get hostname(){
+			var m = hostname.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hostname(_hostname){
+			this.href = this.protocol + _hostname + ((this.port===&quot;&quot;)?&quot;&quot;:(&quot;:&quot;+this.port)) +
+			 	 this.pathname + this.search + this.hash;
+		},
+		get pathname(){
+			var m = this.href;
+			m = pathname.exec(m.substring(m.indexOf(this.hostname)));
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;/&quot;;
+		},
+		set pathname(_pathname){
+			this.href = this.protocol + this.host + _pathname + 
+				this.search + this.hash;
+		},
+		get port(){
+			var m = port.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set port(_port){
+			this.href = this.protocol + this.hostname + &quot;:&quot;+_port + this.pathname + 
+				this.search + this.hash;
+		},
+		get protocol(){
+			return protocol.exec(this.href)[0];
+		},
+		set protocol(_protocol){
+			this.href = _protocol + this.host + this.pathname + 
+				this.search + this.hash;
+		},
+		get search(){
+			var m = search.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set search(_search){
+			this.href = this.protocol + this.host + this.pathname + 
+				_search + this.hash;
+		}
+  });
+};
+
+
+			$log(&quot;Defining Event&quot;);
+/*
+* event.js
+*/
+$w.__defineGetter__(&quot;Event&quot;, function(){
+  __extend__(this,{
+    CAPTURING_PHASE : 1,
+    AT_TARGET       : 2,
+    BUBBLING_PHASE  : 3
+  });
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Event = function(options){
+  if(options === undefined){options={target:window,currentTarget:window};}
+  __extend__(this,{
+    CAPTURING_PHASE : 1,
+    AT_TARGET       : 2,
+    BUBBLING_PHASE  : 3
+  });
+  $log(&quot;Creating new Event&quot;);
+  var $bubbles = options.bubbles?options.bubbles:true,
+      $cancelable = options.cancelable?options.cancelable:true,
+      $currentTarget = options.currentTarget?options.currentTarget:null,
+      $eventPhase = options.eventPhase?options.eventPhase:Event.CAPTURING_PHASE,
+      $target = options.eventPhase?options.eventPhase:document,
+      $timestamp = options.timestamp?options.timestamp:new Date().getTime().toString(),
+      $type = options.type?options.type:&quot;&quot;;
+  return __extend__(this,{
+    get bubbles(){return $bubbles;},
+    get cancelable(){return $cancelable;},
+    get currentTarget(){return $currentTarget;},
+    get eventPhase(){return $eventPhase;},
+    get target(){return $target;},
+    get timestamp(){return $timestamp;},
+    get type(){return $type;},
+    initEvent: function(type,bubbles,cancelable){
+      $type=type?type:$type;
+      $bubbles=bubbles?bubbles:$bubbles;
+      $cancelable=cancelable?cancelable:$cancelable;
+    },
+    preventDefault: function(){return;/* TODO */},
+    stopPropagation: function(){return;/* TODO */}
+  });
+};
+
+$log(&quot;Defining MouseEvent&quot;);
+/*
+*	mouseevent.js
+*/
+$log(&quot;Defining MouseEvent&quot;);
+/*
+*	uievent.js
+*/
+
+var $onblur,
+    $onfocus,
+    $onresize;/*
+* CSS2Properties - DOM Level 2 CSS
+*/
+$w.__defineGetter__(&quot;CSS2Properties&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+
+var CSS2Properties = function(options){
+  var $styles = [];
+  var $styleMap = {};
+  for (var prop in $supportedStyles){
+    $styleMap[prop] = &quot;&quot;;
+    this.__defineGetter__(prop, function(){return $styleMap[prop];});
+    if(!options.readonly){
+      //because the window.getComputedStyle return a CSS2Properties
+      //object that is read only we make the setter optional
+      this.__defineSetter__(prop, function(value){$styleMap[prop] = value;});
+    }
+  }
+  if(options.cssText){cssTextToStyles(options.cssText);}
+  function cssTextToStyles(cssText){
+    $styles=[];
+    var style, styles = cssText.split(';');
+    for ( var i = 0; i &lt; styles.length; i++ ) {
+    	style = styles[i].split(':');
+    	if ( style.length == 2 ){
+  	    //keep a reference to the original name of the style which was set
+  	    $styles[i]=styles[i];
+  		  //camel case for dash case
+  		  //this could be done much better with a match with function arg
+  		  //but I'm tearing through this just to get a first pass
+    	  style[0] = trim(style[0]).split('-');
+    	  if(style[0].length == 2){
+    	    style[0] = style[0][0]+style[0][1].substring(0,1).toUpperCase()+
+    	      style[0][1].substring(1,style[0][1].length);
+    	  }else{
+    	    //No '-' dash present
+    	    style[0] = style[0][0];
+        }
+    	  if($styleMap[style[0]]){
+    	    //set the value internally with camelcase name so its exposed via the 'get'.
+    	    $styleMap[style[0]] = trim(style[1]);
+    	  };
+    	}
+    }
+    setArray(this, $styles);
+  };
+  
+  return __extend__(this, {
+    get cssText(){$styles.join(';');},
+    set cssText(cssText){ cssTextToStyles(cssText); }
+  });
+};
+
+//Obviously these arent all supported but by commenting out various sections
+//this provides a single location to configure what is exposed as supported.
+var $supportedStyles = {
+    azimuth:	&quot;&quot;,
+    background:	&quot;&quot;,
+    backgroundAttachment:	&quot;&quot;,
+    backgroundColor:	&quot;&quot;,
+    backgroundImage:	&quot;&quot;,
+    backgroundPosition:	&quot;&quot;,
+    backgroundRepeat:	&quot;&quot;,
+    border:	&quot;&quot;,
+    borderBottom:	&quot;&quot;,
+    borderBottomColor:	&quot;&quot;,
+    borderBottomStyle:	&quot;&quot;,
+    borderBottomWidth:	&quot;&quot;,
+    borderCollapse:	&quot;&quot;,
+    borderColor:	&quot;&quot;,
+    borderLeft:	&quot;&quot;,
+    borderLeftColor:	&quot;&quot;,
+    borderLeftStyle:	&quot;&quot;,
+    borderLeftWidth:	&quot;&quot;,
+    borderRight:	&quot;&quot;,
+    borderRightColor:	&quot;&quot;,
+    borderRightStyle:	&quot;&quot;,
+    borderRightWidth:	&quot;&quot;,
+    borderSpacing:	&quot;&quot;,
+    borderStyle:	&quot;&quot;,
+    borderTop:	&quot;&quot;,
+    borderTopColor:	&quot;&quot;,
+    borderTopStyle:	&quot;&quot;,
+    borderTopWidth:	&quot;&quot;,
+    borderWidth:	&quot;&quot;,
+    bottom:	&quot;&quot;,
+    captionSide:	&quot;&quot;,
+    clear:	&quot;&quot;,
+    clip:	&quot;&quot;,
+    color:	&quot;&quot;,
+    content:	&quot;&quot;,
+    counterIncrement:	&quot;&quot;,
+    counterReset:	&quot;&quot;,
+    cssFloat:	&quot;&quot;,
+    cue:	&quot;&quot;,
+    cueAfter:	&quot;&quot;,
+    cueBefore:	&quot;&quot;,
+    cursor:	&quot;&quot;,
+    direction:	&quot;&quot;,
+    display:	&quot;&quot;,
+    elevation:	&quot;&quot;,
+    emptyCells:	&quot;&quot;,
+    font:	&quot;&quot;,
+    fontFamily:	&quot;&quot;,
+    fontSize:	&quot;&quot;,
+    fontSizeAdjust:	&quot;&quot;,
+    fontStretch:	&quot;&quot;,
+    fontStyle:	&quot;&quot;,
+    fontVariant:	&quot;&quot;,
+    fontWeight:	&quot;&quot;,
+    height:	&quot;&quot;,
+    left:	&quot;&quot;,
+    letterSpacing:	&quot;&quot;,
+    lineHeight:	&quot;&quot;,
+    listStyle:	&quot;&quot;,
+    listStyleImage:	&quot;&quot;,
+    listStylePosition:	&quot;&quot;,
+    listStyleType:	&quot;&quot;,
+    margin:	&quot;&quot;,
+    marginBottom:	&quot;&quot;,
+    marginLeft:	&quot;&quot;,
+    marginRight:	&quot;&quot;,
+    marginTop:	&quot;&quot;,
+    markerOffset:	&quot;&quot;,
+    marks:	&quot;&quot;,
+    maxHeight:	&quot;&quot;,
+    maxWidth:	&quot;&quot;,
+    minHeight:	&quot;&quot;,
+    minWidth:	&quot;&quot;,
+    opacity:	&quot;&quot;,
+    orphans:	&quot;&quot;,
+    outline:	&quot;&quot;,
+    outlineColor:	&quot;&quot;,
+    outlineOffset:	&quot;&quot;,
+    outlineStyle:	&quot;&quot;,
+    outlineWidth:	&quot;&quot;,
+    overflow:	&quot;&quot;,
+    overflowX:	&quot;&quot;,
+    overflowY:	&quot;&quot;,
+    padding:	&quot;&quot;,
+    paddingBottom:	&quot;&quot;,
+    paddingLeft:	&quot;&quot;,
+    paddingRight:	&quot;&quot;,
+    paddingTop:	&quot;&quot;,
+    page:	&quot;&quot;,
+    pageBreakAfter:	&quot;&quot;,
+    pageBreakBefore:	&quot;&quot;,
+    pageBreakInside:	&quot;&quot;,
+    pause:	&quot;&quot;,
+    pauseAfter:	&quot;&quot;,
+    pauseBefore:	&quot;&quot;,
+    pitch:	&quot;&quot;,
+    pitchRange:	&quot;&quot;,
+    position:	&quot;&quot;,
+    quotes:	&quot;&quot;,
+    richness:	&quot;&quot;,
+    right:	&quot;&quot;,
+    size:	&quot;&quot;,
+    speak:	&quot;&quot;,
+    speakHeader:	&quot;&quot;,
+    speakNumeral:	&quot;&quot;,
+    speakPunctuation:	&quot;&quot;,
+    speechRate:	&quot;&quot;,
+    stress:	&quot;&quot;,
+    tableLayout:	&quot;&quot;,
+    textAlign:	&quot;&quot;,
+    textDecoration:	&quot;&quot;,
+    textIndent:	&quot;&quot;,
+    textShadow:	&quot;&quot;,
+    textTransform:	&quot;&quot;,
+    top:	&quot;&quot;,
+    unicodeBidi:	&quot;&quot;,
+    verticalAlign:	&quot;&quot;,
+    visibility:	&quot;&quot;,
+    voiceFamily:	&quot;&quot;,
+    volume:	&quot;&quot;,
+    whiteSpace:	&quot;&quot;,
+    widows:	&quot;&quot;,
+    width:	&quot;&quot;,
+    wordSpacing:	&quot;&quot;,
+    zIndex:	&quot;&quot;
+};/* 
+* CSSRule - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CSSRule&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CSSRule = function(options){
+  var $style, 
+      $selectorText = options.selectorText?options.selectorText:&quot;&quot;;
+      $style = new CSS2Properties({cssText:options.cssText?options.cssText:null});
+    return __extend__(this, {
+      get style(){return $style;},
+      get selectorText(){return $selectorText;},
+      set selectorText(selectorText){$selectorText = selectorText;}
+    });
+};
+/* 
+* CSSStyleSheet - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CSSStyleSheet&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CSSStyleSheet = function(options){
+    var $cssRules, 
+        $disabled = options.disabled?options.disabled:false,
+        $href = options.href?options.href:null,
+        $parentStyleSheet = options.parentStyleSheet?options.parentStyleSheet:null,
+        $title = options.title?options.title:&quot;&quot;,
+        $type = &quot;text/css&quot;;
+        
+    function parseStyleSheet(text){
+      //this is pretty ugly, but text is the entire text of a stylesheet
+      var cssRules = [];
+    	if (!text) text = &quot;&quot;;
+    	text = trim(text.replace(/\/\*(\r|\n|.)*\*\//g,&quot;&quot;));
+    	// TODO: @import ?
+    	var blocks = text.split(&quot;}&quot;);
+    	blocks.pop();
+    	var i, len = blocks.length;
+    	var definition_block, properties, selectors;
+    	for (i=0; i&lt;len; i++){
+    		definition_block = blocks[i].split(&quot;{&quot;);
+    		if(definition_block.length === 2){
+      		selectors = definition_block[0].split(&quot;,&quot;);
+      		for(var j=0;j&lt;selectors.length;j++){
+      		  cssRules.push(new CSSRule({
+      		    selectorText:selectors[j],
+      		    cssText:definition_block[1]
+      		  }));
+      		}
+      		setArray($cssRules, cssRules);
+    		}
+    	}
+    };
+    parseStyleSheet(options.text);
+    return __extend__(this, {
+      get cssRules(){return $cssRules;},
+      get rule(){return $cssRules;},//IE - may be deprecated
+      get href(){return $href;},
+      get parentStyleSheet(){return $parentStyleSheet;},
+      get title(){return $title;},
+      get type(){return $type;},
+      addRule: function(selector, style, index){/*TODO*/},
+      deleteRule: function(index){/*TODO*/},
+      insertRule: function(rule, index){/*TODO*/},
+      removeRule: function(index){this.deleteRule(index);}//IE - may be deprecated
+    });
+};
+/*
+*	location.js
+*   - requires env
+*/
+$log(&quot;Initializing Window Location.&quot;);
+//the current location
+var $location = $env.location('./');
+
+$w.__defineSetter__(&quot;location&quot;, function(url){
+  //$w.onunload();
+	$w.document.load(url);
+	$location = url;
+	setHistory($location);
+});
+
+$w.__defineGetter__(&quot;location&quot;, function(url){
+	var hash 	 = new RegExp('(\\#.*)'),
+		hostname = new RegExp('\/\/([^\:\/]+)'),
+		pathname = new RegExp('(\/[^\\?\\#]*)'),
+		port 	 = new RegExp('\:(\\d+)\/'),
+		protocol = new RegExp('(^\\w*\:)'),
+		search 	 = new RegExp('(\\?[^\\#]*)');
+	return {
+		get hash(){
+			var m = hash.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hash(_hash){
+			//setting the hash is the only property of the location object
+			//that doesn't cause the window to reload
+			_hash = _hash.indexOf('#')===0?_hash:&quot;#&quot;+_hash;	
+			$location = this.protocol + this.host + this.pathname + 
+				this.search + _hash;
+			setHistory(_hash, &quot;hash&quot;);
+		},
+		get host(){
+			return this.hostname + (this.port !== &quot;&quot;)?&quot;:&quot;+this.port:&quot;&quot;;
+		},
+		set host(_host){
+			$w.location = this.protocol + _host + this.pathname + 
+				this.search + this.hash;
+		},
+		get hostname(){
+			var m = hostname.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hostname(_hostname){
+			$w.location = this.protocol + _hostname + ((this.port===&quot;&quot;)?&quot;&quot;:(&quot;:&quot;+this.port)) +
+			 	 this.pathname + this.search + this.hash;
+		},
+		get href(){
+			//This is the only env specific function
+			return $location;
+		},
+		set href(url){
+			$w.location = url;	
+		},
+		get pathname(){
+			var m = this.href;
+			m = pathname.exec(m.substring(m.indexOf(this.hostname)));
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;/&quot;;
+		},
+		set pathname(_pathname){
+			$w.location = this.protocol + this.host + _pathname + 
+				this.search + this.hash;
+		},
+		get port(){
+			var m = port.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set port(_port){
+			$w.location = this.protocol + this.hostname + &quot;:&quot;+_port + this.pathname + 
+				this.search + this.hash;
+		},
+		get protocol(){
+			return protocol.exec(this.href)[0];
+		},
+		set protocol(_protocol){
+			$w.location = _protocol + this.host + this.pathname + 
+				this.search + this.hash;
+		},
+		get search(){
+			var m = search.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set search(_search){
+			$w.location = this.protocol + this.host + this.pathname + 
+				_search + this.hash;
+		},
+		toString: function(){
+			return this.href;
+		},
+		reload: function(force){
+			//TODO
+		},
+		replace: function(url){
+			//TODO
+		}
+	};
+});
+
 /*
 *	history.js
 */
 
+  $log(&quot;Initializing Window History.&quot;);
 	$currentHistoryIndex = 0;
 	$history = [];
 	
@@ -365,6 +1760,8 @@ function trim( str ){
 *	navigator.js
 *   - requires env
 */
+$log(&quot;Initializing Window Navigator.&quot;);
+
 var $appCodeName  = &quot;EnvJS&quot;;//eg &quot;Mozilla&quot;
 var $appName      = &quot;Resig/20070309 BirdDog/0.0.0.1&quot;;//eg &quot;Gecko/20070309 Firefox/2.0.0.3&quot;
 
@@ -411,7 +1808,8 @@ $w.__defineGetter__(&quot;navigator&quot;, function(){
 *	timer.js
 */
 	
-// Timers
+
+$log(&quot;Initializing Window Timer.&quot;);
 
 var $timers = [];
 
@@ -439,9 +1837,8 @@ $w.clearInterval = $w.clearTimeout = function(num){
 	/*
 * event.js
 */
-	
 // Window Events
-
+$log(&quot;Initializing Window Event.&quot;);
 var $events = [{}],
     $onerror,
     $onload,
@@ -524,643 +1921,9 @@ $w.__defineGetter__('onunload', function(){
 $w.__defineSetter__('onunload', function(fn){
   //$w.addEventListener('unload', fn);
 });*//*
-*	dom.js
-*
-*	DOM Level 2 /DOM level 3 (partial)
-*	
-*	The DOMDocument is now private in scope but you can create new
-*	DOMDocuments via document.implementation.createDocument which
-*	now also exposes the DOM Level 3 function 'load(uri)'.
-*
-*/
-
-  // Helper method for generating the right
-	// DOM objects based upon the type
-	/*var obj_nodes = {};
-
-	function makeNode(node){
-	  $log(&quot;Making Node&quot;);
-		if ( node ) {
-			if ( !obj_nodes[node]){
-				obj_nodes[node] = node.getNodeType() == 1 ? new DOMElement( node ) :
-					(node.getNodeType() == 8 ? new DOMComment( node ) : new DOMNode( node )) ;
-  		}
-			return obj_nodes[node];
-		} else
-			return null;
-	};*/
-	// Helper method for generating the right
-	// DOM objects based upon the type
-	
-	var $nodeCache = {};//caches a reference to our implementation of the node
-	var $nodeImplCache = {};//reverse look-up : caches a reference to the env supplied implementors dom node
-	var $guid = (-1)*Math.pow(2,31);
-  function createGUID(){
-    return String(++$guid);
-  };
-	
-	function makeNode(node){
-		if ( node ) {
-			if ( !$nodeCache[ $env.hashCode(node) ] ){
-				if( node.getNodeType() == 1){
-				  $nodeCache[$env.hashCode(node)] = new DOMElement( node );
-				  $nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
-				}else{
-				  if(node.getNodeType() == 8){
-				    $nodeCache[$env.hashCode(node)] = new DOMComment( node );
-				    $nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
-				  }else{
-				    $nodeCache[$env.hashCode(node)] = new DOMNode( node );
-				    $nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
-			    }
-				}
-			}
-			return $nodeCache[$env.hashCode(node)];
-		} else{ 
-		  return null;
-	  }
-	}
-	
-	//DOMImplementation
-	var DOMImplementation = function(){
-		return {
-			hasFeature: function(feature, version){
-				//TODO
-				return false;
-			},
-			createDocumentType: function(qname, publicId, systemId){
-				//TODO
-			},
-			createDocument:function(namespace, qname, docType){
-				return new DOMDocument();
-			},
-			getFeature:function(feature, version){
-				//TODO or TODONT?
-			}
-		};
-	};
-	
-	// DOM Document
-$w.__defineGetter__('DOMDocument', function(){
-  var $dom, $id, $url;
-  return function(){
-    $id = createGUID();
-    return __extend__(this,{
-  		load: function(url){
-  		  $log(&quot;Loading url into DOM Document: &quot;+ url + &quot; - (Asynch? &quot;+$w.document.async+&quot;)&quot;);
-  			var _this = this;
-  			var xhr = new XMLHttpRequest();
-  			xhr.open(&quot;GET&quot;, url, $w.document.async);
-  			xhr.onreadystatechange = function(){
-				  try{
-					  _this.loadXML(xhr.responseText);
-				  }catch(e){
-				    $error(&quot;Error Parsing XML - &quot;,e);
-	          _this.loadXML(
-	            &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&quot;+
-	              &quot;&lt;h1&gt;Parse Error&lt;/h1&gt;&quot;+
-	              &quot;&lt;p&gt;&quot;+e.toString()+&quot;&lt;/p&gt;&quot;+  
-	            &quot;&lt;/body&gt;&lt;/html&gt;&quot;);
-			    }
-  			  $url = url;
-      		if ( !$nodeCache[$dom] ){
-      			$nodeCache[$dom] = _this;
-    			}
-  				$log(&quot;Sucessfully loaded document.&quot;);
-  				var event = document.createEvent();
-  				event.initEvent(&quot;load&quot;);
-  				$w.dispatchEvent( event );
-  			};
-  			xhr.send();
-  		},
-  		//This is actuall IE specific but still convenient
-  		loadXML: function(xmlString){
-  		  $dom = $env.parseXML(xmlString);
-  		  return this;
-  		},
-  		get nodeType(){
-  			return 9;
-  		},
-  		createTextNode: function(text){
-  			return makeNode( $dom.createTextNode(
-  				text.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;)) );
-  		},
-  		createElement: function(name){
-  			return makeNode( $dom.createElement(name.toLowerCase()) );
-  		},
-  		getElementsByTagName: function(name){
-  			return new DOMNodeList( 
-  			  $dom.getElementsByTagName(
-  				  name.toLowerCase()) );
-  		},
-  		getElementsByName: function(name){
-  		  // why can't we just do ?: 
-  			//var elems = $dom.getElementsByTagName(name), ret = [];
-  			var elems = $dom.getElementsByTagName(&quot;*&quot;), ret = [];
-  			ret.item = function(i){ return this[i]; };
-  			ret.getLength = function(){ return this.length; };
-  			for ( var i = 0; i &lt; elems.length; i++ ) {
-  				var elem = elems.item(i);
-  				if ( elem.getAttribute(&quot;name&quot;) == name )
-  					ret.push( elem );
-  			}return new DOMNodeList( ret );
-  		},
-  		getElementById: function(id){
-  		  // why can't we just do ?: 
-  		  //return makeNode($dom.getElementById(id));
-  		  var elems = $dom.getElementsByTagName(&quot;*&quot;);
-  			
-  			for ( var i = 0; i &lt; elems.length; i++ ) {
-  				var elem = elems.item(i);
-  				if ( elem.getAttribute(&quot;id&quot;) == id )
-  					return makeNode(elem);
-  			}
-  			
-  			return null;
-  		},
-  		get body(){
-  			return this.getElementsByTagName(&quot;body&quot;)[0];
-  		},
-  		get documentElement(){
-  			return makeNode( $dom.getDocumentElement() );
-  		},
-  		get ownerDocument(){
-  			return null;
-  		},
-  		addEventListener: window.addEventListener,
-  		removeEventListener: window.removeEventListener,
-  		dispatchEvent: window.dispatchEvent,
-  		get nodeName() {
-  			return &quot;#document&quot;;
-  		},
-  		importNode: function(node, deep){
-  		  //need to replace this with some innerHtml magic
-  		  //because the ._dom is private in scope now
-  			return makeNode( $dom.importNode($nodeImplCache[node.__guid__], deep) );
-  		},
-  		toString: function(){
-  			return &quot;Document&quot; + 
-  			  (typeof $url == &quot;string&quot; ? &quot;: &quot; + $url : &quot;&quot;);
-  		},
-  		get innerHTML(){
-  			return this.documentElement.outerHTML;
-  		},
-  		
-  		get defaultView(){
-  			return {
-  				getComputedStyle: function(elem){
-  					return {
-  						getPropertyValue: function(prop){
-  							prop = prop.replace(/\-(\w)/g,function(m,c){
-  								return c.toUpperCase();
-  							});
-  							var val = elem.style[prop];
-  							if ( prop === &quot;opacity&quot; &amp;&amp; val === &quot;&quot; ){
-  								val = &quot;1&quot;;
-  							}return val;
-  						}
-  					};
-  				}
-  			};
-  		},
-  		
-  		createEvent: function(){
-  			return {
-  				type: &quot;&quot;,
-  				initEvent: function(type){
-  					this.type = type;
-  				}
-  			};
-  		},
-  		get __guid__(){return $id;}
-    });
-  };
-});
-
-function getDocument(node){
-	return $nodeCache[node];
-}
-	
-	// DOM NodeList
-
-$w.__defineGetter__(&quot;DOMNodeList&quot;, function(){
-  var $dom;
-  return function(list){
-		$dom = list;
-		this.length = list.getLength();
-		
-		for ( var i = 0; i &lt; this.length; i++ ) {
-			var node = list.item(i);
-			this[i] = makeNode( node );
-		}
-		return __extend__(this,{
-  		toString: function(){
-  			return &quot;[ &quot; +
-  				Array.prototype.join.call( this, &quot;, &quot; ) + &quot; ]&quot;;
-  		},
-  		get outerHTML(){
-  			return Array.prototype.map.call(
-  				this, function(node){return node.outerHTML;}).join('');
-  		}
-		});
-	};
-});
-	
-	// DOM Node
-	
-$w.__defineGetter__(&quot;DOMNode&quot;, function(){
-  var $dom, $id;
-  return function(node){
-    $id = createGUID();
-	  $dom = node;
-	  return __extend__(this, {
-  		get nodeType(){
-  			return $dom.getNodeType();
-  		},
-  		get nodeValue(){
-  			return $dom.getNodeValue();
-  		},
-  		get nodeName() {
-  			return $dom.getNodeName();
-  		},
-  		get childNodes(){
-  			return new DOMNodeList( $dom.getChildNodes() );
-  		},
-  		cloneNode: function(deep){
-  			return makeNode( $dom.cloneNode(deep) );
-  		},
-  		get ownerDocument(){
-  			return getDocument( $dom.ownerDocument );
-  		},
-  		get documentElement(){
-  			return makeNode( $dom.documentElement );
-  		},
-  		get parentNode() {
-  			return makeNode( $dom.getParentNode() );
-  		},
-  		get nextSibling() {
-  			return makeNode( $dom.getNextSibling() );
-  		},
-  		get previousSibling() {
-  			return makeNode( $dom.getPreviousSibling() );
-  		},
-  		toString: function(){
-  			return '&quot;' + this.nodeValue + '&quot;';
-  		},
-  		get outerHTML(){
-  			return this.nodeValue;
-  		},
-  		get __guid__(){return $id;}
-	  });
-  };
-});
-
-  // DOMComment
-
-$w.__defineGetter__(&quot;DOMComment&quot;, function(){
-	  $id = createGUID();
-  return function(node){
-    return __extend__(this, __extend__(new DOMNode(node),{
-      get nodeType(){
-  			return 8;
-  		},
-  		get outerHTML(){
-  			return &quot;&lt;!--&quot; + this.nodeValue + &quot;--&gt;&quot;;
-  		}
-    }));
-  };
-});
-
-	// DOM Element
-
-$w.__defineGetter__(&quot;DOMElement&quot;, function(){
-	var $dom, $id;
-	return function(elem){
-	  $dom = elem;
-	  $id = createGUID();
-	  __extend__(this, new DOMNode($dom));
-		
-		// A lot of the methods defined below belong in HTML specific
-		// subclasses.  This is already unwieldy since most of these
-		//methods are meant for general xml consumption
-		__extend__(this, {
-  		get nodeName(){
-  			return this.tagName;
-  		},
-  		get tagName(){
-  			return $dom.getTagName().toUpperCase();
-  		},
-  		toString: function(){
-  			return &quot;&lt;&quot; + this.tagName + (this.id ? &quot;#&quot; + this.id : &quot;&quot; ) + &quot;&gt;&quot;;
-  		},
-  		get outerHTML(){
-  			var ret = &quot;&lt;&quot; + this.tagName, attr = this.attributes;
-  			
-  			for ( var i in attr )
-  				ret += &quot; &quot; + i + &quot;='&quot; + attr[i] + &quot;'&quot;;
-  				
-  			if ( this.childNodes.length || this.nodeName == &quot;SCRIPT&quot; )
-  				ret += &quot;&gt;&quot; + this.childNodes.outerHTML + 
-  					&quot;&lt;/&quot; + this.tagName + &quot;&gt;&quot;;
-  			else
-  				ret += &quot;/&gt;&quot;;
-  			
-  			return ret;
-  		},
-  		
-  		get attributes(){
-  			var attr = {}, attrs = $dom.getAttributes();
-  			for ( var i = 0; i &lt; attrs.getLength(); i++ ){
-  				attr[ attrs.item(i).nodeName ] = attrs.item(i).nodeValue;
-				}return attr;
-  		},
-  		
-  		get innerHTML(){
-  			return this.childNodes.outerHTML;	
-  		},
-  		set innerHTML(html){
-  			html = html.replace(/&lt;\/?([A-Z]+)/g, function(m){
-  				return m.toLowerCase();
-  			}).replace(/&amp;nbsp;/g, &quot; &quot;);
-  			
-  			var dom = new DOMParser().parseFromString(&quot;&lt;wrap&gt;&quot; + html + &quot;&lt;/wrap&gt;&quot;);
-  			var nodes = this.ownerDocument.importNode( dom.documentElement,  true ).childNodes;
-  				
-  			while (this.firstChild){
-  				this.removeChild( this.firstChild );
-				}
-  			
-  			for ( var i = 0; i &lt; nodes.length; i++ )
-  				this.appendChild( nodes[i] );
-  		},
-  		
-  		get textContent(){
-  			function nav(nodes){
-  				var str = &quot;&quot;;
-  				for ( var i = 0; i &lt; nodes.length; i++ ){
-  					if ( nodes[i].nodeType == 3 ){
-  						str += nodes[i].nodeValue;
-  					}else if ( nodes[i].nodeType == 1 ){
-  						str += nav(nodes[i].childNodes);
-  					}
-  				} return str;
-  			} return nav(this.childNodes);
-  		},
-  		set textContent(text){
-  			while (this.firstChild)
-  				this.removeChild( this.firstChild );
-  			this.appendChild( this.ownerDocument.createTextNode(text));
-  		},
-  		
-  		style: {},
-  		clientHeight: 0,
-  		clientWidth: 0,
-  		offsetHeight: 0,
-  		offsetWidth: 0,
-  		
-  		get disabled() {
-  			var val = this.getAttribute(&quot;disabled&quot;);
-  			return val != &quot;false&quot; &amp;&amp; !!val;
-  		},
-  		set disabled(val) { return this.setAttribute(&quot;disabled&quot;,val); },
-  		
-  		get checked() {
-  			var val = this.getAttribute(&quot;checked&quot;);
-  			return val != &quot;false&quot; &amp;&amp; !!val;
-  		},
-  		set checked(val) { return this.setAttribute(&quot;checked&quot;,val); },
-  		
-  		get selected() {
-  			if ( !this._selectDone ) {
-  				this._selectDone = true;
-  				
-  				if ( this.nodeName == &quot;OPTION&quot; &amp;&amp; !this.parentNode.getAttribute(&quot;multiple&quot;) ) {
-  					var opt = this.parentNode.getElementsByTagName(&quot;option&quot;);
-  					
-  					if ( this == opt[0] ) {
-  						var select = true;
-  						
-  						for ( var i = 1; i &lt; opt.length; i++ ){
-  							if ( opt[i].selected ) {
-  								select = false;
-  								break;
-  							}
-  						}
-  						if ( select ){ this.selected = true; }
-  					}
-  				}
-  			}
-  			
-  			var val = this.getAttribute(&quot;selected&quot;);
-  			return val != &quot;false&quot; &amp;&amp; !!val;
-  		},
-  		set selected(val) { return this.setAttribute(&quot;selected&quot;,val); },
-  
-  		get className() { return this.getAttribute(&quot;class&quot;) || &quot;&quot;; },
-  		set className(val) {
-  			return this.setAttribute(&quot;class&quot;,
-  				val.replace(/(^\s*|\s*$)/g,&quot;&quot;));
-  		},
-  		
-  		get type() { return this.getAttribute(&quot;type&quot;) || &quot;&quot;; },
-  		set type(val) { return this.setAttribute(&quot;type&quot;,val); },
-  
-  		get defaultValue() { return this.getAttribute(&quot;defaultValue&quot;) || &quot;&quot;; },
-  		set defaultValue(val) { return this.setAttribute(&quot;defaultValue&quot;,val); },
-  
-  		get value() { return this.getAttribute(&quot;value&quot;) || &quot;&quot;; },
-  		set value(val) { return this.setAttribute(&quot;value&quot;,val); },
-  		
-  		get src() { return this.getAttribute(&quot;src&quot;) || &quot;&quot;; },
-  		set src(val) { return this.setAttribute(&quot;src&quot;,val); },
-  		
-  		get id() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
-  		set id(val) { return this.setAttribute(&quot;id&quot;,val); },
-  		
-  		getAttribute: function(name){
-  			return $dom.hasAttribute(name) ?
-  				new String( $dom.getAttribute(name) ) :
-  				null;
-  		},
-  		setAttribute: function(name,value){
-  			$dom.setAttribute(name,value);
-  		},
-  		removeAttribute: function(name){
-  			$dom.removeAttribute(name);
-  		},
-  		
-  		get childNodes(){
-  			return new DOMNodeList( $dom.getChildNodes() );
-  		},
-  		get firstChild(){
-  			return makeNode( $dom.getFirstChild() );
-  		},
-  		get lastChild(){
-  			return makeNode( $dom.getLastChild() );
-  		},
-  		appendChild: function(node){
-  		  //Because the dom implementation is private in scope now,
-  		  //we will need to fix these to use some innerHtml etc
-  		  //if required
-  			$dom.appendChild( $nodeImplCache[node.__guid__] );
-  		},
-  		insertBefore: function(node,before){
-  			$dom.insertBefore( $nodeImplCache[node.__guid__], before ? $nodeImplCache[before.__guid__] : before );
-  			
-  			execScripts( node );
-  			
-  			function execScripts( node ) {
-  				if ( node.nodeName == &quot;SCRIPT&quot; ) {
-  					if ( !node.getAttribute(&quot;src&quot;) ) {
-  						eval.call( window, node.textContent );
-  					}
-  				} else {
-  					var scripts = node.getElementsByTagName(&quot;script&quot;);
-  					for ( var i = 0; i &lt; scripts.length; i++ ) {
-  						execScripts( node );
-  					}
-  				}
-  			}
-  		},
-  		removeChild: function(node){
-  			$dom.removeChild( $nodeImplCache[node.__guid__] );
-  		},
-  
-  		getElementsByTagName: function(name){
-  		  // why can't we just do ?: 
-  			//var elems = $dom.getElementsByTagName(name), ret = [];
-  			var elems = $dom.getElementsByTagName(&quot;*&quot;), ret = [];
-  			ret.item = function(i){ return this[i]; };
-  			ret.getLength = function(){ return this.length; };
-  			for ( var i = 0; i &lt; elems.length; i++ ) {
-  				var elem = elems.item(i);
-  				if ( elem.getAttribute(&quot;name&quot;) == name )
-  					ret.push( elem );
-  			}return new DOMNodeList( ret );
-			},
-  		
-  		addEventListener: window.addEventListener,
-  		removeEventListener: window.removeEventListener,
-  		dispatchEvent: window.dispatchEvent,
-  		
-  		click: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;click&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		submit: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;submit&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		focus: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;focus&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		blur: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;blur&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		get contentWindow(){
-  			return this.nodeName == &quot;IFRAME&quot; ? {
-  				document: this.contentDocument
-  			} : null;
-  		},
-  		get contentDocument(){
-  			if ( this.nodeName == &quot;IFRAME&quot; ) {
-  				if ( !this._doc )
-  					this._doc = HTMLtoDOM(&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
-  				return this._doc;
-  			} else { return null; }
-    	},
-  		get __guid__(){return $id;}
-		});
-		
-	  //All this constructor stuff belond in the HTML subclasses
-	  //and even more generally in the HTML specific element
-	  //subclass otherwise its going to become a mess
-  	this.style = {
-  		get opacity(){ return this._opacity; },
-  		set opacity(val){ this._opacity = val + &quot;&quot;; }
-  	};
-		
-		// Load CSS info
-		var styles = (this.getAttribute(&quot;style&quot;) || &quot;&quot;).split(/\s*;\s*/);
-		for ( var i = 0; i &lt; styles.length; i++ ) {
-			var style = styles[i].split(/\s*:\s*/);
-			if ( style.length == 2 )
-				this.style[ style[0] ] = style[1];
-		}
-		
-		if ( this.nodeName == &quot;FORM&quot; ) {
-			this.__defineGetter__(&quot;elements&quot;, function(){
-				return this.getElementsByTagName(&quot;*&quot;);
-			});
-			this.__defineGetter__(&quot;length&quot;, function(){
-				var elems = this.elements;
-				for ( var i = 0; i &lt; elems.length; i++ ) {
-					this[i] = elems[i];
-				}
-				return elems.length;
-			});
-		}
-
-		if ( this.nodeName == &quot;SELECT&quot; ) {
-			this.__defineGetter__(&quot;options&quot;, function(){
-				return this.getElementsByTagName(&quot;option&quot;);
-			});
-		}
-
-		this.defaultValue = this.value;
-		return this;
-	};
-});
-
-$w.__defineGetter__('DOMParser', function(){
-  return function(){
-    return __extend__(this, {
-      parseFromString: function(xmlString){
-        return document.implementation.createDocument().loadXML(xmlString);
-      }
-    });
-  };
-});
-	
-	/*
-*	document.js
-*
-*	DOM Level 2 /DOM level 3 (partial)
-*	
-*	This file adds the document object to the window and allows you
-*	you to set the window.document using an html string or dom object.
-*
-*/
-
-// read only reference to the Document object
-var $document =  new DOMDocument();
-var $implementation =  new DOMImplementation();
-var $async = false;
-
-$w.__defineGetter__(&quot;document&quot;, function(){
-	return __extend__($document, {
-		get async(){ return $async;},
-		set async(async){ $async = async; },
-		get baseURI(){ return $env.location('./'); },
-		get implementation(){ return $implementation; },
-		get URL(){ return $w.location.href;  }
-	});
-});
-
-	
-	/*
-*	html.js
-*
-*	DOM Level 2 HTML
-*//*
 *	xhr.js
 */
+$log(&quot;Initializing Window XMLHttpRequest.&quot;);
 // XMLHttpRequest
 // Originally implemented by Yehuda Katz
 $w.XMLHttpRequest = function(){
@@ -1187,16 +1950,19 @@ XMLHttpRequest.prototype = {
 		
 		function makeRequest(){
 			$env.connection(self, function(){
+			  var responseXML = null;
 				self.__defineGetter__(&quot;responseXML&quot;, function(){
-					return responseXML;
-				});
-				if ( self.responseText.match(/^\s*&lt;/) ) {
-					try {
-						var doc = $w.document.implementation.createDocument();
-						doc._dom = $env.parseXML(responseText);
-						responseXML = doc;
-					} catch(e) { /*TODO: need to flag an error here*/}
-				}
+  				if ( self.responseText.match(/^\s*&lt;/) ) {
+  				  if(responseXML){return responseXML;}
+  				  else{
+    					try {
+    					  $log(&quot;parsing response text into xml document&quot;);
+    						responseXML = $domparser.parseFromString(self.responseText);
+  					    return responseXML;
+    					} catch(e) { return null;/*TODO: need to flag an error here*/}
+  					}
+  				}else{return null;}
+  			});
 			});
 			self.onreadystatechange();
 		}
@@ -1228,15 +1994,14 @@ XMLHttpRequest.prototype = {
 		}return null;
 	},
 	getAllResponseHeaders: function(){
-	  var header;
+	  var header, returnedHeaders = [];
 		if (this.readyState &lt; 3){
 			throw new Error(&quot;INVALID_STATE_ERR&quot;);
 		} else {
-			var returnedHeaders = [];
 			for (header in this.responseHeaders){
 				returnedHeaders.push( header + &quot;: &quot; + this.responseHeaders[header] );
-			}return returnedHeaders.join(&quot;\r\n&quot;);
-		}
+			}
+		}return returnedHeaders.join(&quot;\r\n&quot;);
 	},
 	async: true,
 	readyState: 0,
@@ -1245,147 +2010,17 @@ XMLHttpRequest.prototype = {
 };/*
 *	css.js
 */
-
+$log(&quot;Initializing Window CSS&quot;);
 // returns a CSS2Properties object that represents the style
 // attributes and values used to render the specified element in this
-// window.  Any length values are alwasys expressed in pixel, or
+// window.  Any length values are always expressed in pixel, or
 // absolute values.
 $w.getComputedStyle = function(elt, pseudo_elt){
   //TODO
 };/*
-*	cookie.js
-*   - requires env
-*/
-
-var $cookies = {
-	persistent:{
-		//domain - key on domain name {
-			//path - key on path {
-				//name - key on name {
-					 //value : cookie value
-					 //other cookie properties
-				//}
-			//}
-		//}
-		//expire - provides a timestamp for expiring the cookie
-		//cookie - the cookie!
-	},
-	temporary:{//transient is a reserved word :(
-		//like above
-	}
-};
-
-//Window cookie
-$w.__defineSetter__(&quot;cookie&quot;, function(cookie){
-	var i,name,value,properties = {},attr,attrs = cookie.split(&quot;;&quot;);
-	//for now the strategy is to simply create a json object
-	//and post it to a file in the .cookies.js file.  I hate parsing
-	//dates so I decided not to implement support for 'expires' 
-	//(which is deprecated) and instead focus on the easier 'max-age'
-	//(which succeeds 'expires') 
-	cookie = {};//keyword properties of the cookie
-	for(i=0;i&lt;attrs.length;i++){
-		attr = attrs[i].split(&quot;=&quot;);
-		if(attr.length &gt; 0){
-			name = trim(attr[0]);
-			value = trim(attr[1]);
-			if(name=='max-age'){ 
-				//we'll have to set a timer to check these 
-				//and garbage collect expired cookies
-				cookie[name] = parseInt(value, 10);
-			} else if(name=='domain'){
-				if(domainValid(value)){
-					cookie['domain']=value;
-				}else{
-					cookie['domain']=$w.location.domain;
-				}
-			} else if(name=='path'){
-				//not sure of any special logic for path
-				cookie['path'] = value;
-			} else {
-				//its not a cookie keyword so store it in our array of properties
-				//and we'll serialize individually in a moment
-				properties[name] = value;
-			}
-		}else{
-			if(attr[0] == 'secure'){
-				cookie[attr[0]] = true;
-			}
-		}
-	}
-	if(!cookie['max-age']){
-		//it's a transient cookie so it only lasts as long as 
-		//the window.location remains the same
-		mergeCookie($cookies.temporary, cookie, properties);
-	}else if(cookie['max-age']===0){
-		//delete the cookies
-		//TODO
-	}else{
-		//the cookie is persistent
-		mergeCookie($cookies.persistent, cookie, properties);
-		persistCookies();
-	}
-});
-
-$w.__defineGetter__(&quot;cookie&quot;, function(c){
-	//The cookies that are returned must belong to the same domain
-	//and be at or below the current window.location.path.  Also
-	//we must check to see if the cookie was set to 'secure' in which
-	//case we must check our current location.protocol to make sure it's
-	//https:
-	var allcookies = [], i;
-	//TODO 	
-});
-
-
-
-var domainValid = function(domain){
-	//make sure the domain
-	//TODO 	
-};
-
-var mergeCookie = function(target, cookie, properties){
-	var name, now;
-	if(!target[cookie.domain]){
-		target[cookie.domain] = {};
-	}
-	if(!target[cookie.domain][cookie.path]){
-		target[cookie.domain][cookie.path] = {};
-	}
-	for(name in properties){
-		now = new Date().getTime();
-		target[cookie.domain][cookie.path][name] = {
-			value:properties[name],
-			&quot;@env:secure&quot;:cookie.secure,
-			&quot;@env:max-age&quot;:cookie['max-age'],
-			&quot;@env:date-created&quot;:now,
-			&quot;@env:expiration&quot;:now + cookie['max-age']
-		};
-	}
-};
-
-var persistCookies = function(){
-	//TODO
-	//I think it should be done via $env so it can be customized
-};
-
-var loadCookies = function(){
-	//TODO
-	//should also be configurable via $env	
-};
-
-//We simply use the default ajax get to load the .cookies.js file
-//if it doesn't exist we create it with a post.  Cookies are maintained
-//in memory, but serialized with each set.
-try{
-	//TODO - load cookies
-	loadCookies();
-}catch(e){
-	//TODO - fail gracefully
-}	
-	/*
 *	screen.js
 */
+$log(&quot;Initializing Window Screen.&quot;);
 
 var $availHeight  = 600,
     $availWidth   = 800,
@@ -1431,14 +2066,9 @@ $w.scrollBy = function(dx, dy){
 $w.scrollTo = function(x,y){
   //TODO
 };/*
-*	uievent.js
-*/
-
-var $onblur,
-    $onfocus,
-    $onresize;/*
 *	dialog.js
 */
+$log(&quot;Initializing Window Dialogs.&quot;);
 $w.alert = function(message){
  //TODO 
 };
@@ -1450,312 +2080,33 @@ $w.confirm = function(question){
 $w.prompt = function(message, defaultMsg){
   //TODO
 };/*
-*	env.parser.js
+*	document.js
+*
+*	DOM Level 2 /DOM level 3 (partial)
+*	
+*	This file adds the document object to the window and allows you
+*	you to set the window.document using an html string or dom object.
+*
 */
-/*
- * HTML Parser By John Resig (ejohn.org)
- * Original code by Erik Arvidsson, Mozilla Public License
- * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
- *
- * // Use like so:
- * HTMLParser(htmlString, {
- *     start: function(tag, attrs, unary) {},
- *     end: function(tag) {},
- *     chars: function(text) {},
- *     comment: function(text) {}
- * });
- *
- * // or to get an XML string:
- * HTMLtoXML(htmlString);
- *
- * // or to get an XML DOM Document
- * HTMLtoDOM(htmlString);
- *
- * // or to inject into an existing document/DOM node
- * HTMLtoDOM(htmlString, document);
- * HTMLtoDOM(htmlString, document.body);
- *
- */
-
-(function(){
-
-	// Regular Expressions for parsing tags and attributes
-	var startTag = /^&lt;([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:&quot;[^&quot;]*&quot;)|(?:'[^']*')|[^&gt;\s]+))?)*)\s*(\/?)&gt;/,
-		endTag = /^&lt;\/([\w:-]+)[^&gt;]*&gt;/,
-		attr = /([\w:-]+)(?:\s*=\s*(?:(?:&quot;((?:\\.|[^&quot;])*)&quot;)|(?:'((?:\\.|[^'])*)')|([^&gt;\s]+)))?/g;
-		
-	// Empty Elements - HTML 4.01
-	var empty = makeMap(&quot;area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed&quot;);
-
-	// Block Elements - HTML 4.01
-	var block = makeMap(&quot;address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul&quot;);
-
-	// Inline Elements - HTML 4.01
-	var inline = makeMap(&quot;a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var&quot;);
-
-	// Elements that you can, intentionally, leave open
-	// (and which close themselves)
-	var closeSelf = makeMap(&quot;colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr&quot;);
-
-	// Attributes that have their values filled in disabled=&quot;disabled&quot;
-	var fillAttrs = makeMap(&quot;checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected&quot;);
-
-	// Special Elements (can contain anything)
-	var special = makeMap(&quot;script,style&quot;);
-
-	var HTMLParser = this.HTMLParser = function( html, handler ) {
-		var index, chars, match, stack = [], last = html;
-		stack.last = function(){
-			return this[ this.length - 1 ];
-		};
-
-		while ( html ) {
-			chars = true;
-
-			// Make sure we're not in a script or style element
-			if ( !stack.last() || !special[ stack.last() ] ) {
-
-				// Comment
-				if ( html.indexOf(&quot;&lt;!--&quot;) === 0 ) {
-					index = html.indexOf(&quot;--&gt;&quot;);
-	
-					if ( index &gt;= 0 ) {
-						if ( handler.comment )
-							handler.comment( html.substring( 4, index ) );
-						html = html.substring( index + 3 );
-						chars = false;
-					}
-	
-				// end tag
-				} else if ( html.indexOf(&quot;&lt;/&quot;) === 0 ) {
-					match = html.match( endTag );
-	
-					if ( match ) {
-						html = html.substring( match[0].length );
-						match[0].replace( endTag, parseEndTag );
-						chars = false;
-					}
-	
-				// start tag
-				} else if ( html.indexOf(&quot;&lt;&quot;) === 0 ) {
-					match = html.match( startTag );
-	
-					if ( match ) {
-						html = html.substring( match[0].length );
-						match[0].replace( startTag, parseStartTag );
-						chars = false;
-					}
-				}
 
-				if ( chars ) {
-					index = html.indexOf(&quot;&lt;&quot;);
-					var text = index &lt; 0 ? html : html.substring( 0, index );
-					html = index &lt; 0 ? &quot;&quot; : html.substring( index );
-					if ( handler.chars ){handler.chars( text );}
-				}
-			} else {
-				html = html.replace(new RegExp(&quot;(.*)&lt;\/&quot; + stack.last() + &quot;[^&gt;]*&gt;&quot;), function(all, text){
-					text = text.replace(/&lt;!--(.*?)--&gt;/g, &quot;$1&quot;).
-						replace(/&lt;!\[CDATA\[(.*?)]]&gt;/g, &quot;$1&quot;);
-					if ( handler.chars ){handler.chars( text );}
-					return &quot;&quot;;
-				});
-				parseEndTag( &quot;&quot;, stack.last() );
-			}
-			if ( html == last ){throw &quot;Parse Error: &quot; + html;}
-			last = html;
-		}
-		
-		// Clean up any remaining tags
-		parseEndTag();
-
-		function parseStartTag( tag, tagName, rest, unary ) {
-			if ( block[ tagName ] ) {
-				while ( stack.last() &amp;&amp; inline[ stack.last() ] ) {
-					parseEndTag( &quot;&quot;, stack.last() );
-				}
-			}
-
-			if ( closeSelf[ tagName ] &amp;&amp; stack.last() == tagName ) {
-				parseEndTag( &quot;&quot;, tagName );
-			}
-
-			unary = empty[ tagName ] || !!unary;
+// read only reference to the Document object
 
-			if ( !unary )
-				stack.push( tagName );
-			
-			if ( handler.start ) {
-				var attrs = [];
-	
-				rest.replace(attr, function(match, name) {
-					var value = arguments[2] ? arguments[2] :
-						arguments[3] ? arguments[3] :
-						arguments[4] ? arguments[4] :
-						fillAttrs[name] ? name : &quot;&quot;;
-					
-					attrs.push({
-						name: name,
-						value: value,
-						escaped: value.replace(/(^|[^\\])&quot;/g, '$1\\\&quot;') //&quot;
-					});
-				});
-	
-				if ( handler.start )
-					handler.start( tagName, attrs, unary );
-			}
-		}
+$log(&quot;Initializing window.document.&quot;);
+var $document =  new HTMLDocument();
+var $async = false;
 
-		function parseEndTag( tag, tagName ) {
-		  var pos;
-			// If no tag name is provided, clean shop
-			if ( !tagName ){
-				pos = 0;
-			}else{
-			// Find the closest opened tag of the same type
-				for ( pos = stack.length - 1; pos &gt;= 0; pos-- ){
-					if ( stack[ pos ] == tagName ){ break; }
-				}
-  		}
-			if ( pos &gt;= 0 ) {
-				// Close all the open elements, up the stack
-				for ( var i = stack.length - 1; i &gt;= pos; i-- ){
-					if ( handler.end ){
-						handler.end( stack[ i ] );
-  				}
-				}
-				// Remove the open elements from the stack
-				stack.length = pos;
-			}
-		}
-	};
-	
-	this.HTMLtoXML = function( html ) {
-		var results = &quot;&quot;;
-		
-		HTMLParser(html, {
-			start: function( tag, attrs, unary ) {
-				results += &quot;&lt;&quot; + tag;
-		
-				for ( var i = 0; i &lt; attrs.length; i++ )
-					results += &quot; &quot; + attrs[i].name + '=&quot;' + attrs[i].escaped + '&quot;';
-		
-				results += (unary ? &quot;/&quot; : &quot;&quot;) + &quot;&gt;&quot;;
-			},
-			end: function( tag ) {
-				results += &quot;&lt;/&quot; + tag + &quot;&gt;&quot;;
-			},
-			chars: function( text ) {
-				results += text;
-			},
-			comment: function( text ) {
-				results += &quot;&lt;!--&quot; + text + &quot;--&gt;&quot;;
-			}
-		});
-		
-		return results;
-	};
-	
-	this.HTMLtoDOM = function( html, doc ) {
-		// There can be only one of these elements
-		var one = makeMap(&quot;html,head,body,title&quot;);
-		
-		// Enforce a structure for the document
-		var structure = {
-			link: &quot;head&quot;,
-			base: &quot;head&quot;
-		};
-	
-		if ( !doc ) {
-			if ( typeof DOMDocument != &quot;undefined&quot; ){
-				doc = new DOMDocument();
-			}else if ( typeof document != &quot;undefined&quot; &amp;&amp; document.implementation &amp;&amp; document.implementation.createDocument ){
-				doc = document.implementation.createDocument(&quot;&quot;, &quot;&quot;, null);
-			}else if ( typeof ActiveX != &quot;undefined&quot; ){
-				doc = new ActiveXObject(&quot;Msxml.DOMDocument&quot;);
-			}
-		} else {
-			doc = doc.ownerDocument ||
-				doc.getOwnerDocument &amp;&amp; doc.getOwnerDocument() ||
-				doc;
-		}
-		
-		var elems = [],
-			documentElement = doc.documentElement || doc.getDocumentElement &amp;&amp; doc.getDocumentElement();
-				
-		// If we're dealing with an empty document then we
-		// need to pre-populate it with the HTML document structure
-		if ( !documentElement &amp;&amp; doc.createElement ) (function(){
-			var html = doc.createElement(&quot;html&quot;);
-			var head = doc.createElement(&quot;head&quot;);
-			head.appendChild( doc.createElement(&quot;title&quot;) );
-			html.appendChild( head );
-			html.appendChild( doc.createElement(&quot;body&quot;) );
-			doc.appendChild( html );
-		})();
-		
-		// Find all the unique elements
-		if ( doc.getElementsByTagName ){
-			for ( var i in one ){
-			   one[ i ] = doc.getElementsByTagName( i )[0];
-		  }
-		}
-		
-		// If we're working with a document, inject contents into
-		// the body element
-		var curParentNode = one.body;
-		
-		HTMLParser( html, {
-			start: function( tagName, attrs, unary ) {
-				// If it's a pre-built element, then we can ignore
-				// its construction
-				if ( one[ tagName ] ) {
-					curParentNode = one[ tagName ];
-					return;
-				}
-			
-				var elem = doc.createElement( tagName );
-				
-				for ( var attr in attrs )
-					elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
-				
-				if ( structure[ tagName ] &amp;&amp; typeof one[ structure[ tagName ] ] != &quot;boolean&quot; )
-					one[ structure[ tagName ] ].appendChild( elem );
-				
-				else if ( curParentNode &amp;&amp; curParentNode.appendChild )
-					curParentNode.appendChild( elem );
-					
-				if ( !unary ) {
-					elems.push( elem );
-					curParentNode = elem;
-				}
-			},
-			end: function( tag ) {
-				elems.length -= 1;
-				
-				// Init the new parentNode
-				curParentNode = elems[ elems.length - 1 ];
-			},
-			chars: function( text ) {
-				curParentNode.appendChild( doc.createTextNode( text ) );
-			},
-			comment: function( text ) {
-				// create comment node
-			}
-		});
-		
-		return doc;
-	};
+$log(&quot;Adding window.document features.&quot;);
+$w.__defineGetter__(&quot;document&quot;, function(){
+	return __extend__($document, {
+		get async(){ return $async;},
+		set async(async){ $async = async; },
+		get baseURI(){ return $env.location('./'); },
+		get URL(){ return $w.location.href;  }
+	});
+});
 
-	function makeMap(str){
-		var obj = {}, items = str.split(&quot;,&quot;);
-		for ( var i = 0; i &lt; items.length; i++ )
-			obj[ items[i] ] = true;
-		return obj;
-	};
 	
-})();
-/*
+	/*
 *	outro.js
 */
 </diff>
      <filename>dist/env.js</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,12 @@
 var __env__ = {};
 (function($env){
 	
+  $env.debug = function(){};
+  
   $env.log = function(){};
   //uncomment this if you want to get some internal log statementes
-  //$env.log = print;
+  $env.log = print;
+  $env.log(&quot;Initializing Rhino Platform Env&quot;);
   
   $env.error = function(msg, e){
     print(&quot;ERROR! : &quot; + msg);
@@ -15,7 +18,7 @@ var __env__ = {};
   
   $env.hashCode = function(obj){
     return obj?obj.hashCode().toString():null;
-  }
+  };
 	//For Java the window.location object is a java.net.URL
 	$env.location = function(path, base){
 	  var protocol = new RegExp('(^\\w*\:)');
@@ -134,15 +137,33 @@ var __env__ = {};
 		}
 	};
 	
+	var htmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+	htmlDocBuilder.setNamespaceAware(false);
+	htmlDocBuilder.setValidating(false);
+	
+	$env.parseHTML = function(htmlstring){
+		return htmlDocBuilder.newDocumentBuilder().parse(
+				  new java.io.ByteArrayInputStream(
+						(new java.lang.String(htmlstring)).getBytes(&quot;UTF8&quot;)));
+	};
+	
+	var xmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+	xmlDocBuilder.setNamespaceAware(true);
+	xmlDocBuilder.setValidating(true);
+	
 	$env.parseXML = function(xmlstring){
-		return Packages.javax.xml.parsers.
-			DocumentBuilderFactory.newInstance().
-				newDocumentBuilder().parse(
+		return xmlDocBuilder.newDocumentBuilder().parse(
 				  new java.io.ByteArrayInputStream(
 						(new java.lang.String(xmlstring)).getBytes(&quot;UTF8&quot;)));
 	};
 	
-
+	
+  $env.xpath = function(expression, doc){
+    return Packages.javax.xml.xpath.
+      XPathFactory.newInstance().newXPath().
+        evaluate(expression, doc, javax.xml.xpath.XPathConstants.NODESET);
+  };
+	
   $env.os_name        = java.lang.System.getProperty(&quot;os.name&quot;); 
   $env.os_arch        = java.lang.System.getProperty(&quot;os.arch&quot;); 
   $env.os_version     = java.lang.System.getProperty(&quot;os.version&quot;); 
@@ -157,14 +178,18 @@ var __env__ = {};
  
 
 // The Window Object
-var window = this;
+var __this__ = this;
+this.__defineGetter__('window', function(){
+  return __this__;
+});
 (function($w, $env){/*
 *	window.js
 *   - this file will be wrapped in a closure providing the window object as $w
 */
 // a logger or empty function available to all modules.
-var $log = $env.log;
-var $error = $env.error;
+var $log = $env.log,
+    $error = $env.error,
+    $debug = $env.debug;
 //The version of this application
 var $version = &quot;0.1&quot;;
 //This should be hooked to git or svn or whatever
@@ -246,6 +271,7 @@ var $top;
 // the window property is identical to the self property.
 var $window = $w;
 
+$log(&quot;Initializing Window.&quot;);
 __extend__($w,{
   get closed(){return $closed;},
   get defaultStatus(){return $defaultStatus;},
@@ -267,7 +293,7 @@ __extend__($w,{
   get pageXOffest(){return $pageXOffset;},
   get pageYOffset(){return $pageYOffset;},
   get parent(){return $parent;},
-  get screen(){return $w.screen;},
+  //get screen(){return $screen;}, see screen.js
   get screenLeft(){return $screenLeft;},
   get screenTop(){return $screenTop;},
   get screenX(){return $screenX;},
@@ -354,114 +380,1504 @@ function __extend__(a,b) {
 function trim( str ){
  var start = -1,
   end = str.length;
-/*jsl:ignore*/
+ /*jsl:ignore*/
  while( str.charCodeAt(--end) &lt; 33 );
  while( str.charCodeAt(++start) &lt; 33 );
-/*jsl:end*/
+ /*jsl:end*/
  return str.slice( start, end + 1 );
-};/*
-*	location.js
-*   - requires env
+};
+
+//from jQuery
+function setArray( target, array ) {
+	// Resetting the length to 0, then using the native Array push
+	// is a super-fast way to populate an object with array-like properties
+	target.length = 0;
+	Array.prototype.push.apply( target, array );
+};
+/*
+*	dom.js
+*
+*	DOM Level 2 /DOM level 3 (partial)
+*	
+*	The Document Object is now private in scope but you can create new
+*	Documents via document.implementation.createDocument which
+*	now also exposes the DOM Level 3 function 'load(uri)'.
+*
+*/
+	// Helper method for generating the right
+	// DOM objects based upon the type
+	
+	var $nodeCache = {};//caches a reference to our implementation of the node
+	var $nodeImplCache = {};//reverse look-up : caches a reference to the env supplied implementors dom node
+	var $guid = (-1)*Math.pow(2,31);
+  function createGUID(){
+    /*jsl:ignore*/
+    return String(++$guid);
+    /*jsl:end*/
+  };
+	
+  // A handy utility method to convert the env supplied DOM Level 2 implementation
+  // into our window externalized implementaion.
+  // Its kept here since Node is the base class of all the DOM window level classes
+	function makeNode(node, doc ){
+		if ( node !== null &amp;&amp; node !== undefined) {
+			if ( !$nodeCache[ $env.hashCode(node) ] ){
+        if( (document.__html__)&amp;&amp;(node.getNodeType()===$w.Node.ELEMENT_NODE)){
+          //$log(&quot;Caching HTML Node: &quot; + node);
+          makeHTMLElement(node.getTagName().toUpperCase(), node);
+        }else if( (document.__html__)&amp;&amp;(node.getNodeType()===$w.Node.DOCUMENT_NODE)){
+          //$log(&quot;Caching HTML Document: &quot; + node);
+          cacheNode( node, HTMLDocument );
+        }else{
+          $debug(&quot;Caching Node: &quot; + node);
+          if(     node.getNodeType() === $w.Node.ELEMENT_NODE){cacheNode(node, Element);}
+          else if(node.getNodeType() === $w.Node.ATTRIBUTE_NODE){cacheNode(node, Attr);}
+          else if(node.getNodeType() === $w.Node.TEXT_NODE){cacheNode(node, Text);}
+          else if(node.getNodeType() === $w.Node.CDATA_SECTION_NODE){cacheNode(node, CDATASection);}
+          else if(node.getNodeType() === $w.Node.PROCESSING_INSTRUCTION_NODE){cacheNode(node, ProcessingInstruction);}
+          else if(node.getNodeType() === $w.Node.COMMENT_NODE){cacheNode(node, Comment);}
+          else if(node.getNodeType() === $w.Node.DOCUMENT_NODE){cacheNode( node, Document );}
+          else if(node.getNodeType() === $w.Node.DOCUMENT_TYPE_NODE){cacheNode(node, DocumentType);}
+          else if(node.getNodeType() === $w.Node.DOCUMENT_FRAGMENT_NODE){cacheNode(node, DocumentFragment);}
+          else{cacheNode(node, Node);}
+        }
+			}
+			//$log(&quot;Retreived Node from cache: &quot; + $env.hashCode(node ) + &quot; =&gt; &quot;+ $nodeCache[$env.hashCode(node)]);
+			return $nodeCache[$env.hashCode(node)];
+		} else{ 
+		  //$log(&quot;makeNode =&gt; Node is null!&quot;);
+		  return null;
+	  }
+	};
+	
+
+  function cacheNode(node, constructor){
+    if(node &amp;&amp; constructor){
+      var cachednode = new constructor( node );
+      $debug(&quot;Caching node &quot;+ cachednode);
+      $nodeCache[$env.hashCode(node)] = cachednode;
+      $debug(&quot;Reversing lookup for node &quot;+ cachednode.__$__);
+      $nodeImplCache[cachednode.__$__] = node;
+    }
+  };$log(&quot;Defining Document&quot;);
+/*
+* Document - DOM Level 2
+*  The Document object is not directly 
+*/
+$w.__defineGetter__('Document', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Document = function(node){
+  var $dom = node, 
+      $id = createGUID(), 
+      $url; 
+  $debug(&quot;Document &quot; +$id);
+  return __extend__(this,{
+		get defaultView(){ //TODO: why isnt this just 'return $w;'?
+			return { getComputedStyle: function(elem){
+				return { getPropertyValue: function(prop){
+					prop = prop.replace(/\-(\w)/g,function(m,c){ return c.toUpperCase(); });
+					var val = elem.style[prop];
+					if ( prop === &quot;opacity&quot; &amp;&amp; val === &quot;&quot; ){ val = &quot;1&quot;; }return val;
+				}};
+			}};
+		},
+		get doctype(){return makeNode( $dom.getDoctype() );},
+		get documentElement(){ return makeNode( $dom.getDocumentElement() ); },
+	  get implementation(){ return $implementation; },
+		get nodeName() { return &quot;#document&quot;; },
+	  get styleSheets(){ return [];/*TODO*/ },
+		addEventListener        : $w.addEventListener,
+	  attachEvent             : $w.addEventListener,/*IE only subject to random, frustrating, obscure deprecation*/
+	  createAttribute         : function(name){return makeNode( $dom.createAttribute(name) );},
+	  createAttributeNS       : function(nsuri, qname){return makeNode($dom.createAttribute(nsuri, qname) );},
+	  createCDATASection      : function(data){return makeNode( $dom.createCDATASection(data) );},
+	  createComment           : function(data){return makeNode( $dom.createComment(data) );},
+	  createDocumentFragment  : function(){return $dom.createDocumentFragment();},
+	  createElement           : function(tagname){ return makeNode( $dom.createElement(tagname) );},
+	  createElementNS         : function(nsuri, qname){ return makeNode( $dom.createElementNS(nsuri, qname) );},
+		createEvent             : function(eventType){ 
+		  var event;
+		  if(eventType === &quot;UIEvents&quot;){ event = new UIEvent();}
+		  else if(eventType === &quot;MouseEvents&quot;){ event = new MouseEvent();}
+		  else{ event = new Event(); } 
+		  return event;
+	  },
+	  createExpression        : function(xpath, nsuriMap){ return null;/*TODO*/},
+	  createProcessingInstruction: function(target,data){ return makeNode( $dom.createProcessingInstruction(target, data) );},
+	  createTextNode          : function(data){ return makeNode( $dom.createTextNode(data) );},
+	  detachEvent             : window.detachEvent,/*IE only subject to random, frustrating, obscure deprecation*/
+		dispatchEvent           : window.dispatchEvent,
+	  evaluate                : function(xpath, context, nsuriMap, resulttype, result){ 
+		  $log(&quot;document.evaluate(&quot;+xpath+&quot;)&quot;);
+		  var nodelist = new NodeList($env.xpath(xpath, context?context:$dom));
+		  $log(&quot;length :=&gt; &quot;+nodelist.length);
+	    return nodelist;
+    },
+		getElementById          : function(id){
+      $debug(&quot;document.getElementById( &quot;+id+&quot; )&quot;);
+      var elem = makeNode( $dom.getElementById(id) );
+			return elem;
+		},
+		getElementsByTagName    : function(name){ 
+		  $debug(&quot;document.getElementsByTagName(&quot;+name+&quot;)&quot;);
+			return new NodeList( $dom.getElementsByTagName(name) );
+	  },
+		getElementsByTagNameNS  : function(nsuri,qname){ 
+		  $debug(&quot;document.getElementsByTagNameNS(&quot;+nsuri+&quot;, &quot;+qname+&quot;)&quot;);
+		  return  new NodeList( $dom.getElementsByTagNameNS( nsuri,qname ) );
+	  },
+		importNode              : function(node, deep){
+		  return makeNode($dom.importNode($nodeImplCache[node.__$__], deep));
+	  },
+		adoptNode              : function(node){
+		  return makeNode($dom.adoptNode($nodeImplCache[node.__$__]));
+	  },
+		load: function(url){
+		  $log(&quot;Loading url into DOM Document: &quot;+ url + &quot; - (Asynch? &quot;+$w.document.async+&quot;)&quot;);
+			var _this = this;
+			var xhr = new XMLHttpRequest();
+			xhr.open(&quot;GET&quot;, url, $w.document.async);
+			xhr.onreadystatechange = function(){
+			  try{
+				  _this.loadXML(xhr.responseText);
+			  }catch(e){
+			    $error(&quot;Error Parsing XML - &quot;,e);
+          _this.loadXML(
+            &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&quot;+
+              &quot;&lt;h1&gt;Parse Error&lt;/h1&gt;&quot;+
+              &quot;&lt;p&gt;&quot;+e.toString()+&quot;&lt;/p&gt;&quot;+  
+            &quot;&lt;/body&gt;&lt;/html&gt;&quot;);
+		    }
+			  $url = url;
+				$log(&quot;Sucessfully loaded document.&quot;);
+				var event = document.createEvent();
+				event.initEvent(&quot;load&quot;);
+				$w.dispatchEvent( event );
+			};
+			xhr.send();
+		},
+		//This is actually IE specific but still convenient
+		loadXML                 : function(xmlString){ 
+		  $debug(&quot;Parsing document into internal dom&quot;);
+		  $dom = $env.parseHTML(xmlString);
+		  $nodeCache[$env.hashCode($dom)] = this;
+		  $nodeImplCache[$id] = $dom;
+		  $url = $url?$url:xmlString;
+		  $debug(&quot;Finished Parsing Document (&quot;+$id+&quot;), Internal DOM is set. =&gt; &quot; + $dom);
+		  return this; 
+	  },
+	  normalizeDocument: function(){
+	    $log(&quot;Normalizing Document&quot;);
+	    $dom.normalizeDocument();
+	    $log(&quot;Finished Normalizing Document&quot;);
+    },
+	  get xml(){return this.doctype.xml + &quot;\n&quot; +this.documentElement.xml;},
+		removeEventListener     : window.removeEventListener,
+		toString: function(){ return &quot;Document&quot; +  (typeof $url == &quot;string&quot; ? &quot;: &quot; + $url : &quot;&quot;); },
+		get __$__(){return $id;}
+  });
+};$log(&quot;Defining Attr&quot;);
+/*
+* Attr - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Attr&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Attr = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Attr &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get name(){return String($dom.getName()); },
+    get ownerElement(){ return makeNode( $dom.getOwnerElement() );},
+    get specified(){ return makeNode( $dom.getSpecified() );},
+    get value(){return String($dom.getValue()); },
+    set value(value){return $dom.setValue(value); },
+    get xml(){return this.nodeName + &quot;='&quot; + this.nodeValue + &quot;' &quot;;}
+  });
+};$log(&quot;Defining CDATASection&quot;);
+/*
+* CDATASection - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CDATASection&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CDATASection = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;CDATASection &quot;+$id);
+  __extend__(this, new Text($dom, $id));
+  return __extend__(this,{
+    get xml(){return &quot;&lt;![CDATA[&quot; + this.nodeValue + &quot;]]&gt;&quot;;}
+  });
+};
+$debug(&quot;Defining CharacterData&quot;);
+/*
+* CharacterData - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CharacterData&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CharacterData = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;CharacterData &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get data(){return $dom.getData();},
+    set data(data){return $dom.setData(data);},
+    get length(){return $dom.getLength();},
+    appendData: function(arg){return $dom.appendData(arg);},
+    deleteData: function(offset, count){ return $dom.deleteData(offset, count);},
+    insertData: function(offset, arg){return $dom.insertData(offset, arg);},
+    replaceData: function(offset, count, arg){return $dom.replaceData(offset, count, arg);},
+    substringData: function(offset, count){return $dom.substringData(offset, count);}
+  });
+};$log(&quot;Defining Comment&quot;);
+/* 
+* Comment - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Comment&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Comment = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Comment &quot;+$id);
+  __extend__(this, new CharacterData($dom, $id));
+  return __extend__(this,{
+    get xml(){return &quot;&lt;!-- &quot; + this.nodeValue + &quot; --&gt;&quot;;}
+  });
+};
+
+	$log(&quot;Defining DocumentType&quot;);
+;/*
+* DocumentType - DOM Level 2
+*/
+$w.__defineGetter__('DocumentType', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var DocumentType = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;DocumentType &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get internalSubset(){return $dom.getInternalSubset();},
+    get name(){return $dom.getName();},
+    get publicId(){return $dom.getPublicId();},
+    get systemId(){return $dom.getSystemId();},
+    get xml(){return '&lt;!DOCTYPE ' +this.name+ ' PUBLIC &quot;'+this.publicId+'&quot; &quot;'+this.systemId+'&quot;&gt;';}
+  });
+};
+
+var __DocumentType__ = function(doctype){
+  $domparser.parseString('&lt;!DOCTYPE ' +doctype.name||''+ 
+    ' PUBLIC &quot;'+doctype.publicId||''+' '+'&quot;'+
+    doctype.systemId||''+'&quot;&gt;&lt;asdf&gt;&lt;/asdf&gt;').doctype;
+};$log(&quot;Defining Element&quot;);
+/*
+* Element - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Element&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Element = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  
+  $debug(&quot;Element &quot;+$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+  	get tagName(){ return $dom.getTagName(); },
+  	get attributes(){
+  	  //Simple way to emulate NamedNodeMap which is only
+  	  //ever used here
+  		var attrs = new NodeList($dom.getAttributes());
+  		if(!attrs||(attrs.length === undefined)){setArray(attrs,[]);}
+  		for ( var i = 0; i &lt; attrs.length; i++ ){
+  		  attrs[attrs[i].nodeName] = attrs[i];
+  		}return attrs;
+  	},
+  	addEventListener: window.addEventListener,
+  	removeEventListener: window.removeEventListener,
+  	dispatchEvent: window.dispatchEvent,
+  	getAttribute: function(name){ return String($dom.getAttribute(name));},
+  	getAttributeNode: function(name){ return makeNode( $dom.getAttributeNode(name) ); },
+  	getAttributeNodeNS: function(nsuri,localname){ return makeNode( $dom.getAttributeNodeNS(nsuri,localname) ); },
+  	getElementsByTagName: function(name){ 
+  	  //$debug(&quot;element.getElementsByTagName(&quot;+name+&quot;)&quot;);
+  	  return new NodeList($dom.getElementsByTagName(name));
+	  },
+  	getElementsByTagNameNS: function(nsuri, localname){ return new NodeList( $dom.getElementsByTagNameNS(nsuri, localname) );},
+  	hasAttribute: function(name){return $dom.hasAttribute(name);},
+  	hasAttributeNS: function(nsuri,localname){return $dom.hasAttributeNS(nsuri,localname);},
+  	removeAttribute: function(name){ $dom.removeAttribute(name); },
+  	removeAttributeNode: function(node){ return makeNode($dom.removeAttributeNode($nodeImplCache[node.__$__])); },
+  	removeAttributeNS: function(nsuri,localname){ $dom.removeAttributeNS(nsuri, localname); },
+  	setAttribute: function(name,value){
+  	  $dom.setAttribute(name,value);
+  	  if(name === 'id' &amp;&amp; this.ownerDocument.__html__){this.setIdAttribute(name,true);} 
+	  },
+  	setIdAttribute: function(name,bool){ $dom.setIdAttribute(name,bool); },
+  	setAttributeNode: function(node){ return makeNode($dom.setAttributeNode($nodeImplCache[node.__$__])); },
+  	setAttributeNodeNS: function(node){ return makeNode($dom.setAttributeNodeNS($nodeImplCache[node.__$__])); },
+  	setAttributeNS: function(nsuri,qname,value){ $dom.setAttributeNS(nsuri,qname,value); },
+  	toString: function(){ return &quot;&lt;&quot; + this.tagName + (this.id ? &quot;#&quot; + this.id : &quot;&quot; ) + &quot;&gt;&quot;; },
+  	get xml(){
+			var ret = &quot;&lt;&quot; + this.tagName, attrs = this.attributes;
+			for ( var i = 0; i&lt; attrs.length;i++ ){ ret += &quot; &quot; + attrs[i].xml; }
+			if ( this.childNodes.length || this.nodeName == &quot;SCRIPT&quot; ){
+			  ret += &quot;&gt;&quot; + this.childNodes.xml + &quot;&lt;/&quot; + this.tagName + &quot;&gt;&quot;;
+			}else{
+				ret += &quot;/&gt;&quot;;
+			} return ret;
+		}
+  });
+};
+
+	/*
+* DOMException - DOM Level 2
+*/	
+
+// For now I'm passing on this since DOMExceptions can simply flow 
+// through the underlying env supplied dom implementation
+
+$log(&quot;Defining DocumentFragment&quot;);
+/* 
+* DocumentFragment - DOM Level 2
+*/
+$w.__defineGetter__(&quot;DocumentFragment&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var DocumentFragment = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;DocumentFragment &quot; +$id);
+  __extend__(this, new Node($dom, $id));
+  // Nothing to extend as far as I know.  This and several other
+  // classes need to be moved off of window as the constructor, though available
+  // (by this I mean it wont throw a 'no such method') are not meant
+  // to be used directly. Instead the document.create* is meant to be used.
+  // Not perfectly sure how to implement this.  perhaps we have to examine
+  // the context inside the constructor
+};
+//DOMImplementation
+$log(&quot;Defining DOMImplementation&quot;);
+$w.__defineGetter__(&quot;DOMImplementation&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var DOMImplementation = function(){
+	return {
+		hasFeature: function(feature, version){
+			//TODO
+			return false;
+		},
+		createDocumentType: function(qname, publicid, systemid){
+			return new __DocumentType__({
+			  name:qname, publicId:publicid, systemId:systemid
+			});
+		},
+		createDocument:function(nsuri, qname, doctype){
+		  //TODO - this currently returns an empty doc
+		  //but needs to handle the args
+			return new HTMLDocument();
+		},
+		getFeature:function(feature, version){
+			//TODO or TODONT?
+		}
+	};
+};
+
+
+$log(&quot;Initializing document.implementation&quot;);
+var $implementation =  new DOMImplementation();$log(&quot;Defining ProcessingInstruction&quot;);
+/*
+* ProcessingInstruction - DOM Level 2
+*/
+$w.__defineGetter__('ProcessingInstruction', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var ProcessingInstruction = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;ProcessingInstruction &quot; +$id);
+  __extend__(this, new Node($dom, $id));
+  return __extend__(this, {
+    get data(){return $dom.getData();},
+    set data(data){return $dom.setData(data);},
+    get target(){return $dom.getTarget();}
+  });
+};$log(&quot;Defining Node&quot;);
+/*
+* Node - DOM Level 2
+*/	
+$w.__defineGetter__('Node', function(){
+  return __extend__(function(){
+        throw new Error(&quot;Object cannot be created in this context&quot;);
+      } , {
+  		ELEMENT_NODE    :1,
+  		ATTRIBUTE_NODE  :2,
+  		TEXT_NODE       :3,
+  		CDATA_SECTION_NODE: 4,
+  		PROCESSING_INSTRUCTION_NODE: 7,
+  		COMMENT_NODE: 8,
+  		DOCUMENT_NODE: 9,
+  		DOCUMENT_TYPE_NODE: 10,
+  		DOCUMENT_FRAGMENT_NODE: 11
+	});
+});
+
+var Node = function(node, id){
+  __extend__(this, {
+  		ELEMENT_NODE    :1,
+  		ATTRIBUTE_NODE  :2,
+  		TEXT_NODE       :3,
+  		CDATA_SECTION_NODE: 4,
+  		PROCESSING_INSTRUCTION_NODE: 7,
+  		COMMENT_NODE: 8,
+  		DOCUMENT_NODE: 9,
+  		DOCUMENT_TYPE_NODE: 10,
+  		DOCUMENT_FRAGMENT_NODE: 11
+	});
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Node  &quot;+$id);
+  return __extend__(this, {
+    get attributes(){ return null;},
+		get childNodes(){ return new NodeList( $dom.getChildNodes() ); },
+		get firstChild(){ return makeNode( $dom.getFirstChild() ); },
+		get lastChild(){ return makeNode( $dom.getLastChild() ); },
+		get localName(){ return  String($dom.getLocalName()); },
+		get namespaceURI(){ return  String($dom.getNamespaceURI()); },
+		get nextSibling() { return makeNode( $dom.getNextSibling() ); },
+		get nodeName() {return String($dom.getNodeName()); },
+		get nodeType(){ return Number($dom.getNodeType()); },
+		get nodeValue(){ return $dom.getNodeValue(); },
+		set nodeValue(value){ return $dom.setNodeValue(value); },
+		get ownerDocument(){ return makeNode(  $dom.getOwnerDocument() ); },
+		get parentNode() { return makeNode( $dom.getParentNode() ); },
+		get prefix() { return $dom.getPrefix(); },
+		set prefix(prefix) { return $dom.setPrefix(prefix); },
+		get previousSibling() { return makeNode( $dom.getPreviousSibling() ); },
+		get xml() { return this.nodeValue; },
+		appendChild: function(node){ $dom.appendChild( $nodeImplCache[node.__$__] ); },
+		cloneNode: function(deep){ return makeNode( $dom.cloneNode(deep) ); },
+		hasAttributes: function(){ return $dom.hasAttributes(); },
+		hasChildNodes: function(){ return $dom.hasChildNodes(); },
+		insertBefore: function(node,before){
+			$dom.insertBefore( $nodeImplCache[node.__$__], before ? $nodeImplCache[before.__$__] : before );
+		},
+		isSupported: function(feature,version){return $dom.isSupported(feature,version);},
+		normalize: function(){return $dom.normalize();},
+		removeChild: function(node){ 
+		  $dom.removeChild( $nodeImplCache[node.__$__] ); 
+		  $nodeCache[$nodeImplCache[node.__$__]]=null;
+		  delete $nodeCache[$nodeImplCache[node.__$__]];
+		  delete $nodeImplCache[node.__$__];
+		  node = null;
+		  delete node;
+	  },
+		replaceChild: function(newNode, oldNode){ 
+		  $dom.replaceChild( $nodeImplCache[newNode.__$__],$nodeImplCache[oldNode.__$__] ); 
+		  $nodeCache[$nodeImplCache[oldNode.__$__]]=null;
+		  delete $nodeCache[$nodeImplCache[oldNode.__$__]];
+		  delete $nodeImplCache[oldNode.__$__];
+		  oldNode = null;
+		  delete oldNode;
+	  },
+		toString: function(){ return '&quot;' + this.nodeValue + '&quot;'; },
+		get __$__(){return String($id);}
+  });
+};
+
+
+__extend__(Node, {
+		ELEMENT_NODE    :1,
+		ATTRIBUTE_NODE  :2,
+		TEXT_NODE       :3,
+		CDATA_SECTION_NODE: 4,
+		PROCESSING_INSTRUCTION_NODE: 7,
+		COMMENT_NODE: 8,
+		DOCUMENT_NODE: 9,
+		DOCUMENT_TYPE_NODE: 10,
+		DOCUMENT_FRAGMENT_NODE: 11
+});$log(&quot;Defining NodeList&quot;);
+/*
+* NodeList - DOM Level 2
+*/
+$w.__defineGetter__('NodeList', function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var NodeList = function(nodes){
+  function toArray(nodelist){
+    if(nodelist&amp;&amp;nodelist.getLength){
+      var node, nodeArray = [];
+  		for ( var i = 0; i &lt; nodelist.getLength(); i++ ) {
+  		  node = makeNode( nodelist.item(i) );
+  		  if(node === null){$log(node + &quot; = makeNode(&quot;+nodelist.item(i)+&quot;); : NodeList&quot;);}
+  			nodeArray.push(node);
+  		}return nodeArray;
+	  }else{return [];}
+  };
+	setArray(this,toArray(nodes));
+	__extend__(this,{
+		toString: function(){ return &quot;[ &quot; + Array.prototype.join.apply(this,[&quot;,&quot;]) + &quot; ]&quot;; },
+  	item: function(index){return  this[index] ;},
+  	get xml(){
+  	  var xml = &quot;&quot;;
+		  for(var i=0;i&lt;this.length;i++){ xml +=  this[i].xml; }
+		  return xml;
+		}
+	});
+	return this;
+};$log(&quot;Defining DOMParser&quot;);
+/*
+* DOMParser
+*/
+$w.__defineGetter__('DOMParser', function(){
+  return function(){
+    return __extend__(this, {
+      parseFromString: function(xmlString){
+        $debug(&quot;Parsing XML String: &quot; +xmlString);
+        return document.implementation.createDocument().loadXML(xmlString);
+      }
+    });
+  };
+});
+
+$log(&quot;Initializing Internal DOMParser.&quot;);
+//keep one around for internal use
+$domparser = new DOMParser();
+$log(&quot;Defining Text&quot;);
+/*
+* Text - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Text&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Text = function(node, id){
+  var $dom = node, 
+      $id = id?id:createGUID();
+  $debug(&quot;Text &quot; +$id);
+  __extend__(this, new CharacterData($dom, $id));
+  return __extend__(this, {
+    splitText: function(offset){return makeNode($dom.splitText(offset));}
+  });
+};
+/*
+*	html.js
+*
+*	DOM Level 2 HTML
 */
-	//the current location
-	var $location = $env.location('./');
+
+var correctHTMLIds = function (node){
+  var children;
+  try{
+    if(node.nodeType === Node.ELEMENT_NODE){
+        //$log(&quot;Setting ID Attribute &quot; + node);
+        if(node.hasAttribute('id'))
+          node.setIdAttribute('id',true);
+      children = node.childNodes;
+      for(var i=0;i&lt;children.length;i++){
+        correctHTMLIds(children.item(i));
+      }
+    }
+  }catch(e){$log(e);}
+};
+			
+//This extends makeNode by allowing HTML&lt;T&gt;Elements to be defined
+function makeHTMLElement(name, node){
+  //This is an html document so we need to use explicit interfaces per the 
+  if(     name.match(/A/)){cacheNode(node, HTMLAnchorElement);}
+  else if(name.match(/AREA/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BASE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BLOCKQUOTE|Q/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BODY/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BR/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/BUTTON/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/CAPTION/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/COL|COLGROUP/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/DEL|INS/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/DIV/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/DL/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/FIELDSET/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/FORM/)){cacheNode(node, HTMLFormElement);}
+  else if(name.match(/FRAME/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/FRAMESET/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/H1|H2|H3|H4|H5|H6/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/HEAD/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/HR/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/HTML/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/IFRAME/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/IMG/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/INPUT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LABEL/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LEGEND/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LI/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/LINK/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/MAP/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/META/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OBJECT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OL/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OPTGROUP/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/OPTION/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/P/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/PARAM/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/PRE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/SCRIPT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/SELECT/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/STYLE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TABLE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TBODY|TFOOT|THEAD/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TD|TH/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TEXTAREA/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TITLE/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/TR/)){cacheNode(node, HTMLElement);}
+  else if(name.match(/UL/)){cacheNode(node, HTMLElement);}
+  else{
+    $debug(&quot;Caching HTML Element &quot; + name);
+    cacheNode(node, HTMLElement);
+  }
+};
 	
-	$w.__defineSetter__(&quot;location&quot;, function(url){
-	  //$w.onunload();
-		$w.document.load(url);
-		$location = url;
-		setHistory($location);
+$log(&quot;Defining HTMLDocument&quot;);
+/*
+* HTMLDocument - DOM Level 2
+*  The Document object is not directly 
+*/
+$w.__defineGetter__(&quot;HTMLDocument&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+var HTMLDocument = function(node){
+  var $url, 
+      $domain, 
+      $title = &quot;&quot;, 
+      $lastModified = &quot;&quot;,
+      $refferer = &quot;&quot;,
+      $open = false;
+  __extend__(this, new Document(node));
+  return __extend__(this, {
+    get anchors(){return new HTMLCollection(this.getElementsByName('a'), 'Anchor');},
+    get applets(){return new HTMLCollection(this.getElementsByName('applet'), 'Applet');},
+    get body(){ return this.getElementsByName('body')[0];},
+    set body(html){return this.replaceNode(this.body,html);},
+    //set/get cookie see cookie.js
+    get domain(){return $domain||$w.location.domain;},
+    set domain(){return; /* TODO - requires a bit of thought to enforce domain restrictions */ },
+    get forms(){
+      $log(&quot;document.forms&quot;);
+      return new HTMLCollection(this.getElementsByName('form'), 'Form');
+    },
+    get images(){return new HTMLCollection(this.getElementsByName('img'), 'Image');},
+    get lastModified(){ return $lastModified; /* TODO */},
+    get links(){return new HTMLCollection(this.getElementsByName('link'), 'Link');},
+    get referrer(){return $refferer; /* TODO */},
+    get title(){return $title; /* TODO */},
+    set title(title){$title = title;},
+    get URL(){return $url; /* TODO*/},
+		close : function(){ $open = false;/* TODO */ },
+		getElementsByName : function(name){
+		  $debug(&quot;document.getElementsByName ( &quot;+name+&quot; )&quot;);
+		  return this.getElementsByTagName(name);
+	  },
+	  open : function(){ $open = true; /* TODO */ },
+	  write: function(htmlstring){ return;/* TODO */ },
+	  writeln: function(htmlstring){ this.write(htmlstring+'\n'); },
+		toString: function(){ return &quot;Document&quot; +  (typeof $url == &quot;string&quot; ? &quot;: &quot; + $url : &quot;&quot;); },
+		get innerHTML(){ return this.documentElement.outerHTML; },
+		get __html__(){return true;}
+  });
+};
+
+//This is useful as html elements that modify the dom must also run through the new 
+//nodes and determine if they are javascript tags and load it.  This is really the fun 
+//parts! ;)
+function execScripts( node ) {
+	if ( node.nodeName == &quot;SCRIPT&quot; ) {
+		if ( !node.getAttribute(&quot;src&quot;) ) {
+			eval.call( window, node.textContent );
+		}
+	} else {
+		var scripts = node.getElementsByTagName(&quot;script&quot;);
+		for ( var i = 0; i &lt; scripts.length; i++ ) {
+			execScripts( node );
+		}
+	}
+};$log(&quot;Defining HTMLElement&quot;);
+/*
+* HTMLElement - DOM Level 2
+*/
+$w.__defineGetter__(&quot;HTMLElement&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLElement = function(node){
+  __extend__(this, new Element(node));  
+	registerEventAttrs(this);
+	return __extend__(this, {
+		get className() { return this.getAttribute(&quot;class&quot;) || &quot;&quot;; },
+		set className(val) { return this.setAttribute(&quot;class&quot;,trim(val)); },
+		get dir() { return this.getAttribute(&quot;dir&quot;) || &quot;&quot;; },
+		set dir(val) { return this.setAttribute(&quot;dir&quot;,val); },
+		get id() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set id(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get innerHTML(){  return this.childNodes.xml; },
+		set innerHTML(html){
+		  //$debug(&quot;htmlElement.innerHTML(&quot;+html+&quot;)&quot;);
+		  //Should be replaced with HTMLPARSER usage
+			html = (html?html:&quot;&quot;).replace(/&lt;\/?([A-Z]+)/g, function(m){
+				return m.toLowerCase();
+			}).replace(/&amp;nbsp;/g, &quot; &quot;);
+			var doc = new DOMParser().
+			  parseFromString('&lt;div&gt;'+html+'&lt;/div&gt;');
+      var elements, nodes = this.ownerDocument.importNode(doc.documentElement, true).childNodes;
+			while (this.firstChild){ this.removeChild( this.firstChild );}
+			for(var i = 0; i&lt;nodes.length; i++ ){
+			  this.appendChild( nodes.item(i) );
+        correctHTMLIds(nodes.item(i));
+		  }
+		  delete doc;
+		},
+		get lang() { return this.getAttribute(&quot;lang&quot;) || &quot;&quot;; },
+		set lang(val) { return this.setAttribute(&quot;lang&quot;,val); },
+		offsetHeight: 0,
+		offsetWidth: 0,
+		offsetLeft: 0,
+		offsetRight: 0,
+		get offsetParent(){return;/* TODO */},
+		set offsetParent(element){return;/*TODO*/},
+		scrollHeight: 0,
+		scrollWidth: 0,
+		scrollLeft: 0, 
+		scrollRight: 0,
+		get style(){return null;},//new CSS2Properties(trim(this.getAttribute(&quot;style&quot;) || &quot;&quot;));},
+		get title() { return this.getAttribute(&quot;title&quot;) || &quot;&quot;; },
+		set title(val) { return this.setAttribute(&quot;title&quot;,val); },
+		//Not in the specs but I'll leave it here for now.
+		get outerHTML(){ return this.xml; },
+	  scrollIntoView: function(){/*TODO*/},
+		onclick: function(event){try{eval(this.getAttribute('onclick'));}catch(e){$error(e);}},
+		ondblclick: function(event){try{eval(this.getAttribute('ondblclick'));}catch(e){$error(e);}},
+		onkeydown: function(event){try{eval(this.getAttribute('onkeydown'));}catch(e){$error(e);}},
+		onkeypress: function(event){try{eval(this.getAttribute('onkeypress'));}catch(e){$error(e);}},
+		onkeyup: function(event){try{eval(this.getAttribute('onkeyup'));}catch(e){$error(e);}},
+		onmousedown: function(event){try{eval(this.getAttribute('onmousedown'));}catch(e){$error(e);}},
+		onmousemove: function(event){try{eval(this.getAttribute('onmousemove'));}catch(e){$error(e);}},
+		onmouseout: function(event){try{eval(this.getAttribute('onmouseout'));}catch(e){$error(e);}},
+		onmouseover: function(event){try{eval(this.getAttribute('onmouseover'));}catch(e){$error(e);}},
+		onmouseup: function(event){try{eval(this.getAttribute('onmouseup'));}catch(e){$error(e);}}
 	});
+};
+
+
+	var registerEventAttrs = function(elm){
+    if(elm.hasAttribute('onclick')){ elm.addEventListener('click', elm.onclick ); }
+    if(elm.hasAttribute('ondblclick')){ elm.addEventListener('dblclick', elm.onclick ); }
+    if(elm.hasAttribute('onkeydown')){ elm.addEventListener('keydown', elm.onclick ); }
+    if(elm.hasAttribute('onkeypress')){ elm.addEventListener('keypress', elm.onclick ); }
+    if(elm.hasAttribute('onkeyup')){ elm.addEventListener('keyup', elm.onclick ); }
+    if(elm.hasAttribute('onmousedown')){ elm.addEventListener('mousedown', elm.onclick ); }
+    if(elm.hasAttribute('onmousemove')){ elm.addEventListener('mousemove', elm.onclick ); }
+    if(elm.hasAttribute('onmouseout')){ elm.addEventListener('mouseout', elm.onclick ); }
+    if(elm.hasAttribute('onmouseover')){ elm.addEventListener('mouseover', elm.onclick ); }
+    if(elm.hasAttribute('onmouseup')){ elm.addEventListener('mouseup', elm.onclick ); }
+    return elm;
+	};
 	
-	$w.__defineGetter__(&quot;location&quot;, function(url){
-		var hash 	 = new RegExp('(\\#.*)'),
+	var click = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;click&quot;);
+		element.dispatchEvent(event);
+	};
+	var submit = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;submit&quot;);
+		element.dispatchEvent(event);
+	};
+	var focus = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;focus&quot;);
+		element.dispatchEvent(event);
+	};
+	var blur = function(element){
+		var event = new Event({
+		  target:element,
+		  currentTarget:element
+		});
+		event.initEvent(&quot;blur&quot;);
+		element.dispatchEvent(event);
+	};$log(&quot;Defining HTMLFormElement&quot;);
+/* 
+* HTMLAnchorElement - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Form&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+$w.__defineGetter__(&quot;HTMLFormElement&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLFormElement = function(node){
+  __extend__(this, new HTMLElement(node));
+  return __extend__(this,{
+    get acceptCharset(){ return this.getAttribute('acceptCharset');},
+    set acceptCharset(acceptCharset){this.setAttribute('acceptCharset', acceptCharset);},
+    get action(){return this.getAttribute('action');},
+    set action(action){this.setAttribute('action', action);},
+    get elements() {return this.getElementsByTagName(&quot;*&quot;);},
+    get enctype(){return this.getAttribute('enctype');},
+    set enctype(enctype){this.setAttribute('enctype', enctype);},
+    get length() {return this.elements.length;},
+    get method(){return this.getAttribute('method');},
+    set method(action){this.setAttribute('method', method);},
+		get name() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set name(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get target() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set target(val) { return this.setAttribute(&quot;id&quot;,val); },
+		submit:function(){submit(this);},
+		reset:function(){reset(this);}
+  });
+};
+
+
+			$log(&quot;Defining HTMLCollection&quot;);
+/*
+* HTMLCollection - DOM Level 2
+*/
+$w.__defineGetter__(&quot;HTMLCollection&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLCollection = function(nodelist, type){
+  var $items = [], 
+      $item, i;
+  if(type === &quot;Anchor&quot; ){
+    for(i=0;i&lt;nodelist.length;i++){ 
+      //The name property is required to be add to the collection
+      if(nodelist.item(i).name){
+        item = new nodelist.item(i);
+        $items.push(item);
+        this[nodelist.item(i).name] = item;
+      }
+    }
+  }else if(type === &quot;Link&quot;){
+    for(i=0;i&lt;nodelist.length;i++){ 
+      //The name property is required to be add to the collection
+      if(nodelist.item(i).href){
+        item = new nodelist.item(i);
+        $items.push(item);
+        this[nodelist.item(i).name] = item;
+      }
+    }
+  }else if(type === &quot;Form&quot;){
+    for(i=0;i&lt;nodelist.length;i++){ 
+      //The name property is required to be add to the collection
+      if(nodelist.item(i).href){
+        item = new nodelist.item(i);
+        $items.push(item);
+        this[nodelist.item(i).name] = item;
+      }
+    }
+  }
+  setArray(this, $items);
+  return __extend__(this, {
+    item : function(i){return this[i];},
+    namedItem : function(name){return this[name];}
+  });
+};
+
+	$log(&quot;Defining HTMLAnchorElement&quot;);
+/* 
+* HTMLAnchorElement - DOM Level 2
+*/
+$w.__defineGetter__(&quot;Anchor&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+$w.__defineGetter__(&quot;HTMLAnchorElement&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var HTMLAnchorElement = function(node){
+	var hash 	 = new RegExp('(\\#.*)'),
 			hostname = new RegExp('\/\/([^\:\/]+)'),
 			pathname = new RegExp('(\/[^\\?\\#]*)'),
 			port 	 = new RegExp('\:(\\d+)\/'),
 			protocol = new RegExp('(^\\w*\:)'),
 			search 	 = new RegExp('(\\?[^\\#]*)');
-		return {
-			get hash(){
-				var m = hash.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set hash(_hash){
-				//setting the hash is the only property of the location object
-				//that doesn't cause the window to reload
-				_hash = _hash.indexOf('#')===0?_hash:&quot;#&quot;+_hash;	
-				$location = this.protocol + this.host + this.pathname + 
-					this.search + _hash;
-				setHistory(_hash, &quot;hash&quot;);
-			},
-			get host(){
-				return this.hostname + (this.port !== &quot;&quot;)?&quot;:&quot;+this.port:&quot;&quot;;
-			},
-			set host(_host){
-				$w.location = this.protocol + _host + this.pathname + 
-					this.search + this.hash;
-			},
-			get hostname(){
-				var m = hostname.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set hostname(_hostname){
-				$w.location = this.protocol + _hostname + ((this.port===&quot;&quot;)?&quot;&quot;:(&quot;:&quot;+this.port)) +
-				 	 this.pathname + this.search + this.hash;
-			},
-			get href(){
-				//This is the only env specific function
-				return $location;
-			},
-			set href(url){
-				$w.location = url;	
-			},
-			get pathname(){
-				var m = this.href;
-				m = pathname.exec(m.substring(m.indexOf(this.hostname)));
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;/&quot;;
-			},
-			set pathname(_pathname){
-				$w.location = this.protocol + this.host + _pathname + 
-					this.search + this.hash;
-			},
-			get port(){
-				var m = port.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set port(_port){
-				$w.location = this.protocol + this.hostname + &quot;:&quot;+_port + this.pathname + 
-					this.search + this.hash;
-			},
-			get protocol(){
-				return protocol.exec(this.href)[0];
-			},
-			set protocol(_protocol){
-				$w.location = _protocol + this.host + this.pathname + 
-					this.search + this.hash;
-			},
-			get search(){
-				var m = search.exec(this.href);
-				return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
-			},
-			set search(_search){
-				$w.location = this.protocol + this.host + this.pathname + 
-					_search + this.hash;
-			},
-			toString: function(){
-				return this.href;
-			},
-			reload: function(force){
-				//TODO
-			},
-			replace: function(url){
-				//TODO
-			}
-		};
-	});
+  __extend__(this, new HTMLElement(node));
+  return __extend__(this,{
+		get accessKey() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set accessKey(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get charset() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set charset(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get coords() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set coords(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get href() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set href(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get hreflang() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set hreflang(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get name() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set name(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get rel() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set rel(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get rev() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set rev(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get shape() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set shape(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get tabIndex() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set tabIndex(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get target() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set target(val) { return this.setAttribute(&quot;id&quot;,val); },
+		get type() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
+		set type(val) { return this.setAttribute(&quot;id&quot;,val); },
+		blur:function(){blur(this);},
+		focus:function(){focus(this);},
+		get hash(){
+			var m = hash.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hash(_hash){
+			//setting the hash is the only property of the location object
+			//that doesn't cause the window to reload
+			_hash = _hash.indexOf('#')===0?_hash:&quot;#&quot;+_hash;	
+			this.href = this.protocol + this.host + this.pathname + this.search + _hash;
+		},
+		get host(){
+			return this.hostname + (this.port !== &quot;&quot;)?&quot;:&quot;+this.port:&quot;&quot;;
+		},
+		set host(_host){
+			this.href = this.protocol + _host + this.pathname + this.search + this.hash;
+		},
+		get hostname(){
+			var m = hostname.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hostname(_hostname){
+			this.href = this.protocol + _hostname + ((this.port===&quot;&quot;)?&quot;&quot;:(&quot;:&quot;+this.port)) +
+			 	 this.pathname + this.search + this.hash;
+		},
+		get pathname(){
+			var m = this.href;
+			m = pathname.exec(m.substring(m.indexOf(this.hostname)));
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;/&quot;;
+		},
+		set pathname(_pathname){
+			this.href = this.protocol + this.host + _pathname + 
+				this.search + this.hash;
+		},
+		get port(){
+			var m = port.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set port(_port){
+			this.href = this.protocol + this.hostname + &quot;:&quot;+_port + this.pathname + 
+				this.search + this.hash;
+		},
+		get protocol(){
+			return protocol.exec(this.href)[0];
+		},
+		set protocol(_protocol){
+			this.href = _protocol + this.host + this.pathname + 
+				this.search + this.hash;
+		},
+		get search(){
+			var m = search.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set search(_search){
+			this.href = this.protocol + this.host + this.pathname + 
+				_search + this.hash;
+		}
+  });
+};
+
+
+			$log(&quot;Defining Event&quot;);
+/*
+* event.js
+*/
+$w.__defineGetter__(&quot;Event&quot;, function(){
+  __extend__(this,{
+    CAPTURING_PHASE : 1,
+    AT_TARGET       : 2,
+    BUBBLING_PHASE  : 3
+  });
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var Event = function(options){
+  if(options === undefined){options={target:window,currentTarget:window};}
+  __extend__(this,{
+    CAPTURING_PHASE : 1,
+    AT_TARGET       : 2,
+    BUBBLING_PHASE  : 3
+  });
+  $log(&quot;Creating new Event&quot;);
+  var $bubbles = options.bubbles?options.bubbles:true,
+      $cancelable = options.cancelable?options.cancelable:true,
+      $currentTarget = options.currentTarget?options.currentTarget:null,
+      $eventPhase = options.eventPhase?options.eventPhase:Event.CAPTURING_PHASE,
+      $target = options.eventPhase?options.eventPhase:document,
+      $timestamp = options.timestamp?options.timestamp:new Date().getTime().toString(),
+      $type = options.type?options.type:&quot;&quot;;
+  return __extend__(this,{
+    get bubbles(){return $bubbles;},
+    get cancelable(){return $cancelable;},
+    get currentTarget(){return $currentTarget;},
+    get eventPhase(){return $eventPhase;},
+    get target(){return $target;},
+    get timestamp(){return $timestamp;},
+    get type(){return $type;},
+    initEvent: function(type,bubbles,cancelable){
+      $type=type?type:$type;
+      $bubbles=bubbles?bubbles:$bubbles;
+      $cancelable=cancelable?cancelable:$cancelable;
+    },
+    preventDefault: function(){return;/* TODO */},
+    stopPropagation: function(){return;/* TODO */}
+  });
+};
+
+$log(&quot;Defining MouseEvent&quot;);
+/*
+*	mouseevent.js
+*/
+$log(&quot;Defining MouseEvent&quot;);
+/*
+*	uievent.js
+*/
+
+var $onblur,
+    $onfocus,
+    $onresize;/*
+* CSS2Properties - DOM Level 2 CSS
+*/
+$w.__defineGetter__(&quot;CSS2Properties&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+
+var CSS2Properties = function(options){
+  var $styles = [];
+  var $styleMap = {};
+  for (var prop in $supportedStyles){
+    $styleMap[prop] = &quot;&quot;;
+    this.__defineGetter__(prop, function(){return $styleMap[prop];});
+    if(!options.readonly){
+      //because the window.getComputedStyle return a CSS2Properties
+      //object that is read only we make the setter optional
+      this.__defineSetter__(prop, function(value){$styleMap[prop] = value;});
+    }
+  }
+  if(options.cssText){cssTextToStyles(options.cssText);}
+  function cssTextToStyles(cssText){
+    $styles=[];
+    var style, styles = cssText.split(';');
+    for ( var i = 0; i &lt; styles.length; i++ ) {
+    	style = styles[i].split(':');
+    	if ( style.length == 2 ){
+  	    //keep a reference to the original name of the style which was set
+  	    $styles[i]=styles[i];
+  		  //camel case for dash case
+  		  //this could be done much better with a match with function arg
+  		  //but I'm tearing through this just to get a first pass
+    	  style[0] = trim(style[0]).split('-');
+    	  if(style[0].length == 2){
+    	    style[0] = style[0][0]+style[0][1].substring(0,1).toUpperCase()+
+    	      style[0][1].substring(1,style[0][1].length);
+    	  }else{
+    	    //No '-' dash present
+    	    style[0] = style[0][0];
+        }
+    	  if($styleMap[style[0]]){
+    	    //set the value internally with camelcase name so its exposed via the 'get'.
+    	    $styleMap[style[0]] = trim(style[1]);
+    	  };
+    	}
+    }
+    setArray(this, $styles);
+  };
+  
+  return __extend__(this, {
+    get cssText(){$styles.join(';');},
+    set cssText(cssText){ cssTextToStyles(cssText); }
+  });
+};
+
+//Obviously these arent all supported but by commenting out various sections
+//this provides a single location to configure what is exposed as supported.
+var $supportedStyles = {
+    azimuth:	&quot;&quot;,
+    background:	&quot;&quot;,
+    backgroundAttachment:	&quot;&quot;,
+    backgroundColor:	&quot;&quot;,
+    backgroundImage:	&quot;&quot;,
+    backgroundPosition:	&quot;&quot;,
+    backgroundRepeat:	&quot;&quot;,
+    border:	&quot;&quot;,
+    borderBottom:	&quot;&quot;,
+    borderBottomColor:	&quot;&quot;,
+    borderBottomStyle:	&quot;&quot;,
+    borderBottomWidth:	&quot;&quot;,
+    borderCollapse:	&quot;&quot;,
+    borderColor:	&quot;&quot;,
+    borderLeft:	&quot;&quot;,
+    borderLeftColor:	&quot;&quot;,
+    borderLeftStyle:	&quot;&quot;,
+    borderLeftWidth:	&quot;&quot;,
+    borderRight:	&quot;&quot;,
+    borderRightColor:	&quot;&quot;,
+    borderRightStyle:	&quot;&quot;,
+    borderRightWidth:	&quot;&quot;,
+    borderSpacing:	&quot;&quot;,
+    borderStyle:	&quot;&quot;,
+    borderTop:	&quot;&quot;,
+    borderTopColor:	&quot;&quot;,
+    borderTopStyle:	&quot;&quot;,
+    borderTopWidth:	&quot;&quot;,
+    borderWidth:	&quot;&quot;,
+    bottom:	&quot;&quot;,
+    captionSide:	&quot;&quot;,
+    clear:	&quot;&quot;,
+    clip:	&quot;&quot;,
+    color:	&quot;&quot;,
+    content:	&quot;&quot;,
+    counterIncrement:	&quot;&quot;,
+    counterReset:	&quot;&quot;,
+    cssFloat:	&quot;&quot;,
+    cue:	&quot;&quot;,
+    cueAfter:	&quot;&quot;,
+    cueBefore:	&quot;&quot;,
+    cursor:	&quot;&quot;,
+    direction:	&quot;&quot;,
+    display:	&quot;&quot;,
+    elevation:	&quot;&quot;,
+    emptyCells:	&quot;&quot;,
+    font:	&quot;&quot;,
+    fontFamily:	&quot;&quot;,
+    fontSize:	&quot;&quot;,
+    fontSizeAdjust:	&quot;&quot;,
+    fontStretch:	&quot;&quot;,
+    fontStyle:	&quot;&quot;,
+    fontVariant:	&quot;&quot;,
+    fontWeight:	&quot;&quot;,
+    height:	&quot;&quot;,
+    left:	&quot;&quot;,
+    letterSpacing:	&quot;&quot;,
+    lineHeight:	&quot;&quot;,
+    listStyle:	&quot;&quot;,
+    listStyleImage:	&quot;&quot;,
+    listStylePosition:	&quot;&quot;,
+    listStyleType:	&quot;&quot;,
+    margin:	&quot;&quot;,
+    marginBottom:	&quot;&quot;,
+    marginLeft:	&quot;&quot;,
+    marginRight:	&quot;&quot;,
+    marginTop:	&quot;&quot;,
+    markerOffset:	&quot;&quot;,
+    marks:	&quot;&quot;,
+    maxHeight:	&quot;&quot;,
+    maxWidth:	&quot;&quot;,
+    minHeight:	&quot;&quot;,
+    minWidth:	&quot;&quot;,
+    opacity:	&quot;&quot;,
+    orphans:	&quot;&quot;,
+    outline:	&quot;&quot;,
+    outlineColor:	&quot;&quot;,
+    outlineOffset:	&quot;&quot;,
+    outlineStyle:	&quot;&quot;,
+    outlineWidth:	&quot;&quot;,
+    overflow:	&quot;&quot;,
+    overflowX:	&quot;&quot;,
+    overflowY:	&quot;&quot;,
+    padding:	&quot;&quot;,
+    paddingBottom:	&quot;&quot;,
+    paddingLeft:	&quot;&quot;,
+    paddingRight:	&quot;&quot;,
+    paddingTop:	&quot;&quot;,
+    page:	&quot;&quot;,
+    pageBreakAfter:	&quot;&quot;,
+    pageBreakBefore:	&quot;&quot;,
+    pageBreakInside:	&quot;&quot;,
+    pause:	&quot;&quot;,
+    pauseAfter:	&quot;&quot;,
+    pauseBefore:	&quot;&quot;,
+    pitch:	&quot;&quot;,
+    pitchRange:	&quot;&quot;,
+    position:	&quot;&quot;,
+    quotes:	&quot;&quot;,
+    richness:	&quot;&quot;,
+    right:	&quot;&quot;,
+    size:	&quot;&quot;,
+    speak:	&quot;&quot;,
+    speakHeader:	&quot;&quot;,
+    speakNumeral:	&quot;&quot;,
+    speakPunctuation:	&quot;&quot;,
+    speechRate:	&quot;&quot;,
+    stress:	&quot;&quot;,
+    tableLayout:	&quot;&quot;,
+    textAlign:	&quot;&quot;,
+    textDecoration:	&quot;&quot;,
+    textIndent:	&quot;&quot;,
+    textShadow:	&quot;&quot;,
+    textTransform:	&quot;&quot;,
+    top:	&quot;&quot;,
+    unicodeBidi:	&quot;&quot;,
+    verticalAlign:	&quot;&quot;,
+    visibility:	&quot;&quot;,
+    voiceFamily:	&quot;&quot;,
+    volume:	&quot;&quot;,
+    whiteSpace:	&quot;&quot;,
+    widows:	&quot;&quot;,
+    width:	&quot;&quot;,
+    wordSpacing:	&quot;&quot;,
+    zIndex:	&quot;&quot;
+};/* 
+* CSSRule - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CSSRule&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CSSRule = function(options){
+  var $style, 
+      $selectorText = options.selectorText?options.selectorText:&quot;&quot;;
+      $style = new CSS2Properties({cssText:options.cssText?options.cssText:null});
+    return __extend__(this, {
+      get style(){return $style;},
+      get selectorText(){return $selectorText;},
+      set selectorText(selectorText){$selectorText = selectorText;}
+    });
+};
+/* 
+* CSSStyleSheet - DOM Level 2
+*/
+$w.__defineGetter__(&quot;CSSStyleSheet&quot;, function(){
+  return function(){
+    throw new Error(&quot;Object cannot be created in this context&quot;);
+  };
+});
+
+var CSSStyleSheet = function(options){
+    var $cssRules, 
+        $disabled = options.disabled?options.disabled:false,
+        $href = options.href?options.href:null,
+        $parentStyleSheet = options.parentStyleSheet?options.parentStyleSheet:null,
+        $title = options.title?options.title:&quot;&quot;,
+        $type = &quot;text/css&quot;;
+        
+    function parseStyleSheet(text){
+      //this is pretty ugly, but text is the entire text of a stylesheet
+      var cssRules = [];
+    	if (!text) text = &quot;&quot;;
+    	text = trim(text.replace(/\/\*(\r|\n|.)*\*\//g,&quot;&quot;));
+    	// TODO: @import ?
+    	var blocks = text.split(&quot;}&quot;);
+    	blocks.pop();
+    	var i, len = blocks.length;
+    	var definition_block, properties, selectors;
+    	for (i=0; i&lt;len; i++){
+    		definition_block = blocks[i].split(&quot;{&quot;);
+    		if(definition_block.length === 2){
+      		selectors = definition_block[0].split(&quot;,&quot;);
+      		for(var j=0;j&lt;selectors.length;j++){
+      		  cssRules.push(new CSSRule({
+      		    selectorText:selectors[j],
+      		    cssText:definition_block[1]
+      		  }));
+      		}
+      		setArray($cssRules, cssRules);
+    		}
+    	}
+    };
+    parseStyleSheet(options.text);
+    return __extend__(this, {
+      get cssRules(){return $cssRules;},
+      get rule(){return $cssRules;},//IE - may be deprecated
+      get href(){return $href;},
+      get parentStyleSheet(){return $parentStyleSheet;},
+      get title(){return $title;},
+      get type(){return $type;},
+      addRule: function(selector, style, index){/*TODO*/},
+      deleteRule: function(index){/*TODO*/},
+      insertRule: function(rule, index){/*TODO*/},
+      removeRule: function(index){this.deleteRule(index);}//IE - may be deprecated
+    });
+};
+/*
+*	location.js
+*   - requires env
+*/
+$log(&quot;Initializing Window Location.&quot;);
+//the current location
+var $location = $env.location('./');
+
+$w.__defineSetter__(&quot;location&quot;, function(url){
+  //$w.onunload();
+	$w.document.load(url);
+	$location = url;
+	setHistory($location);
+});
+
+$w.__defineGetter__(&quot;location&quot;, function(url){
+	var hash 	 = new RegExp('(\\#.*)'),
+		hostname = new RegExp('\/\/([^\:\/]+)'),
+		pathname = new RegExp('(\/[^\\?\\#]*)'),
+		port 	 = new RegExp('\:(\\d+)\/'),
+		protocol = new RegExp('(^\\w*\:)'),
+		search 	 = new RegExp('(\\?[^\\#]*)');
+	return {
+		get hash(){
+			var m = hash.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hash(_hash){
+			//setting the hash is the only property of the location object
+			//that doesn't cause the window to reload
+			_hash = _hash.indexOf('#')===0?_hash:&quot;#&quot;+_hash;	
+			$location = this.protocol + this.host + this.pathname + 
+				this.search + _hash;
+			setHistory(_hash, &quot;hash&quot;);
+		},
+		get host(){
+			return this.hostname + (this.port !== &quot;&quot;)?&quot;:&quot;+this.port:&quot;&quot;;
+		},
+		set host(_host){
+			$w.location = this.protocol + _host + this.pathname + 
+				this.search + this.hash;
+		},
+		get hostname(){
+			var m = hostname.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set hostname(_hostname){
+			$w.location = this.protocol + _hostname + ((this.port===&quot;&quot;)?&quot;&quot;:(&quot;:&quot;+this.port)) +
+			 	 this.pathname + this.search + this.hash;
+		},
+		get href(){
+			//This is the only env specific function
+			return $location;
+		},
+		set href(url){
+			$w.location = url;	
+		},
+		get pathname(){
+			var m = this.href;
+			m = pathname.exec(m.substring(m.indexOf(this.hostname)));
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;/&quot;;
+		},
+		set pathname(_pathname){
+			$w.location = this.protocol + this.host + _pathname + 
+				this.search + this.hash;
+		},
+		get port(){
+			var m = port.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set port(_port){
+			$w.location = this.protocol + this.hostname + &quot;:&quot;+_port + this.pathname + 
+				this.search + this.hash;
+		},
+		get protocol(){
+			return protocol.exec(this.href)[0];
+		},
+		set protocol(_protocol){
+			$w.location = _protocol + this.host + this.pathname + 
+				this.search + this.hash;
+		},
+		get search(){
+			var m = search.exec(this.href);
+			return m&amp;&amp;m.length&gt;1?m[1]:&quot;&quot;;
+		},
+		set search(_search){
+			$w.location = this.protocol + this.host + this.pathname + 
+				_search + this.hash;
+		},
+		toString: function(){
+			return this.href;
+		},
+		reload: function(force){
+			//TODO
+		},
+		replace: function(url){
+			//TODO
+		}
+	};
+});
+
 /*
 *	history.js
 */
 
+  $log(&quot;Initializing Window History.&quot;);
 	$currentHistoryIndex = 0;
 	$history = [];
 	
@@ -516,6 +1932,8 @@ function trim( str ){
 *	navigator.js
 *   - requires env
 */
+$log(&quot;Initializing Window Navigator.&quot;);
+
 var $appCodeName  = &quot;EnvJS&quot;;//eg &quot;Mozilla&quot;
 var $appName      = &quot;Resig/20070309 BirdDog/0.0.0.1&quot;;//eg &quot;Gecko/20070309 Firefox/2.0.0.3&quot;
 
@@ -562,7 +1980,8 @@ $w.__defineGetter__(&quot;navigator&quot;, function(){
 *	timer.js
 */
 	
-// Timers
+
+$log(&quot;Initializing Window Timer.&quot;);
 
 var $timers = [];
 
@@ -590,9 +2009,8 @@ $w.clearInterval = $w.clearTimeout = function(num){
 	/*
 * event.js
 */
-	
 // Window Events
-
+$log(&quot;Initializing Window Event.&quot;);
 var $events = [{}],
     $onerror,
     $onload,
@@ -675,643 +2093,9 @@ $w.__defineGetter__('onunload', function(){
 $w.__defineSetter__('onunload', function(fn){
   //$w.addEventListener('unload', fn);
 });*//*
-*	dom.js
-*
-*	DOM Level 2 /DOM level 3 (partial)
-*	
-*	The DOMDocument is now private in scope but you can create new
-*	DOMDocuments via document.implementation.createDocument which
-*	now also exposes the DOM Level 3 function 'load(uri)'.
-*
-*/
-
-  // Helper method for generating the right
-	// DOM objects based upon the type
-	/*var obj_nodes = {};
-
-	function makeNode(node){
-	  $log(&quot;Making Node&quot;);
-		if ( node ) {
-			if ( !obj_nodes[node]){
-				obj_nodes[node] = node.getNodeType() == 1 ? new DOMElement( node ) :
-					(node.getNodeType() == 8 ? new DOMComment( node ) : new DOMNode( node )) ;
-  		}
-			return obj_nodes[node];
-		} else
-			return null;
-	};*/
-	// Helper method for generating the right
-	// DOM objects based upon the type
-	
-	var $nodeCache = {};//caches a reference to our implementation of the node
-	var $nodeImplCache = {};//reverse look-up : caches a reference to the env supplied implementors dom node
-	var $guid = (-1)*Math.pow(2,31);
-  function createGUID(){
-    return String(++$guid);
-  };
-	
-	function makeNode(node){
-		if ( node ) {
-			if ( !$nodeCache[ $env.hashCode(node) ] ){
-				if( node.getNodeType() == 1){
-				  $nodeCache[$env.hashCode(node)] = new DOMElement( node );
-				  $nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
-				}else{
-				  if(node.getNodeType() == 8){
-				    $nodeCache[$env.hashCode(node)] = new DOMComment( node );
-				    $nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
-				  }else{
-				    $nodeCache[$env.hashCode(node)] = new DOMNode( node );
-				    $nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
-			    }
-				}
-			}
-			return $nodeCache[$env.hashCode(node)];
-		} else{ 
-		  return null;
-	  }
-	}
-	
-	//DOMImplementation
-	var DOMImplementation = function(){
-		return {
-			hasFeature: function(feature, version){
-				//TODO
-				return false;
-			},
-			createDocumentType: function(qname, publicId, systemId){
-				//TODO
-			},
-			createDocument:function(namespace, qname, docType){
-				return new DOMDocument();
-			},
-			getFeature:function(feature, version){
-				//TODO or TODONT?
-			}
-		};
-	};
-	
-	// DOM Document
-$w.__defineGetter__('DOMDocument', function(){
-  var $dom, $id, $url;
-  return function(){
-    $id = createGUID();
-    return __extend__(this,{
-  		load: function(url){
-  		  $log(&quot;Loading url into DOM Document: &quot;+ url + &quot; - (Asynch? &quot;+$w.document.async+&quot;)&quot;);
-  			var _this = this;
-  			var xhr = new XMLHttpRequest();
-  			xhr.open(&quot;GET&quot;, url, $w.document.async);
-  			xhr.onreadystatechange = function(){
-				  try{
-					  _this.loadXML(xhr.responseText);
-				  }catch(e){
-				    $error(&quot;Error Parsing XML - &quot;,e);
-	          _this.loadXML(
-	            &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&quot;+
-	              &quot;&lt;h1&gt;Parse Error&lt;/h1&gt;&quot;+
-	              &quot;&lt;p&gt;&quot;+e.toString()+&quot;&lt;/p&gt;&quot;+  
-	            &quot;&lt;/body&gt;&lt;/html&gt;&quot;);
-			    }
-  			  $url = url;
-      		if ( !$nodeCache[$dom] ){
-      			$nodeCache[$dom] = _this;
-    			}
-  				$log(&quot;Sucessfully loaded document.&quot;);
-  				var event = document.createEvent();
-  				event.initEvent(&quot;load&quot;);
-  				$w.dispatchEvent( event );
-  			};
-  			xhr.send();
-  		},
-  		//This is actuall IE specific but still convenient
-  		loadXML: function(xmlString){
-  		  $dom = $env.parseXML(xmlString);
-  		  return this;
-  		},
-  		get nodeType(){
-  			return 9;
-  		},
-  		createTextNode: function(text){
-  			return makeNode( $dom.createTextNode(
-  				text.replace(/&amp;/g, &quot;&amp;amp;&quot;).replace(/&lt;/g, &quot;&amp;lt;&quot;).replace(/&gt;/g, &quot;&amp;gt;&quot;)) );
-  		},
-  		createElement: function(name){
-  			return makeNode( $dom.createElement(name.toLowerCase()) );
-  		},
-  		getElementsByTagName: function(name){
-  			return new DOMNodeList( 
-  			  $dom.getElementsByTagName(
-  				  name.toLowerCase()) );
-  		},
-  		getElementsByName: function(name){
-  		  // why can't we just do ?: 
-  			//var elems = $dom.getElementsByTagName(name), ret = [];
-  			var elems = $dom.getElementsByTagName(&quot;*&quot;), ret = [];
-  			ret.item = function(i){ return this[i]; };
-  			ret.getLength = function(){ return this.length; };
-  			for ( var i = 0; i &lt; elems.length; i++ ) {
-  				var elem = elems.item(i);
-  				if ( elem.getAttribute(&quot;name&quot;) == name )
-  					ret.push( elem );
-  			}return new DOMNodeList( ret );
-  		},
-  		getElementById: function(id){
-  		  // why can't we just do ?: 
-  		  //return makeNode($dom.getElementById(id));
-  		  var elems = $dom.getElementsByTagName(&quot;*&quot;);
-  			
-  			for ( var i = 0; i &lt; elems.length; i++ ) {
-  				var elem = elems.item(i);
-  				if ( elem.getAttribute(&quot;id&quot;) == id )
-  					return makeNode(elem);
-  			}
-  			
-  			return null;
-  		},
-  		get body(){
-  			return this.getElementsByTagName(&quot;body&quot;)[0];
-  		},
-  		get documentElement(){
-  			return makeNode( $dom.getDocumentElement() );
-  		},
-  		get ownerDocument(){
-  			return null;
-  		},
-  		addEventListener: window.addEventListener,
-  		removeEventListener: window.removeEventListener,
-  		dispatchEvent: window.dispatchEvent,
-  		get nodeName() {
-  			return &quot;#document&quot;;
-  		},
-  		importNode: function(node, deep){
-  		  //need to replace this with some innerHtml magic
-  		  //because the ._dom is private in scope now
-  			return makeNode( $dom.importNode($nodeImplCache[node.__guid__], deep) );
-  		},
-  		toString: function(){
-  			return &quot;Document&quot; + 
-  			  (typeof $url == &quot;string&quot; ? &quot;: &quot; + $url : &quot;&quot;);
-  		},
-  		get innerHTML(){
-  			return this.documentElement.outerHTML;
-  		},
-  		
-  		get defaultView(){
-  			return {
-  				getComputedStyle: function(elem){
-  					return {
-  						getPropertyValue: function(prop){
-  							prop = prop.replace(/\-(\w)/g,function(m,c){
-  								return c.toUpperCase();
-  							});
-  							var val = elem.style[prop];
-  							if ( prop === &quot;opacity&quot; &amp;&amp; val === &quot;&quot; ){
-  								val = &quot;1&quot;;
-  							}return val;
-  						}
-  					};
-  				}
-  			};
-  		},
-  		
-  		createEvent: function(){
-  			return {
-  				type: &quot;&quot;,
-  				initEvent: function(type){
-  					this.type = type;
-  				}
-  			};
-  		},
-  		get __guid__(){return $id;}
-    });
-  };
-});
-
-function getDocument(node){
-	return $nodeCache[node];
-}
-	
-	// DOM NodeList
-
-$w.__defineGetter__(&quot;DOMNodeList&quot;, function(){
-  var $dom;
-  return function(list){
-		$dom = list;
-		this.length = list.getLength();
-		
-		for ( var i = 0; i &lt; this.length; i++ ) {
-			var node = list.item(i);
-			this[i] = makeNode( node );
-		}
-		return __extend__(this,{
-  		toString: function(){
-  			return &quot;[ &quot; +
-  				Array.prototype.join.call( this, &quot;, &quot; ) + &quot; ]&quot;;
-  		},
-  		get outerHTML(){
-  			return Array.prototype.map.call(
-  				this, function(node){return node.outerHTML;}).join('');
-  		}
-		});
-	};
-});
-	
-	// DOM Node
-	
-$w.__defineGetter__(&quot;DOMNode&quot;, function(){
-  var $dom, $id;
-  return function(node){
-    $id = createGUID();
-	  $dom = node;
-	  return __extend__(this, {
-  		get nodeType(){
-  			return $dom.getNodeType();
-  		},
-  		get nodeValue(){
-  			return $dom.getNodeValue();
-  		},
-  		get nodeName() {
-  			return $dom.getNodeName();
-  		},
-  		get childNodes(){
-  			return new DOMNodeList( $dom.getChildNodes() );
-  		},
-  		cloneNode: function(deep){
-  			return makeNode( $dom.cloneNode(deep) );
-  		},
-  		get ownerDocument(){
-  			return getDocument( $dom.ownerDocument );
-  		},
-  		get documentElement(){
-  			return makeNode( $dom.documentElement );
-  		},
-  		get parentNode() {
-  			return makeNode( $dom.getParentNode() );
-  		},
-  		get nextSibling() {
-  			return makeNode( $dom.getNextSibling() );
-  		},
-  		get previousSibling() {
-  			return makeNode( $dom.getPreviousSibling() );
-  		},
-  		toString: function(){
-  			return '&quot;' + this.nodeValue + '&quot;';
-  		},
-  		get outerHTML(){
-  			return this.nodeValue;
-  		},
-  		get __guid__(){return $id;}
-	  });
-  };
-});
-
-  // DOMComment
-
-$w.__defineGetter__(&quot;DOMComment&quot;, function(){
-	  $id = createGUID();
-  return function(node){
-    return __extend__(this, __extend__(new DOMNode(node),{
-      get nodeType(){
-  			return 8;
-  		},
-  		get outerHTML(){
-  			return &quot;&lt;!--&quot; + this.nodeValue + &quot;--&gt;&quot;;
-  		}
-    }));
-  };
-});
-
-	// DOM Element
-
-$w.__defineGetter__(&quot;DOMElement&quot;, function(){
-	var $dom, $id;
-	return function(elem){
-	  $dom = elem;
-	  $id = createGUID();
-	  __extend__(this, new DOMNode($dom));
-		
-		// A lot of the methods defined below belong in HTML specific
-		// subclasses.  This is already unwieldy since most of these
-		//methods are meant for general xml consumption
-		__extend__(this, {
-  		get nodeName(){
-  			return this.tagName;
-  		},
-  		get tagName(){
-  			return $dom.getTagName().toUpperCase();
-  		},
-  		toString: function(){
-  			return &quot;&lt;&quot; + this.tagName + (this.id ? &quot;#&quot; + this.id : &quot;&quot; ) + &quot;&gt;&quot;;
-  		},
-  		get outerHTML(){
-  			var ret = &quot;&lt;&quot; + this.tagName, attr = this.attributes;
-  			
-  			for ( var i in attr )
-  				ret += &quot; &quot; + i + &quot;='&quot; + attr[i] + &quot;'&quot;;
-  				
-  			if ( this.childNodes.length || this.nodeName == &quot;SCRIPT&quot; )
-  				ret += &quot;&gt;&quot; + this.childNodes.outerHTML + 
-  					&quot;&lt;/&quot; + this.tagName + &quot;&gt;&quot;;
-  			else
-  				ret += &quot;/&gt;&quot;;
-  			
-  			return ret;
-  		},
-  		
-  		get attributes(){
-  			var attr = {}, attrs = $dom.getAttributes();
-  			for ( var i = 0; i &lt; attrs.getLength(); i++ ){
-  				attr[ attrs.item(i).nodeName ] = attrs.item(i).nodeValue;
-				}return attr;
-  		},
-  		
-  		get innerHTML(){
-  			return this.childNodes.outerHTML;	
-  		},
-  		set innerHTML(html){
-  			html = html.replace(/&lt;\/?([A-Z]+)/g, function(m){
-  				return m.toLowerCase();
-  			}).replace(/&amp;nbsp;/g, &quot; &quot;);
-  			
-  			var dom = new DOMParser().parseFromString(&quot;&lt;wrap&gt;&quot; + html + &quot;&lt;/wrap&gt;&quot;);
-  			var nodes = this.ownerDocument.importNode( dom.documentElement,  true ).childNodes;
-  				
-  			while (this.firstChild){
-  				this.removeChild( this.firstChild );
-				}
-  			
-  			for ( var i = 0; i &lt; nodes.length; i++ )
-  				this.appendChild( nodes[i] );
-  		},
-  		
-  		get textContent(){
-  			function nav(nodes){
-  				var str = &quot;&quot;;
-  				for ( var i = 0; i &lt; nodes.length; i++ ){
-  					if ( nodes[i].nodeType == 3 ){
-  						str += nodes[i].nodeValue;
-  					}else if ( nodes[i].nodeType == 1 ){
-  						str += nav(nodes[i].childNodes);
-  					}
-  				} return str;
-  			} return nav(this.childNodes);
-  		},
-  		set textContent(text){
-  			while (this.firstChild)
-  				this.removeChild( this.firstChild );
-  			this.appendChild( this.ownerDocument.createTextNode(text));
-  		},
-  		
-  		style: {},
-  		clientHeight: 0,
-  		clientWidth: 0,
-  		offsetHeight: 0,
-  		offsetWidth: 0,
-  		
-  		get disabled() {
-  			var val = this.getAttribute(&quot;disabled&quot;);
-  			return val != &quot;false&quot; &amp;&amp; !!val;
-  		},
-  		set disabled(val) { return this.setAttribute(&quot;disabled&quot;,val); },
-  		
-  		get checked() {
-  			var val = this.getAttribute(&quot;checked&quot;);
-  			return val != &quot;false&quot; &amp;&amp; !!val;
-  		},
-  		set checked(val) { return this.setAttribute(&quot;checked&quot;,val); },
-  		
-  		get selected() {
-  			if ( !this._selectDone ) {
-  				this._selectDone = true;
-  				
-  				if ( this.nodeName == &quot;OPTION&quot; &amp;&amp; !this.parentNode.getAttribute(&quot;multiple&quot;) ) {
-  					var opt = this.parentNode.getElementsByTagName(&quot;option&quot;);
-  					
-  					if ( this == opt[0] ) {
-  						var select = true;
-  						
-  						for ( var i = 1; i &lt; opt.length; i++ ){
-  							if ( opt[i].selected ) {
-  								select = false;
-  								break;
-  							}
-  						}
-  						if ( select ){ this.selected = true; }
-  					}
-  				}
-  			}
-  			
-  			var val = this.getAttribute(&quot;selected&quot;);
-  			return val != &quot;false&quot; &amp;&amp; !!val;
-  		},
-  		set selected(val) { return this.setAttribute(&quot;selected&quot;,val); },
-  
-  		get className() { return this.getAttribute(&quot;class&quot;) || &quot;&quot;; },
-  		set className(val) {
-  			return this.setAttribute(&quot;class&quot;,
-  				val.replace(/(^\s*|\s*$)/g,&quot;&quot;));
-  		},
-  		
-  		get type() { return this.getAttribute(&quot;type&quot;) || &quot;&quot;; },
-  		set type(val) { return this.setAttribute(&quot;type&quot;,val); },
-  
-  		get defaultValue() { return this.getAttribute(&quot;defaultValue&quot;) || &quot;&quot;; },
-  		set defaultValue(val) { return this.setAttribute(&quot;defaultValue&quot;,val); },
-  
-  		get value() { return this.getAttribute(&quot;value&quot;) || &quot;&quot;; },
-  		set value(val) { return this.setAttribute(&quot;value&quot;,val); },
-  		
-  		get src() { return this.getAttribute(&quot;src&quot;) || &quot;&quot;; },
-  		set src(val) { return this.setAttribute(&quot;src&quot;,val); },
-  		
-  		get id() { return this.getAttribute(&quot;id&quot;) || &quot;&quot;; },
-  		set id(val) { return this.setAttribute(&quot;id&quot;,val); },
-  		
-  		getAttribute: function(name){
-  			return $dom.hasAttribute(name) ?
-  				new String( $dom.getAttribute(name) ) :
-  				null;
-  		},
-  		setAttribute: function(name,value){
-  			$dom.setAttribute(name,value);
-  		},
-  		removeAttribute: function(name){
-  			$dom.removeAttribute(name);
-  		},
-  		
-  		get childNodes(){
-  			return new DOMNodeList( $dom.getChildNodes() );
-  		},
-  		get firstChild(){
-  			return makeNode( $dom.getFirstChild() );
-  		},
-  		get lastChild(){
-  			return makeNode( $dom.getLastChild() );
-  		},
-  		appendChild: function(node){
-  		  //Because the dom implementation is private in scope now,
-  		  //we will need to fix these to use some innerHtml etc
-  		  //if required
-  			$dom.appendChild( $nodeImplCache[node.__guid__] );
-  		},
-  		insertBefore: function(node,before){
-  			$dom.insertBefore( $nodeImplCache[node.__guid__], before ? $nodeImplCache[before.__guid__] : before );
-  			
-  			execScripts( node );
-  			
-  			function execScripts( node ) {
-  				if ( node.nodeName == &quot;SCRIPT&quot; ) {
-  					if ( !node.getAttribute(&quot;src&quot;) ) {
-  						eval.call( window, node.textContent );
-  					}
-  				} else {
-  					var scripts = node.getElementsByTagName(&quot;script&quot;);
-  					for ( var i = 0; i &lt; scripts.length; i++ ) {
-  						execScripts( node );
-  					}
-  				}
-  			}
-  		},
-  		removeChild: function(node){
-  			$dom.removeChild( $nodeImplCache[node.__guid__] );
-  		},
-  
-  		getElementsByTagName: function(name){
-  		  // why can't we just do ?: 
-  			//var elems = $dom.getElementsByTagName(name), ret = [];
-  			var elems = $dom.getElementsByTagName(&quot;*&quot;), ret = [];
-  			ret.item = function(i){ return this[i]; };
-  			ret.getLength = function(){ return this.length; };
-  			for ( var i = 0; i &lt; elems.length; i++ ) {
-  				var elem = elems.item(i);
-  				if ( elem.getAttribute(&quot;name&quot;) == name )
-  					ret.push( elem );
-  			}return new DOMNodeList( ret );
-			},
-  		
-  		addEventListener: window.addEventListener,
-  		removeEventListener: window.removeEventListener,
-  		dispatchEvent: window.dispatchEvent,
-  		
-  		click: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;click&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		submit: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;submit&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		focus: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;focus&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		blur: function(){
-  			var event = document.createEvent();
-  			event.initEvent(&quot;blur&quot;);
-  			this.dispatchEvent(event);
-  		},
-  		get contentWindow(){
-  			return this.nodeName == &quot;IFRAME&quot; ? {
-  				document: this.contentDocument
-  			} : null;
-  		},
-  		get contentDocument(){
-  			if ( this.nodeName == &quot;IFRAME&quot; ) {
-  				if ( !this._doc )
-  					this._doc = HTMLtoDOM(&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
-  				return this._doc;
-  			} else { return null; }
-    	},
-  		get __guid__(){return $id;}
-		});
-		
-	  //All this constructor stuff belond in the HTML subclasses
-	  //and even more generally in the HTML specific element
-	  //subclass otherwise its going to become a mess
-  	this.style = {
-  		get opacity(){ return this._opacity; },
-  		set opacity(val){ this._opacity = val + &quot;&quot;; }
-  	};
-		
-		// Load CSS info
-		var styles = (this.getAttribute(&quot;style&quot;) || &quot;&quot;).split(/\s*;\s*/);
-		for ( var i = 0; i &lt; styles.length; i++ ) {
-			var style = styles[i].split(/\s*:\s*/);
-			if ( style.length == 2 )
-				this.style[ style[0] ] = style[1];
-		}
-		
-		if ( this.nodeName == &quot;FORM&quot; ) {
-			this.__defineGetter__(&quot;elements&quot;, function(){
-				return this.getElementsByTagName(&quot;*&quot;);
-			});
-			this.__defineGetter__(&quot;length&quot;, function(){
-				var elems = this.elements;
-				for ( var i = 0; i &lt; elems.length; i++ ) {
-					this[i] = elems[i];
-				}
-				return elems.length;
-			});
-		}
-
-		if ( this.nodeName == &quot;SELECT&quot; ) {
-			this.__defineGetter__(&quot;options&quot;, function(){
-				return this.getElementsByTagName(&quot;option&quot;);
-			});
-		}
-
-		this.defaultValue = this.value;
-		return this;
-	};
-});
-
-$w.__defineGetter__('DOMParser', function(){
-  return function(){
-    return __extend__(this, {
-      parseFromString: function(xmlString){
-        return document.implementation.createDocument().loadXML(xmlString);
-      }
-    });
-  };
-});
-	
-	/*
-*	document.js
-*
-*	DOM Level 2 /DOM level 3 (partial)
-*	
-*	This file adds the document object to the window and allows you
-*	you to set the window.document using an html string or dom object.
-*
-*/
-
-// read only reference to the Document object
-var $document =  new DOMDocument();
-var $implementation =  new DOMImplementation();
-var $async = false;
-
-$w.__defineGetter__(&quot;document&quot;, function(){
-	return __extend__($document, {
-		get async(){ return $async;},
-		set async(async){ $async = async; },
-		get baseURI(){ return $env.location('./'); },
-		get implementation(){ return $implementation; },
-		get URL(){ return $w.location.href;  }
-	});
-});
-
-	
-	/*
-*	html.js
-*
-*	DOM Level 2 HTML
-*//*
 *	xhr.js
 */
+$log(&quot;Initializing Window XMLHttpRequest.&quot;);
 // XMLHttpRequest
 // Originally implemented by Yehuda Katz
 $w.XMLHttpRequest = function(){
@@ -1338,16 +2122,19 @@ XMLHttpRequest.prototype = {
 		
 		function makeRequest(){
 			$env.connection(self, function(){
+			  var responseXML = null;
 				self.__defineGetter__(&quot;responseXML&quot;, function(){
-					return responseXML;
-				});
-				if ( self.responseText.match(/^\s*&lt;/) ) {
-					try {
-						var doc = $w.document.implementation.createDocument();
-						doc._dom = $env.parseXML(responseText);
-						responseXML = doc;
-					} catch(e) { /*TODO: need to flag an error here*/}
-				}
+  				if ( self.responseText.match(/^\s*&lt;/) ) {
+  				  if(responseXML){return responseXML;}
+  				  else{
+    					try {
+    					  $log(&quot;parsing response text into xml document&quot;);
+    						responseXML = $domparser.parseFromString(self.responseText);
+  					    return responseXML;
+    					} catch(e) { return null;/*TODO: need to flag an error here*/}
+  					}
+  				}else{return null;}
+  			});
 			});
 			self.onreadystatechange();
 		}
@@ -1379,15 +2166,14 @@ XMLHttpRequest.prototype = {
 		}return null;
 	},
 	getAllResponseHeaders: function(){
-	  var header;
+	  var header, returnedHeaders = [];
 		if (this.readyState &lt; 3){
 			throw new Error(&quot;INVALID_STATE_ERR&quot;);
 		} else {
-			var returnedHeaders = [];
 			for (header in this.responseHeaders){
 				returnedHeaders.push( header + &quot;: &quot; + this.responseHeaders[header] );
-			}return returnedHeaders.join(&quot;\r\n&quot;);
-		}
+			}
+		}return returnedHeaders.join(&quot;\r\n&quot;);
 	},
 	async: true,
 	readyState: 0,
@@ -1396,147 +2182,17 @@ XMLHttpRequest.prototype = {
 };/*
 *	css.js
 */
-
+$log(&quot;Initializing Window CSS&quot;);
 // returns a CSS2Properties object that represents the style
 // attributes and values used to render the specified element in this
-// window.  Any length values are alwasys expressed in pixel, or
+// window.  Any length values are always expressed in pixel, or
 // absolute values.
 $w.getComputedStyle = function(elt, pseudo_elt){
   //TODO
 };/*
-*	cookie.js
-*   - requires env
-*/
-
-var $cookies = {
-	persistent:{
-		//domain - key on domain name {
-			//path - key on path {
-				//name - key on name {
-					 //value : cookie value
-					 //other cookie properties
-				//}
-			//}
-		//}
-		//expire - provides a timestamp for expiring the cookie
-		//cookie - the cookie!
-	},
-	temporary:{//transient is a reserved word :(
-		//like above
-	}
-};
-
-//Window cookie
-$w.__defineSetter__(&quot;cookie&quot;, function(cookie){
-	var i,name,value,properties = {},attr,attrs = cookie.split(&quot;;&quot;);
-	//for now the strategy is to simply create a json object
-	//and post it to a file in the .cookies.js file.  I hate parsing
-	//dates so I decided not to implement support for 'expires' 
-	//(which is deprecated) and instead focus on the easier 'max-age'
-	//(which succeeds 'expires') 
-	cookie = {};//keyword properties of the cookie
-	for(i=0;i&lt;attrs.length;i++){
-		attr = attrs[i].split(&quot;=&quot;);
-		if(attr.length &gt; 0){
-			name = trim(attr[0]);
-			value = trim(attr[1]);
-			if(name=='max-age'){ 
-				//we'll have to set a timer to check these 
-				//and garbage collect expired cookies
-				cookie[name] = parseInt(value, 10);
-			} else if(name=='domain'){
-				if(domainValid(value)){
-					cookie['domain']=value;
-				}else{
-					cookie['domain']=$w.location.domain;
-				}
-			} else if(name=='path'){
-				//not sure of any special logic for path
-				cookie['path'] = value;
-			} else {
-				//its not a cookie keyword so store it in our array of properties
-				//and we'll serialize individually in a moment
-				properties[name] = value;
-			}
-		}else{
-			if(attr[0] == 'secure'){
-				cookie[attr[0]] = true;
-			}
-		}
-	}
-	if(!cookie['max-age']){
-		//it's a transient cookie so it only lasts as long as 
-		//the window.location remains the same
-		mergeCookie($cookies.temporary, cookie, properties);
-	}else if(cookie['max-age']===0){
-		//delete the cookies
-		//TODO
-	}else{
-		//the cookie is persistent
-		mergeCookie($cookies.persistent, cookie, properties);
-		persistCookies();
-	}
-});
-
-$w.__defineGetter__(&quot;cookie&quot;, function(c){
-	//The cookies that are returned must belong to the same domain
-	//and be at or below the current window.location.path.  Also
-	//we must check to see if the cookie was set to 'secure' in which
-	//case we must check our current location.protocol to make sure it's
-	//https:
-	var allcookies = [], i;
-	//TODO 	
-});
-
-
-
-var domainValid = function(domain){
-	//make sure the domain
-	//TODO 	
-};
-
-var mergeCookie = function(target, cookie, properties){
-	var name, now;
-	if(!target[cookie.domain]){
-		target[cookie.domain] = {};
-	}
-	if(!target[cookie.domain][cookie.path]){
-		target[cookie.domain][cookie.path] = {};
-	}
-	for(name in properties){
-		now = new Date().getTime();
-		target[cookie.domain][cookie.path][name] = {
-			value:properties[name],
-			&quot;@env:secure&quot;:cookie.secure,
-			&quot;@env:max-age&quot;:cookie['max-age'],
-			&quot;@env:date-created&quot;:now,
-			&quot;@env:expiration&quot;:now + cookie['max-age']
-		};
-	}
-};
-
-var persistCookies = function(){
-	//TODO
-	//I think it should be done via $env so it can be customized
-};
-
-var loadCookies = function(){
-	//TODO
-	//should also be configurable via $env	
-};
-
-//We simply use the default ajax get to load the .cookies.js file
-//if it doesn't exist we create it with a post.  Cookies are maintained
-//in memory, but serialized with each set.
-try{
-	//TODO - load cookies
-	loadCookies();
-}catch(e){
-	//TODO - fail gracefully
-}	
-	/*
 *	screen.js
 */
+$log(&quot;Initializing Window Screen.&quot;);
 
 var $availHeight  = 600,
     $availWidth   = 800,
@@ -1582,14 +2238,9 @@ $w.scrollBy = function(dx, dy){
 $w.scrollTo = function(x,y){
   //TODO
 };/*
-*	uievent.js
-*/
-
-var $onblur,
-    $onfocus,
-    $onresize;/*
 *	dialog.js
 */
+$log(&quot;Initializing Window Dialogs.&quot;);
 $w.alert = function(message){
  //TODO 
 };
@@ -1601,312 +2252,33 @@ $w.confirm = function(question){
 $w.prompt = function(message, defaultMsg){
   //TODO
 };/*
-*	env.parser.js
+*	document.js
+*
+*	DOM Level 2 /DOM level 3 (partial)
+*	
+*	This file adds the document object to the window and allows you
+*	you to set the window.document using an html string or dom object.
+*
 */
-/*
- * HTML Parser By John Resig (ejohn.org)
- * Original code by Erik Arvidsson, Mozilla Public License
- * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
- *
- * // Use like so:
- * HTMLParser(htmlString, {
- *     start: function(tag, attrs, unary) {},
- *     end: function(tag) {},
- *     chars: function(text) {},
- *     comment: function(text) {}
- * });
- *
- * // or to get an XML string:
- * HTMLtoXML(htmlString);
- *
- * // or to get an XML DOM Document
- * HTMLtoDOM(htmlString);
- *
- * // or to inject into an existing document/DOM node
- * HTMLtoDOM(htmlString, document);
- * HTMLtoDOM(htmlString, document.body);
- *
- */
-
-(function(){
-
-	// Regular Expressions for parsing tags and attributes
-	var startTag = /^&lt;([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:&quot;[^&quot;]*&quot;)|(?:'[^']*')|[^&gt;\s]+))?)*)\s*(\/?)&gt;/,
-		endTag = /^&lt;\/([\w:-]+)[^&gt;]*&gt;/,
-		attr = /([\w:-]+)(?:\s*=\s*(?:(?:&quot;((?:\\.|[^&quot;])*)&quot;)|(?:'((?:\\.|[^'])*)')|([^&gt;\s]+)))?/g;
-		
-	// Empty Elements - HTML 4.01
-	var empty = makeMap(&quot;area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed&quot;);
-
-	// Block Elements - HTML 4.01
-	var block = makeMap(&quot;address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul&quot;);
-
-	// Inline Elements - HTML 4.01
-	var inline = makeMap(&quot;a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var&quot;);
-
-	// Elements that you can, intentionally, leave open
-	// (and which close themselves)
-	var closeSelf = makeMap(&quot;colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr&quot;);
-
-	// Attributes that have their values filled in disabled=&quot;disabled&quot;
-	var fillAttrs = makeMap(&quot;checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected&quot;);
-
-	// Special Elements (can contain anything)
-	var special = makeMap(&quot;script,style&quot;);
-
-	var HTMLParser = this.HTMLParser = function( html, handler ) {
-		var index, chars, match, stack = [], last = html;
-		stack.last = function(){
-			return this[ this.length - 1 ];
-		};
-
-		while ( html ) {
-			chars = true;
-
-			// Make sure we're not in a script or style element
-			if ( !stack.last() || !special[ stack.last() ] ) {
-
-				// Comment
-				if ( html.indexOf(&quot;&lt;!--&quot;) === 0 ) {
-					index = html.indexOf(&quot;--&gt;&quot;);
-	
-					if ( index &gt;= 0 ) {
-						if ( handler.comment )
-							handler.comment( html.substring( 4, index ) );
-						html = html.substring( index + 3 );
-						chars = false;
-					}
-	
-				// end tag
-				} else if ( html.indexOf(&quot;&lt;/&quot;) === 0 ) {
-					match = html.match( endTag );
-	
-					if ( match ) {
-						html = html.substring( match[0].length );
-						match[0].replace( endTag, parseEndTag );
-						chars = false;
-					}
-	
-				// start tag
-				} else if ( html.indexOf(&quot;&lt;&quot;) === 0 ) {
-					match = html.match( startTag );
-	
-					if ( match ) {
-						html = html.substring( match[0].length );
-						match[0].replace( startTag, parseStartTag );
-						chars = false;
-					}
-				}
-
-				if ( chars ) {
-					index = html.indexOf(&quot;&lt;&quot;);
-					var text = index &lt; 0 ? html : html.substring( 0, index );
-					html = index &lt; 0 ? &quot;&quot; : html.substring( index );
-					if ( handler.chars ){handler.chars( text );}
-				}
-			} else {
-				html = html.replace(new RegExp(&quot;(.*)&lt;\/&quot; + stack.last() + &quot;[^&gt;]*&gt;&quot;), function(all, text){
-					text = text.replace(/&lt;!--(.*?)--&gt;/g, &quot;$1&quot;).
-						replace(/&lt;!\[CDATA\[(.*?)]]&gt;/g, &quot;$1&quot;);
-					if ( handler.chars ){handler.chars( text );}
-					return &quot;&quot;;
-				});
-				parseEndTag( &quot;&quot;, stack.last() );
-			}
-			if ( html == last ){throw &quot;Parse Error: &quot; + html;}
-			last = html;
-		}
-		
-		// Clean up any remaining tags
-		parseEndTag();
 
-		function parseStartTag( tag, tagName, rest, unary ) {
-			if ( block[ tagName ] ) {
-				while ( stack.last() &amp;&amp; inline[ stack.last() ] ) {
-					parseEndTag( &quot;&quot;, stack.last() );
-				}
-			}
-
-			if ( closeSelf[ tagName ] &amp;&amp; stack.last() == tagName ) {
-				parseEndTag( &quot;&quot;, tagName );
-			}
-
-			unary = empty[ tagName ] || !!unary;
+// read only reference to the Document object
 
-			if ( !unary )
-				stack.push( tagName );
-			
-			if ( handler.start ) {
-				var attrs = [];
-	
-				rest.replace(attr, function(match, name) {
-					var value = arguments[2] ? arguments[2] :
-						arguments[3] ? arguments[3] :
-						arguments[4] ? arguments[4] :
-						fillAttrs[name] ? name : &quot;&quot;;
-					
-					attrs.push({
-						name: name,
-						value: value,
-						escaped: value.replace(/(^|[^\\])&quot;/g, '$1\\\&quot;') //&quot;
-					});
-				});
-	
-				if ( handler.start )
-					handler.start( tagName, attrs, unary );
-			}
-		}
+$log(&quot;Initializing window.document.&quot;);
+var $document =  new HTMLDocument();
+var $async = false;
 
-		function parseEndTag( tag, tagName ) {
-		  var pos;
-			// If no tag name is provided, clean shop
-			if ( !tagName ){
-				pos = 0;
-			}else{
-			// Find the closest opened tag of the same type
-				for ( pos = stack.length - 1; pos &gt;= 0; pos-- ){
-					if ( stack[ pos ] == tagName ){ break; }
-				}
-  		}
-			if ( pos &gt;= 0 ) {
-				// Close all the open elements, up the stack
-				for ( var i = stack.length - 1; i &gt;= pos; i-- ){
-					if ( handler.end ){
-						handler.end( stack[ i ] );
-  				}
-				}
-				// Remove the open elements from the stack
-				stack.length = pos;
-			}
-		}
-	};
-	
-	this.HTMLtoXML = function( html ) {
-		var results = &quot;&quot;;
-		
-		HTMLParser(html, {
-			start: function( tag, attrs, unary ) {
-				results += &quot;&lt;&quot; + tag;
-		
-				for ( var i = 0; i &lt; attrs.length; i++ )
-					results += &quot; &quot; + attrs[i].name + '=&quot;' + attrs[i].escaped + '&quot;';
-		
-				results += (unary ? &quot;/&quot; : &quot;&quot;) + &quot;&gt;&quot;;
-			},
-			end: function( tag ) {
-				results += &quot;&lt;/&quot; + tag + &quot;&gt;&quot;;
-			},
-			chars: function( text ) {
-				results += text;
-			},
-			comment: function( text ) {
-				results += &quot;&lt;!--&quot; + text + &quot;--&gt;&quot;;
-			}
-		});
-		
-		return results;
-	};
-	
-	this.HTMLtoDOM = function( html, doc ) {
-		// There can be only one of these elements
-		var one = makeMap(&quot;html,head,body,title&quot;);
-		
-		// Enforce a structure for the document
-		var structure = {
-			link: &quot;head&quot;,
-			base: &quot;head&quot;
-		};
-	
-		if ( !doc ) {
-			if ( typeof DOMDocument != &quot;undefined&quot; ){
-				doc = new DOMDocument();
-			}else if ( typeof document != &quot;undefined&quot; &amp;&amp; document.implementation &amp;&amp; document.implementation.createDocument ){
-				doc = document.implementation.createDocument(&quot;&quot;, &quot;&quot;, null);
-			}else if ( typeof ActiveX != &quot;undefined&quot; ){
-				doc = new ActiveXObject(&quot;Msxml.DOMDocument&quot;);
-			}
-		} else {
-			doc = doc.ownerDocument ||
-				doc.getOwnerDocument &amp;&amp; doc.getOwnerDocument() ||
-				doc;
-		}
-		
-		var elems = [],
-			documentElement = doc.documentElement || doc.getDocumentElement &amp;&amp; doc.getDocumentElement();
-				
-		// If we're dealing with an empty document then we
-		// need to pre-populate it with the HTML document structure
-		if ( !documentElement &amp;&amp; doc.createElement ) (function(){
-			var html = doc.createElement(&quot;html&quot;);
-			var head = doc.createElement(&quot;head&quot;);
-			head.appendChild( doc.createElement(&quot;title&quot;) );
-			html.appendChild( head );
-			html.appendChild( doc.createElement(&quot;body&quot;) );
-			doc.appendChild( html );
-		})();
-		
-		// Find all the unique elements
-		if ( doc.getElementsByTagName ){
-			for ( var i in one ){
-			   one[ i ] = doc.getElementsByTagName( i )[0];
-		  }
-		}
-		
-		// If we're working with a document, inject contents into
-		// the body element
-		var curParentNode = one.body;
-		
-		HTMLParser( html, {
-			start: function( tagName, attrs, unary ) {
-				// If it's a pre-built element, then we can ignore
-				// its construction
-				if ( one[ tagName ] ) {
-					curParentNode = one[ tagName ];
-					return;
-				}
-			
-				var elem = doc.createElement( tagName );
-				
-				for ( var attr in attrs )
-					elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
-				
-				if ( structure[ tagName ] &amp;&amp; typeof one[ structure[ tagName ] ] != &quot;boolean&quot; )
-					one[ structure[ tagName ] ].appendChild( elem );
-				
-				else if ( curParentNode &amp;&amp; curParentNode.appendChild )
-					curParentNode.appendChild( elem );
-					
-				if ( !unary ) {
-					elems.push( elem );
-					curParentNode = elem;
-				}
-			},
-			end: function( tag ) {
-				elems.length -= 1;
-				
-				// Init the new parentNode
-				curParentNode = elems[ elems.length - 1 ];
-			},
-			chars: function( text ) {
-				curParentNode.appendChild( doc.createTextNode( text ) );
-			},
-			comment: function( text ) {
-				// create comment node
-			}
-		});
-		
-		return doc;
-	};
+$log(&quot;Adding window.document features.&quot;);
+$w.__defineGetter__(&quot;document&quot;, function(){
+	return __extend__($document, {
+		get async(){ return $async;},
+		set async(async){ $async = async; },
+		get baseURI(){ return $env.location('./'); },
+		get URL(){ return $w.location.href;  }
+	});
+});
 
-	function makeMap(str){
-		var obj = {}, items = str.split(&quot;,&quot;);
-		for ( var i = 0; i &lt; items.length; i++ )
-			obj[ items[i] ] = true;
-		return obj;
-	};
 	
-})();
-/*
+	/*
 *	outro.js
 */
 </diff>
      <filename>dist/env.rhino.js</filename>
    </modified>
    <modified>
      <diff>@@ -6,5 +6,8 @@
  
 
 // The Window Object
-var window = this;
+var __this__ = this;
+this.__defineGetter__('window', function(){
+  return __this__;
+});
 (function($w, $env){
\ No newline at end of file</diff>
      <filename>src/intro.js</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,12 @@
 var __env__ = {};
 (function($env){
 	
+  $env.debug = function(){};
+  
   $env.log = function(){};
   //uncomment this if you want to get some internal log statementes
-  //$env.log = print;
+  $env.log = print;
+  $env.log(&quot;Initializing Rhino Platform Env&quot;);
   
   $env.error = function(msg, e){
     print(&quot;ERROR! : &quot; + msg);
@@ -15,7 +18,7 @@ var __env__ = {};
   
   $env.hashCode = function(obj){
     return obj?obj.hashCode().toString():null;
-  }
+  };
 	//For Java the window.location object is a java.net.URL
 	$env.location = function(path, base){
 	  var protocol = new RegExp('(^\\w*\:)');
@@ -134,15 +137,33 @@ var __env__ = {};
 		}
 	};
 	
+	var htmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+	htmlDocBuilder.setNamespaceAware(false);
+	htmlDocBuilder.setValidating(false);
+	
+	$env.parseHTML = function(htmlstring){
+		return htmlDocBuilder.newDocumentBuilder().parse(
+				  new java.io.ByteArrayInputStream(
+						(new java.lang.String(htmlstring)).getBytes(&quot;UTF8&quot;)));
+	};
+	
+	var xmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+	xmlDocBuilder.setNamespaceAware(true);
+	xmlDocBuilder.setValidating(true);
+	
 	$env.parseXML = function(xmlstring){
-		return Packages.javax.xml.parsers.
-			DocumentBuilderFactory.newInstance().
-				newDocumentBuilder().parse(
+		return xmlDocBuilder.newDocumentBuilder().parse(
 				  new java.io.ByteArrayInputStream(
 						(new java.lang.String(xmlstring)).getBytes(&quot;UTF8&quot;)));
 	};
 	
-
+	
+  $env.xpath = function(expression, doc){
+    return Packages.javax.xml.xpath.
+      XPathFactory.newInstance().newXPath().
+        evaluate(expression, doc, javax.xml.xpath.XPathConstants.NODESET);
+  };
+	
   $env.os_name        = java.lang.System.getProperty(&quot;os.name&quot;); 
   $env.os_arch        = java.lang.System.getProperty(&quot;os.arch&quot;); 
   $env.os_version     = java.lang.System.getProperty(&quot;os.version&quot;); </diff>
      <filename>src/platform/rhino.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
+&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;./DTD/xhtml1-transitional.dtd&quot;&gt;
 &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot; dir=&quot;ltr&quot; id=&quot;html&quot;&gt;
 &lt;head&gt;
 	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
@@ -186,8 +186,8 @@ Z&lt;/textarea&gt;
 			&lt;/div&gt;
 		&lt;/div&gt;
 	&lt;/div&gt;
-	&lt;/dl&gt;
 	
+	&lt;/dl&gt;
 	&lt;ol id=&quot;tests&quot;&gt;&lt;/ol&gt;
 &lt;/body&gt;
 &lt;/html&gt;</diff>
      <filename>test/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -127,7 +127,7 @@ jQuery.fn = jQuery.prototype = {
 		// is a super-fast way to populate an object with array-like properties
 		this.length = 0;
 		Array.prototype.push.apply( this, elems );
-
+		
 		return this;
 	},
 </diff>
      <filename>test/jquery.js</filename>
    </modified>
    <modified>
      <diff>@@ -6,12 +6,13 @@ window.onload = function(){
   print(&quot;Handling onload for test.js&quot;);
   // Load the test runner
   load(&quot;test/testrunner.js&quot;, &quot;test/jquery.js&quot;);
-    
+  
   // Load the tests
   load(
-    &quot;test/unit/core.js&quot;,
-    &quot;test/unit/selector.js&quot;,
-    &quot;test/unit/event.js&quot;
+    &quot;test/unit/dom.js&quot;,
+    &quot;test/unit/core.js&quot;
+    //&quot;test/unit/selector.js&quot;,
+    //&quot;test/unit/event.js&quot;
   );
   
   </diff>
      <filename>test/test.js</filename>
    </modified>
    <modified>
      <diff>@@ -88,20 +88,17 @@ function isObj(a, b, msg) {
 
 function serialArray( a ) {
 	var r = [];
-	
-	if ( a &amp;&amp; a.length )
-        for ( var i = 0; i &lt; a.length; i++ ) {
-            var str = a[i] ? a[i].nodeName : &quot;&quot;;
-            if ( str ) {
-                str = str.toLowerCase();
-                if ( a[i].id )
-                    str += &quot;#&quot; + a[i].id;
-            } else
-                str = a[i];
-            r.push( str );
-        }
-
-	return &quot;[ &quot; + r.join(&quot;, &quot;) + &quot; ]&quot;
+	if ( a &amp;&amp; a.length ){
+    for ( var i = 0; i &lt; a.length; i++ ) {
+      var str = a[i] ? a[i].nodeName : &quot;&quot;;
+      if(str){
+        str = str.toLowerCase();
+        if ( a[i].id ){str += &quot;#&quot; + a[i].id;}
+      }else{ str = a[i]; }
+      r.push( str );
+    }
+  }
+	return &quot;[ &quot; + r.join(&quot;, &quot;) + &quot; ]&quot;;
 }
 
 /**</diff>
      <filename>test/testrunner.js</filename>
    </modified>
    <modified>
      <diff>@@ -44,11 +44,8 @@ test(&quot;jQuery()&quot;, function() {
 
 	// can actually yield more than one, when iframes are included, the window is an array as well
 	equals( jQuery(window).length, 1, &quot;Correct number of elements generated for window&quot; );
-
 	equals( jQuery(document).length, 1, &quot;Correct number of elements generated for document&quot; );
-
 	equals( jQuery([1,2,3]).get(1), 2, &quot;Test passing an array to the factory&quot; );
-
 	equals( jQuery(document.body).get(0), jQuery('body').get(0), &quot;Test passing an html node to the factory&quot; );
 });
 
@@ -239,6 +236,7 @@ test(&quot;jQuery(selector, xml).text(str) - Loaded via XML document&quot;, function() {
 
 test(&quot;length&quot;, function() {
 	expect(1);
+	print(jQuery(&quot;p&quot;).length);
 	equals( jQuery(&quot;p&quot;).length, 6, &quot;Get Number of Elements Found&quot; );
 });
 </diff>
      <filename>test/unit/core.js</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>src/cookie.js</filename>
    </removed>
    <removed>
      <filename>src/css.js</filename>
    </removed>
    <removed>
      <filename>src/dialog.js</filename>
    </removed>
    <removed>
      <filename>src/document.js</filename>
    </removed>
    <removed>
      <filename>src/dom.js</filename>
    </removed>
    <removed>
      <filename>src/event.js</filename>
    </removed>
    <removed>
      <filename>src/history.js</filename>
    </removed>
    <removed>
      <filename>src/html.js</filename>
    </removed>
    <removed>
      <filename>src/htmlparser.js</filename>
    </removed>
    <removed>
      <filename>src/location.js</filename>
    </removed>
    <removed>
      <filename>src/navigator.js</filename>
    </removed>
    <removed>
      <filename>src/screen.js</filename>
    </removed>
    <removed>
      <filename>src/timer.js</filename>
    </removed>
    <removed>
      <filename>src/uievent.js</filename>
    </removed>
    <removed>
      <filename>src/window.js</filename>
    </removed>
    <removed>
      <filename>src/xhr.js</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f208815b608977a619d44084d3fca150f919260e</id>
    </parent>
  </parents>
  <author>
    <name>thatcher</name>
    <email>thatcher.christopher@gmail.com</email>
  </author>
  <url>http://github.com/thatcher/env-js/commit/fe3f7052fc4355e42507fffca8fbaa02d59a0eb2</url>
  <id>fe3f7052fc4355e42507fffca8fbaa02d59a0eb2</id>
  <committed-date>2008-11-17T22:09:03-08:00</committed-date>
  <authored-date>2008-11-17T22:09:03-08:00</authored-date>
  <message>theres a hole in the bucket</message>
  <tree>d869a03dc0a259525c6ab1d358eb0d381442cbbc</tree>
  <committer>
    <name>thatcher</name>
    <email>thatcher.christopher@gmail.com</email>
  </committer>
</commit>
