/////////////////////////////////////////////////////////////////
//	Copyright © 2004-2008 by Symmetrix Software, Inc.
//				Brookfield, Wisconsin
//				ALL RIGHTS RESERVED
//
  
//	Implements MSIE selectNodes() and selectSingleNode() members of XMLDocument & Element
//	for Mozilla-based browsers using more verbose W3C standard....
//
//	If NOT MSIE and browser supports XPath 3.0, then..... 
if ( !window.ActiveXObject && document.implementation.hasFeature("XPath", "3.0") )
	{
	// Add function to XMLDocument....
	XMLDocument.prototype.selectNodes = function( xPath, aNode )  
		{
		if( !aNode )
			aNode = this;
		var oNSResolver = this.createNSResolver( this.documentElement );
		var aItems = this.evaluate( xPath, aNode, oNSResolver,
															 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
		var aResult = new Array;
		for( var i = 0; i < aItems.snapshotLength; i++)
			aResult[i] =  aItems.snapshotItem(i);

    return aResult;
		}
		 
	XMLDocument.prototype.selectSingleNode = function( xPath, aNode )
		{
		if( !aNode ) 
			aNode = this;
		
		var xItems = this.selectNodes( xPath, aNode );
		if( xItems.length > 0 )
			return xItems[0];
		else
			return null;
		}
		
	// Ditto for elements....
	Element.prototype.selectNodes = function( xPath )
		{
		if( this.ownerDocument.selectNodes )
			return this.ownerDocument.selectNodes( xPath, this );
    else
			throw "For XML Elements Only";
		}
		
	Element.prototype.selectSingleNode = function( xPath )
		{
		if ( this.ownerDocument.selectSingleNode )
			return this.ownerDocument.selectSingleNode( xPath, this );
		else
			throw "For XML Elements Only";
		}
	}

