
// -----------------------------------------------------------------------------------
// Document Object Model Detection/Cross Browser Functions.
// -----------------------------------------------------------------------------------

var isDHTML = false;	// T/F - browser is DHTML capable
var isID = false;		// T/F - browser uses WC3 ID DOM
var isAll = false;		// T/F - browser uses MS All DOM
var isLayers = false;	// T/F - browser uses NS4 Layers DOM

// Test to see which DOM the browser is using
if (document.getElementById) {
	// WC3 ID DOM
	isID = true;
	isDHTML = true;
} else {
     // Not WC3 ID DOM
     if (document.all) {
     	// MS All DOM
     	isAll = true;
     	isDHTML = true;
     } else {
     	// Test for Netscape 4 Layer DOM
     	var browserVersion = parseInt(navigator.appVersion);
     	if ( (navigator.appName.indexOf('Netscape') != -1) && browserVersion == 4 ) {
     		isLayers=true;
     		isDHTML=true;
     	}
     }
}

// create a global object to save object references.
var ObjDomReferences = new Object;

function showRefProps(objIn){
  if(window.pageLoaded != void(0) && pageLoaded) {
     var msg = "";
     for (var prop in objIn) {
//          alert(prop);
          var harry = ""+objIn[prop];
          if (harry.indexOf('function') == -1) msg += "\n-" + prop + ": " + objIn[prop].toString();
          else msg += "\nmethod: " + prop;
     }
     
     document.datForm.msgBox.value = "";
     document.datForm.msgBox.value = msg;
  }
}



function findDOM(objectID, withStyle) {
	// alert("findDOM: " + objectID + ", " + withStyle);
   	// alert("isDHMTL: " + isDHTML + "\nisID: " + isID + "\nisAll: " + isAll);
	
	if (withStyle) {
          // check to see if it's been referenced before.  If so, get reference from object.
          if ( ObjDomReferences[objectID+"_style"] != void(0) ) {
               //alert('found style ref. to '+objectID);
               return ObjDomReferences[objectID+"_style"];
          }
		// previous reference not found -  find a reference to the style 
		// object associated with the object id passed in and store to object
		if (isID) {
			if (document.getElementById(objectID)== void(0) ) return null;
			ObjDomReferences[objectID+"_style"] = document.getElementById(objectID).style;
		} else if (isAll)  {
			if (document.all[objectID]== void(0) ) return null;
			ObjDomReferences[objectID+"_style"] = document.all[objectID].style;
		} else if (isLayers) {
			if (document.layers[objectID]== void(0) ) return null;
			ObjDomReferences[objectID+"_style"] = document.layers[objectID].style;
		}
		// return reference to requested object
		return ObjDomReferences[objectID+"_style"];
				
	} else {
          // check to see if it's been referenced before.  If so, get reference from object.
          if ( ObjDomReferences[objectID] != void(0) ) {
               //alert('found obj ref. to '+objectID);
               return ObjDomReferences[objectID];
          }

		// previous reference not found -  find a reference to the  
		// object associated with the object id passed in and store to object
		if (isID) {
			if (document.getElementById(objectID)== void(0) ) {
				//alert('not found');
				return null;
			} else {
				//alert('found');
				ObjDomReferences[objectID] = document.getElementById(objectID);
			}
		} else if (isAll)  {
			if (document.all[objectID]== void(0) ) return null;
			else ObjDomReferences[objectID] = document.all[objectID];
		} else if (isLayers) {
			if (document.layers[objectID]== void(0) ) return null;
			else ObjDomReferences[objectID] = document.layers[objectID];
		}
		// return reference to requested object
		//alert('found new');
		return ObjDomReferences[objectID];
	}
}


function findLeft(strIdIn) {
	var thisObj = findDOM(strIdIn, false);
	var intPos = 0;
	
	if (thisObj.style.pixelLeft != void(0) ) {	 	// IE 4/5+	
		intPos = thisObj.style.pixelLeft;
	} else if (thisObj.offsetLeft != void(0) ) { 		// NS 6+
		intPos = thisObj.offsetLeft;
	} else 	if (thisObj.style.left != void(0) ) {		// NS 4
		intPos = thisObj.style.left;
	}
	
	return intPos;
}



function findTop(strIdIn) {
	var thisObj = findDOM(strIdIn, false);
	var intPos = -1;
	
	if (thisObj.offsetTop != void(0) ) {			// NS 6+
		intPos = thisObj.offsetTop;
	} else if (thisObj.style.pixelTop != void(0) ) { 		// IE 4/5+
		intPos = thisObj.style.pixelTop;
	} else if (thisObj.style.top != void(0) ) {		// NS 4
		intPos = thisObj.style.top;
	}

	return intPos;
}

function findPageHeight() {
	if (window.innerHeight != void(0)) {
		alert('innerHeight');
		return window.innerHeight;
	}

/*	
	var strTemp = "";
	for (var prop in document.documentElement) {
		strTemp += prop +" val: " + document.documentElement[prop] + "<br>";
	}
	var harry = window.open('', harry, '');
	harry.document.open();
	harry.document.write(strTemp);
	harry.document.close();
*/	
	
	if (document.body.clientHeight != void(0)) {
		alert('clientHeight');
		return document.body.clientHeight;
	}
	return null;
}

function findPageWidth() {
	if (window.innerHeight != null) return window.innerWidth;
	if (document.body.clientHeight != null) return document.body.clientWidth;
	return null;
}

