// domobjsx.js -- Object Creation Script

// BEGIN Create objects from Divs
function create_objects() {
	if (isLayers) { create_nn_objects(); 
	} else if (isDivs) { create_ie_objects(); 
	} else if (isDOM) { create_dom_objects(); }
} // END create_objects() function


// BEGIN For IE, pull DIV blocks into object array
function create_ie_objects() {
	thedivs = document.all.tags("div");
	theobjs = new Array();
	for (i = 0; i < thedivs.length; i++) {
		if (thedivs[i].id != "") {
			theobjs[thedivs[i].id] = new dom_object(thedivs[i]);
		}
	}
} // END create_ie_objects()


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


// BEGIN For W3C DOM (Navigator 6.x, Mozilla), pull DIV blocks into object array
function create_dom_objects() {
	thedivs = document.getElementsByTagName("div");
	theobjs = new Array();
	for (i = 0; i < thedivs.length; i++) {
		var obj = thedivs[i];
		if (obj.id != "") { 
			theobjs[obj.id] = new dom_object(obj); 
		}
	}
} // END create_dom_objects()


// BEGIN Establish properities of the DOM; also works for IE 4.x and 5.x Object
function dom_object(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.objSetClipRect = domSetClipRect;
} // END ie_object(obj)


// BEGIN Establish properities of the Netscape object
function nn_object(obj) {
	this.css2 = obj;
	this.name = obj.name;
	this.objHide = nnHide;
	this.objShow = nnShow;
	this.objGetTop = nnGetTop;
	this.objGetLeft = nnGetLeft;
	this.objSetTop = nnSetTop;
	this.objSetLeft = nnSetLeft;
	this.objMoveAbsolute = domMoveAbsolute;
	this.objSetClipRect = nnSetClipRect;
} // END nn_object(obj)


// BEGIN DOM and IE get element's left position
function domGetTop() {
	var tp = parseInt(this.css2.style.top);
	return tp;
} // END domGetLeft()


// BEGIN DOM and IE get element's left position
function domGetLeft() {
	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 make absolute move
function domMoveAbsolute(newleft,newtop) {
   this.objSetLeft(newleft);
   this.objSetTop(newtop);
} // END domMoveAbsolute(newleft,newtop)


// 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 top position
function nnGetTop () {
	return this.css2.top;
} // END nnGetTop()


// BEGIN Netscape 4.x get element's top position
function nnGetLeft () {
	return this.css2.left;
} // 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)


// 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(...)