/*
 * ============================================================================
 *                   The ProQuality Inc.
 *         Rapid Efficent Low cost And Xtreme (RELAX)
 *	           Advanced Solutions Framework (ASF)
 *                  Cristian Teodorescu
 *                      Version 6.0
 * ============================================================================
 * 
 *    Copyright (C) 1999 The ProQuality Inc. Foundation. All rights reserved.
 * 
 * The use of this software in any form is strictly prohibited unless you have 
 * purchased a licence from ProQuality Inc. or you have a software agreement with 
 * ProQuality Inc.
 * 
 * Redistributions of source code must retain copyright statements
 * and notices. Redistributions must also contain a copy of this
 * document.
 *
  THIS SOFTWARE IS PROVIDED BY PROQUALITY AND CONTRIBUTORS ``AS IS'' AND
  ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PROQUALITY OR ITS
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  DAMAGE.
    
 *
 */
/**
 * A partial implementation of the W3C DOM Level 2 Node interface.
 */
function MockNode( nodeName, nodeType ) {
  // alert( "MockNode( " + nodeName + " )" );
  this.nodeName = nodeName;
  this.nodeValue;
  this.nodeType = nodeType;
  this.parentNode;
  this.childNodes = new MockNodeList();
  this.firstChild;
  this.lastChild;
  this.previousSibling;
  this.nextSibling;
  this.attributes;
  this.ownerDocument;
  this.style = new MockStyle();
}
MockNode.ELEMENT_NODE = 1;
MockNode.ATTRIBUTE_NODE = 2;
MockNode.TEXT_NODE = 3;
MockNode.CDATA_SECTION_NODE = 4;
MockNode.ENTITY_REFERENCE_NODE = 5;
MockNode.ENTITY_NODE = 6;
MockNode.PROCESSING_INSTRUCTION_NODE = 7;
MockNode.COMMENT_NODE = 8;
MockNode.DOCUMENT_NODE = 9;
MockNode.DOCUMENT_TYPE_NODE = 10;
MockNode.DOCUMENT_FRAGMENT_NODE = 11;
MockNode.NOTATION_NODE = 12;
MockNode.prototype.appendChild = Mock_appendChild;
MockNode.prototype.toString = function() { return "[object MockNode]"; } 

function MockElement( nodeName ) {
  this.base = MockNode;
  this.base( nodeName, MockNode.ELEMENT_NODE );
}
MockElement.prototype = new MockNode;
MockElement.prototype.getAttribute = Mock_getAttribute;
MockElement.prototype.getElementsByTagName = MockElement_getElementsByTagName;
MockElement.prototype.toString = function() { return "[object MockElement]"; } 


/**
 * Implementation of the W3C DOM Level 2 NodeList interface.
 */
function MockNodeList() {
}
MockNodeList.prototype = new Array;
MockNodeList.prototype.item = Mock_item;

function Mock_item( index ) {
  return this[ i ];
}

function MockDocument() {
  this.childNodes = new MockNodeList();
}
MockDocument.prototype.getElementById = Mock_getElementById;
MockDocument.prototype.getElementsByTagName = MockElement_getElementsByTagName;
MockDocument.prototype.createElement = Mock_createElement;

function Mock_getElementById( id ) {
  for ( var i = 0; i < this.childNodes.length; ++i ) {
    if( this.childNodes[ i ].id == id ) {
      return this.childNodes[ i ];
    } else {
      return this.childNode[ i ].getElementById( id );
    }
  }
}

/*
 * Returns all nodes with the tagName that are descendants of the current node.
 */
function MockElement_getElementsByTagName( nodeName ) {
  var nodeList = new MockNodeList();
  for ( var i = 0; i < this.childNodes.length; ++i ) {
    if ( this.childNodes[ i ].nodeName == nodeName ) { // Should also do a type check here.
      nodeList.push( this.elements[ i ] );
    }
    nodeList.concat( nodeList, this.childNodes[ i ].getElementsByTagName( nodeName ) )
  }
  return nodeList;
}

function Mock_removeChild( node ) {
  // this.childNodes // remove from array
}

function Mock_appendChild( node ) {
  this.childNodes.push( node );
}

function Mock_createElement( nodeName ) {
  var node = new MockNode();
  node.nodeName = nodeName;
  return node;
}

function Mock_getAttribute( attributeName ) {

}

function MockStyle() {
  this.marginLeft = "";
}

function NamedNodeMap() {

}
NamedNodeMap.prototype.getNamedItem = Mock_getNamedItem;
NamedNodeMap.prototype.setNamedItem = Mock_setNamedItem;
NamedNodeMap.prototype.removeNamedItem = Mock_removeNamedItem;
NamedNodeMap.prototype.item = Mock_item;
NamedNodeMap.prototype.getNamedItemNS = Mock_getNamedItemNS;
NamedNodeMap.prototype.setNamedItemNS = Mock_setNamedItemNS;
NamedNodeMap.prototype.removeNamedItemNS = Mock_removeNamedItemNS;

function Mock_getNamedItem( nodeName ) {
  var node = new MockNode();
  node.nodeName = nodeName;
  return node;
}
function Mock_setNamedItem( arg ) {
  return new MockNode();
}
function Mock_removeNamedItem( name ) {
  return new MockNode();
}
function Mock_item( index ) {
  return new MockNode();
}
function Mock_getNamedItemNS( namespaceURI, localName ) {
  return new MockNode();
} 
function Mock_setNamedItemNS( arg ) {
  return new MockNode();
}
function Mock_removeNamedItemNS( namespaceURI, localName ) {
  return new MockNode();
}

function MockHTMLElement( nodeName ) {
  // alert( "MockHTMLElement( " + nodeName + " )" );
  this.base = MockElement;
  this.base( nodeName );
  this.className = "";
}
MockHTMLElement.prototype = new MockElement;
MockHTMLElement.prototype.toString = function() { return "[object MockHTMLElement]"; } 

function MockHTMLFormElement() {
  this.base = MockHTMLElement;
  this.base( "FORM" );
}
MockHTMLFormElement.prototype = new MockHTMLElement;
MockHTMLFormElement.prototype.toString = function() { return "[object MockHTMLFormElement]"; }