super(PROTOTYPE);
this.rootDocument = rootDocument;
scopeChain = JsSystem.createGlobal();
addVar("getElementById", new JsFunction(ID_GET_ELEMENT_BY_ID, 1));
addVar("write", new JsFunction(ID_WRITE, 1));
addVar("setTimeout", new JsFunction(ID_SET_TIMEOUT, 2));
addVar("setInterval", new JsFunction(ID_SET_INTERVAL, 2));
addVar("document", this);
addVar("window", this);
addVar("console", this);
addVar("debug", new JsFunction(ID_DEBUG, 1)); //console.debug
if (rootDocument != null) {
System.out.println("doc h:"+rootDocument.getHeight());
addVar("width", new JsFunction(ID_WIDTH, -1));
addVar("height", new JsFunction(ID_HEIGHT, -1));
addVar("innerWidth", new JsFunction(ID_WIDTH, -1));
addVar("innerHeight", new JsFunction(ID_HEIGHT, -1));
} else {
System.out.println("null doc root passed to JsWindow"); //FIXME: need proper err handling
}
stack.setObject(0, this);
}