/*
The SoftAd Group
Copyright (c) 2000-2004 The SoftAd Group, Inc.  All rights reserved
*/
//To use this object the following files must be also included.

// -------------------------------------------------------------------------------
// File name        : HTMLDom.js
// -------------------------------------------------------------------------------
// Author           : Scott Pennington
// Created on       : June 26, 2003
// 
// This file contains the the HTMLDom object that holds all the generic methods
// for HTML dom methods.  This object is a universal method to utilize the HTML
// document.  This is not to replace the DOM but a method of finding nodes inside
// the HTML DOM.  This is object exists to help reduce the amount of unique code
// to manipulate HTML elements in different browsers by giving one universal method
// to get desired elements
// -------------------------------------------------------------------------------
// Last Updated     : Ken Wimberley
// Updated by       : July 31, 2003
// -------------------------------------------------------------------------------
// Copyright (c) 2003 The SoftAd Group, Inc.


// -------------------------------------------------------------------------------
// Function         : HTMLDom()
// -------------------------------------------------------------------------------
// Author           : Scott Pennington
// Created on       : June 23, 2003
// 
// This function creates the HTMLDom Object 
//
// -------------------------------------------------------------------------------
// Parameters
// -------------------------------------------------------------------------------
// NAME				TYPE        DESCRIPTION
// -------------------------------------------------------------------------------
// Last Updated     : Ken Wimberley
// Updated by       : July 31, 2003
// -------------------------------------------------------------------------------

/*Begin Class*/
function HTMLDom() {
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	//Default Methods and properties
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	this.document = window.document;
	this.browser = '';
	this.ver = navigator.appVersion;
	this.agent = navigator.userAgent;
	
	this.isDom = document.getElementById ? true : false;
	this.isOpera5 = this.agent.indexOf("Opera 5")>-1;
	this.isIE5 = (this.ver.indexOf("MSIE 5")>-1 && this.isDom && !this.isOpera5) ? true : false;
	this.isIE6 = (this.ver.indexOf("MSIE 6")>-1 && this.isDom && !this.isOpera5) ? true : false;
	this.isIE4 = (document.all && !this.isDom && !this.isOpera5) ? true : false;
	this.isIE = this.isIE4||this.isIE5||this.isIE6;
	this.isMac = this.agent.indexOf("Mac")>-1;
	this.isNS6 = (this.isDom && this.agent.indexOf("Netscape6")>-1) ? true : false;
	this.isNS4 = (document.layers && !this.isDom) ? true : false;
	this.bw = (this.isIE6 || this.isIE5 || this.isIE4 || this.isNS4 || this.isNS6 || this.isOpera5);

	
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	// Methods to Find nodes
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	this.getElementById = getElementById;
	this.getElementByName = null;
	
	
	
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	// Methods to get/set attributes
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	this.setAttribute = null;
	this.getAttribute = null;
	this.attachEvent = attachEvent;
	
	
	
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	// Methods to create/append/remove nodes
	//88888888888888888888888888888888888888888888888888888888888888888888888888888
	this.createElement = createElement;
	this.removeNode = null;
	this.appendChild = appendChild;
	
	// -------------------------------------------------------------------------------
	// Method	        : getElementById(sID)
	// -------------------------------------------------------------------------------
	// Author           : Scott Pennington
	// Created on       : June 26, 2003
	// 
	// This method wraps all methods for all browsers to find an HTML Element it the
	// document by its ID.
	//
	// -------------------------------------------------------------------------------
	// Parameters
	// Returns a the object of the element found or null.
	// -------------------------------------------------------------------------------
	// NAME				TYPE        DESCRIPTION
	// sID				string		This is the ID of the element 
	// -------------------------------------------------------------------------------
	// Last Updated     : Ken Wimberley
	// Updated by       : August 5, 2003
	// -------------------------------------------------------------------------------		
	function getElementById (sID) {   
		var oReturn = null;
		if(this.isDom){
			try {
				oReturn = this.document.getElementById(sID);
			}
			catch(e) {
				alert("oHTMLDom error: getElementById: id=" + sID + " not found");
			}
		}
		return oReturn;
	}

	// -------------------------------------------------------------------------------
	// Method	        : createElement(sName)
	// -------------------------------------------------------------------------------
	// Author           : Scott Pennington
	// Created on       : June 26, 2003
	// 
	// This method wraps all methods for all browsers to find an HTML Element it the
	// document by its ID.
	//
	// -------------------------------------------------------------------------------
	// Parameters
	// Returns a the object of the element found or null.
	// -------------------------------------------------------------------------------
	// NAME				TYPE        DESCRIPTION
	// sID				string		This is the ID of the element 
	// -------------------------------------------------------------------------------
	// Last Updated     : Ken Wimberley
	// Updated by       : July 31, 2003
	// -------------------------------------------------------------------------------		
	function createElement (sName) {   
		var oReturn = null;
		if(this.isDom){
			oReturn = this.document.createElement(sName);
		}
		return oReturn;
	}
	
	// -------------------------------------------------------------------------------
	// Method	        : appendChild(oChild[,oParent])
	// -------------------------------------------------------------------------------
	// Author           : Scott Pennington
	// Created on       : June 26, 2003
	// 
	// This method wraps all methods for all browsers to append a Node to a Parent.
	// If the Parent is not passed it will add it to the BODY element.
	//
	// -------------------------------------------------------------------------------
	// Parameters
	// Returns a the object of the element found or null.
	// -------------------------------------------------------------------------------
	// NAME				TYPE        DESCRIPTION
	// oChild			Node		This is an HTML node/element created by createElement
	// oParent			Node		This is an HTML node/element. if not passed the BODY will be used.
	// -------------------------------------------------------------------------------
	// Last Updated     : Ken Wimberley
	// Updated by       : July 31, 2003
	// -------------------------------------------------------------------------------		
	function appendChild (oChild, oParent) {   
		var oReturn = null;
		oParent	? oParent = oParent	: oParent = this.document.body;
		if(this.isDom){
			oReturn = oParent.appendChild(oChild);
		}
		return oReturn;
	}

	// -------------------------------------------------------------------------------
	// Method	        : attachEvent(oNode,sEventName,oFunctionReference)
	// -------------------------------------------------------------------------------
	// Author           : Scott Pennington
	// Created on       : June 26, 2003
	// 
	// This method wraps all methods for all browsers to attach an Event to an Element
	//
	// -------------------------------------------------------------------------------
	// Parameters
	// Returns a the object of the element or null.
	// -------------------------------------------------------------------------------
	// NAME				TYPE        DESCRIPTION
	// oNode			Node		This is an HTML node/element created by createElement
	// sEventName		String		The name of the Event to attach to oNode
	// oFunctionReference Function	This is a pointer to a Function
	// -------------------------------------------------------------------------------
	// Last Updated     : Ken Wimberley
	// Updated by       : July 31, 2003
	// -------------------------------------------------------------------------------		
	function attachEvent (oNode, sEventName, oFunctionReference) {   
		var oReturn = null;
		if(this.isDom){
			oReturn = oNode.attachEvent(sEventName, oFunctionReference);
		}
		return oReturn;
	}

}
/*End Class*/

var oHTMLDom = new HTMLDom();