// objects.js -- Object Creation Script with Full Feature Set:
//	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

// BEGIN Create objects from Divs
function createObjects() {
	if (domData.isNN4) { createNN4Objects(); 
	} else if (domData.isIE4Up) { createIEObjects(); 
	} else if (domData.isNN6Up) { createDOMObjects(); }
} // END createObjects() function


// 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("dynamic") == 0) {
				mNames[mNumAll] = theDivs[i].id;
				mNumAll ++;
			}
		}
	}
} // 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 (obj.id.indexOf('dynamic') == 0) {
				mNames[mNumAll] = obj.id;
				mNumAll ++;
			}
		}
	}
} // END createDOMObjects()


// 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;
} // END ie_object(obj)


// BEGIN Establish properities of the Netscape object
function nn4Object(obj) {
	this.css2 = obj;
	this.name = obj.name;
	this.objGetTop = nnGetTop;
	this.objGetLeft = nnGetLeft;
	this.objHide = nnHide;
	this.objShow = nnShow;
	this.objSetTop = nnSetTop;
	this.objSetLeft = nnSetLeft;
	this.objGetWidth = nnGetWidth;
	this.objGetHeight = nnGetHeight;
	this.objMoveAbsolute = domMoveAbsolute;
	this.objMoveRelative = domMoveRelative;
	this.objSetZIndex = nnSetZIndex;
	this.objSetClipRect = nnSetClipRect;
} // END nn_object(obj)


// BEGIN DOM and IE get element's top position
function domGetTop(top) {
	var tp = parseInt(this.css2.style.top);
	return tp;
} // END domGetTop(top)


// BEGIN DOM and IE get element's left position
function domGetLeft(left) {
	var lt = parseInt(this.css2.style.left);
	return lt;
} // END domGetLeft()


// BEGIN DOM and IE set element's top position
function domSetTop(top) {
	this.css2.style.top = top + "px";
} // END domSetTop(top)


// BEGIN DOM and IE set element's left position
function domSetLeft(left) {
	this.css2.style.left = left + "px";
} // END domSetLeft(left)


// BEGIN DOM and IE hide element
function domHide() {
   this.css2.style.visibility = "hidden";
} // END domHide()


// BEGIN DOM and IE show element
function domShow() {
   this.css2.style.visibility = "visible";
} // END domShow()


// BEGIN DOM and IE get element's width
function domGetWidth() {
	var wd = parseInt(this.css2.style.width);
	return wd;
} // END domGetWidth


// BEGIN DOM and IE get element's height
function domGetHeight() {
	var ht = parseInt(this.css2.style.height);
	return ht;
} // END domGetHeight()


// BEGIN DOM and IE 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 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 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 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)


// Clipping Objects

// BEGIN DOM and IE 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 clip object
// 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(...)

