
// The W3C DOM Object

function dom_object(obj) {
	this.css2 = obj;
	this.name = obj.id;
	this.objHide = domHide;
	this.objShow = domShow;
	this.objGetLeft = domGetLeft;
	this.objGetTop = domGetTop;
	this.objSetTop = domSetTop;
	this.objSetLeft = domSetLeft;
	this.objMoveSide = domMoveSide;
	this.objSetZIndex = domSetZIndex;
	this.objGetZIndex = domGetZIndex;
    this.objGetVisibility = domGetVisibility;
}


// The Navigator DOM Object

function ns_object(obj) {
	this.css2 = obj;
	this.name = obj.name;
	this.objHide = nsobjHide;
	this.objShow = nsobjShow;
	this.objGetLeft = nsobjGetLeft;
	this.objGetTop = nsobjGetTop;
	this.objSetTop = nsobjSetTop;
	this.objSetLeft = nsobjSetLeft;
	this.objMoveSide = domMoveSide;
	this.objSetZIndex = nsobjSetZIndex;
	this.objGetZIndex = nsobjGetZIndex;
    this.objGetVisibility = nsVisibility;
}


// The DOM Object Implementations

// element's top position
function domGetTop () {
    var tp = parseInt(this.css2.style.top);
	return tp;
}

// set element's top position
function domSetTop (top) {
	this.css2.style.top = top + "px";
}

// element's left position
function domGetLeft() {
    var lt = parseInt(this.css2.style.left);
	return lt;
}

// set element's left position
function domSetLeft(left) {
	this.css2.style.left = left + "px";
}

// hide element
function domHide() {
   this.css2.style.visibility = "hidden";
}

// show element
function domShow() {
   this.css2.style.visibility = "visible";
}

function domMoveSide(sidePos) {
   this.objSetLeft(sidePos);
}

// set element's zindex order
function domSetZIndex(zindex) {
   this.css2.style.zIndex = zindex;
}

// get element's current zindex order
function domGetZIndex(zindex) {
   return this.css2.style.zIndex;
}

// return visibility
function domGetVisibility() {
    return this.css2.style.visibility;
}



// The Navigator 4.x Objects

// hide element
function nsobjHide() {
	this.css2.visibility = "hidden";
}

// show element
function nsobjShow() {
	this.css2.visibility = "inherit";
}

// element's top position
function nsobjGetTop () {
	return this.css2.top;
}

// set element's top position
function nsobjSetTop(top) {
	this.css2.top = top;
}

// element's left position
function nsobjGetLeft() {
	return this.css2.left;
}

// set element's left position
function nsobjSetLeft(left) {
	this.css2.left = left;
}

// get element's width
function nsobjGetWidth() {
	return this.css2.clip.width;
}

// set element's height
function nsobjSetHeight(height) {
	this.css2.clip.height = height;
}

// set element's zindex order
function nsobjSetZIndex(zindex) {
	this.css2.zIndex = zindex;
}

// get element's current zindex order
function nsobjGetZIndex() {
	return this.css2.zIndex;
}

// return visibility
function nsVisibility() {
   return this.css2.visibility;
}


// Create the objects
// menu will not function until all objects are created and the turnOn function is called

function create_objects() {

    // if IE
    if (navigator.appName == "Microsoft Internet Explorer")
	   create_ie_objects();
    else // Navigator or Mozilla
        if (navigator.appName == "Mozilla" || navigator.appName == "Netscape")
           if (navigator.appVersion.indexOf("4.") == -1)
	      create_dom_objects();
           else 
  	      create_ns_objects();
}

// For IE, pull all DIV blocks into object array
function create_ie_objects() {
   theelements = document.all.tags("DIV");
   theobjs = new Array();
   for (i = 0; i < theelements.length; i++){
      if (theelements[i].id != "") {
	   theobjs[theelements[i].id] = new dom_object(theelements[i]);
	   }
      }
	turnOn();
}

// For Navigator 4.x, pull all DIV blocks into object array
function create_ns_objects(newarray) {
	theobjs = new Array();
	for (i = 0; i < document.layers.length; i++) {
		if (document.layers[i].name != "") {
			theobjs[document.layers[i].name] = new ns_object(document.layers[i]);
		}
	}
	turnOn();
}

// For W3C DOM (Navigator 6.x, Mozilla, IE), pull all named DIV blocks into an array
function create_dom_objects() {
	theelements = document.getElementsByTagName("DIV");
	theobjs = new Array();
	for (i = 0; i < theelements.length; i++) {
		var obj = theelements[i];
		if (obj.id != "") {
			theobjs[obj.id] = new dom_object(obj);
		}
	}
	turnOn();
}
