﻿// The W3C DOM Object
function dom_object(obj) {
	this.css2 = obj;
	this.name = obj.id;
	this.objHide = domHide;
	this.objShow = domShow;
	if (document.all && document.all[this.name] && document.all[this.name].style && document.all[this.name].style.left) {
		temp = document.all[this.name].style.left;
	} else if (document.getElementById && document.getElementById(this.name) && document.getElementById(this.name).style && document.getElementById(this.name).style.left) {
		temp = document.getElementById(this.name).style.left;
	} else {
		temp = '0px';
	}
	this.leftOffset = parseInt(temp.substr(0, temp.length-2));
	this.setLP = setLeftPosition;
}

// The Navigator DOM Object
function ns_object(obj) {
	this.css2 = obj;
	this.name = obj.name;
	this.objHide = nsobjHide;
	this.objShow = nsobjShow;
	if (document.layers && document.layers[this.name] && document.layers[this.name].left) {
		temp = document.layers[this.name].left;		
	} else {
		temp = '0px';
	}
	this.leftOffset = parseInt(temp.substr(0, temp.length-2));
	this.setLP = setLeftPosition;
}

// The DOM Object Implementations
function setLeftPosition(new_left_position) {
	if (document.layers && document.layers[this.name] && document.layers[this.name].left) {
		temp = new_left_position + this.leftOffset;
		this.css2.left = temp.toString() + 'px';
	} else if (document.all && document.all[this.name] && document.all[this.name].style && document.all[this.name].style.left) {
		temp = new_left_position + this.leftOffset;
		this.css2.style.left = temp.toString() + 'px';
	} else if (document.getElementById && document.getElementById(this.name) && document.getElementById(this.name).style && document.getElementById(this.name).style.left) {
		temp = new_left_position + this.leftOffset
		this.css2.style.left = temp.toString() + 'px';
	}
}

// hide element
function domHide() {
   this.css2.style.visibility = "hidden";
}

// show element
function domShow() {
   this.css2.style.visibility = "visible";
}

// The Navigator 4.x Objects
// hide element
function nsobjHide() {
	this.css2.visibility = "hidden";
}

// show element
function nsobjShow() {
	this.css2.visibility = "inherit";
}


// Create the objects
// menu will not function until all objects are created and the turnOn function is called
function create_objects() {
    if (document.all && document.all.tags)
		create_ie_objects();
    else if (document.layers && document.layers.length)
		create_ns_objects();
	else if (document.getElementsByTagName)
		create_dom_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]);
		}
	}
	create_nodes();	
}

// 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]);
		}
	}
	create_nodes();	
}

// 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);
		}
	}
	create_nodes();	
}

// For dhtml navigation highlights
var color = '';

function over(id,alayer,color) {
    if (document.layers) {
		window.color = window.document.layers[alayer].document.layers[id].bgColor;
        if (color == '#')
			window.document.layers[alayer].document.layers[id].bgColor = 'none';
        else
			window.document.layers[alayer].document.layers[id].bgColor = color;
    }
    else if (document.all) {
        window.color = window.document.all[id].style.background;
        if (color == '#')
			window.document.all[id].style.background = 'none';
		else
			window.document.all[id].style.background = color;
    }
	 else if (document.getElementById) {
        window.color = window.document.getElementById(id).style.background;
        if (color == '#')
			window.document.getElementById(id).style.background = 'none';
        else
			window.document.getElementById(id).style.background = color;
    }
}

function out(id,alayer,color) {
    if (document.layers) {
        window.color = window.document.layers[alayer].document.layers[id].bgColor;
        window.document.layers[alayer].document.layers[id].bgColor = color;
    }
    else if (document.all) {
        window.color = window.document.all[id].style.background;
        window.document.all[id].style.background = color;
    }
	 else if (document.getElementById) {
        window.color = window.document.getElementById(id).style.background;
        window.document.getElementById(id).style.background = color;
   }
}
