// domobjsx.js -- Object Creation Script with Full Feature Set.
// This Version abandons support for Netscape 4
//	theObjs.objHide				hide the object 
//	theObjs.objShow				show the object
//	theObjs.objGetTop			find the object's top coordinate (y)
//	theObjs.objGetLeft			find the object's left coordinate (x)
//	theObjs.objSetTop			set the object's top coordinate (y)
//	theObjs.objSetLeft			set the object's top coordinate (x)
//	theObjs.objMoveAbsolute		move the object to coordinate x,y
//	theObjs.objMoveRelative		move the object x and/or y pixels
//	theObjs.objSetZIndex		reset the objet's z-index
//	theObjs.objGetWidth			find the object's width
//	theObjs.objGetHeight		find the object's height
//	theObjs.objSetClipRect		clip the object to rectangle
//  theObjs.objsReplaceHTML		replace the HTML contents of the object


// BEGIN Create objects from Divs
function createObjects() {
	if (domData.isNN4) { createNNObjects();
	} else if (domData.isIE4up) { createIEObjects();
	} else if (domData.isNN6up) { createDOMObjects(); }
} // END createObjects() function


// BEGIN For Navigator 4.x, pull layer blocks into object array
function createNNObjects() {
	theObjs = new Array();
	for (i = 0; i < document.layers.length; i++) {
		if (document.layers[i].name != "") {
			theObjs[document.layers[i].name] = new nnObject(document.layers[i]);
		}
	}
} // END createNNobjects()


// BEGIN For IE, pull DIV blocks into object array
function createIEObjects() {
	theDivs = document.all.tags("div");
	theObjs = new Array();
	for (var i=0; i < theDivs.length; i++) {
		if (theDivs[i].id != "") {
			theObjs[theDivs[i].id] = new domObject(theDivs[i]);
//			if (theDivs[i].id.indexOf("menu") == 0) {
//				menus[menusCount] = theDivs[i].id;
//				menusCount ++;
//			}
		}
	}
	theSpans = document.all.tags("span");
	for (var i=0; i < theSpans.length; i++) {
		if (theSpans[i].id != "") {
			theObjs[theSpans[i].id] = new spanObject(theSpans[i]);
		}
	}
} // END createIEobjects()


// BEGIN For W3C DOM (Navigator 6.x, Mozilla), pull DIV blocks into object array
function createDOMObjects() {
	theDivs = document.getElementsByTagName("div");
	theObjs = new Array();
	for (var i=0; i < theDivs.length; i++) {
		var obj = theDivs[i];
		if (obj.id != "") { 
			theObjs[obj.id] = new domObject(obj); 
//			if (theDivs[i].id.indexOf('menu') == 0) {
//				menus[menusCount] = theDivs[i].id;
//				menusCount ++;
//			}
		}
	}
	theSpans = document.getElementsByTagName("span");
	for (var i=0; i < theSpans.length; i++) {
		var obj = theSpans[i];
		if (obj.id != "") { 
			theObjs[obj.id] = new spanObject(obj); 
		}
	}
} // END createDOMobjects()


// BEGIN Establish properities of the Netscape object
function nnObject(obj) {
	this.css2 = obj;
	this.name = obj.name;
	this.objGetTop = nnGetTop;
	this.objGetLeft = nnGetLeft;
	this.objSetTop = nnSetTop;
	this.objSetLeft = nnSetLeft;
	this.objHide = nnHide;
	this.objShow = nnShow;
	this.objGetVisibility = nnGetVisibility;
	this.objSetWidth = nnSetWidth;
	this.objSetHeight = nnSetHeight;
	this.objGetWidth = nnGetWidth;
	this.objGetHeight = nnGetHeight;
	this.objMoveAbsolute = domMoveAbsolute;
	this.objMoveRelative = domMoveRelative;
	this.objGetZIndex = nnGetZIndex;
	this.objSetZIndex = nnSetZIndex;
	this.objReplaceHTML	= nnReplaceHTML;
	this.objSetClipRect = nnSetClipRect;
} // END nnObject(obj)


// BEGIN Establish properities of the DOM; also works for IE 4.x and 5.x Object
function domObject(obj) {
	this.css2 = obj;
	this.name = obj.id;
	this.objHide = domHide; 
	this.objShow = domShow;
	this.objGetTop = domGetTop;
	this.objGetLeft = domGetLeft;
	this.objSetTop = domSetTop;
	this.objSetLeft = domSetLeft;
	this.objMoveAbsolute = domMoveAbsolute;
	this.objMoveRelative = domMoveRelative;
	this.objSetZIndex = domSetZIndex;
	this.objGetWidth = domGetWidth;
	this.objGetHeight = domGetHeight;
	this.objSetClipRect = domSetClipRect;
	this.objReplaceHTML	= domReplaceHTML;
} // END domObject(obj)

// BEGIN Establish properities of the DOM; also works for IE 4.x and 5.x Object
function spanObject(obj) {
	this.css2 = obj;
	this.name = obj.id;
	this.objHide = domHide; 
	this.objShow = domShow;
	this.objReplaceHTML	= domReplaceHTML;
} // END spanObject(obj)


// BEGIN Get element's top position
function domGetTop(top) {
	var tp = parseInt(this.css2.style.top);
	return tp;
} // END domGetTop(top)


// BEGIN Get element's left position
function domGetLeft(left) {
	var lt = parseInt(this.css2.style.left);
	return lt;
} // END domGetLeft()


// BEGIN Set element's top position
function domSetTop(top) {
	this.css2.style.top = top + "px";
} // END domSetTop(top)


// BEGIN Set element's left position
function domSetLeft(left) {
	this.css2.style.left = left + "px";
} // END domSetLeft(left)


// BEGIN Hide element
function domHide() {
   this.css2.style.visibility = "hidden";
} // END domHide()


// BEGIN Show element
function domShow() {
   this.css2.style.visibility = "visible";
} // END domShow()


// BEGIN Get element's width
function domGetWidth() {
	var wd = parseInt(this.css2.style.width);
	return wd;
} // END domGetWidth


// BEGIN Get element's height
function domGetHeight() {
	var ht = parseInt(this.css2.style.height);
	return ht;
} // END domGetHeight()


// BEGIN Set element's zindex order
function domSetZIndex(zindex) {
   this.css2.style.zIndex = zindex;
} // END domSetZIndex(zindex)


// BEGIN Make absolute move
function domMoveAbsolute(newleft,newtop) {
   this.objSetLeft(newleft);
   this.objSetTop(newtop);
} // END domMoveAbsolute


// BEGIN Make relative move
function domMoveRelative(left,top) {
   this.objSetLeft(left + this.objGetLeft());
   this.objSetTop(top + this.objGetTop());    
} // END domMoveRelative


// BEGIN Replace contents of Object
function domReplaceHTML(stuffing) {
	this.css2.innerHTML = stuffing;
} // END domReplaceHTML


// BEGIN Clip object
function domSetClipRect(left,top,right,bottom) {
	var strng = "rect(" + top + "px, " + right + "px, " + bottom + "px, " + left + "px)";
	this.css2.style.clip = strng;
} // END domSetClipRect(...)


// BEGIN Netscape 4.x hide element
function nnHide() {
	this.css2.visibility = "hidden";
} // END nnHide

// BEGIN Netscape 4.x show element
function nnShow() {
	this.css2.visibility = "inherit";
} // END nnShow()

// BEGIN Netscape 4.x return visibility
function nnGetVisibility() {
	if (this.css2.visibility = "inherit") {
		return "visible";
	} else {
		return this.css2.visibility;
	}
} // END nnGetVisibility()

// BEGIN Netscape 4.x get element's left position
function nnGetLeft() {
	return this.css2.left;
} // END nnGetLeft()


// BEGIN Netscape 4.x get element's top position
function nnGetTop () {
	return this.css2.top;
} // END nnGetTop()


// BEGIN Netscape 4.x set element's top position
function nnSetTop(top) {
	this.css2.top = top;
} // END nnSetTop(top)


// BEGIN Netscape 4.x set element's left position
function nnSetLeft(left) {
	this.css2.left = left;
} // END nnSetLeft(left)


// BEGIN Netscape 4.x set element's top position
function nnSetHeight(height) {
	this.css2.clip.height = height;
} // END nnSetTop(top)


// BEGIN Netscape 4.x set element's left position
function nnSetWidth(width) {
	this.css2.clip.width = width;
} // END nnSetLeft(left)


// BEGIN Netscape 4.x get element's width
function nnGetWidth() {
	return this.css2.clip.width;
} // END nnGetWidth()


// BEGIN Netscape 4.x get element's height
function nnGetHeight() {
	return this.css2.clip.height;
} // END nnGetHeight()


// BEGIN Netscape 4.x set element's zindex order
function nnSetZIndex(zindex) {
	this.css2.zIndex = zindex;
} // END nnSetZindex(zindex)


// BEGIN Netscape 4.x get element's zindex order
function nnGetZIndex() {
	return this.css2.zIndex;
} // END nnGetZindex(zindex)


// BEGIN Netscape 4.x write new code to layer
function nnReplaceHTML(stuffing) {
    this.css2.document.writeln(stuffing);
    this.css2.document.close();
} // END 

// BEGIN Netscape 4.x clip object
function nnSetClipRect(left,top,right,bottom) {
	this.css2.clip.top = top;
	this.css2.clip.right = right;
	this.css2.clip.bottom = bottom;
	this.css2.clip.left = left;
} // END nnSetClipRect(...)




