/*
	XPDOM Cross-Platform DOM 
	Compatibility Wrapper for Web Scripting with W3C DOM
	using  W3C Java DOM interfaces.
	http://xpdom.sourceforge.net
	http://www.sourceforge.net/projects/xpdom

	(c) 2000-2002, José María Arranz Santamaría
	mailto:jmarranz@users.sourceforge.net
	mailto:jmarranz@eresmas.com
	(Spanish citizen)
 
	Copyright of this library is covered with GNU General Public License (GPL) v2
	(see file COPYING)

	Comercial use at commercial web sites is forbidden without a license
	of the author.
*/

// Implementation of Interfaces For IE 4.x (and 5.x)
// **************************************

function pkg_net_sf_xpdom_views_ie4()
{
	this.ViewDOMImplementation = ViewDOMImplementation;
	this.AbstractViewFactory = AbstractViewFactory;
	this.AbstractView = AbstractView;


	// ViewDOMImplementation Interface (Auxiliar)
	// **************************************
	function ViewDOMImplementation() 
	{
		this.ViewDOMImplementation_init = init;

		function init()
		{
			var listfactory = this.aux_list_node_factory;

			listfactory["#window"] = new AbstractViewFactory();
		}
	}


	// Window Interface
	// **************************************
	function AbstractViewFactory()
	{
		this.NodeFactory = xpdom_dom_NodeFactory;
		this.NodeFactory();

		// Bind functions
		this.overload = overload;

		function overload(native_object,wrap_elem)
		{
			this.init(native_object,wrap_elem); // Call to NodeFactory.init()

			wrap_elem.AbstractView = AbstractView; // Constructor
			wrap_elem.AbstractView();

			native_object = null; // Help garbage col.
		}
	}

	function AbstractView()
	{
		this.SimulNativeNode = net.sf.xpdom.core.ie4.SimulNativeNode;
		this.SimulNativeNode("#window");

		// We derive from interface Node, because in MSIE 5 probably event handlers
		// of BODY or document elements are really handlers fired by window object
		// then window object hasn't the EventTarget interface (EventTarget interface needs Node interface)
		// Anyway Netscape 6 process events too.
		// It works with MSIE 4 too.

		this.Node_constructor = net.sf.xpdom.core.ie4.Node;
		this.Node_constructor(0);
		this.Node_finalize = this.finalize;

		this.EventTarget = net.sf.xpdom.events.ie4.EventTarget;
 		this.EventTarget();
		this.EventTarget_finalize = this.finalize;


		// Bind functions
		this.AbstractViewImpl = xpdom_dom_AbstractViewImpl;
		this.AbstractViewImpl();

		// These methods aren't W3C DOM (Java)
		this.finalize = finalize; // Virtual like

		// Overload 
		this.getInnerWidth =  getInnerWidth;
		this.getInnerHeight = getInnerHeight;
		this.getScrollX = getScrollX;
		this.getScrollY = getScrollY;


		// Implementation
		function finalize()
		{
			this.getDocument().finalize();
			this.aux_impl = null;

			// finalize base interfaces
			if (this.EventTarget_finalize) this.EventTarget_finalize();
			this.Node_finalize();
		}

		function getInnerWidth()
		{
			return this.native_object.document.body.clientWidth;
		}

		function getInnerHeight()
		{
			return this.native_object.document.body.clientHeight;
		}

		function getScrollX()
		{
			return this.native_object.document.body.scrollLeft;
		}

		function getScrollY()
		{
			return this.native_object.document.body.scrollTop;
		}
	}
}
