//
// @(#)findTheBrowserDOM.js   1.0 10/22/2001
//

//
// This library file will be used by any JavaScript function that needs to 
// access or address an object on the screen. The capability for the web page 
// to change dynamically the properties of object with scripting language 
// is called Document Object Model. Each browser has its own DOM standards. 
// Including this file as an external file using the following code snippet
// <script src="/location/findTheBrowserDOM.js"></script>
// allows to to have a cross-browser DOM identification, just by calling 
// the findDOM(ObjectID,withStyle) method. 
// By ObjectID we mean the name of the any element defined with an 
// an ID - an Object - to a JavaScript function.
//
// @version    1.0 10/22/2001 
// @since      JavaScript1.1
//

//
// isLayers    -> Netscape's Layer DOM used only in Netscape 4.x
// isAll       -> Internet Explorer's All DOM used in IE 4 and available in IE5
//                and IE6
// isID        -> The W3C's ID DOM used in Netscape 6 and IE5 
// isDHTML     -> Records if the Browser is capable of DHTML
// Initialize four variables (isID, isAll, isLayers, isDHTML) to 0(false). 
// The first three variables record the DOM type as detected;the fourth 
// simply records whether any DOM is present - whether the browser is 
// DHTML-capable.
//
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

//
// Detect for each DOM, and assign the corresponding variable to 1(true) if that 
// DOM works best in the current browser. Its important to note that if the DOM
// exists, the subsequent DOMs are not nested. This setup allows you to use 
// the best DOM available for the current browser.
//
if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
   isLayers = 1; isDHTML = 1;
   }
}}

//
// In your JavaScript program you can this function to find the DOM object by 
// passing two parameters one the ObjectID and the other 0 for without style
// and 1 for with style.
//
function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
		if (isID) { return (document.getElementById(objectID).style) ; }
		else { 
			if (isAll) { return (document.all[objectID].style); }
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
	else {
		if (isID) { return (document.getElementById(objectID)) ; }
		else { 
			if (isAll) { return (document.all[objectID]); }
		else {
			if (isLayers) { return (document.layers[objectID]); }
		};}
	}
}