<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>vendor/plugins/blue-ridge/lib/env-js.jar</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -8,7 +8,7 @@ The Blue Ridge JavaScript Testing Rails Plugin adds support for command-line and
 * `Smoke` - a JavaScript mocking &amp; stubbing library similar to Mocha
 * `env.js` - a DOM implementation written entirely in JavaScript
 
-Please join our [mailing list](http://groups.google.com/group/blueridgejs) if you're interested in Blue Ridge!
+Please join our [mailing list](http://groups.google.com/group/blueridgejs) if you're interested in Blue Ridge!  Also, check out if our build is broken (it'd better NOT be!) on [RunCodeRun](http://runcoderun.com/relevance/blue-ridge).
 
 Installing and Running
 ----------------------
@@ -209,6 +209,7 @@ Links
 * [Blue Ridge JavaScript Testing Rails Plugin](http://github.com/relevance/blue-ridge)
 * [Blue Ridge Sample App](http://github.com/relevance/blue-ridge-sample-app)
 * [Mailing List](http://groups.google.com/group/blueridgejs)
+* [Blue Ridge Build Status on RunCodeRun](http://runcoderun.com/relevance/blue-ridge)
 * [Justin Gehtland's &quot;Fully Headless JSSpec&quot; Blog Post](http://blog.thinkrelevance.com/2008/7/31/fully-headless-jsspec)
 * [Screw.Unit](http://github.com/nkallen/screw-unit)
 * [Screw.Unit Mailing List](http://groups.google.com/group/screw-unit)</diff>
      <filename>vendor/plugins/blue-ridge/README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module BlueRidge
   end
   
   def self.rhino_command
-    &quot;java -Dblue.ridge.prefix=\&quot;#{plugin_prefix}\&quot; -jar #{plugin_prefix}/lib/js.jar -w -debug&quot;
+    &quot;java -Dblue.ridge.prefix=\&quot;#{plugin_prefix}\&quot; -jar #{plugin_prefix}/lib/env-js.jar -w -debug&quot;
   end
   
   def self.test_runner_command</diff>
      <filename>vendor/plugins/blue-ridge/lib/blue_ridge.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,32 +1,55 @@
 /*
+ * Envjs env-js.1.0.rc5 
+ * Pure JavaScript Browser Environment
+ *   By John Resig &lt;http://ejohn.org/&gt;
+ * Copyright 2008-2009 John Resig, under the MIT License
+ */
+/**
+ * @author thatcher
+ */
+var Envjs = function(){
+    if(arguments.length === 2){
+        for ( var i in arguments[1] ) {
+    		var g = arguments[1].__lookupGetter__(i), 
+                s = arguments[1].__lookupSetter__(i);
+    		if ( g || s ) {
+    			if ( g ) Envjs.__defineGetter__(i, g);
+    			if ( s ) Envjs.__defineSetter__(i, s);
+    		} else
+    			Envjs[i] = arguments[1][i];
+    	}
+    }
+    window.location = arguments[0];
+};
+
+/*
 *	env.rhino.js
 */
-var __env__ = {};
 (function($env){
     
     //You can emulate different user agents by overriding these after loading env
-    $env.appCodeName  = &quot;EnvJS&quot;;//eg &quot;Mozilla&quot;
+    $env.appCodeName  = &quot;Envjs&quot;;//eg &quot;Mozilla&quot;
     $env.appName      = &quot;Resig/20070309 BirdDog/0.0.0.1&quot;;//eg &quot;Gecko/20070309 Firefox/2.0.0.3&quot;
 
     //set this to true and see profile/profile.js to select which methods
     //to profile
     $env.profile = false;
     
-    $env.log = function(msg, level){
-         print(' '+ (level?level:'LOG') + ':\t['+ new Date()+&quot;] {ENVJS} &quot;+msg);
-    };
+    $env.log = function(msg, level){};
     $env.debug  = function(){};
     $env.info   = function(){};
     $env.warn   = function(){};
     $env.error  = function(){};
     
+    
+    $env.debugParser = false;
     //uncomment these if you want to get some internal log statementes
     /*$env.debug  = function(msg){
         $env.log(msg,&quot;DEBUG&quot;); 
-    };
+    };*/
     $env.info   = function(msg){
         $env.log(msg,&quot;INFO&quot;); 
-    };*/
+    };
     $env.warn   = function(msg){
         $env.log(msg,&quot;WARNIING&quot;);    
     };
@@ -35,7 +58,208 @@ var __env__ = {};
         $env.log(e||&quot;&quot;,'ERROR');
     };
     
-    $env.info(&quot;Initializing Rhino Platform Env&quot;);
+    $env.info(&quot;Initializing Core Platform Env&quot;);
+    
+    $env.lineSource = function(e){};
+    
+    $env.hashCode = function(obj){};
+    
+    //resolves location relative to base or window location
+    $env.location = function(path, base){};
+    
+    //For Java the window.timer is created using the java.lang.Thread in combination
+    //with the java.lang.Runnable
+    $env.timer = function(fn, time){};	
+    $env.wait = function(wait){};
+    
+    $env.javaEnabled = false;	
+    
+    //Used in the XMLHttpRquest implementation to run a
+    // request in a seperate thread
+    $env.runAsync = function(fn){};
+    
+    //Used to write to a local file
+    $env.writeToFile = function(text, url){};
+    
+    //Used to write to a local file
+    $env.writeToTempFile = function(text, suffix){};
+    
+    //Used to delete a local file
+    $env.deleteFile = function(url){};
+    
+    $env.connection = function(xhr, responseHandler, data){};
+    
+    $env.parseHTML = function(htmlstring){};
+    $env.parseXML = function(xmlstring){};
+    $env.xpath = function(expression, doc){};
+    
+    $env.tmpdir         = ''; 
+    $env.os_name        = ''; 
+    $env.os_arch        = ''; 
+    $env.os_version     = ''; 
+    $env.lang           = ''; 
+    $env.platform       = &quot;Rhino &quot;;//how do we get the version
+    
+    $env.load = function(){};
+    
+    $env.safeScript = function(){
+      //do nothing  
+    };
+    
+    $env.scriptTypes = {
+        &quot;text/javascript&quot;   :false,
+        &quot;text/envjs&quot;        :true
+    };
+    
+    $env.onScriptLoadError = function(){};
+    $env.loadLocalScript = function(script, parser){
+        $env.debug(&quot;loading script &quot;);
+        var types, type, src, i, base, 
+            docWrites = [],
+            write = document.write,
+            writeln = document.writeln;
+        //temporarily replace document write becuase the function
+        //has a different meaning during parsing
+        document.write = function(text){
+			docWrites.push(text);
+		};
+        try{
+			if(script.type){
+                types = script.type?script.type.split(&quot;;&quot;):[];
+                for(i=0;i&lt;types.length;i++){
+                    if($env.scriptTypes[types[i]]){
+						if(script.src){
+                            $env.info(&quot;loading allowed external script :&quot; + script.src);
+                            //lets you register a function to execute 
+                            //before the script is loaded
+                            if($env.beforeload){
+                                for(src in $env.beforeload){
+                                    if(script.src.match(src)){
+                                        $env.beforeload[src]();
+                                    }
+                                }
+                            }
+                            base = &quot;&quot; + window.location;
+							load($env.location(script.src.match(/([^\?#]*)/)[1], base ));
+                            //lets you register a function to execute 
+                            //after the script is loaded
+                            if($env.afterload){
+                                for(src in $env.afterload){
+                                    if(script.src.match(src)){
+                                        $env.afterload[src]();
+                                    }
+                                }
+                            }
+                        }else{
+                            $env.loadInlineScript(script);
+                        }
+                    }else{
+                        if(!script.src &amp;&amp; script.type == &quot;text/javascript&quot;){
+                            $env.loadInlineScript(script);
+                        }
+                    }
+                }
+            }else{
+                //anonymous type and anonymous src means inline
+                if(!script.src){
+                    $env.loadInlineScript(script);
+                }
+            }
+        }catch(e){
+            $env.error(&quot;Error loading script.&quot;, e);
+            $env.onScriptLoadError(script);
+        }finally{
+            if(parser){
+                parser.appendFragment(docWrites.join(''));
+			}
+			//return document.write to it's non-script loading form
+            document.write = write;
+            document.writeln = writeln;
+        }
+    };
+    
+    $env.loadInlineScript = function(script){};
+    
+    
+    $env.globalize = function(){};
+    $env.getScope = function(){};
+    $env.setScope = function(){};
+    $env.configureScope = function(){};
+    $env.restoreScope = function(){};
+    $env.loadFrame = function(frame, url){
+        try {
+
+            var frameWindow,
+            	makingNewWinFlag = !(frame._content);
+            if (makingNewWinFlag)
+                // a blank object, inherits from original global
+                // see org.mozilla.javascript.tools.envjs.Window.java
+                frameWindow = $env.globalize();
+            else
+                frameWindow = frame._content;
+
+
+            // define local variables with content of things that are
+            // in current global/window, because when the following
+            // function executes we'll have a new/blank
+            // global/window and won't be able to get at them....
+            var local__window__    = $env.window,
+            	local_env          = $env,
+                local_window       = frame.ownerDocument.parentWindow;
+
+            // a local function gives us something whose scope
+            // is easy to change
+            var __frame__   = function(){
+                if (makingNewWinFlag){
+                    local__window__(frameWindow, 
+                                    local_env,
+                                    local_window,
+                                    local_window.top);
+                }
+
+                frameWindow.location = url;
+            }
+
+
+            // change scope of window object creation
+            //   functions, so that functions/code they create
+            //   will be scoped to new window object
+            // getScope()/setScope() from Window.java
+            var scopes = {
+                frame : $env.getScope(__frame__),
+                window : $env.getScope(local__window__),
+                global_load: $env.getScope(load),
+                local_load: $env.getScope($env.loadLocalScript)
+            };
+
+            $env.setScope(__frame__,             frameWindow);
+            $env.setScope(local__window__,       frameWindow);
+            $env.setScope($env.load,             frameWindow);
+            $env.setScope($env.loadLocalScript,  frameWindow);
+
+            __frame__();
+            frame._content = frameWindow;
+
+            // now restore the scope
+            $env.setScope(__frame__, scopes.frame);
+            $env.setScope(local__window__, scopes.window);
+            $env.setScope($env.load, scopes.global_load);
+            $env.setScope($env.loadLocalScript, scopes.local_load);
+            
+        } catch(e){
+            $env.error(&quot;failed to load frame content: from &quot; + url, e);
+        }
+
+    };
+    
+})(Envjs);/*
+*	env.rhino.js
+*/
+(function($env){
+    
+    $env.log = function(msg, level){
+         print(' '+ (level?level:'LOG') + ':\t['+ new Date()+&quot;] {ENVJS} &quot;+msg);
+    };
     
     $env.lineSource = function(e){
         return e&amp;&amp;e.rhinoException?e.rhinoException.lineSource():&quot;(line ?)&quot;;
@@ -64,20 +288,40 @@ var __env__ = {};
         }
     };
     
+    var timers = [];
+
     //For Java the window.timer is created using the java.lang.Thread in combination
     //with the java.lang.Runnable
     $env.timer = function(fn, time){
-        //$env.debug(&quot;wating for timer &quot;+time);
-        return new java.lang.Thread(new java.lang.Runnable({
+       var running = true;
+        
+        var run = sync(function(){ //while happening only thing in this timer    
+    	    //$env.debug(&quot;running timed function&quot;);
+            fn();
+        });
+        var _this = this;
+        var thread = new java.lang.Thread(new java.lang.Runnable({
             run: function(){
-                while (true){
-                    java.lang.Thread.currentThread().sleep(time);
-                    //$env.debug(&quot;calling in timer &quot;+time);
-                    fn();
-                }
+                try {
+                    while (running){
+                        java.lang.Thread.currentThread().sleep(time);
+                        run.apply(_this);
+                    }
+                }catch(e){
+                    $env.debug(&quot;interuption running timed function&quot;);
+                    _this.stop();
+                    $env.onInterrupt();
+                };
             }
         }));
-    };	
+        this.start = function(){ 
+            thread.start(); 
+        };
+        this.stop = sync(function(num){
+            running = false;
+            thread.interrupt();
+        })
+    };
     
     //Since we're running in rhino I guess we can safely assume
     //java is 'enabled'.  I'm sure this requires more thought
@@ -87,11 +331,27 @@ var __env__ = {};
     
     //Used in the XMLHttpRquest implementation to run a
     // request in a seperate thread
+    $env.onInterrupt = function(){};
     $env.runAsync = function(fn){
         $env.debug(&quot;running async&quot;);
-        (new java.lang.Thread(new java.lang.Runnable({
-            run: fn
-        }))).start();
+        var running = true;
+        
+        var run = sync(function(){ //while happening only thing in this timer    
+    	    //$env.debug(&quot;running timed function&quot;);
+            fn();
+        });
+        
+        var async = (new java.lang.Thread(new java.lang.Runnable({
+            run: run
+        })));
+        
+        try{
+            async.start();
+        }catch(e){
+            $env.error(&quot;error while running async&quot;, e);
+            async.interrupt();
+            $env.onInterrupt();
+        }
     };
     
     //Used to write to a local file
@@ -127,64 +387,121 @@ var __env__ = {};
         file[&quot;delete&quot;]();
     };
     
-    $env.connection = function(xhr, responseHandler){
+    $env.connection = function(xhr, responseHandler, data){
         var url = java.net.URL(xhr.url);//, $w.location);
       var connection;
         if ( /^file\:/.test(url) ) {
-            if ( xhr.method == &quot;PUT&quot; ) {
-                var text =  data || &quot;&quot; ;
-                $env.writeToFile(text, url);
-            } else if ( xhr.method == &quot;DELETE&quot; ) {
-                $env.deleteFile(url);
-            } else {
-                connection = url.openConnection();
-                connection.connect();
+            try{
+                if ( xhr.method == &quot;PUT&quot; ) {
+                    var text =  data || &quot;&quot; ;
+                    $env.writeToFile(text, url);
+                } else if ( xhr.method == &quot;DELETE&quot; ) {
+                    $env.deleteFile(url);
+                } else {
+                    connection = url.openConnection();
+                    connection.connect();
+                    //try to add some canned headers that make sense
+                    
+                    try{
+                        if(xhr.url.match(/html$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/html';
+                        }else if(xhr.url.match(/.xml$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/xml';
+                        }else if(xhr.url.match(/.js$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/javascript';
+                        }else if(xhr.url.match(/.json$/)){
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'application/json';
+                        }else{
+                            xhr.responseHeaders[&quot;Content-Type&quot;] = 'text/plain';
+                        }
+                    //xhr.responseHeaders['Last-Modified'] = connection.getLastModified();
+                    //xhr.responseHeaders['Content-Length'] = headerValue+'';
+                    //xhr.responseHeaders['Date'] = new Date()+'';*/
+                    }catch(e){
+                        $env.error('failed to load response headers',e);
+                    }
+                    	
+                }
+            }catch(e){
+                $env.error('failed to open file '+ url, e);
+                connection = null;
+                xhr.readyState = 4;
+                xhr.statusText = &quot;Local File Protocol Error&quot;;
+                xhr.responseText = &quot;&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&quot;+ e+ &quot;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
             }
         } else { 
             connection = url.openConnection();
             connection.setRequestMethod( xhr.method );
-            
+			
             // Add headers to Java connection
             for (var header in xhr.headers){
                 connection.addRequestProperty(header+'', xhr.headers[header]+'');
-          }connection.connect();
-            
-            // Stick the response headers into responseHeaders
-            for (var i = 0; ; i++) { 
-                var headerName = connection.getHeaderFieldKey(i); 
-                var headerValue = connection.getHeaderField(i); 
-                if (!headerName &amp;&amp; !headerValue) break; 
-                if (headerName)
-                    xhr.responseHeaders[headerName+''] = headerValue+'';
             }
+			
+			//write data to output stream if required
+            if(data&amp;&amp;data.length&amp;&amp;data.length&gt;0){
+				 if ( xhr.method == &quot;PUT&quot; || xhr.method == &quot;POST&quot; ) {
+                	connection.setDoOutput(true);
+					var outstream = connection.getOutputStream(),
+						outbuffer = new java.lang.String(data).getBytes('UTF-8');
+					
+                    outstream.write(outbuffer, 0, outbuffer.length);
+					outstream.close();
+            	}
+			}else{
+		  		connection.connect();
+			}
+			
+            
         }
         if(connection){
-                xhr.readyState = 4;
-                xhr.status = parseInt(connection.responseCode,10) || undefined;
-                xhr.statusText = connection.responseMessage || &quot;&quot;;
-                
-                var contentEncoding = connection.getContentEncoding() || &quot;utf-8&quot;,
-                    stream = (contentEncoding.equalsIgnoreCase(&quot;gzip&quot;) || contentEncoding.equalsIgnoreCase(&quot;decompress&quot;) )?
-                            new java.util.zip.GZIPInputStream(connection.getInputStream()) :
-                            connection.getInputStream(),
-                    baos = new java.io.ByteArrayOutputStream(),
+            try{
+                var respheadlength = connection.getHeaderFields().size();
+                // Stick the response headers into responseHeaders
+                for (var i = 0; i &lt; respheadlength; i++) { 
+                    var headerName = connection.getHeaderFieldKey(i); 
+                    var headerValue = connection.getHeaderField(i); 
+                    if (headerName)
+                        xhr.responseHeaders[headerName+''] = headerValue+'';
+                }
+            }catch(e){
+                $env.error('failed to load response headers',e);
+            }
+            
+            xhr.readyState = 4;
+            xhr.status = parseInt(connection.responseCode,10) || undefined;
+            xhr.statusText = connection.responseMessage || &quot;&quot;;
+            
+            var contentEncoding = connection.getContentEncoding() || &quot;utf-8&quot;,
+                baos = new java.io.ByteArrayOutputStream(),
                 buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024),
-                    length,
-                    responseXML = null;
+                length,
+                stream = null,
+                responseXML = null;
 
-                while ((length = stream.read(buffer)) != -1) {
-                    baos.write(buffer, 0, length);
-                }
+            try{
+                stream = (contentEncoding.equalsIgnoreCase(&quot;gzip&quot;) || contentEncoding.equalsIgnoreCase(&quot;decompress&quot;) )?
+                        new java.util.zip.GZIPInputStream(connection.getInputStream()) :
+                        connection.getInputStream();
+            }catch(e){
+                $env.error('failed to open connection stream \n'+e.toString(), e);
+                stream = connection.getErrorStream();
+            }
+            
+            while ((length = stream.read(buffer)) != -1) {
+                baos.write(buffer, 0, length);
+            }
 
-                baos.close();
-                stream.close();
+            baos.close();
+            stream.close();
 
-                xhr.responseText = java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
-                    decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
+            xhr.responseText = java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
+                decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
                 
         }
         if(responseHandler){
-          responseHandler();
+            $env.debug('calling ajax response handler');
+            responseHandler();
         }
     };
     
@@ -192,27 +509,90 @@ var __env__ = {};
     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;)))+&quot;&quot;;
+    var htmlCleaner,
+        cleanXMLSerializer,
+        cleanerProperties,
+        htmlTransformer,
+        htmlOutputProps;
+    $env.fixHTML = false;
+    $env.cleanHTML = function(xmlString){
+        var htmlString;
+        $env.debug('Cleaning html :\n'+xmlString);
+        if(!htmlCleaner){
+            cleanerProperties = new org.htmlcleaner.CleanerProperties();
+            cleanerProperties.setOmitHtmlEnvelope(true);
+            cleanerProperties.setTranslateSpecialEntities(true);
+            cleanerProperties.setAdvancedXmlEscape(true);
+            cleanerProperties.setUseCdataForScriptAndStyle(false);
+            cleanerProperties.setOmitXmlDeclaration(true);
+            htmlCleaner = new org.htmlcleaner.HtmlCleaner(cleanerProperties);
+            cleanXMLSerializer = new org.htmlcleaner.SimpleXmlSerializer(cleanerProperties);
+            //may have been initialized in $env.xslt
+            /*transformerFactory = transformerFactory||
+                Packages.javax.xml.transform.TransformerFactory.newInstance();
+            htmlTransformer = transformerFactory.newTransformer();
+            htmlOutputProps = new java.util.Properties();
+            htmlOutputProps.put(javax.xml.transform.OutputKeys.METHOD, &quot;xml&quot;);
+            htmlOutputProps.put(javax.xml.transform.OutputKeys.INDENT , &quot;no&quot;);
+            htmlOutputProps.put(javax.xml.transform.OutputKeys.ENCODING  , &quot;UTF-8&quot;);
+            htmlOutputProps.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION  , &quot;yes&quot;);
+            htmlTransformer.setOutputProperties(htmlOutputProps)*/
+        }
+        
+        /*var node = cleanXMLSerializer.createDOM(htmlCleaner.clean(xmlString)),
+            outText = new java.io.StringWriter();
+        htmlTransformer.transform(
+            new javax.xml.transform.dom.DOMSource(node),
+            new javax.xml.transform.stream.StreamResult(outText));
+            
+        htmlString = outText.toString()+'';*/
+        htmlString = cleanXMLSerializer.getXmlAsString(htmlCleaner.clean(xmlString));
+        //$env.info('Cleaned html :\n'+htmlString);
+        return htmlString;
     };
     
     var xmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
     xmlDocBuilder.setNamespaceAware(true);
-    xmlDocBuilder.setValidating(true);
+    xmlDocBuilder.setValidating(false);
     
     $env.parseXML = function(xmlstring){
         return xmlDocBuilder.newDocumentBuilder().parse(
                   new java.io.ByteArrayInputStream(
-                        (new java.lang.String(xmlstring)).getBytes(&quot;UTF8&quot;)))+&quot;&quot;;
+                        (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);
+        return Packages.javax.xml.xpath.
+          XPathFactory.newInstance().newXPath().
+            evaluate(expression, doc, javax.xml.xpath.XPathConstants.NODESET);
+    };
+    
+    var jsonmlxslt;
+    $env.jsonml = function(xmlstring){
+        jsonmlxslt = jsonmlxslt||$env.xslt($env.xml2jsonml.toXMLString());
+        var jsonml = $env.xslttransform(jsonmlxslt, xmlstring);
+        //$env.debug('jsonml :\n'+jsonml);
+        return eval(jsonml);
+    };
+    var transformerFactory;
+    $env.xslt = function(xsltstring){
+        transformerFactory = transformerFactory||
+            Packages.javax.xml.transform.TransformerFactory.newInstance();
+        return transformerFactory.newTransformer(
+              new javax.xml.transform.dom.DOMSource(
+                  $env.parseXML(xsltstring)
+              )
+          );
+    };
+    $env.xslttransform = function(xslt, xmlstring){
+        var baos = new java.io.ByteArrayOutputStream();
+        xslt.transform(
+            new javax.xml.transform.dom.DOMSource($env.parseHTML(xmlstring)),
+            new javax.xml.transform.stream.StreamResult(baos)
+        );
+        return java.nio.charset.Charset.forName(&quot;UTF-8&quot;).
+            decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+&quot;&quot;;
     };
     
     $env.tmpdir         = java.lang.System.getProperty(&quot;java.io.tmpdir&quot;); 
@@ -221,7 +601,10 @@ var __env__ = {};
     $env.os_version     = java.lang.System.getProperty(&quot;os.version&quot;); 
     $env.lang           = java.lang.System.getProperty(&quot;user.lang&quot;); 
     $env.platform       = &quot;Rhino &quot;;//how do we get the version
-    
+
+    //injected by org.mozilla.javascript.tools.envjs.
+    $env.load = load;
+
     $env.safeScript = function(){
       //do nothing  
     };
@@ -231,87 +614,42 @@ var __env__ = {};
         &quot;text/envjs&quot;        :true
     };
     
-    $env.loadLocalScript = function(script, parser){
-        $env.debug(&quot;loading script &quot;);
-        var types, type, src, i, base, 
-            docWrites = [],
-            write = document.write,
-            writeln = document.writeln;
-        //temporarily replace document write becuase the function
-        //has a different meaning during parsing
-        document.write = function(text){
-			docWrites.push(text);
-		};
-        try{
-			if(script.type){
-                types = script.type?script.type.split(&quot;;&quot;):[];
-                for(i=0;i&lt;types.length;i++){
-                    if($env.scriptTypes[types[i]]){
-						if(script.src){
-                            $env.info(&quot;loading allowed external script :&quot; + script.src);
-                            base = &quot;&quot; + window.location;
-							load($env.location(script.src.match(/([^\?#]*)/)[1], base ));
-                        }else{
-                            $env.loadInlineScript(script);
-                        }
-                    }else{
-                        if(!script.src &amp;&amp; script.type == &quot;text/javascript&quot;){
-                            $env.loadInlineScript(script);
-                        }
-                    }
-                }
-            }else{
-                //anonymous type and anonymous src means inline
-                if(!script.src){
-                    $env.loadInlineScript(script);
-                }
-            }
-        }catch(e){
-            $env.error(&quot;Error loading script.&quot;, e);
-        }finally{
-            if(parser){
-                parser.appendFragment(docWrites.join(''));
-			}
-			//return document.write to it's non-script loading form
-            document.write = write;
-            document.writeln = writeln;
-        }
-    };
     
     $env.loadInlineScript = function(script){
-        $env.debug(&quot;loading inline script :&quot; + script.text);
         var tmpFile = $env.writeToTempFile(script.text, 'js') ;
-        $env.info(&quot;loading &quot; + tmpFile);
-        load(tmpFile);
+        $env.debug(&quot;loading &quot; + tmpFile);
+        $env.load(tmpFile);
     };
     
-})(__env__);/*
-*	policy.js
-*/
-var __policy__ = {};
-(function($policy, $env){
+    //injected by org.mozilla.javascript.tools.envjs.
+    $env.globalize = globalize;
+    $env.getScope = getScope;
+    $env.setScope = setScope;
+    $env.configureScope = configureScope;
+    $env.restoreScope = restoreScope;
     
-    //you can change these to $env.safeScript to avoid loading scripts
-    //or change to $env.loadLocalScripts to load local scripts
-    $policy.loadScript    = $env.safeScript;
-    // $policy.loadScript    = $env.loadLocalScript;
-    
-})(__policy__, __env__);/*
+})(Envjs);/*
+ * Envjs env-js.1.0.rc5 
  * Pure JavaScript Browser Environment
  *   By John Resig &lt;http://ejohn.org/&gt;
- * Copyright 2008 John Resig, under the MIT License
+ * Copyright 2008-2009 John Resig, under the MIT License
  */
 
 
-// The Window Object
-var __this__ = this;
-this.__defineGetter__('window', function(){
-  return __this__;
-});
+try {
+        
+    Envjs.window = function($w, 
+                            $env,
+                            $parentWindow,
+                            $initTop){
 
-try{
-(function($w, $env, $policy){
-        /*
+    // The Window Object
+    var __this__ = $w;
+    $w.__defineGetter__('window', function(){
+        return __this__;
+    });
+
+/*
 *	window.js
 *   - this file will be wrapped in a closure providing the window object as $w
 */
@@ -344,7 +682,8 @@ var $defaultStatus = &quot;Done&quot;;
 var $event = null;
 
 //A read-only array of window objects
-var $frames = [];
+//var $frames = [];    // TODO: since window.frames can be accessed like a
+                       //   hash, will need an object to really implement
 
 // a read-only reference to the History object
 /**&gt;  $history - see location.js &lt;**/
@@ -355,9 +694,9 @@ var $innerHeight = 600, $innerWidth = 800;
 // a read-only reference to the Location object.  the location object does expose read/write properties
 /**&gt; $location - see location.js &lt;**/
 
-// a read only property specifying the name of the window.  Can be set when using open()
-// and may be used when specifying the target attribute of links
-var $name = 'Resig Env Browser';
+// The name of window/frame.  Set directly, when using open(), or in frameset.
+// May be used when specifying the target attribute of links
+var $name;
 
 // a read-only reference to the Navigator object
 /**&gt; $navigator - see navigator.js &lt;**/
@@ -379,28 +718,24 @@ var $pageXOffset = 0, $pageYOffset = 0;
 //A read-only reference to the Window object that contains this window or frame.  If the window is
 // a top-level window, parent refers to the window itself.  If this window is a frame, this property
 // refers to the window or frame that conatins it.
-var $parent;
+var $parent = $parentWindow;
 
 // a read-only refernce to the Screen object that specifies information about the screen: 
 // the number of available pixels and the number of available colors.
 /**&gt; $screen - see screen.js &lt;**/
-
 // read only properties that specify the coordinates of the upper-left corner of the screen.
 var $screenX = 0, $screenY = 0;
 var $screenLeft = $screenX, $screenTop = $screenY;
 
-// a read-only refernce to this window itself.
-var $self;
-
 // a read/write string that specifies the current contents of the status line.
 var $status = '';
 
 // a read-only reference to the top-level window that contains this window.  If this
 // window is a top-level window it is simply a refernce to itself.  If this window 
 // is a frame, the top property refers to the top-level window that contains the frame.
-var $top;
+var $top = $initTop;
 
-// the window property is identical to the self property.
+// the window property is identical to the self property and to this obj
 var $window = $w;
 
 $debug(&quot;Initializing Window.&quot;);
@@ -410,7 +745,10 @@ __extend__($w,{
   set defaultStatus(_defaultStatus){$defaultStatus = _defaultStatus;},
   //get document(){return $document;}, - see document.js
   get event(){return $event;},
-  get frames(){return $frames;},
+
+  get frames(){return undefined;}, // TODO: not yet any code to maintain list
+  get length(){return undefined;}, //   should be frames.length, but.... TODO
+
   //get history(){return $history;}, - see location.js
   get innerHeight(){return $innerHeight;},
   get innerWidth(){return $innerWidth;},
@@ -418,6 +756,7 @@ __extend__($w,{
   get clientWidth(){return $innerWidth;},
   //get location(){return $location;}, see location.js
   get name(){return $name;},
+  set name(newName){ $name = newName; },
   //get navigator(){return $navigator;}, see navigator.js
   get opener(){return $opener;},
   get outerHeight(){return $outerHeight;},
@@ -430,7 +769,7 @@ __extend__($w,{
   get screenTop(){return $screenTop;},
   get screenX(){return $screenX;},
   get screenY(){return $screenY;},
-  get self(){return $self;},
+  get self(){return $window;},
   get status(){return $status;},
   set status(_status){$status = _status;},
   get top(){return $top || $window;},
@@ -438,11 +777,11 @@ __extend__($w,{
 });
 
 $w.open = function(url, name, features, replace){
-  //TODO
+  //TODO.  Remember to set $opener, $name
 };
 
 $w.close = function(){
-  //TODO
+  //TODO.  Remember to set $closed
 };     
   
 /* Time related functions - see timer.js
@@ -530,17 +869,12 @@ function __setArray__( target, array ) {
 	target.length = 0;
 	Array.prototype.push.apply( target, array );
 };
+
+
 $debug(&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;);
-  };
-});
-
-
 /**
  * @class  DOMNodeList - provides the abstraction of an ordered collection of nodes
  *
@@ -631,8 +965,7 @@ var __findItemIndex__ = function (nodelist, id) {
  * @param  refChildIndex : int     - the array index to insert the Node before
  */
 var __insertBefore__ = function(nodelist, newChild, refChildIndex) {
-    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt; nodelist.length)) { // bounds check
-        
+    if ((refChildIndex &gt;= 0) &amp;&amp; (refChildIndex &lt;= nodelist.length)) { // bounds check
         if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) {  // node is a DocumentFragment
             // append the children of DocumentFragment
             Array.prototype.splice.apply(nodelist,[refChildIndex, 0].concat(newChild.childNodes.toArray()));
@@ -732,6 +1065,7 @@ var __cloneNodes__ = function(nodelist, deep, parentNode) {
     return cloneNodeList;
 };
 
+$w.NodeList = DOMNodeList;
 
 /**
  * @class  DOMNamedNodeMap - used to represent collections of nodes that can be accessed by name
@@ -794,12 +1128,12 @@ __extend__(DOMNamedNodeMap.prototype, {
               throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
             } else {
               this[itemIndex] = arg;                // over-write existing NamedNode
-              this[arg.name] = arg;
+              this[arg.name.toLowerCase()] = arg;
             }
       } else {
             // add new NamedNode
             Array.prototype.push.apply(this, [arg]);
-            this[arg.name] = arg;
+            this[arg.name.toLowerCase()] = arg;
       }
     
       arg.ownerElement = this.parentNode;            // update ownerElement
@@ -947,12 +1281,12 @@ var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
   for (var i=0; i&lt;namednodemap.length; i++) {
     // compare name to each node's nodeName
     if(isnsmap){
-        if (namednodemap[i].localName == localName) {         // found it!
+        if (namednodemap[i].localName.toLowerCase() == name.toLowerCase()) {         // found it!
           ret = i;
           break;
         }
     }else{
-        if (namednodemap[i].name == name) {         // found it!
+        if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {         // found it!
           ret = i;
           break;
         }
@@ -978,7 +1312,8 @@ var __findNamedItemNSIndex__ = function(namednodemap, namespaceURI, localName) {
     // loop through all nodes
     for (var i=0; i&lt;namednodemap.length; i++) {
       // compare name to each node's namespaceURI and localName
-      if ((namednodemap[i].namespaceURI == namespaceURI) &amp;&amp; (namednodemap[i].localName == localName)) {
+      if ((namednodemap[i].namespaceURI.toLowerCase() == namespaceURI.toLowerCase()) &amp;&amp; 
+          (namednodemap[i].localName.toLowerCase() == localName.toLowerCase())) {
         ret = i;                                 // found it!
         break;
       }
@@ -1099,22 +1434,6 @@ $debug(&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
-	});
-});
-
 /**
  * @class  DOMNode - The Node interface is the primary datatype for the entire Document Object Model.
  *   It represents a single node in the document tree.
@@ -1131,8 +1450,8 @@ var DOMNode = function(ownerDocument) {
   this.localName    = &quot;&quot;;                        // The localName of this node (Level 2)
 
   this.nodeName = &quot;&quot;;                            // The name of this node
-  this.nodeValue = &quot;&quot;;                           // The value of this node
-  this.className = &quot;&quot;;                           // The CSS class name of this node.
+  this.nodeValue = null;                           // The value of this node
+  //this.className = &quot;&quot;;                           // The CSS class name of this node.
   
   // The parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent.
   // However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null
@@ -1181,6 +1500,14 @@ __extend__(DOMNode.prototype, {
     insertBefore : function(newChild, refChild) {
         var prevNode;
         
+        if(newChild==null){
+            return newChild;
+        }
+        if(refChild==null){
+            this.appendChild(newChild);
+            return this.newChild;
+        }
+        
         // test for exceptions
         if (__ownerDocument__(this).implementation.errorChecking) {
             // throw Exception if DOMNode is readonly
@@ -1202,7 +1529,6 @@ __extend__(DOMNode.prototype, {
         if (refChild) {                                // if refChild is specified, insert before it
             // find index of refChild
             var itemIndex = __findItemIndex__(this.childNodes, refChild._id);
-            
             // throw Exception if there is no child node with this id
             if (__ownerDocument__(this).implementation.errorChecking &amp;&amp; (itemIndex &lt; 0)) {
               throw(new DOMException(DOMException.NOT_FOUND_ERR));
@@ -1216,8 +1542,7 @@ __extend__(DOMNode.prototype, {
             }
             
             // insert newChild into childNodes
-            __insertBefore__(this.childNodes, newChild, 
-                __findItemIndex__(this.childNodes, refChild._id));
+            __insertBefore__(this.childNodes, newChild, itemIndex);
             
             // do node pointer surgery
             prevNode = refChild.previousSibling;
@@ -1237,6 +1562,7 @@ __extend__(DOMNode.prototype, {
                 newChild.parentNode = this;                // set the parentNode of the newChild
                 refChild.previousSibling = newChild;       // link refChild to newChild
             }
+            
         }else {                                         // otherwise, append to end
             prevNode = this.lastChild;
             this.appendChild(newChild);
@@ -1271,6 +1597,10 @@ __extend__(DOMNode.prototype, {
     replaceChild : function(newChild, oldChild) {
         var ret = null;
         
+        if(newChild==null || oldChild==null){
+            return oldChild;
+        }
+        
         // test for exceptions
         if (__ownerDocument__(this).implementation.errorChecking) {
             // throw Exception if DOMNode is readonly
@@ -1350,6 +1680,9 @@ __extend__(DOMNode.prototype, {
         return ret;
     },
     removeChild : function(oldChild) {
+        if(!oldChild){
+            return null;
+        }
         // throw Exception if DOMNamedNodeMap is readonly
         if (__ownerDocument__(this).implementation.errorChecking &amp;&amp; (this._readonly || oldChild._readonly)) {
             throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR));
@@ -1386,6 +1719,9 @@ __extend__(DOMNode.prototype, {
         return oldChild;
     },
     appendChild : function(newChild) {
+        if(!newChild){
+            return null;
+        }
       // test for exceptions
       if (__ownerDocument__(this).implementation.errorChecking) {
         // throw Exception if Node is readonly
@@ -1692,6 +2028,9 @@ var __isAncestor__ = function(target, node) {
 var __ownerDocument__ = function(node){
     return (node.nodeType == DOMNode.DOCUMENT_NODE)?node:node.ownerDocument;
 };
+
+$w.Node = DOMNode;
+
 /**
  * @class  DOMNamespace - The Namespace interface represents an namespace in an Element object
  *
@@ -1745,12 +2084,6 @@ $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;);
-  };
-});
-
 /**
  * @class  DOMCharacterData - parent abstract class for DOMText and DOMComment
  * @extends DOMNode
@@ -1864,16 +2197,11 @@ __extend__(DOMCharacterData.prototype,{
         return ret;
     }
 });
-$debug(&quot;Defining Text&quot;);
+
+$w.CharacterData = DOMCharacterData;$debug(&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;);
-    };
-});
-
 /**
  * @class  DOMText - The Text interface represents the textual content (termed character data in XML) of an Element or Attr.
  *   If there is no markup inside an element's content, the text is contained in a single object implementing the Text interface
@@ -1883,7 +2211,7 @@ $w.__defineGetter__(&quot;Text&quot;, function(){
  * @author Jon van Noort (jon@webarcana.com.au) and David Joham (djoham@yahoo.com)
  * @param  ownerDocument : DOMDocument - The Document object associated with this node.
  */
-DOMText = function(ownerDocument) {
+var DOMText = function(ownerDocument) {
   this.DOMCharacterData  = DOMCharacterData;
   this.DOMCharacterData(ownerDocument);
 
@@ -1936,22 +2264,17 @@ __extend__(DOMText.prototype,{
     },
     get xml(){
         return __escapeXML__(&quot;&quot;+ this.nodeValue);
+        //return &quot;&quot;+ this.nodeValue;
     },
     toString: function(){
         return &quot;Text #&quot; + this._id;    
     }
 });
 
-$debug(&quot;Defining CDATASection&quot;);
+$w.Text = DOMText;$debug(&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;);
-  };
-});
-
 /**
  * @class  DOMCDATASection - CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup.
  *   The only delimiter that is recognized in a CDATA section is the &quot;\]\]\&gt;&quot; string that ends the CDATA section
@@ -1976,16 +2299,12 @@ __extend__(DOMCDATASection.prototype,{
     toString : function(){
         return &quot;CDATA #&quot;+this._id;
     }
-});$debug(&quot;Defining Comment&quot;);
+});
+
+$w.CDATASection = DOMCDATASection;$debug(&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;);
-    };
-});
-
 /**
  * @class  DOMComment - This represents the content of a comment, i.e., all the characters between the starting '&lt;!--' and ending '--&gt;'
  * @extends DOMCharacterData
@@ -2010,27 +2329,21 @@ __extend__(DOMComment.prototype, {
         return &quot;Comment #&quot;+this._id;
     }
 });
+
+$w.Comment = DOMComment;
 $debug(&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 DOMDocumentType    = function() { 
+    $error(&quot;DOMDocumentType.constructor(): Not Implemented&quot;   ); 
+};
 
-var DOMDocumentType    = function() { $error(&quot;DOMDocumentType.constructor(): Not Implemented&quot;   ); };$debug(&quot;Defining Attr&quot;);
+$w.DocumentType = DOMDocumentType;
+$debug(&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;);
-    };
-});
-
-
 /**
  * @class  DOMAttr - The Attr interface represents an attribute in an Element object
  * @extends DOMNode
@@ -2065,30 +2378,24 @@ __extend__(DOMAttr.prototype, {
         this.nodeValue = value;
     },
     get specified(){
-        return (this.value.length &gt; 0);
+        return (this!==null&amp;&amp;this!=undefined);
     },
     get nodeType(){
         return DOMNode.ATTRIBUTE_NODE;
     },
     get xml(){
-        return this.nodeName + '=&quot;' + __escapeXML__(this.nodeValue) + '&quot; ';
+        if(this.nodeValue)
+            return this.nodeName + '=&quot;' + __escapeXML__(this.nodeValue) + '&quot; ';
+        else
+            return '';
     },
     toString : function(){
         return &quot;Attr #&quot; + this._id + &quot; &quot; + this.name;
     }
-});    
-
-$debug(&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;);
-  };
 });
 
-	
+$w.Attr = DOMAttr;
+$debug(&quot;Defining Element&quot;);
 /**
  * @class  DOMElement - By far the vast majority of objects (apart from text) that authors encounter
  *   when traversing a document are Element nodes.
@@ -2099,7 +2406,7 @@ $w.__defineGetter__(&quot;Element&quot;, function(){
 var DOMElement = function(ownerDocument) {
     this.DOMNode  = DOMNode;
     this.DOMNode(ownerDocument);                   
-    this.id = &quot;&quot;;                                  // the ID of the element
+    //this.id = null;                                  // the ID of the element
 };
 DOMElement.prototype = new DOMNode;
 __extend__(DOMElement.prototype, {	
@@ -2120,17 +2427,17 @@ __extend__(DOMElement.prototype, {
         if (attr) {
             ret = attr.value;
         }
-        return ret; // if Attribute exists, return its value, otherwise, return &quot;&quot;
+        return ret; // if Attribute exists, return its value, otherwise, return null
     },
     setAttribute : function (name, value) {
         // if attribute exists, use it
         var attr = this.attributes.getNamedItem(name);
-        var value = value+'';
+        
         //I had to add this check becuase as the script initializes
         //the id may be set in the constructor, and the html element
         //overrides the id property with a getter/setter.
         if(__ownerDocument__(this)){
-            if (!attr) {
+            if (attr===null||attr===undefined) {
                 attr = __ownerDocument__(this).createAttribute(name);  // otherwise create it
             }
             
@@ -2148,15 +2455,17 @@ __extend__(DOMElement.prototype, {
                 }
             }
             
-            if (__isIdDeclaration__(name)) {
-            //    this.id = value;  // cache ID for getElementById()
-            }
+            /*if (__isIdDeclaration__(name)) {
+                this.id = value;  // cache ID for getElementById()
+            }*/
             
             // assign values to properties (and aliases)
             attr.value     = value;
             
             // add/replace Attribute in NamedNodeMap
             this.attributes.setNamedItem(attr);
+        }else{
+            $warn('Element has no owner document '+this.tagName+'\n\t cant set attribute ' + name + ' = '+value );
         }
     },
     removeAttribute : function removeAttribute(name) {
@@ -2292,6 +2601,7 @@ __extend__(DOMElement.prototype, {
     }
 });
 
+$w.Element = DOMElement;
 /**
  * @class  DOMException - raised when an operation is impossible to perform
  * @author Jon van Noort (jon@webarcana.com.au)
@@ -2324,12 +2634,6 @@ $debug(&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;);
-    };
-});
-
 /**
  * @class  DOMDocumentFragment - DocumentFragment is a &quot;lightweight&quot; or &quot;minimal&quot; Document object.
  * @extends DOMNode
@@ -2361,16 +2665,12 @@ __extend__(DOMDocumentFragment.prototype,{
         return &quot;DocumentFragment #&quot;+this._id;
     }
 });
+
+$w.DocumentFragment = DOMDocumentFragment;
 $debug(&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;);
-    };
-});
-
 /**
  * @class  DOMProcessingInstruction - The ProcessingInstruction interface represents a &quot;processing instruction&quot;,
  *   used in XML as a way to keep processor-specific information in the text of the document
@@ -2400,6 +2700,12 @@ __extend__(DOMProcessingInstruction.prototype, {
       // The content of this processing instruction.
         return this.nodeName;
     },
+    set target(value){
+      // The target of this processing instruction.
+      // XML defines this as being the first token following the markup that begins the processing instruction.
+      // The content of this processing instruction.
+        this.nodeName = value;
+    },
     get nodeType(){
         return DOMNode.PROCESSING_INSTRUCTION_NODE;
     },
@@ -2410,6 +2716,8 @@ __extend__(DOMProcessingInstruction.prototype, {
         return &quot;ProcessingInstruction #&quot;+this._id;
     }
 });
+
+$w.ProcessesingInstruction = DOMProcessingInstruction;
 $debug(&quot;Defining DOMParser&quot;);
 /*
 * DOMParser
@@ -2427,7 +2735,7 @@ $debug(&quot;Initializing Internal DOMParser.&quot;);
 //keep one around for internal use
 $domparser = new DOMParser();
 
-$w.__defineGetter__('DOMParser', DOMParser);
+$w.DOMParser = DOMParser;
 // =========================================================================
 //
 // xmlsax.js - an XML SAX parser in JavaScript.
@@ -2692,7 +3000,7 @@ XMLP.prototype.appendFragment = function(xmlfragment) {
 
 XMLP.prototype._parse = function() {
 
-        if(this.m_iP == this.m_xml.length) {
+    if(this.m_iP == this.m_xml.length) {
         return XMLP._NONE;
     }
 
@@ -2712,6 +3020,7 @@ XMLP.prototype._parse = function() {
             }
         }
         else{
+              
             return this._parseElement(this.m_iP + 1);
         }
     }
@@ -2719,6 +3028,7 @@ XMLP.prototype._parse = function() {
         return this._parseEntity(this.m_iP + 1);
     }
     else{
+          
         return this._parseText(this.m_iP);
     }
 
@@ -3058,22 +3368,20 @@ XMLP.prototype._replaceEntity = function(strD, iB, iE) {
     iB = iB || 0;
     iE = iE || strD.length;
 
-    switch(strD.substring(iB, iE)) {
-        case &quot;amp&quot;:  strEnt = &quot;&amp;&quot;;  break;
-        case &quot;lt&quot;:   strEnt = &quot;&lt;&quot;;  break;
-        case &quot;gt&quot;:   strEnt = &quot;&gt;&quot;;  break;
-        case &quot;apos&quot;: strEnt = &quot;'&quot;;  break;
-        case &quot;quot&quot;: strEnt = &quot;\&quot;&quot;; break;
-        default:
-            if(strD.charAt(iB) == &quot;#&quot;) {
-                strEnt = String.fromCharCode(parseInt(strD.substring(iB + 1, iE)))+'';
-            } else {
-                return this._setErr(XMLP.ERR_ENTITY_UNKNOWN);
-            }
-        break;
+
+    ent = strD.substring(iB, iE);
+    strEnt = $w.$entityDefinitions[ent];
+    if (!strEnt)  // special case for entity name==JS reserved keyword
+        strEnt = $w.$entityDefinitions[ent+&quot;XX&quot;];
+    if (!strEnt) {
+        if(strD.charAt(iB) == &quot;#&quot;)
+            strEnt = String.fromCharCode(
+                         parseInt(strD.substring(iB + 1, iE)))+'';
+        else
+            return this._setErr(XMLP.ERR_ENTITY_UNKNOWN);
     }
-    this._setContent(XMLP._CONT_ALT, strEnt);
 
+    this._setContent(XMLP._CONT_ALT, strEnt);
     return XMLP._ENTITY;
 }
 
@@ -3545,7 +3853,7 @@ function isEmpty(str) {
  * @param  str : string - The string to be escaped
  * @return : string - The escaped string
  */
-var escAmpRegEx = /&amp;/g;
+var escAmpRegEx = /&amp;(?!(amp;|lt;|gt;|quot|apos;))/g;
 var escLtRegEx = /&lt;/g;
 var escGtRegEx = /&gt;/g;
 var quotRegEx = /&quot;/g;
@@ -3581,14 +3889,281 @@ function __unescapeXML__(str) {
     return str;
 };
 
+/**
+ * @author Glen Ivey (gleneivey@wontology.org)
+ */
+
+$debug(&quot;Instantiating list of HTML4 standard entities&quot;);
+/*
+ * $w.$entityDefinitions
+ */
+
+var $entityDefinitions = {
+        // content taken from W3C &quot;HTML 4.01 Specification&quot;
+        //                        &quot;W3C Recommendation 24 December 1999&quot;
+
+    nbsp: &quot;\u00A0&quot;,
+    iexcl: &quot;\u00A1&quot;,
+    cent: &quot;\u00A2&quot;,
+    pound: &quot;\u00A3&quot;,
+    curren: &quot;\u00A4&quot;,
+    yen: &quot;\u00A5&quot;,
+    brvbar: &quot;\u00A6&quot;,
+    sect: &quot;\u00A7&quot;,
+    uml: &quot;\u00A8&quot;,
+    copy: &quot;\u00A9&quot;,
+    ordf: &quot;\u00AA&quot;,
+    laquo: &quot;\u00AB&quot;,
+    not: &quot;\u00AC&quot;,
+    shy: &quot;\u00AD&quot;,
+    reg: &quot;\u00AE&quot;,
+    macr: &quot;\u00AF&quot;,
+    deg: &quot;\u00B0&quot;,
+    plusmn: &quot;\u00B1&quot;,
+    sup2: &quot;\u00B2&quot;,
+    sup3: &quot;\u00B3&quot;,
+    acute: &quot;\u00B4&quot;,
+    micro: &quot;\u00B5&quot;,
+    para: &quot;\u00B6&quot;,
+    middot: &quot;\u00B7&quot;,
+    cedil: &quot;\u00B8&quot;,
+    sup1: &quot;\u00B9&quot;,
+    ordm: &quot;\u00BA&quot;,
+    raquo: &quot;\u00BB&quot;,
+    frac14: &quot;\u00BC&quot;,
+    frac12: &quot;\u00BD&quot;,
+    frac34: &quot;\u00BE&quot;,
+    iquest: &quot;\u00BF&quot;,
+    Agrave: &quot;\u00C0&quot;,
+    Aacute: &quot;\u00C1&quot;,
+    Acirc: &quot;\u00C2&quot;,
+    Atilde: &quot;\u00C3&quot;,
+    Auml: &quot;\u00C4&quot;,
+    Aring: &quot;\u00C5&quot;,
+    AElig: &quot;\u00C6&quot;,
+    Ccedil: &quot;\u00C7&quot;,
+    Egrave: &quot;\u00C8&quot;,
+    Eacute: &quot;\u00C9&quot;,
+    Ecirc: &quot;\u00CA&quot;,
+    Euml: &quot;\u00CB&quot;,
+    Igrave: &quot;\u00CC&quot;,
+    Iacute: &quot;\u00CD&quot;,
+    Icirc: &quot;\u00CE&quot;,
+    Iuml: &quot;\u00CF&quot;,
+    ETH: &quot;\u00D0&quot;,
+    Ntilde: &quot;\u00D1&quot;,
+    Ograve: &quot;\u00D2&quot;,
+    Oacute: &quot;\u00D3&quot;,
+    Ocirc: &quot;\u00D4&quot;,
+    Otilde: &quot;\u00D5&quot;,
+    Ouml: &quot;\u00D6&quot;,
+    times: &quot;\u00D7&quot;,
+    Oslash: &quot;\u00D8&quot;,
+    Ugrave: &quot;\u00D9&quot;,
+    Uacute: &quot;\u00DA&quot;,
+    Ucirc: &quot;\u00DB&quot;,
+    Uuml: &quot;\u00DC&quot;,
+    Yacute: &quot;\u00DD&quot;,
+    THORN: &quot;\u00DE&quot;,
+    szlig: &quot;\u00DF&quot;,
+    agrave: &quot;\u00E0&quot;,
+    aacute: &quot;\u00E1&quot;,
+    acirc: &quot;\u00E2&quot;,
+    atilde: &quot;\u00E3&quot;,
+    auml: &quot;\u00E4&quot;,
+    aring: &quot;\u00E5&quot;,
+    aelig: &quot;\u00E6&quot;,
+    ccedil: &quot;\u00E7&quot;,
+    egrave: &quot;\u00E8&quot;,
+    eacute: &quot;\u00E9&quot;,
+    ecirc: &quot;\u00EA&quot;,
+    euml: &quot;\u00EB&quot;,
+    igrave: &quot;\u00EC&quot;,
+    iacute: &quot;\u00ED&quot;,
+    icirc: &quot;\u00EE&quot;,
+    iuml: &quot;\u00EF&quot;,
+    eth: &quot;\u00F0&quot;,
+    ntilde: &quot;\u00F1&quot;,
+    ograve: &quot;\u00F2&quot;,
+    oacute: &quot;\u00F3&quot;,
+    ocirc: &quot;\u00F4&quot;,
+    otilde: &quot;\u00F5&quot;,
+    ouml: &quot;\u00F6&quot;,
+    divide: &quot;\u00F7&quot;,
+    oslash: &quot;\u00F8&quot;,
+    ugrave: &quot;\u00F9&quot;,
+    uacute: &quot;\u00FA&quot;,
+    ucirc: &quot;\u00FB&quot;,
+    uuml: &quot;\u00FC&quot;,
+    yacute: &quot;\u00FD&quot;,
+    thorn: &quot;\u00FE&quot;,
+    yuml: &quot;\u00FF&quot;,
+    fnof: &quot;\u0192&quot;,
+    Alpha: &quot;\u0391&quot;,
+    Beta: &quot;\u0392&quot;,
+    Gamma: &quot;\u0393&quot;,
+    Delta: &quot;\u0394&quot;,
+    Epsilon: &quot;\u0395&quot;,
+    Zeta: &quot;\u0396&quot;,
+    Eta: &quot;\u0397&quot;,
+    Theta: &quot;\u0398&quot;,
+    Iota: &quot;\u0399&quot;,
+    Kappa: &quot;\u039A&quot;,
+    Lambda: &quot;\u039B&quot;,
+    Mu: &quot;\u039C&quot;,
+    Nu: &quot;\u039D&quot;,
+    Xi: &quot;\u039E&quot;,
+    Omicron: &quot;\u039F&quot;,
+    Pi: &quot;\u03A0&quot;,
+    Rho: &quot;\u03A1&quot;,
+    Sigma: &quot;\u03A3&quot;,
+    Tau: &quot;\u03A4&quot;,
+    Upsilon: &quot;\u03A5&quot;,
+    Phi: &quot;\u03A6&quot;,
+    Chi: &quot;\u03A7&quot;,
+    Psi: &quot;\u03A8&quot;,
+    Omega: &quot;\u03A9&quot;,
+    alpha: &quot;\u03B1&quot;,
+    beta: &quot;\u03B2&quot;,
+    gamma: &quot;\u03B3&quot;,
+    delta: &quot;\u03B4&quot;,
+    epsilon: &quot;\u03B5&quot;,
+    zeta: &quot;\u03B6&quot;,
+    eta: &quot;\u03B7&quot;,
+    theta: &quot;\u03B8&quot;,
+    iota: &quot;\u03B9&quot;,
+    kappa: &quot;\u03BA&quot;,
+    lambda: &quot;\u03BB&quot;,
+    mu: &quot;\u03BC&quot;,
+    nu: &quot;\u03BD&quot;,
+    xi: &quot;\u03BE&quot;,
+    omicron: &quot;\u03BF&quot;,
+    pi: &quot;\u03C0&quot;,
+    rho: &quot;\u03C1&quot;,
+    sigmaf: &quot;\u03C2&quot;,
+    sigma: &quot;\u03C3&quot;,
+    tau: &quot;\u03C4&quot;,
+    upsilon: &quot;\u03C5&quot;,
+    phi: &quot;\u03C6&quot;,
+    chi: &quot;\u03C7&quot;,
+    psi: &quot;\u03C8&quot;,
+    omega: &quot;\u03C9&quot;,
+    thetasym: &quot;\u03D1&quot;,
+    upsih: &quot;\u03D2&quot;,
+    piv: &quot;\u03D6&quot;,
+    bull: &quot;\u2022&quot;,
+    hellip: &quot;\u2026&quot;,
+    prime: &quot;\u2032&quot;,
+    Prime: &quot;\u2033&quot;,
+    oline: &quot;\u203E&quot;,
+    frasl: &quot;\u2044&quot;,
+    weierp: &quot;\u2118&quot;,
+    image: &quot;\u2111&quot;,
+    real: &quot;\u211C&quot;,
+    trade: &quot;\u2122&quot;,
+    alefsym: &quot;\u2135&quot;,
+    larr: &quot;\u2190&quot;,
+    uarr: &quot;\u2191&quot;,
+    rarr: &quot;\u2192&quot;,
+    darr: &quot;\u2193&quot;,
+    harr: &quot;\u2194&quot;,
+    crarr: &quot;\u21B5&quot;,
+    lArr: &quot;\u21D0&quot;,
+    uArr: &quot;\u21D1&quot;,
+    rArr: &quot;\u21D2&quot;,
+    dArr: &quot;\u21D3&quot;,
+    hArr: &quot;\u21D4&quot;,
+    forall: &quot;\u2200&quot;,
+    part: &quot;\u2202&quot;,
+    exist: &quot;\u2203&quot;,
+    empty: &quot;\u2205&quot;,
+    nabla: &quot;\u2207&quot;,
+    isin: &quot;\u2208&quot;,
+    notin: &quot;\u2209&quot;,
+    ni: &quot;\u220B&quot;,
+    prod: &quot;\u220F&quot;,
+    sum: &quot;\u2211&quot;,
+    minus: &quot;\u2212&quot;,
+    lowast: &quot;\u2217&quot;,
+    radic: &quot;\u221A&quot;,
+    prop: &quot;\u221D&quot;,
+    infin: &quot;\u221E&quot;,
+    ang: &quot;\u2220&quot;,
+    and: &quot;\u2227&quot;,
+    or: &quot;\u2228&quot;,
+    cap: &quot;\u2229&quot;,
+    cup: &quot;\u222A&quot;,
+    intXX: &quot;\u222B&quot;,
+    there4: &quot;\u2234&quot;,
+    sim: &quot;\u223C&quot;,
+    cong: &quot;\u2245&quot;,
+    asymp: &quot;\u2248&quot;,
+    ne: &quot;\u2260&quot;,
+    equiv: &quot;\u2261&quot;,
+    le: &quot;\u2264&quot;,
+    ge: &quot;\u2265&quot;,
+    sub: &quot;\u2282&quot;,
+    sup: &quot;\u2283&quot;,
+    nsub: &quot;\u2284&quot;,
+    sube: &quot;\u2286&quot;,
+    supe: &quot;\u2287&quot;,
+    oplus: &quot;\u2295&quot;,
+    otimes: &quot;\u2297&quot;,
+    perp: &quot;\u22A5&quot;,
+    sdot: &quot;\u22C5&quot;,
+    lceil: &quot;\u2308&quot;,
+    rceil: &quot;\u2309&quot;,
+    lfloor: &quot;\u230A&quot;,
+    rfloor: &quot;\u230B&quot;,
+    lang: &quot;\u2329&quot;,
+    rang: &quot;\u232A&quot;,
+    loz: &quot;\u25CA&quot;,
+    spades: &quot;\u2660&quot;,
+    clubs: &quot;\u2663&quot;,
+    hearts: &quot;\u2665&quot;,
+    diams: &quot;\u2666&quot;,
+    quot: &quot;\u0022&quot;,
+    amp: &quot;\u0026&quot;,
+    lt: &quot;\u003C&quot;,
+    gt: &quot;\u003E&quot;,
+    OElig: &quot;\u0152&quot;,
+    oelig: &quot;\u0153&quot;,
+    Scaron: &quot;\u0160&quot;,
+    scaron: &quot;\u0161&quot;,
+    Yuml: &quot;\u0178&quot;,
+    circ: &quot;\u02C6&quot;,
+    tilde: &quot;\u02DC&quot;,
+    ensp: &quot;\u2002&quot;,
+    emsp: &quot;\u2003&quot;,
+    thinsp: &quot;\u2009&quot;,
+    zwnj: &quot;\u200C&quot;,
+    zwj: &quot;\u200D&quot;,
+    lrm: &quot;\u200E&quot;,
+    rlm: &quot;\u200F&quot;,
+    ndash: &quot;\u2013&quot;,
+    mdash: &quot;\u2014&quot;,
+    lsquo: &quot;\u2018&quot;,
+    rsquo: &quot;\u2019&quot;,
+    sbquo: &quot;\u201A&quot;,
+    ldquo: &quot;\u201C&quot;,
+    rdquo: &quot;\u201D&quot;,
+    bdquo: &quot;\u201E&quot;,
+    dagger: &quot;\u2020&quot;,
+    Dagger: &quot;\u2021&quot;,
+    permil: &quot;\u2030&quot;,
+    lsaquo: &quot;\u2039&quot;,
+    rsaquo: &quot;\u203A&quot;,
+    euro: &quot;\u20AC&quot;,
+
+    // non-standard entities
+    apos: &quot;'&quot;
+};
+
+
+$w.$entityDefinitions = $entityDefinitions;
+
 //DOMImplementation
 $debug(&quot;Defining DOMImplementation&quot;);
-$w.__defineGetter__(&quot;DOMImplementation&quot;, function(){
-  return function(){
-    throw new Error(&quot;Object cannot be created in this context&quot;);
-  };
-});
-
 /**
  * @class  DOMImplementation - provides a number of methods for performing operations
  *   that are independent of any particular instance of the document object model.
@@ -3600,6 +4175,50 @@ var DOMImplementation = function() {
     this.namespaceAware = true;       // by default, handle namespaces
     this.errorChecking  = true;       // by default, test for exceptions
 };
+
+var __endHTMLElement__ = function(node, doc, p){
+    if(node.nodeName.toLowerCase() == 'script'){
+        p.replaceEntities = true;
+        $env.loadLocalScript(node, p);
+
+        // only fire event if we actually had something to load
+        if (node.src &amp;&amp; node.src.length &gt; 0){
+            var event = doc.createEvent();
+            event.initEvent(&quot;load&quot;);
+            node.dispatchEvent( event, false );
+        }
+    }
+    else if (node.nodeName.toLowerCase() == 'frame' ||
+             node.nodeName.toLowerCase() == 'iframe'   ){
+
+        if (node.src &amp;&amp; node.src.length &gt; 0){
+            $debug(&quot;getting content document for (i)frame from &quot; + node.src);
+
+            $env.loadFrame(node, $env.location(node.src));
+
+            var event = doc.createEvent();
+            event.initEvent(&quot;load&quot;);
+            node.dispatchEvent( event, false );
+        }
+    }
+    else if (node.nodeName.toLowerCase() == 'link'){
+        if (node.href &amp;&amp; node.href.length &gt; 0){
+            // don't actually load anything, so we're &quot;done&quot; immediately:
+            var event = doc.createEvent();
+            event.initEvent(&quot;load&quot;);
+            node.dispatchEvent( event, false );
+        }
+    }
+    else if (node.nodeName.toLowerCase() == 'img'){
+        if (node.src &amp;&amp; node.src.length &gt; 0){
+            // don't actually load anything, so we're &quot;done&quot; immediately:
+            var event = doc.createEvent();
+            event.initEvent(&quot;load&quot;);
+            node.dispatchEvent( event, false );
+        }
+    }
+}
+
 __extend__(DOMImplementation.prototype,{
     // @param  feature : string - The package name of the feature to test.
     //      the legal only values are &quot;XML&quot; and &quot;CORE&quot; (case-insensitive).
@@ -3622,7 +4241,7 @@ __extend__(DOMImplementation.prototype,{
     createDocument : function(nsuri, qname, doctype){
       //TODO - this currently returns an empty doc
       //but needs to handle the args
-        return new HTMLDocument($implementation);
+        return new HTMLDocument($implementation, null);
     },
     translateErrCode : function(code) {
         //convert DOMException Code to human readable error message;
@@ -3715,7 +4334,8 @@ __extend__(DOMImplementation.prototype,{
  *
  * @return : DOMDocument
  */
-function __parseLoop__(impl, doc, p) {
+
+function __parseLoop__(impl, doc, p, isWindowDocument) {
     var iEvt, iNode, iAttr, strName;
     var iNodeParent = doc;
 
@@ -3732,10 +4352,11 @@ function __parseLoop__(impl, doc, p) {
     }
 
   // loop until SAX parser stops emitting events
+  var q = 0;
   while(true) {
     // get next event
     iEvt = p.next();
-
+    
     if (iEvt == XMLP._ELM_B) {                      // Begin-Element Event
       var pName = p.getName();                      // get the Element name
       pName = trim(pName, true, true);              // strip spaces from Element name
@@ -3744,7 +4365,6 @@ function __parseLoop__(impl, doc, p) {
 
       if (!impl.namespaceAware) {
         iNode = doc.createElement(p.getName());     // create the Element
-
         // add attributes to Element
         for(var i = 0; i &lt; p.getAttributeCount(); i++) {
           strName = p.getAttributeName(i);          // get Attribute name
@@ -3818,21 +4438,16 @@ function __parseLoop__(impl, doc, p) {
 
       // if this is the Root Element
       if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) {
-        iNodeParent.documentElement = iNode;        // register this Element as the Document.documentElement
+        iNodeParent._documentElement = iNode;        // register this Element as the Document.documentElement
       }
 
       iNodeParent.appendChild(iNode);               // attach Element to parentNode
       iNodeParent = iNode;                          // descend one level of the DOM Tree
     }
 
-    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event
-      //handle script tag
-      if(iNodeParent.nodeName.toLowerCase() == 'script'){
-         p.replaceEntities = true;
-         $policy.loadScript(iNodeParent, p);
-      }
-      iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
-
+    else if(iEvt == XMLP._ELM_E) {                  // End-Element Event        
+        __endHTMLElement__(iNodeParent, doc, p);
+        iNodeParent = iNodeParent.parentNode;         // ascend one level of the DOM Tree
     }
 
     else if(iEvt == XMLP._ELM_EMP) {                // Empty Element Event
@@ -3915,9 +4530,10 @@ function __parseLoop__(impl, doc, p) {
 
       // if this is the Root Element
       if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) {
-        iNodeParent.documentElement = iNode;        // register this Element as the Document.documentElement
+        iNodeParent._documentElement = iNode;        // register this Element as the Document.documentElement
       }
 
+      __endHTMLElement__(iNode, doc, p);
       iNodeParent.appendChild(iNode);               // attach Element to parentNode
     }
     else if(iEvt == XMLP._TEXT || iEvt == XMLP._ENTITY) {                   // TextNode and entity Events
@@ -3994,12 +4610,16 @@ function __parseLoop__(impl, doc, p) {
         throw(new DOMException(DOMException.SYNTAX_ERR));
     }
     else if(iEvt == XMLP._NONE) {                   // no more events
-      if (iNodeParent == doc) {                     // confirm that we have recursed back up to root
+      //steven woods notes that unclosed tags are rejected elsewhere and this check
+	  //breaks a table patching routine
+	  /*if (iNodeParent == doc) {                     // confirm that we have recursed back up to root
         break;
       }
       else {
         throw(new DOMException(DOMException.SYNTAX_ERR));  // one or more Tags were not closed properly
-      }
+      }*/
+        break;
+
     }
   }
 
@@ -4156,17 +4776,6 @@ $debug(&quot;Initializing document.implementation&quot;);
 var $implementation =  new DOMImplementation();
 $implementation.namespaceAware = false;
 $implementation.errorChecking = false;$debug(&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;);
-  };
-});
-
-
 /**
  * @class  DOMDocument - The Document interface represents the entire HTML or XML document.
  *   Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
@@ -4175,14 +4784,15 @@ $w.__defineGetter__('Document', function(){
  * @author Jon van Noort (jon@webarcana.com.au)
  * @param  implementation : DOMImplementation - the creator Implementation
  */
-var DOMDocument = function(implementation) {
+var DOMDocument = function(implementation, docParentWindow) {
     //$log(&quot;\tcreating dom document&quot;);
     this.DOMNode = DOMNode;
     this.DOMNode(this);
     
     this.doctype = null;                  // The Document Type Declaration (see DocumentType) associated with this document
     this.implementation = implementation; // The DOMImplementation object that handles this document.
-    this.documentElement = null;          // This is a convenience attribute that allows direct access to the child node that is the root element of the document
+    this._documentElement = null;         // &quot;private&quot; variable providing the read-only document.documentElement property
+    this._parentWindow = docParentWindow; // &quot;private&quot; variable providing the read-only document.parentWindow property
     
     this.nodeName  = &quot;#document&quot;;
     this._id = 0;
@@ -4209,19 +4819,38 @@ __extend__(DOMDocument.prototype, {
     get all(){
         return this.getElementsByTagName(&quot;*&quot;);
     },
-    loadXML : function(xmlStr) {
+    get documentElement(){
+        return this._documentElement;
+    },
+    get parentWindow(){
+        return this._parentWindow;
+    },
+    loadXML : function(xmlString) {
         // create SAX Parser
-        var parser = new XMLP(xmlStr+'');
+        var htmlString;
+        if($env.fixHTML){
+            htmlString = $env.cleanHTML(xmlString);
+        }else{
+            htmlString = xmlString
+        }
+        var parser = new XMLP(htmlString+'');
         
         // create DOM Document
-        var doc = new HTMLDocument(this.implementation);
         if(this === $document){
             $debug(&quot;Setting internal window.document&quot;);
-            $document = doc;
+            $document = this;
         }
         // populate Document with Parsed Nodes
         try {
-            __parseLoop__(this.implementation, doc, parser);
+            // make sure thid document object is empty before we try to load ...
+            this.childNodes      = new DOMNodeList(this, this);
+            this.firstChild      = null;
+            this.lastChild       = null;
+            this.attributes      = new DOMNamedNodeMap(this, this);
+            this._namespaces     = new DOMNamespaceNodeMap(this, this);
+            this._readonly = false;
+
+            __parseLoop__(this.implementation, this, parser);
             //doc = html2dom(xmlStr+&quot;&quot;, doc);
         	//$log(&quot;\nhtml2xml\n&quot; + doc.xml);
         } catch (e) {
@@ -4230,8 +4859,8 @@ __extend__(DOMDocument.prototype, {
         }
 
         // set parseComplete flag, (Some validation Rules are relaxed if this is false)
-        doc._parseComplete = true;
-        return doc;
+        this._parseComplete = true;
+        return this;
     },
     load: function(url){
 		$debug(&quot;Loading url into DOM Document: &quot;+ url + &quot; - (Asynch? &quot;+$w.document.async+&quot;)&quot;);
@@ -4252,9 +4881,19 @@ __extend__(DOMDocument.prototype, {
             _this._url = url;
             
         	$info(&quot;Sucessfully loaded document at &quot;+url);
-        	var event = document.createEvent();
-        	event.initEvent(&quot;load&quot;);
-        	$w.dispatchEvent( event );
+
+                // first fire body-onload event
+            var event = document.createEvent();
+            event.initEvent(&quot;load&quot;);
+            try {  // assume &lt;body&gt; element, but just in case....
+                $w.document.getElementsByTagName('body')[0].
+                  dispatchEvent( event, false );
+            } catch (e){;}
+
+                // then fire window-onload event
+            event = document.createEvent();
+            event.initEvent(&quot;load&quot;);
+            $w.dispatchEvent( event, false );
         };
         xhr.send();
     },
@@ -4266,7 +4905,7 @@ __extend__(DOMDocument.prototype, {
         return event;
     },
     createExpression        : function(xpath, nsuriMap){ 
-        return null;/*TODO*/
+        return new XPathExpression(xpath, nsuriMap);
     },
     createElement : function(tagName) {
           //$debug(&quot;DOMDocument.createElement( &quot;+tagName+&quot; )&quot;);
@@ -4416,6 +5055,39 @@ __extend__(DOMDocument.prototype, {
         
           return node;
     },
+    /** from David Flanagan's JavaScript - The Definitive Guide
+     * 
+     * @param {String} xpathText
+     *     The string representing the XPath expression to evaluate.
+     * @param {Node} contextNode 
+     *     The node in this document against which the expression is to
+     *     be evaluated.
+     * @param {Function} nsuriMapper 
+     *     A function that will map from namespace prefix to to a full 
+     *     namespace URL or null if no such mapping is required.
+     * @param {Number} resultType 
+     *     Specifies the type of object expected as a result, using
+     *     XPath conversions to coerce the result. Possible values for
+     *     type are the constrainsts defined by the XPathResult object.
+     *     (null if not required)
+     * @param {XPathResult} result 
+     *     An XPathResult object to be reused or null
+     *     if you want a new XPathResult object to be created.
+     * @returns {XPathResult} result
+     *     A XPathResult object representing the evaluation of the 
+     *     expression against the given context node.
+     * @throws {Exception} e
+     *     This method may throw an exception if the xpathText contains 
+     *     a syntax error, if the expression cannot be converted to the
+     *     desired resultType, if the expression contains namespaces 
+     *     that nsuriMapper cannot resolve, or if contextNode is of the 
+     *     wrong type or is not assosciated with this document.
+     * @seealso
+     *     Document.evaluate
+     */
+    /*evaluate: function(xpathText, contextNode, nsuriMapper, resultType, result){
+        return new XPathExpression().evaluate();
+    },*/
     getElementById : function(elementId) {
           var retNode = null,
               node;
@@ -4423,9 +5095,9 @@ __extend__(DOMDocument.prototype, {
           var all = this.all;
           for (var i=0; i &lt; all.length; i++) {
             node = all[i];
-            // if id matches &amp; node is alive (ie, connected (in)directly to the documentElement)
+            // if id matches &amp; node is alive (ie, connected (in)directly to the _documentElement)
             if (node.id == elementId) {
-                if((__ownerDocument__(node).documentElement._id == this.documentElement._id)){
+                if((__ownerDocument__(node)._documentElement._id == this._documentElement._id)){
                     retNode = node;
                     //$log(&quot;Found node with id = &quot; + node.id);
                     break;
@@ -4437,25 +5109,21 @@ __extend__(DOMDocument.prototype, {
           return retNode;
     },
     normalizeDocument: function(){
-	    this.documentElement.normalize();
+	    this._documentElement.normalize();
     },
     get nodeType(){
         return DOMNode.DOCUMENT_NODE;
     },
     get xml(){
         //$log(&quot;Serializing &quot; + this);
-        return this.documentElement.xml;
+        return this._documentElement.xml;
     },
 	toString: function(){ 
 	    return &quot;Document&quot; +  (typeof this._url == &quot;string&quot; ? &quot;: &quot; + this._url : &quot;&quot;); 
     },
-	get defaultView(){ //TODO: why isnt this just 'return $w;'?
+	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;
-			}};
+			return $w.getComputedStyle(elem);
 		}};
 	},
     _genId : function() {
@@ -4509,6 +5177,8 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut
     
       return valid;
 };
+
+$w.Document = DOMDocument;
 /*
 *	parser.js
 */
@@ -4852,24 +5522,17 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut
 $debug(&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;);
-  };
-});
 /**
  * @class  HTMLDocument - The Document interface represents the entire HTML or XML document.
  *   Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
  *
  * @extends DOMDocument
  */
-var HTMLDocument = function(implementation) {
+var HTMLDocument = function(implementation, docParentWindow) {
   this.DOMDocument = DOMDocument;
-  this.DOMDocument(implementation);
+  this.DOMDocument(implementation, docParentWindow);
 
-  this.title = &quot;&quot;;
   this._refferer = &quot;&quot;;
   this._domain;
   this._open = false;
@@ -4886,16 +5549,16 @@ __extend__(HTMLDocument.prototype, {
           // create DOMElement specifying 'this' as ownerDocument
           //This is an html document so we need to use explicit interfaces per the 
           if(     tagName.match(/^A$/))                 {node = new HTMLAnchorElement(this);}
-          else if(tagName.match(/AREA/))                {node = new HTMLAreaElement(this);}
+          else if(tagName.match(/^AREA$/))              {node = new HTMLAreaElement(this);}
           else if(tagName.match(/BASE/))                {node = new HTMLBaseElement(this);}
           else if(tagName.match(/BLOCKQUOTE|Q/))        {node = new HTMLQuoteElement(this);}
-          else if(tagName.match(/BODY/))                {node = new HTMLElement(this);}
+          else if(tagName.match(/BODY/))                {node = new HTMLBodyElement(this);}
           else if(tagName.match(/BR/))                  {node = new HTMLElement(this);}
           else if(tagName.match(/BUTTON/))              {node = new HTMLButtonElement(this);}
           else if(tagName.match(/CAPTION/))             {node = new HTMLElement(this);}
           else if(tagName.match(/COL|COLGROUP/))        {node = new HTMLTableColElement(this);}
           else if(tagName.match(/DEL|INS/))             {node = new HTMLModElement(this);}
-          else if(tagName.match(/DIV/))                 {node = new HTMLElement(this);}
+          else if(tagName.match(/DIV/))                 {node = new HTMLDivElement(this);}
           else if(tagName.match(/DL/))                  {node = new HTMLElement(this);}
           else if(tagName.match(/FIELDSET/))            {node = new HTMLFieldSetElement(this);}
           else if(tagName.match(/FORM/))                {node = new HTMLFormElement(this);}
@@ -4925,10 +5588,10 @@ __extend__(HTMLDocument.prototype, {
           else if(tagName.match(/SELECT/))              {node = new HTMLSelectElement(this);}
           else if(tagName.match(/STYLE/))               {node = new HTMLStyleElement(this);}
           else if(tagName.match(/TABLE/))               {node = new HTMLTableElement(this);}
-          else if(tagName.match(/TBODY|TFOOT|THEAD/))   {node = new HTMLElement(this);}
+          else if(tagName.match(/TBODY|TFOOT|THEAD/))   {node = new HTMLTableSectionElement(this);}
           else if(tagName.match(/TD|TH/))               {node = new HTMLTableCellElement(this);}
-          else if(tagName.match(/TEXTAREA/))            {node = new HTMLElement(this);}
-          else if(tagName.match(/TITLE/))               {node = new HTMLElement(this);}
+          else if(tagName.match(/TEXTAREA/))            {node = new HTMLTextAreaElement(this);}
+          else if(tagName.match(/TITLE/))               {node = new HTMLTitleElement(this);}
           else if(tagName.match(/TR/))                  {node = new HTMLTableRowElement(this);}
           else if(tagName.match(/UL/))                  {node = new HTMLElement(this);}
           else{
@@ -4956,6 +5619,29 @@ __extend__(HTMLDocument.prototype, {
         return this.replaceNode(this.body,html);
         
     },
+
+    get title(){
+        var titleArray = this.getElementsByTagName('title');
+        if (titleArray.length &lt; 1)
+            return &quot;&quot;;
+        return titleArray[0].text;
+    },
+    set title(titleStr){
+        titleArray = this.getElementsByTagName('title');
+        if (titleArray.length &lt; 1){
+            // need to make a new element and add it to &quot;head&quot;
+            var titleElem = new HTMLTitleElement(this);
+            titleElem.text = titleStr;
+            var headArray = this.getElementsByTagName('head');
+	    if (headArray.length &lt; 1)
+                return;  // ill-formed, just give up.....
+            headArray[0].appendChild(titleElem);
+        }
+        else {
+            titleArray[0].text = titleStr;
+        }
+    },
+
     //set/get cookie see cookie.js
     get domain(){
         return this._domain||window.location.domain;
@@ -5038,30 +5724,11 @@ __extend__(HTMLDocument.prototype, {
     }
 });
 
-//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 );
-		}
-	}
-};$debug(&quot;Defining HTMLElement&quot;);
+$w.HTMLDocument = HTMLDocument;
+$debug(&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(ownerDocument) {
     this.DOMElement = DOMElement;
     this.DOMElement(ownerDocument);
@@ -5071,11 +5738,10 @@ var HTMLElement = function(ownerDocument) {
 HTMLElement.prototype = new DOMElement;
 __extend__(HTMLElement.prototype, {
 		get className() { 
-		    return this.getAttribute(&quot;class&quot;)||&quot;&quot;; 
-		    
+		    return this.getAttribute(&quot;class&quot;)||''; 
 	    },
-		set className(val) { 
-		    return this.setAttribute(&quot;class&quot;,trim(val)); 
+		set className(value) { 
+		    return this.setAttribute(&quot;class&quot;,trim(value)); 
 		    
 	    },
 		get dir() { 
@@ -5087,7 +5753,7 @@ __extend__(HTMLElement.prototype, {
 		    
 	    },
 		get id(){  
-		    return this.getAttribute('id')||''; 
+		    return this.getAttribute('id'); 
 		    
 	    },
 		set id(id){  
@@ -5099,8 +5765,8 @@ __extend__(HTMLElement.prototype, {
 		    
 	    },
 		set innerHTML(html){
-		    $debug(&quot;htmlElement.innerHTML(&quot;+html+&quot;)&quot;);
 		    //Should be replaced with HTMLPARSER usage
+            //$debug('SETTING INNER HTML ('+this+'+'+html.substring(0,64));
 		    var doc = new DOMParser().
 			  parseFromString('&lt;div&gt;'+html+'&lt;/div&gt;');
             var parent = doc.documentElement;
@@ -5117,7 +5783,7 @@ __extend__(HTMLElement.prototype, {
 		    doc = null;
 		},
 		get lang() { 
-		    return this.getAttribute(&quot;lang&quot;)||&quot;&quot;; 
+		    return this.getAttribute(&quot;lang&quot;); 
 		    
 	    },
 		set lang(val) { 
@@ -5146,20 +5812,39 @@ __extend__(HTMLElement.prototype, {
 		scrollRight: 0,
 		get style(){
 		    if(this.$css2props === null){
-		        this.$css2props = new CSS2Properties({
-    		        cssText:this.getAttribute(&quot;style&quot;)
-    	        });
+	            this.$css2props = new CSS2Properties(this);
 	        }
-	        return this.$css2props
+	        return this.$css2props;
+		},
+        set style(values){
+		    __updateCss2Props__(this, values);
+        },
+		setAttribute: function (name, value) {
+            DOMElement.prototype.setAttribute.apply(this,[name, value]);
+		    if (name === &quot;style&quot;) {
+		        __updateCss2Props__(this, value);
+		    }
 		},
 		get title() { 
-		    return this.getAttribute(&quot;title&quot;)||&quot;&quot;; 
+		    return this.getAttribute(&quot;title&quot;); 
 		    
 	    },
-		set title(val) { 
-		    return this.setAttribute(&quot;title&quot;,val); 
+		set title(value) { 
+		    return this.setAttribute(&quot;title&quot;, value); 
 		    
 	    },
+		get tabIndex(){
+            var ti = this.getAttribute('tabindex');
+            if(ti!==null)
+                return Number(ti);
+            else
+                return 0;
+        },
+        set tabIndex(value){
+            if(value===undefined||value===null)
+                value = 0;
+            this.setAttribute('tabindex',Number(value));
+        },
 		//Not in the specs but I'll leave it here for now.
 		get outerHTML(){ 
 		    return this.xml; 
@@ -5170,46 +5855,76 @@ __extend__(HTMLElement.prototype, {
 	        return;
 	    
         },
+
 		onclick: function(event){
-		    __eval__(this.getAttribute('onclick')||'')
+		    __eval__(this.getAttribute('onclick')||'', this);
 	    },
+        
+
 		ondblclick: function(event){
-            __eval__(this.getAttribute('ondblclick')||'');
+            __eval__(this.getAttribute('ondblclick')||'', this);
 	    },
 		onkeydown: function(event){
-            __eval__(this.getAttribute('onkeydown')||'');
+            __eval__(this.getAttribute('onkeydown')||'', this);
 	    },
 		onkeypress: function(event){
-            __eval__(this.getAttribute('onkeypress')||'');
+            __eval__(this.getAttribute('onkeypress')||'', this);
 	    },
 		onkeyup: function(event){
-            __eval__(this.getAttribute('onkeyup')||'');
+            __eval__(this.getAttribute('onkeyup')||'', this);
 	    },
 		onmousedown: function(event){
-            __eval__(this.getAttribute('onmousedown')||'');
+            __eval__(this.getAttribute('onmousedown')||'', this);
 	    },
 		onmousemove: function(event){
-            __eval__(this.getAttribute('onmousemove')||'');
+            __eval__(this.getAttribute('onmousemove')||'', this);
 	    },
 		onmouseout: function(event){
-            __eval__(this.getAttribute('onmouseout')||'');
+            __eval__(this.getAttribute('onmouseout')||'', this);
 	    },
 		onmouseover: function(event){
-            __eval__(this.getAttribute('onmouseover')||'');
+            __eval__(this.getAttribute('onmouseover')||'', this);
 	    },
 		onmouseup: function(event){
-            __eval__(this.getAttribute('onmouseup')||'');
+            __eval__(this.getAttribute('onmouseup')||'', this);
 	    }
 });
 
-var __eval__ = function(script){
+var __eval__ = function(script, startingNode){
+    if (script == &quot;&quot;)
+        return;                    // don't assemble environment if no script...
+
     try{
-        eval(script);
+        var doEval = function(scriptText){
+            eval(scriptText);
+        }
+
+        var listOfScopes = [];
+        for (var node = startingNode; node != null; node = node.parentNode)
+            listOfScopes.push(node);
+        listOfScopes.push(window);
+
+
+        var oldScopesArray = $env.configureScope(
+          doEval,        // the function whose scope chain to change
+          listOfScopes); // last array element is &quot;head&quot; of new chain
+        doEval.call(startingNode, script);
+        $env.restoreScope(oldScopesArray);
+                         // oldScopesArray is N-element array of two-element
+                         // arrays.  First element is JS object whose scope
+                         // was modified, second is original value to restore.
     }catch(e){
         $error(e);
     }
 };
 
+var __updateCss2Props__ = function(elem, values){
+    if(elem.$css2props === null){
+        elem.$css2props = new CSS2Properties(elem);
+    }
+    __cssTextToStyles__(elem.$css2props, values);
+};
+
 var __registerEventAttrs__ = function(elm){
     if(elm.hasAttribute('onclick')){ 
         elm.addEventListener('click', elm.onclick ); 
@@ -5244,13 +5959,14 @@ var __registerEventAttrs__ = function(elm){
     return elm;
 };
 	
-var __click__ = function(element){
-	var event = new Event({
-	  target:element,
-	  currentTarget:element
-	});
-	event.initEvent(&quot;click&quot;);
-	element.dispatchEvent(event);
+// non-ECMA function, but no other way for click events to enter env.js
+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({
@@ -5276,17 +5992,13 @@ var __blur__ = function(element){
 	event.initEvent(&quot;blur&quot;);
 	element.dispatchEvent(event);
 };
+
+$w.HTMLElement = HTMLElement;
 $debug(&quot;Defining HTMLCollection&quot;);
 /*
 * HTMLCollection - DOM Level 2
 * Implementation Provided by Steven Wood
 */
-$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){
 
   __setArray__(this, []);
@@ -5313,6 +6025,8 @@ HTMLCollection.prototype = {
     }
 };
 
+$w.HTMLCollection = HTMLCollection;
+
 /*var HTMLCollection = function(nodelist, type){
   var $items = [], 
       $item, i;
@@ -5355,12 +6069,6 @@ HTMLCollection.prototype = {
 /* 
 * HTMLAnchorElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLAnchorElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLAnchorElement = function(ownerDocument) {
     //$log(&quot;creating anchor element&quot;);
     this.HTMLElement = HTMLElement;
@@ -5369,7 +6077,7 @@ var HTMLAnchorElement = function(ownerDocument) {
 HTMLAnchorElement.prototype = new HTMLElement;
 __extend__(HTMLAnchorElement.prototype, {
 	get accessKey() { 
-	    return this.getAttribute(&quot;accesskey&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;accesskey&quot;); 
 	    
     },
 	set accessKey(val) { 
@@ -5377,7 +6085,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get charset() { 
-	    return this.getAttribute(&quot;charset&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;charset&quot;); 
 	    
     },
 	set charset(val) { 
@@ -5385,7 +6093,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get coords() { 
-	    return this.getAttribute(&quot;coords&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;coords&quot;); 
 	    
     },
 	set coords(val) { 
@@ -5393,7 +6101,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get href() { 
-	    return this.getAttribute(&quot;href&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;href&quot;); 
 	    
     },
 	set href(val) { 
@@ -5401,7 +6109,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get hreflang() { 
-	    return this.getAttribute(&quot;hreflang&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;hreflang&quot;); 
 	    
     },
 	set hreflang(val) { 
@@ -5409,7 +6117,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get name() { 
-	    return this.getAttribute(&quot;name&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;name&quot;); 
 	    
     },
 	set name(val) { 
@@ -5417,7 +6125,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get rel() { 
-	    return this.getAttribute(&quot;rel&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;rel&quot;); 
 	    
     },
 	set rel(val) { 
@@ -5425,7 +6133,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get rev() { 
-	    return this.getAttribute(&quot;rev&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;rev&quot;); 
 	    
     },
 	set rev(val) { 
@@ -5433,23 +6141,15 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get shape() { 
-	    return this.getAttribute(&quot;shape&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;shape&quot;); 
 	    
     },
 	set shape(val) { 
 	    return this.setAttribute(&quot;shape&quot;,val); 
 	    
     },
-	get tabIndex() { 
-	    return this.getAttribute(&quot;tabindex&quot;) || &quot;&quot;; 
-	    
-    },
-	set tabIndex(val) { 
-	    return this.setAttribute(&quot;tabindex&quot;,val); 
-	    
-    },
 	get target() { 
-	    return this.getAttribute(&quot;target&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;target&quot;); 
 	    
     },
 	set target(val) { 
@@ -5457,7 +6157,7 @@ __extend__(HTMLAnchorElement.prototype, {
 	    
     },
 	get type() { 
-	    return this.getAttribute(&quot;type&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;type&quot;); 
 	    
     },
 	set type(val) { 
@@ -5474,21 +6174,14 @@ __extend__(HTMLAnchorElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining Anchor&quot;);
+$w.HTMLAnchorElement = HTMLAnchorElement;$debug(&quot;Defining Anchor&quot;);
 /* 
 * Anchor - DOM Level 2
 */
-$w.__defineGetter__(&quot;Anchor&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var Anchor = function(ownerDocument) {
     this.HTMLAnchorElement = HTMLAnchorElement;
     this.HTMLAnchorElement(ownerDocument);
 };
-Anchor.prototype = new Anchor;
 
 (function(){
     //static regular expressions
@@ -5559,16 +6252,12 @@ Anchor.prototype = new Anchor;
   });
 
 })();
-			$debug(&quot;Defining HTMLAreaElement&quot;);
+
+$w.Anchor = Anchor;
+$debug(&quot;Defining HTMLAreaElement&quot;);
 /* 
 * HTMLAreaElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLAreaElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLAreaElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5606,12 +6295,12 @@ __extend__(HTMLAreaElement.prototype, {
         //TODO
         return 0;
     },
-    get tabIndex(){
+    /*get tabIndex(){
         return this.getAttribute('tabindex');
     },
     set tabIndex(value){
         this.setAttribute('tabindex',value);
-    },
+    },*/
     get target(){
         return this.getAttribute('target');
     },
@@ -5620,16 +6309,11 @@ __extend__(HTMLAreaElement.prototype, {
     }
 });
 
+$w.HTMLAreaElement = HTMLAreaElement;
 			$debug(&quot;Defining HTMLBaseElement&quot;);
 /* 
 * HTMLBaseElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLBaseElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLBaseElement = function(ownerDocument) {
     //$log(&quot;creating anchor element&quot;);
     this.HTMLElement = HTMLElement;
@@ -5651,16 +6335,10 @@ __extend__(HTMLBaseElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLQuoteElement&quot;);
+$w.HTMLBaseElement = HTMLBaseElement;		$debug(&quot;Defining HTMLQuoteElement&quot;);
 /* 
 * HTMLQuoteElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLQuoteElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLQuoteElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5675,16 +6353,26 @@ __extend__(HTMLQuoteElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLButtonElement&quot;);
-/* 
-* HTMLButtonElement - DOM Level 2
+$w.HTMLQuoteElement = HTMLQuoteElement;		$debug(&quot;Defining HTMLBodyElement&quot;);
+/*
+* HTMLBodyElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLButtonElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
+var HTMLBodyElement = function(ownerDocument) {
+    this.HTMLElement = HTMLElement;
+    this.HTMLElement(ownerDocument);
+};
+HTMLBodyElement.prototype = new HTMLElement;
+__extend__(HTMLBodyElement.prototype, {
+    onload: function(event){
+        __eval__(this.getAttribute('onload')||'', this)
+    }
 });
 
+$w.HTMLBodyElement = HTMLBodyElement;
+$debug(&quot;Defining HTMLButtonElement&quot;);
+/* 
+* HTMLButtonElement - DOM Level 2
+*/
 var HTMLButtonElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5704,12 +6392,12 @@ __extend__(HTMLButtonElement.prototype, {
     set accessKey(value){
         this.setAttribute('accesskey',value);
     },
-    get tabIndex(){
+    /*get tabIndex(){
         return Number(this.getAttribute('tabindex'));
     },
     set tabIndex(value){
         this.setAttribute('tabindex',Number(value));
-    },
+    },*/
     get type(){
         return this.getAttribute('type');
     },
@@ -5724,16 +6412,10 @@ __extend__(HTMLButtonElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLTableColElement&quot;);
+$w.HTMLButtonElement = HTMLButtonElement;				$debug(&quot;Defining HTMLTableColElement&quot;);
 /* 
 * HTMLTableColElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLTableColElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLTableColElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5778,16 +6460,11 @@ __extend__(HTMLTableColElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLModElement&quot;);
+$w.HTMLTableColElement = HTMLTableColElement;
+$debug(&quot;Defining HTMLModElement&quot;);
 /* 
 * HTMLModElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLModElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLModElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5808,16 +6485,38 @@ __extend__(HTMLModElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLFieldSetElement&quot;);
-/* 
-* HTMLFieldSetElement - DOM Level 2
+$w.HTMLModElement = HTMLModElement;	/*
+ * This file is a component of env.js,
+ *     http://github.com/gleneivey/env-js/commits/master/README
+ * a Pure JavaScript Browser Environment
+ * Copyright 2009 John Resig, licensed under the MIT License
+ *     http://www.opensource.org/licenses/mit-license.php
+ */
+
+
+$debug(&quot;Defining HTMLDivElement&quot;);
+/*
+* HTMLDivElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLFieldSetElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
+var HTMLDivElement = function(ownerDocument) {
+    this.HTMLElement = HTMLElement;
+    this.HTMLElement(ownerDocument);
+};
+HTMLDivElement.prototype = new HTMLElement;
+__extend__(HTMLDivElement.prototype, {
+    get align(){
+        return this.getAttribute('align') || 'left';
+    },
+    set align(value){
+        this.setAttribute('align', value);
+    }
 });
 
+$w.HTMLDivElement = HTMLDivElement;
+$debug(&quot;Defining HTMLFieldSetElement&quot;);
+/* 
+* HTMLFieldSetElement - DOM Level 2
+*/
 var HTMLFieldSetElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5833,21 +6532,10 @@ __extend__(HTMLFieldSetElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLFormElement&quot;);
+$w.HTMLFieldSetElement = HTMLFieldSetElement;	$debug(&quot;Defining HTMLFormElement&quot;);
 /* 
-* HTMLAnchorElement - DOM Level 2
+* HTMLFormElement - 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(ownerDocument){
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5895,7 +6583,7 @@ __extend__(HTMLFormElement.prototype,{
         
     },
 	get name() {
-	    return this.getAttribute(&quot;name&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;name&quot;); 
 	    
     },
 	set name(val) { 
@@ -5903,7 +6591,7 @@ __extend__(HTMLFormElement.prototype,{
 	    
     },
 	get target() { 
-	    return this.getAttribute(&quot;target&quot;) || &quot;&quot;; 
+	    return this.getAttribute(&quot;target&quot;); 
 	    
     },
 	set target(val) { 
@@ -5920,16 +6608,10 @@ __extend__(HTMLFormElement.prototype,{
     }
 });
 
-			$debug(&quot;Defining HTMLFrameElement&quot;);
+$w.HTMLFormElement	= HTMLFormElement;$debug(&quot;Defining HTMLFrameElement&quot;);
 /* 
 * HTMLFrameElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLFrameElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLFrameElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -5983,34 +6665,33 @@ __extend__(HTMLFrameElement.prototype, {
     },
     set src(value){
         this.setAttribute('src', value);
+
+        if (value &amp;&amp; value.length &gt; 0){
+            $env.loadFrame(this, $env.location(value));
+            
+            var event = document.createEvent();
+            event.initEvent(&quot;load&quot;);
+            this.dispatchEvent( event, false );
+        }
     },
     get contentDocument(){
-        $debug(&quot;getting content document for (i)frame&quot;);
-        if(!this._content){
-            this._content = new HTMLDocument($implementation);
-            if(this.src.length &gt; 0){
-                $info(&quot;Loading frame content from &quot; + this.src);
-                try{
-                    this._content.load(this.src);
-                }catch(e){
-                    $error(&quot;failed to load frame content: from &quot; + this.src, e);
-                }
-            }
-        }
-        return true;
+        if (!this._content)
+            return null;
+        return this._content.document;
+    },
+    get contentWindow(){
+        return this._content;
+    },
+    onload: function(event){
+        __eval__(this.getAttribute('onload')||'', this)
     }
 });
 
-			$debug(&quot;Defining HTMLFrameSetElement&quot;);
+$w.HTMLFrameElement = HTMLFrameElement;
+$debug(&quot;Defining HTMLFrameSetElement&quot;);
 /* 
 * HTMLFrameSetElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLFrameSetElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLFrameSetElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6031,16 +6712,10 @@ __extend__(HTMLFrameSetElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLHeadElement&quot;);
+$w.HTMLFrameSetElement = HTMLFrameSetElement;	$debug(&quot;Defining HTMLHeadElement&quot;);
 /* 
 * HTMLHeadElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLHeadElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLHeadElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6078,16 +6753,13 @@ var __evalScript__ = function(newChild){
             $policy.loadScript(newChild);
         }
     }
-};$debug(&quot;Defining HTMLIFrameElement&quot;);
+};
+
+$w.HTMLHeadElement = HTMLHeadElement;
+$debug(&quot;Defining HTMLIFrameElement&quot;);
 /* 
 * HTMLIFrameElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLIFrameElement&quot;, function(){
-  return function(){
-    throw new Error(&quot;Object cannot be created in this context&quot;);
-  };
-});
-
 var HTMLIFrameElement = function(ownerDocument) {
     this.HTMLFrameElement = HTMLFrameElement;
     this.HTMLFrameElement(ownerDocument);
@@ -6108,17 +6780,11 @@ __extend__(HTMLIFrameElement.prototype, {
     }
 });
 
-
+$w.HTMLIFrameElement = HTMLIFrameElement;
 			$debug(&quot;Defining HTMLImageElement&quot;);
 /* 
 * HTMLImageElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLImageElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLImageElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6160,28 +6826,31 @@ __extend__(HTMLImageElement.prototype, {
     },
     set src(value){
         this.setAttribute('src', value);
+
+        var event = document.createEvent();
+        event.initEvent(&quot;load&quot;);
+        this.dispatchEvent( event, false );
     },
     get width(){
         return this.getAttribute('width');
     },
     set width(value){
         this.setAttribute('width', value);
+    },
+    onload: function(event){
+        __eval__(this.getAttribute('onload')||'', this)
     }
 });
 
-			$debug(&quot;Defining HTMLInputElement&quot;);
+$w.HTMLImageElement = HTMLImageElement;$debug(&quot;Defining HTMLInputElement&quot;);
 /* 
 * HTMLInputElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLInputElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLInputElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
+
+    this._oldValue = &quot;&quot;;
 };
 HTMLInputElement.prototype = new HTMLElement;
 __extend__(HTMLInputElement.prototype, {
@@ -6261,12 +6930,12 @@ __extend__(HTMLInputElement.prototype, {
     set src(value){
         this.setAttribute('src', value);
     },
-    get tabIndex(){
+    /*get tabIndex(){
         return Number(this.getAttribute('tabindex'));
     },
     set tabIndex(value){
         this.setAttribute('tabindex',Number(value));
-    },
+    },*/
     get type(){
         return this.getAttribute('type');
     },
@@ -6280,15 +6949,22 @@ __extend__(HTMLInputElement.prototype, {
         return this.getAttribute('value');
     },
     set value(value){
+        if(this.defaultValue===null&amp;&amp;this.value!==null)
+            this.defaultValue = this.value;
         this.setAttribute('value',value);
     },
-	blur:function(){
-	    __blur__(this);
-	    
+    blur:function(){
+        __blur__(this);
+
+        if (this._oldValue != this.getAttribute('value')){
+            var event = document.createEvent();
+            event.initEvent(&quot;change&quot;);
+            this.dispatchEvent( event );
+        }
     },
-	focus:function(){
-	    __focus__(this);
-	    
+    focus:function(){
+        __focus__(this);
+        this._oldValue = this.getAttribute('value');
     },
 	select:function(){
 	    __select__(this);
@@ -6297,19 +6973,16 @@ __extend__(HTMLInputElement.prototype, {
 	click:function(){
 	    __click__(this);
 	    
+    },
+    onchange: function(event){
+        __eval__(this.getAttribute('onchange')||'', this)
     }
 });
 
-			$debug(&quot;Defining HTMLLabelElement&quot;);
+$w.HTMLInputElement = HTMLInputElement;$debug(&quot;Defining HTMLLabelElement&quot;);
 /* 
 * HTMLLabelElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLLabelElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLLabelElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6337,16 +7010,10 @@ __extend__(HTMLLabelElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLLegendElement&quot;);
+$w.HTMLLabelElement = HTMLLabelElement;	$debug(&quot;Defining HTMLLegendElement&quot;);
 /* 
 * HTMLLegendElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLLegendElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLLegendElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6368,7 +7035,7 @@ __extend__(HTMLLegendElement.prototype, {
     }
 });
 
-			/**
+$w.HTMLLegendElement = HTMLLegendElement;	/**
 * Link - HTMLElement 
 */
 $w.__defineGetter__(&quot;Link&quot;, function(){
@@ -6382,12 +7049,6 @@ $debug(&quot;Defining HTMLLinkElement&quot;);
 /* 
 * HTMLLinkElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLLinkElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLLinkElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6447,21 +7108,17 @@ __extend__(HTMLLinkElement.prototype, {
     },
     set type(value){
         this.setAttribute('type',value);
+    },
+    onload: function(event){
+        __eval__(this.getAttribute('onload')||'', this)
     }
 });
 
-			
-
-			$debug(&quot;Defining HTMLMapElement&quot;);
+$w.HTMLLinkElement = HTMLLinkElement;
+$debug(&quot;Defining HTMLMapElement&quot;);
 /* 
 * HTMLMapElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLMapElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLMapElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6479,16 +7136,10 @@ __extend__(HTMLMapElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLMetaElement&quot;);
+$w.HTMLMapElement = HTMLMapElement;$debug(&quot;Defining HTMLMetaElement&quot;);
 /* 
 * HTMLMetaElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLMetaElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLMetaElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6521,16 +7172,11 @@ __extend__(HTMLMetaElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLObjectElement&quot;);
+$w.HTMLMetaElement = HTMLMetaElement;
+$debug(&quot;Defining HTMLObjectElement&quot;);
 /* 
 * HTMLObjectElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLObjectElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLObjectElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6585,12 +7231,12 @@ __extend__(HTMLObjectElement.prototype, {
     set standby(value){
         this.setAttribute('standby',value);
     },
-    get tabIndex(){
+    /*get tabIndex(){
         return this.getAttribute('tabindex');
     },
     set tabIndex(value){
         this.setAttribute('tabindex',value);
-    },
+    },*/
     get type(){
         return this.getAttribute('type');
     },
@@ -6614,16 +7260,11 @@ __extend__(HTMLObjectElement.prototype, {
     }
 });
 
+$w.HTMLObjectElement = HTMLObjectElement;
 			$debug(&quot;Defining HTMLOptGroupElement&quot;);
 /* 
 * HTMLOptGroupElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLOptGroupElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLOptGroupElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6644,16 +7285,10 @@ __extend__(HTMLOptGroupElement.prototype, {
     },
 });
 
-			$debug(&quot;Defining HTMLOptionElement&quot;);
+$w.HTMLOptGroupElement = HTMLOptGroupElement;		$debug(&quot;Defining HTMLOptionElement&quot;);
 /* 
 * HTMLOptionElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLOptionElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLOptionElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6674,7 +7309,9 @@ __extend__(HTMLOptionElement.prototype, {
         this.setAttribute('defaultSelected',value);
     },
     get text(){
-        return this.nodeValue;
+         return ((this.nodeValue === null) ||  (this.nodeValue ===undefined)) ? 
+             this.innerHTML : 
+             this.nodeValue;
     },
     get index(){
         var options = this.parent.childNodes;
@@ -6700,26 +7337,25 @@ __extend__(HTMLOptionElement.prototype, {
         return (this.getAttribute('selected')=='selected');
     },
     set selected(value){
+        if(this.defaultSelected===null&amp;&amp;this.selected!==null)
+            this.defaultSelected = this.selected;
         this.setAttribute('selected', (value ? 'selected' :''));
     },
     get value(){
-        return this.getAttribute('value');
+        return ((this.getAttribute('value') === undefined) || (this.getAttribute('value') === null)) ?
+            this.text : 
+            this.getAttribute('value');
     },
     set value(value){
         this.setAttribute('value',value);
     }
 });
 
-			$debug(&quot;Defining HTMLParamElement&quot;);
+$w.HTMLOptionElement = HTMLOptionElement;
+$debug(&quot;Defining HTMLParamElement&quot;);
 /* 
 * HTMLParamElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLParamElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLParamElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6752,16 +7388,11 @@ __extend__(HTMLParamElement.prototype, {
     },
 });
 
-			$debug(&quot;Defining HTMLScriptElement&quot;);
+$w.HTMLParamElement = HTMLParamElement;
+		$debug(&quot;Defining HTMLScriptElement&quot;);
 /* 
 * HTMLScriptElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLScriptElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLScriptElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6783,6 +7414,10 @@ __extend__(HTMLScriptElement.prototype, {
         return this.nodeValue;
 
     },
+    set text(value){
+        this.nodeValue = value;
+        $env.loadInlineScript(this);
+    },
     get htmlFor(){
         return this.getAttribute('for');
     },
@@ -6818,22 +7453,21 @@ __extend__(HTMLScriptElement.prototype, {
     },
     set type(value){
         this.setAttribute('type',value);
+    },
+    onload: function(event){
+        __eval__(this.getAttribute('onload')||'', this)
     }
 });
 
-            $debug(&quot;Defining HTMLSelectElement&quot;);
-/* 
+$w.HTMLScriptElement = HTMLScriptElement;$debug(&quot;Defining HTMLSelectElement&quot;);
+/*
 * HTMLSelectElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLSelectElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLSelectElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
+
+    this._oldIndex = -1;
 };
 HTMLSelectElement.prototype = new HTMLElement;
 __extend__(HTMLSelectElement.prototype, {
@@ -6850,7 +7484,13 @@ __extend__(HTMLSelectElement.prototype, {
         return -1;
     },
     set selectedIndex(value){
-        this.options[Number(value)].selected = 'selected';
+        if (this.selectedIndex != -1) {
+            this.options[this.selectedIndex].selected = '';
+        }
+        var option = this.options[Number(value)];
+        if (option) {
+            option.selected = 'selected';
+        }
     },
     get value(){
         return this.getAttribute('value')||'';
@@ -6906,12 +7546,12 @@ __extend__(HTMLSelectElement.prototype, {
     set size(value){
         this.setAttribute('size',value);
     },
-    get tabIndex(){
+    /*get tabIndex(){
         return Number(this.getAttribute('tabindex'));
     },
     set tabIndex(value){
         this.setAttribute('tabindex',value);
-    },
+    },*/
     add : function(){
         __add__(this);
     },
@@ -6920,22 +7560,26 @@ __extend__(HTMLSelectElement.prototype, {
     },
     blur: function(){
         __blur__(this);
+
+        if (this._oldIndex != this.selectedIndex){
+            var event = document.createEvent();
+            event.initEvent(&quot;change&quot;);
+            this.dispatchEvent( event );
+        }
     },
     focus: function(){
         __focus__(this);
+        this._oldIndex = this.selectedIndex;
+    },
+    onchange: function(event){
+        __eval__(this.getAttribute('onchange')||'', this)
     }
 });
 
-			$debug(&quot;Defining HTMLStyleElement&quot;);
+$w.HTMLSelectElement = HTMLSelectElement;$debug(&quot;Defining HTMLStyleElement&quot;);
 /* 
 * HTMLStyleElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLStyleElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLStyleElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -6962,19 +7606,12 @@ __extend__(HTMLStyleElement.prototype, {
     }
 });
 
-			$debug(&quot;Defining HTMLTableElement&quot;);
+$w.HTMLStyleElement = HTMLStyleElement;$debug(&quot;Defining HTMLTableElement&quot;);
 /* 
 * HTMLTableElement - DOM Level 2
 * Implementation Provided by Steven Wood
 */
-$w.__defineGetter__(&quot;HTMLTableElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLTableElement = function(ownerDocument) {
-
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
 
@@ -6983,6 +7620,84 @@ var HTMLTableElement = function(ownerDocument) {
 HTMLTableElement.prototype = new HTMLElement;
 __extend__(HTMLTableElement.prototype, {
     
+        get tFoot() { 
+        //tFoot returns the table footer.
+        return this.getElementsByTagName(&quot;tfoot&quot;)[0];
+    },
+    
+    createTFoot : function () {
+        var tFoot = this.tFoot;
+       
+        if (!tFoot) {
+            tFoot = document.createElement(&quot;tfoot&quot;);
+            this.appendChild(tFoot);
+        }
+        
+        return tFoot;
+    },
+    
+    deleteTFoot : function () {
+        var foot = this.tFoot;
+        if (foot) {
+            foot.parentNode.removeChild(foot);
+        }
+    },
+    
+    get tHead() { 
+        //tHead returns the table head.
+        return this.getElementsByTagName(&quot;thead&quot;)[0];
+    },
+    
+    createTHead : function () {
+        var tHead = this.tHead;
+       
+        if (!tHead) {
+            tHead = document.createElement(&quot;thead&quot;);
+            this.insertBefore(tHead, this.firstChild);
+        }
+        
+        return tHead;
+    },
+    
+    deleteTHead : function () {
+        var head = this.tHead;
+        if (head) {
+            head.parentNode.removeChild(head);
+        }
+    },
+ 
+    appendChild : function (child) {
+        
+        var tagName;
+        if(child.tagName){
+            tagName = child.tagName.toLowerCase();
+            if (tagName === &quot;tr&quot;) {
+                // need an implcit &lt;tbody&gt; to contain this...
+                if (!this.currentBody) {
+                    this.currentBody = document.createElement(&quot;tbody&quot;);
+                
+                    DOMNode.prototype.appendChild.apply(this, [this.currentBody]);
+                }
+              
+                return this.currentBody.appendChild(child); 
+       
+            } else if (tagName === &quot;tbody&quot; || tagName === &quot;tfoot&quot; &amp;&amp; this.currentBody) {
+                this.currentBody = child;
+                return DOMNode.prototype.appendChild.apply(this, arguments);  
+                
+            } else {
+                return DOMNode.prototype.appendChild.apply(this, arguments);
+            }
+        }else{
+            $error('HTMLTableElement.appendChild =&gt; child.tagName should not be undefined here... Fix ME!');
+        }
+    },
+     
+    get tBodies() {
+        return new HTMLCollection(this.getElementsByTagName(&quot;tbody&quot;));
+        
+    },
+    
     get rows() {
         return new HTMLCollection(this.getElementsByTagName(&quot;tr&quot;));
     },
@@ -6992,11 +7707,165 @@ __extend__(HTMLTableElement.prototype, {
             throw new Error(&quot;Index omitted in call to HTMLTableElement.insertRow &quot;);
         }
         
+        var rows = this.rows, 
+            numRows = rows.length,
+            node,
+            inserted, 
+            lastRow;
+        
+        if (idx &gt; numRows) {
+            throw new Error(&quot;Index &gt; rows.length in call to HTMLTableElement.insertRow&quot;);
+        }
+        
+        var inserted = document.createElement(&quot;tr&quot;);
+        // If index is -1 or equal to the number of rows, 
+        // the row is appended as the last row. If index is omitted 
+        // or greater than the number of rows, an error will result
+        if (idx === -1 || idx === numRows) {
+            lastRow = rows[rows.length-1];
+            lastRow.parentNode.appendChild(inserted);
+        } else {
+            rows[idx].parentNode.insertBefore(inserted, rows[idx]);
+        }
+
+        return inserted;
+    },
+    
+    deleteRow : function (idx) {
+        var elem = this.rows[idx];
+        elem.parentNode.removeChild(elem);
+    },
+    
+    get summary() {
+        return this.getAttribute(&quot;summary&quot;);
+    },
+    
+    set summary(summary) {
+        this.setAttribute(&quot;summary&quot;, summary);
+    },
+    
+    get align() {
+        return this.getAttribute(&quot;align&quot;);
+    },
+    
+    set align(align) {
+        this.setAttribute(&quot;align&quot;, align);
+    },
+    
+     
+    get bgColor() {
+        return this.getAttribute(&quot;bgColor&quot;);
+    },
+    
+    set bgColor(bgColor) {
+        return this.setAttribute(&quot;bgColor&quot;, bgColor);
+    },
+   
+    get cellPadding() {
+        return this.getAttribute(&quot;cellPadding&quot;);
+    },
+    
+    set cellPadding(cellPadding) {
+        return this.setAttribute(&quot;cellPadding&quot;, cellPadding);
+    },
+    
+    
+    get cellSpacing() {
+        return this.getAttribute(&quot;cellSpacing&quot;);
+    },
+    
+    set cellSpacing(cellSpacing) {
+        this.setAttribute(&quot;cellSpacing&quot;, cellSpacing);
+    },
+
+    get frame() {
+        return this.getAttribute(&quot;frame&quot;);
+    },
+    
+    set frame(frame) { 
+        this.setAttribute(&quot;frame&quot;, frame);
+    },
+    
+    get rules() {
+        return this.getAttribute(&quot;rules&quot;);
+    }, 
+    
+    set rules(rules) {
+        this.setAttribute(&quot;rules&quot;, rules);
+    }, 
+    
+    get width() {
+        return this.getAttribute(&quot;width&quot;);
+    },
+    
+    set width(width) {
+        this.setAttribute(&quot;width&quot;, width);
+    }
+    
+});
+
+$w.HTMLTableElement = HTMLTableElement;		$debug(&quot;Defining HTMLTableSectionElement&quot;);
+/* 
+* HTMLxElement - DOM Level 2
+* - Contributed by Steven Wood
+*/
+var HTMLTableSectionElement = function(ownerDocument) {
+    this.HTMLElement = HTMLElement;
+    this.HTMLElement(ownerDocument);
+};
+HTMLTableSectionElement.prototype = new HTMLElement;
+__extend__(HTMLTableSectionElement.prototype, {    
+    
+    appendChild : function (child) {
+    
+        // disallow nesting of these elements.
+        if (child.tagName.match(/TBODY|TFOOT|THEAD/)) {
+            return this.parentNode.appendChild(child);
+        } else {
+            return DOMNode.prototype.appendChild.apply(this, arguments);
+        }
+
+    },
+    
+    get align() {
+        return this.getAttribute(&quot;align&quot;);
+    },
+
+    get ch() {
+        return this.getAttribute(&quot;ch&quot;);
+    },
+     
+    set ch(ch) {
+        this.setAttribute(&quot;ch&quot;, ch);
+    },
+    
+    // ch gets or sets the alignment character for cells in a column. 
+    set chOff(chOff) {
+        this.setAttribute(&quot;chOff&quot;, chOff);
+    },
+     
+    get chOff(chOff) {
+        return this.getAttribute(&quot;chOff&quot;);
+    },
+     
+    get vAlign () {
+         return this.getAttribute(&quot;vAlign&quot;);
+    },
+    
+    get rows() {
+        return new HTMLCollection(this.getElementsByTagName(&quot;tr&quot;));
+    },
+    
+    insertRow : function (idx) {
+        if (idx === undefined) {
+            throw new Error(&quot;Index omitted in call to HTMLTableSectionElement.insertRow &quot;);
+        }
+        
         var numRows = this.rows.length,
             node = null;
         
         if (idx &gt; numRows) {
-            throw new Error(&quot;Index &gt; rows.length in call to HTMLTableElement.insertRow&quot;);
+            throw new Error(&quot;Index &gt; rows.length in call to HTMLTableSectionElement.insertRow&quot;);
         }
         
         var row = document.createElement(&quot;tr&quot;);
@@ -7006,8 +7875,6 @@ __extend__(HTMLTableElement.prototype, {
         if (idx === -1 || idx === numRows) {
             this.appendChild(row);
         } else {
-            
-
             node = this.firstChild;
 
             for (var i=0; i&lt;idx; i++) {
@@ -7024,20 +7891,15 @@ __extend__(HTMLTableElement.prototype, {
         var elem = this.rows[idx];
         this.removeChild(elem);
     }
-    
+
 });
 
-			$debug(&quot;Defining HTMLTableCellElement&quot;);
+$w.HTMLTableSectionElement = HTMLTableSectionElement;
+$debug(&quot;Defining HTMLTableCellElement&quot;);
 /* 
 * HTMLTableCellElement - DOM Level 2
 * Implementation Provided by Steven Wood
 */
-$w.__defineGetter__(&quot;HTMLTableCellElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
-});
-
 var HTMLTableCellElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -7050,17 +7912,163 @@ __extend__(HTMLTableCellElement.prototype, {
     
 });
 
-			$debug(&quot;Defining HTMLRowElement&quot;);
+$w.HTMLTableCellElement	= HTMLTableCellElement;$debug(&quot;Defining HTMLTextAreaElement&quot;);
+/*
+* HTMLTextAreaElement - DOM Level 2
+*/
+var HTMLTextAreaElement = function(ownerDocument) {
+    this.HTMLElement = HTMLElement;
+    this.HTMLElement(ownerDocument);
+};
+HTMLTextAreaElement.prototype = new HTMLElement;
+__extend__(HTMLTextAreaElement.prototype, {
+    get cols(){
+        return this.getAttribute('cols');
+    },
+    set cols(value){
+        this.setAttribute('cols', value);
+    },
+    get rows(){
+        return this.getAttribute('rows');
+    },
+    set rows(value){
+        this.setAttribute('rows', value);
+    },
+
+    get defaultValue(){
+        return this.getAttribute('defaultValue');
+    },
+    set defaultValue(value){
+        this.setAttribute('defaultValue', value);
+    },
+    get form(){
+        var parent = this.parent;
+        while(parent.nodeName.toLowerCase() != 'form'){
+            parent = parent.parent;
+        }
+        return parent;
+    },
+    get accessKey(){
+        return this.getAttribute('accesskey');
+    },
+    set accessKey(value){
+        this.setAttribute('accesskey',value);
+    },
+    get access(){
+        return this.getAttribute('access');
+    },
+    set access(value){
+        this.setAttribute('access', value);
+    },
+    get disabled(){
+        return (this.getAttribute('disabled')=='disabled');
+    },
+    set disabled(value){
+        this.setAttribute('disabled', (value ? 'disabled' :''));
+    },
+    get maxLength(){
+        return Number(this.getAttribute('maxlength')||'0');
+    },
+    set maxLength(value){
+        this.setAttribute('maxlength', value);
+    },
+    get name(){
+        return this.getAttribute('name')||'';
+    },
+    set name(value){
+        this.setAttribute('name', value);
+    },
+    get readOnly(){
+        return (this.getAttribute('readonly')=='readonly');
+    },
+    set readOnly(value){
+        this.setAttribute('readonly', (value ? 'readonly' :''));
+    },
+    /*get tabIndex(){
+        return Number(this.getAttribute('tabindex'));
+    },
+    set tabIndex(value){
+        this.setAttribute('tabindex',Number(value));
+    },*/
+    get type(){
+        return this.getAttribute('type');
+    },
+    set type(value){
+        this.setAttribute('type',value);
+    },
+    get value(){
+        return this.text;
+    },
+    set value(value){
+        if(this.defaultValue===null&amp;&amp;this.text!==null)
+            this.defaultValue = this.text;
+        return this.text = value;
+    },
+    blur:function(){
+        __blur__(this);
+
+        if (this._oldValue != this.getAttribute('value')){
+            var event = document.createEvent();
+            event.initEvent(&quot;change&quot;);
+            this.dispatchEvent( event );
+        }
+    },
+    focus:function(){
+        __focus__(this);
+        this._oldValue = this.getAttribute('value');
+    },
+    select:function(){
+        __select__(this);
+
+    },
+    click:function(){
+        __click__(this);
+
+    },
+    onchange: function(event){
+        __eval__(this.getAttribute('onchange')||'', this)
+    }
+});
+
+$w.HTMLTextAreaElement = HTMLTextAreaElement;
+$debug(&quot;Defining HTMLTitleElement&quot;);
 /* 
-* HTMLRowElement - DOM Level 2
-* Implementation Provided by Steven Wood
+* HTMLTitleElement - DOM Level 2
 */
-$w.__defineGetter__(&quot;HTMLTableRowElement&quot;, function(){
-    return function(){
-        throw new Error(&quot;Object cannot be created in this context&quot;);
-    };
+var HTMLTitleElement = function(ownerDocument) {
+    this.HTMLElement = HTMLElement;
+    this.HTMLElement(ownerDocument);
+};
+HTMLTitleElement.prototype = new HTMLElement;
+__extend__(HTMLTitleElement.prototype, {
+    $recursivelyGatherTextFromNodeTree: function(aNode) {
+        var accumulateText = &quot;&quot;;
+        var idx; var n;
+        for (idx=0;idx &lt; aNode.childNodes.length;idx++){
+            n = aNode.childNodes.item(idx);
+	    if      (n.nodeType == DOMNode.TEXT_NODE)
+                accumulateText += n.data;
+            else
+                accumulateText += this.$recursivelyGatherTextFromNodeTree(n);
+        }
+
+        return accumulateText;
+    },
+    get text() {
+        return this.$recursivelyGatherTextFromNodeTree(this);
+    },
+
+    set text(titleStr) {
+        this.innerHTML = titleStr; // if paranoid, would error on embedded HTML
+    }
 });
 
+$w.HTMLTitleElement = HTMLTitleElement;
+$debug(&quot;Defining HTMLTableRowElement&quot;);
+/* 
+* HTMLRowElement - DOM Level 2
+* Implementation Provided by Steven Wood
+*/
 var HTMLTableRowElement = function(ownerDocument) {
     this.HTMLElement = HTMLElement;
     this.HTMLElement(ownerDocument);
@@ -7157,28 +8165,138 @@ __extend__(HTMLTableRowElement.prototype, {
         var elem = this.cells[idx];
         this.removeChild(elem);
     }
-    
-    
+
 });
 
-			$debug(&quot;Defining Event&quot;);
+$w.HTMLTableRowElement = HTMLTableRowElement;
+/**
+ * @author thatcher
+ */
+$debug(&quot;Defining XMLSerializer&quot;);
 /*
-* event.js
+* XMLSerializer 
 */
-$w.__defineGetter__(&quot;Event&quot;, function(){
-    __extend__(this,{
-        CAPTURING_PHASE : 1,
-        AT_TARGET       : 2,
-        BUBBLING_PHASE  : 3
-    });
-    if(this.__output__ == undefined) {
-        this.__output__ = function(){
-            throw new Error(&quot;Object cannot be created in this context&quot;);
-        };
+$w.__defineGetter__(&quot;XMLSerializer&quot;, function(){
+    return new XMLSerializer(arguments);
+});
+
+var XMLSerializer = function() {
+
+};
+__extend__(XMLSerializer.prototype, {
+    serializeToString: function(node){
+        return node.xml;
+    }
+});/**
+ * @author thatcher
+ */
+$debug(&quot;Defining XPathExpression&quot;);
+/*
+* XPathExpression 
+*/
+$w.__defineGetter__(&quot;XPathExpression&quot;, function(){
+    return XPathExpression;
+});
+
+var XPathExpression = function() {};
+__extend__(XPathExpression.prototype, {
+    evaluate: function(){
+        //TODO for now just return an empty XPathResult
+        return new XPathResult();        
+    }
+});/**
+ * @author thatcher
+ */
+$debug(&quot;Defining XPathResult&quot;);
+/*
+* XPathResult 
+*/
+$w.__defineGetter__(&quot;XPathResult&quot;, function(){
+    return XPathResult;
+});
+
+var XPathResult = function() {
+    this.snapshotLength = 0;
+    this.stringValue = '';
+};
+
+__extend__( XPathResult, {
+    ANY_TYPE:                     0,
+    NUMBER_TYPE:                  1,
+    STRING_TYPE:                  2,
+    BOOLEAN_TYPE:                 3,
+    UNORDERED_NODE_ITERATOR_TYPE: 4,
+    ORDERED_NODEITERATOR_TYPE:    5,
+    UNORDERED_NODE_SNAPSHOT_TYPE: 6,
+    ORDERED_NODE_SNAPSHOT_TYPE:   7,
+    ANY_ORDERED_NODE_TYPE:        8,
+    FIRST_ORDERED_NODE_TYPE:      9
+});
+
+__extend__(XPathResult.prototype, {
+    get booleanValue(){
+      //TODO  
+    },
+    get invalidIteration(){
+        //TODO
+    },
+    get numberValue(){
+        //TODO
+    },
+    get resultType(){
+        //TODO
+    },
+    get singleNodeValue(){
+        //TODO
+    },
+    iterateNext: function(){
+        //TODO
+    },
+    snapshotItem: function(index){
+        //TODO
     }
-    return this.__output__;
 });
 
+/**
+ * @author thatcher
+ */
+
+$w.__defineGetter__(&quot;XSLTProcessor&quot;, function(){
+    return new XSLTProcessor(arguments);
+});
+
+var XSLTProcessor = function() {
+    this.__stylesheet__ = null;
+};
+__extend__(XSLTProcessor.prototype, {
+    clearParameters: function(){
+        //TODO
+    },
+    getParameter: function(nsuri, name){
+        //TODO
+    },
+    importStyleSheet: function(stylesheet){
+        this.__stylesheet__ = stylesheet;
+    },
+    removeParameter: function(nsuri, name){
+        //TODO
+    },
+    reset: function(){
+        //TODO
+    },
+    setParameter: function(nsuri, name, value){
+        //TODO
+    },
+    transformToDocument: function(sourceNode){
+        return xsltProcess(sourceNode, this.__stylesheet__);
+    },
+    transformToFragment: function(sourceNode, ownerDocument){
+        return xsltProcess(sourceNode, this.__stylesheet__).childNodes;
+    }
+});$debug(&quot;Defining Event&quot;);
+/*
+* event.js
+*/
 var Event = function(options){
   if(options === undefined){
       options={target:window,currentTarget:window};
@@ -7214,11 +8332,12 @@ var Event = function(options){
   });
 };
 
+$w.Event = Event;
 $debug(&quot;Defining MouseEvent&quot;);
 /*
 *	mouseevent.js
 */
-$debug(&quot;Defining MouseEvent&quot;);
+$debug(&quot;Defining UiEvent&quot;);
 /*
 *	uievent.js
 */
@@ -7228,52 +8347,67 @@ var $onblur,
     $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){
-    __extend__(this, __supportedStyles__);
-    __cssTextToStyles__(this, options.cssText?options.cssText:&quot;&quot;);
+var CSS2Properties = function(element){
+    //this.onSetCallback = options.onSet?options.onSet:(function(){});
+    this.styleIndex = __supportedStyles__();
+    this.nameMap = {};
+    this.__previous__ = {};
+    this.__element__ = element;
+    __cssTextToStyles__(this, element.getAttribute('style')||'');
 };
 __extend__(CSS2Properties.prototype, {
     get cssText(){
-        return Array.prototype.apply.join(this,[';\n']);
+        var css = '';
+        for(var i=0;i&lt;this.length;i++){
+            css+=this[i]+&quot;:&quot;+this.getPropertyValue(this[i])+';'
+        }
+        return css;
     },
     set cssText(cssText){ 
         __cssTextToStyles__(this, cssText); 
     },
-    getPropertyCSSValue : function(){
-        
+    getPropertyCSSValue : function(name){
+        //?
     },
     getPropertyPriority : function(){
         
     },
     getPropertyValue : function(name){
-		var camelCase = name.replace(/\-(\w)/g, function(all, letter){
-			return letter.toUpperCase();
-		});
-        var i, value = this[camelCase];
-        if(value === undefined){
-            for(i=0;i&lt;this.length;i++){
-                if(this[i]===name){
-                    return this[i];
-                }
-            }
+        if(name in this.styleIndex){
+            //$info(name +' in style index');
+            return this[name];
+        }else if(name in this.nameMap){
+            return this[__toCamelCase__(name)];
         }
-        return value;
+        //$info(name +' not found');
+        return null;
     },
     item : function(index){
         return this[index];
     },
-    removeProperty: function(){
-        
+    removeProperty: function(name){
+        this.styleIndex[name] = null;
     },
-    setProperty: function(){
-        
+    setProperty: function(name, value){
+        //$info('setting css property '+name+' : '+value);
+        name = __toCamelCase__(name);
+        if(name in this.styleIndex){
+            //$info('setting camel case css property ');
+            if (value!==undefined){
+                this.styleIndex[name] = value;
+            }
+            if(name!==__toDashed__(name)){
+                //$info('setting dashed name css property ');
+                name = __toDashed__(name);
+                this[name] = value;
+                if(!(name in this.nameMap)){
+                    Array.prototype.push.apply(this, [name]);
+                    this.nameMap[name] = this.length;
+                }
+                
+            }
+        }
+        //$info('finished setting css property '+name+' : '+value);
     },
     toString:function(){
         if (this.length &gt;0){
@@ -7284,170 +8418,227 @@ __extend__(CSS2Properties.prototype, {
     }
 });
 
+
+
 var __cssTextToStyles__ = function(css2props, cssText){
-    var styleArray=[];
-    var style, name, value, camelCaseName, w3cName, styles = cssText.split(';');
+    //var styleArray=[];
+    var style, styles = cssText.split(';');
     for ( var i = 0; i &lt; styles.length; i++ ) {
         //$log(&quot;Adding style property &quot; + styles[i]);
     	style = styles[i].split(':');
+        //$log(&quot; style  &quot; + style[0]);
     	if ( style.length == 2 ){
-    	    //keep a reference to the original name of the style which was set
-    	    //this is the w3c style setting method.
-    	    styleArray[styleArray.length] = w3cName = styles[i];
-            //camel case for dash case
-    	    value = trim(style[1]);
-            camelCaseName = trim(style[0].replace(/\-(\w)/g, function(all, letter){
-				return letter.toUpperCase();
-			}));
-            $debug('CSS Style Name:  ' + camelCaseName);
-            if(css2props[camelCaseName]!==undefined){
-                //set the value internally with camelcase name 
-                $debug('Setting css ' + camelCaseName + ' to ' + value);
-                css2props[camelCaseName] = value;
-            };
+            //$log(&quot; value  &quot; + style[1]);
+    	    css2props.setProperty( style[0].replace(&quot; &quot;,'','g'), style[1].replace(&quot; &quot;,'','g'));
     	}
     }
-    __setArray__(css2props, styleArray);
 };
+
+var __toCamelCase__ = function(name) {
+    //$info('__toCamelCase__'+name);
+    if(name){
+    	return name.replace(/\-(\w)/g, function(all, letter){
+    		return letter.toUpperCase();
+    	});
+    }
+    return name;
+};
+
+var __toDashed__ = function(camelCaseName) {
+    //$info(&quot;__toDashed__&quot;+camelCaseName);
+    if(camelCaseName){
+    	return camelCaseName.replace(/[A-Z]/g, function(all) {
+    		return &quot;-&quot; + all.toLowerCase();
+    	});
+    }
+    return camelCaseName;
+};
+
 //Obviously these arent all supported but by commenting out various sections
 //this provides a single location to configure what is exposed as supported.
-//These will likely need to be functional getters/setters in the future to deal with
-//the variation on input formulations
-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:	1,
-    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;
-};/* 
+var __supportedStyles__ = function(){
+    return {
+        azimuth:                null,
+        background:	            null,
+        backgroundAttachment:	null,
+        backgroundColor:	    null,
+        backgroundImage:	    null,
+        backgroundPosition:	    null,
+        backgroundRepeat:	    null,
+        border:	                null,
+        borderBottom:	        null,
+        borderBottomColor:	    null,
+        borderBottomStyle:	    null,
+        borderBottomWidth:	    null,
+        borderCollapse:	        null,
+        borderColor:	        null,
+        borderLeft:	            null,
+        borderLeftColor:	    null,
+        borderLeftStyle:	    null,
+        borderLeftWidth:	    null,
+        borderRight:	        null,
+        borderRightColor:	    null,
+        borderRightStyle:	    null,
+        borderRightWidth:	    null,
+        borderSpacing:	        null,
+        borderStyle:	        null,
+        borderTop:	            null,
+        borderTopColor:	        null,
+        borderTopStyle:	        null,
+        borderTopWidth:	        null,
+        borderWidth:	        null,
+        bottom:	                null,
+        captionSide:	        null,
+        clear:	                null,
+        clip:	                null,
+        color:	                null,
+        content:	            null,
+        counterIncrement:	    null,
+        counterReset:	        null,
+        cssFloat:	            null,
+        cue:	                null,
+        cueAfter:	            null,
+        cueBefore:	            null,
+        cursor:	                null,
+        direction:	            'ltr',
+        display:	            null,
+        elevation:	            null,
+        emptyCells:	            null,
+        font:	                null,
+        fontFamily:	            null,
+        fontSize:	            &quot;1em&quot;,
+        fontSizeAdjust:	null,
+        fontStretch:	null,
+        fontStyle:	null,
+        fontVariant:	null,
+        fontWeight:	null,
+        height:	'1px',
+        left:	null,
+        letterSpacing:	null,
+        lineHeight:	null,
+        listStyle:	null,
+        listStyleImage:	null,
+        listStylePosition:	null,
+        listStyleType:	null,
+        margin:	null,
+        marginBottom:	&quot;0px&quot;,
+        marginLeft:	&quot;0px&quot;,
+        marginRight:	&quot;0px&quot;,
+        marginTop:	&quot;0px&quot;,
+        markerOffset:	null,
+        marks:	null,
+        maxHeight:	null,
+        maxWidth:	null,
+        minHeight:	null,
+        minWidth:	null,
+        opacity:	1,
+        orphans:	null,
+        outline:	null,
+        outlineColor:	null,
+        outlineOffset:	null,
+        outlineStyle:	null,
+        outlineWidth:	null,
+        overflow:	null,
+        overflowX:	null,
+        overflowY:	null,
+        padding:	null,
+        paddingBottom:	&quot;0px&quot;,
+        paddingLeft:	&quot;0px&quot;,
+        paddingRight:	&quot;0px&quot;,
+        paddingTop:	&quot;0px&quot;,
+        page:	null,
+        pageBreakAfter:	null,
+        pageBreakBefore:	null,
+        pageBreakInside:	null,
+        pause:	null,
+        pauseAfter:	null,
+        pauseBefore:	null,
+        pitch:	null,
+        pitchRange:	null,
+        position:	null,
+        quotes:	null,
+        richness:	null,
+        right:	null,
+        size:	null,
+        speak:	null,
+        speakHeader:	null,
+        speakNumeral:	null,
+        speakPunctuation:	null,
+        speechRate:	null,
+        stress:	null,
+        tableLayout:	null,
+        textAlign:	null,
+        textDecoration:	null,
+        textIndent:	null,
+        textShadow:	null,
+        textTransform:	null,
+        top:	null,
+        unicodeBidi:	null,
+        verticalAlign:	null,
+        visibility:	null,
+        voiceFamily:	null,
+        volume:	null,
+        whiteSpace:	null,
+        widows:	null,
+        width:	'1px',
+        wordSpacing:	null,
+        zIndex:	1
+    };
+};
+
+var __displayMap__ = {
+		&quot;DIV&quot;      : &quot;block&quot;,
+		&quot;P&quot;        : &quot;block&quot;,
+		&quot;A&quot;        : &quot;inline&quot;,
+		&quot;CODE&quot;     : &quot;inline&quot;,
+		&quot;PRE&quot;      : &quot;block&quot;,
+		&quot;SPAN&quot;     : &quot;inline&quot;,
+		&quot;TABLE&quot;    : &quot;table&quot;,
+		&quot;THEAD&quot;    : &quot;table-header-group&quot;,
+		&quot;TBODY&quot;    : &quot;table-row-group&quot;,
+		&quot;TR&quot;       : &quot;table-row&quot;,
+		&quot;TH&quot;       : &quot;table-cell&quot;,
+		&quot;TD&quot;       : &quot;table-cell&quot;,
+		&quot;UL&quot;       : &quot;block&quot;,
+		&quot;LI&quot;       : &quot;list-item&quot;
+};
+var __styleMap__ = __supportedStyles__();
+
+for(var style in __supportedStyles__()){
+    (function(name){
+        if(name === 'width' || name === 'height'){
+            CSS2Properties.prototype.__defineGetter__(name, function(){
+                if(this.display==='none'){
+                    return '0px';
+                }
+                //$info(name+' = '+this.getPropertyValue(name));
+                return this.styleIndex[name];
+            });
+        }else if(name === 'display'){
+            //display will be set to a tagName specific value if &quot;&quot;
+            CSS2Properties.prototype.__defineGetter__(name, function(){
+                var val = this.styleIndex[name];
+                val = val?val:__displayMap__[this.__element__.tagName];
+                //$log(&quot; css2properties.get  &quot; + name + &quot;=&quot;+val+&quot; for(&quot;+this.__element__.tagName+&quot;)&quot;);
+                return val;
+            });
+        }else{
+            CSS2Properties.prototype.__defineGetter__(name, function(){
+                //$log(&quot; css2properties.get  &quot; + name + &quot;=&quot;+this.styleIndex[name]);
+                return this.styleIndex[name];
+            });
+       }
+       CSS2Properties.prototype.__defineSetter__(name, function(value){
+           //$log(&quot; css2properties.set  &quot; + name +&quot;=&quot;+value);
+           this.setProperty(name, value);
+       });
+    })(style);
+};
+
+
+$w.CSS2Properties = CSS2Properties;/* 
 * 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;;
@@ -7466,15 +8657,10 @@ var CSSRule = function(options){
       }
     });
 };
+$w.CSSRule = CSSRule;
 /* 
 * 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,
@@ -7522,6 +8708,8 @@ var CSSStyleSheet = function(options){
       removeRule: function(index){this.deleteRule(index);}//IE - may be deprecated
     });
 };
+
+$w.CSSStyleSheet = CSSStyleSheet;
 /*
 *	location.js
 *   - requires env
@@ -7627,7 +8815,6 @@ $w.__defineGetter__(&quot;location&quot;, function(url){
 *	history.js
 */
 
-    $info(&quot;Initializing Window History.&quot;);
 	$currentHistoryIndex = 0;
 	$history = [];
 	
@@ -7736,12 +8923,12 @@ $debug(&quot;Initializing Window Timer.&quot;);
 //private
 var $timers = [];
 
-$w.setTimeout = function(fn, time){
-	var num;
-	return num = window.setInterval(function(){
-		fn();
-		window.clearInterval(num);
-	}, time);
+window.setTimeout = function(fn, time){
+  var num;
+  return num = window.setInterval(function(){
+    fn();
+    window.clearInterval(num);
+  }, time);
 };
 
 window.setInterval = function(fn, time){
@@ -7756,17 +8943,17 @@ window.setInterval = function(fn, time){
 	if(time===0){
 	    fn();
 	}else{
-	    $log(&quot;Creating timer number &quot;+num);
-    	$timers[num] = $env.timer(fn, time);
+	    //$debug(&quot;Creating timer number &quot;+num);
+    	$timers[num] = new $env.timer(fn, time);
     	$timers[num].start();
 	}
 	return num;
 };
 
 window.clearInterval = window.clearTimeout = function(num){
+	//$log(&quot;clearing interval &quot;+num);
 	if ( $timers[num] ) {
 	    
-	    $debug(&quot;Deleting timer number &quot;+num);
 		$timers[num].stop();
 		delete $timers[num];
 	}
@@ -7782,7 +8969,7 @@ var $events = [],
     $onunload;
 
 $w.addEventListener = function(type, fn){
-  //$log(&quot;adding event listener &quot; + type);
+    $debug(&quot;adding event listener \n\t&quot; + type +&quot; \n\tfor &quot;+this+&quot; with callback \n\t&quot;+fn);
 	if ( !this.uuid ) {
 		this.uuid = $events.length;
 		$events[this.uuid] = {};
@@ -7809,25 +8996,39 @@ $w.removeEventListener = function(type, fn){
 		});
 };
 
-$w.dispatchEvent = function(event){
-    //$log(&quot;dispatching event &quot; + event.type);
+$w.dispatchEvent = function(event, bubbles){
+    $debug(&quot;dispatching event &quot; + event.type);
+
     //the window scope defines the $event object, for IE(^^^) compatibility;
     $event = event;
-    if(!event.target)
+
+    if (bubbles == undefined || bubbles == null)
+        bubbles = true;
+
+    if (!event.target) {
+        $debug(&quot;no event target : &quot;+event.target);
         event.target = this;
-    if ( event.type ) {
+    }
+    $debug(&quot;event target: &quot; + event.target);
+    if ( event.type &amp;&amp; this.nodeType || this===window) {
+        $debug(&quot;nodeType: &quot; + this.nodeType);
         if ( this.uuid &amp;&amp; $events[this.uuid][event.type] ) {
             var _this = this;
             $events[this.uuid][event.type].forEach(function(fn){
-                fn.call( _this, event );
+                $debug('calling event handler '+fn+' on target '+_this);
+                fn( event );
             });
         }
     
-        if ( this[&quot;on&quot; + event.type] )
-            this[&quot;on&quot; + event.type].call( _this, event );
+        if (this[&quot;on&quot; + event.type]) {
+            $debug('calling event handler on'+event.type+' on target '+this);
+            this[&quot;on&quot; + event.type](event);
+        }
+    }else{
+        $debug(&quot;non target: &quot; + event.target + &quot; \n this-&gt;&quot;+this);
     }
-    if(this.parentNode){
-        this.parentNode.dispatchEvent.call(this.parentNode,event);
+    if (bubbles &amp;&amp; this.parentNode){
+        this.parentNode.dispatchEvent(event);
     }
 };
 	
@@ -7886,7 +9087,6 @@ XMLHttpRequest.prototype = {
 	setRequestHeader: function(header, value){
 		this.headers[header] = value;
 	},
-	getResponseHeader: function(header){ },
 	send: function(data){
 		var _this = this;
 		
@@ -7903,11 +9103,22 @@ XMLHttpRequest.prototype = {
         					    $debug(&quot;parsing response text into xml document&quot;);
         						responseXML = $domparser.parseFromString(_this.responseText+&quot;&quot;);
                                 return responseXML;
-        					} catch(e) { return null;/*TODO: need to flag an error here*/}
+        					} catch(e) { 
+                                $error('response XML does not apear to be well formed xml', e);
+        						responseXML = $domparser.parseFromString(&quot;&lt;html&gt;&quot;+
+                                    &quot;&lt;head/&gt;&lt;body&gt;&lt;p&gt; parse error &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
+                                return responseXML;
+                            }
       					}
-      				}else{return null;}
+      				}else{
+                        $env.warn('response XML does not apear to be xml');
+                        return null;
+                    }
       			});
-			});
+                _this.__defineSetter__(&quot;responseXML&quot;,function(xml){
+                    responseXML = xml;
+                });
+			}, data);
 			_this.onreadystatechange();
 		}
 		if (this.async){
@@ -7925,6 +9136,7 @@ XMLHttpRequest.prototype = {
 		//TODO
 	},
 	getResponseHeader: function(header){
+        $debug('GETTING RESPONSE HEADER '+header);
 	  var rHeader, returnedHeaders;
 		if (this.readyState &lt; 3){
 			throw new Error(&quot;INVALID_STATE_ERR&quot;);
@@ -7934,8 +9146,13 @@ XMLHttpRequest.prototype = {
 				if (rHeader.match(new RegExp(header, &quot;i&quot;)))
 					returnedHeaders.push(this.responseHeaders[rHeader]);
 			}
-			if (returnedHeaders.length){ return returnedHeaders.join(&quot;, &quot;); }
-		}return null;
+            
+			if (returnedHeaders.length){ 
+                $debug('GOT RESPONSE HEADER '+returnedHeaders.join(&quot;, &quot;));
+                return returnedHeaders.join(&quot;, &quot;); 
+            }
+		}
+        return null;
 	},
 	getAllResponseHeaders: function(){
 	  var header, returnedHeaders = [];
@@ -7959,6 +9176,7 @@ $debug(&quot;Initializing Window CSS&quot;);
 // attributes and values used to render the specified element in this
 // window.  Any length values are always expressed in pixel, or
 // absolute values.
+
 $w.getComputedStyle = function(elt, pseudo_elt){
   //TODO
   //this is a naive implementation
@@ -8021,7 +9239,7 @@ $w.scrollTo = function(x,y){
 */
 $debug(&quot;Initializing Window Dialogs.&quot;);
 $w.alert = function(message){
- //TODO 
+     $env.warn(message);
 };
 
 $w.confirm = function(question){
@@ -8311,7 +9529,7 @@ window.$profiler.stats = function(raw){
     };
 };
 
-if(__env__.profile){
+if($env.profile){
     /**
     *   CSS2Properties
     */
@@ -8693,7 +9911,7 @@ __extend__(HTMLDocument.prototype, {
 	
 
 
-var $document =  new HTMLDocument($implementation);
+var $document =  new HTMLDocument($implementation, $w);
 $w.__defineGetter__(&quot;document&quot;, function(){
 	return $document;
 });
@@ -8823,7 +10041,6 @@ var loadCookies = function(){
 //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.
-$info(&quot;Loading Cookies&quot;);
 try{
 	//TODO - load cookies
 	loadCookies();
@@ -8834,8 +10051,15 @@ try{
 *	outro.js
 */
 
-})(window, __env__, __policy__); 
 
-}catch(e){
-    __env__.error(&quot;ERROR LOADING ENV : &quot; + e + &quot;\nLINE SOURCE:\n&quot; +__env__.lineSource(e));
+    };// close function definition begun in 'intro.js'
+
+
+    // turn &quot;original&quot; JS interpreter global object into the
+    // &quot;root&quot; window object; third param value for new window's &quot;parent&quot;
+    Envjs.window(this, Envjs, null, this);
+
+} catch(e){
+    Envjs.error(&quot;ERROR LOADING ENV : &quot; + e + &quot;\nLINE SOURCE:\n&quot; +
+        Envjs.lineSource(e));
 }</diff>
      <filename>vendor/plugins/blue-ridge/lib/env.rhino.js</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,11 @@ if(BlueRidge.loaded != true) {
 
   var BLUE_RIDGE_LIB_PREFIX = (environment[&quot;blue.ridge.prefix&quot;] || &quot;../../vendor/plugins/blue-ridge&quot;) + &quot;/lib/&quot;;
   require(BLUE_RIDGE_LIB_PREFIX + &quot;env.rhino.js&quot;);
-  window.location = BlueRidge.CommandLine.fixtureFile;
+
+  Envjs(BlueRidge.CommandLine.fixtureFile, {
+    loadInlineScript: function(){},
+    log: function(){}
+  });
 
   require(BLUE_RIDGE_LIB_PREFIX + &quot;jquery-1.3.2.js&quot;);
   require(BLUE_RIDGE_LIB_PREFIX + &quot;jquery.fn.js&quot;);</diff>
      <filename>vendor/plugins/blue-ridge/lib/test_runner.js</filename>
    </modified>
    <modified>
      <diff>@@ -81,7 +81,7 @@ Screw.Unit(function() {
 
       describe('when the element is an img', function() {
         it('prints out the img src attribute', function() {
-          expect($.print($('&lt;img src=&quot;test.png&quot;/&gt;'))).to(match, /&lt;img src=&quot;.+?test.png&quot;&gt;/);
+          expect($.print($('&lt;img src=&quot;test.png&quot;/&gt;'))).to(match, /&lt;img src=&quot;.*?test.png&quot;&gt;/);
         })
       });
     });</diff>
      <filename>vendor/plugins/blue-ridge/spec/javascripts/screw.unit/screw.print_spec.js</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>vendor/plugins/blue-ridge/lib/js.jar</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>a4e394577fe55afde13e76e1dbaa1c4c8ad38425</id>
    </parent>
  </parents>
  <author>
    <name>Larry Karnowski</name>
    <email>larry@thinkrelevance.com</email>
  </author>
  <url>http://github.com/relevance/blue-ridge-sample-app/commit/5c70fb0e70e1355c8427f929ad7479cad2603166</url>
  <id>5c70fb0e70e1355c8427f929ad7479cad2603166</id>
  <committed-date>2009-08-28T06:44:04-07:00</committed-date>
  <authored-date>2009-08-28T06:44:04-07:00</authored-date>
  <message>Updated Blue Ridge plugin.</message>
  <tree>01caa29e5053dcaa7afa2c6b64c58b83efc86a69</tree>
  <committer>
    <name>Larry Karnowski</name>
    <email>larry@thinkrelevance.com</email>
  </committer>
</commit>
