//
// CONSTRUCTOR
//
// myObject = new layerHandler("divID");
//
// PROPERTIES
//
// content
//		Reference to the actual DOM object for the layer. Use this to reference other properties and
//		methods of the layer.  For example:
//			myVar = myObject.content.name;
//
// obj
//		Reference to the style object of the layer. Use this to manipulate the objects style.  For
//		example:
//			myObject.obj.background = "red";
//
// METHODS
//
// setTop(int n);
//		Sets the top of the layer n pixels from the top of the page window.
//
// setLeft(int n);
//		Sets the left of the layer n pixels from the left of the page window.
//
// setPosition(int x, int y);
//		Sets the position of the layer to x pixels from the left and y pixels from the top of the
//		page window, using the top-left corner of the layer as the handle/reference.
//
// setWidth(int n);
//		Sets the width of the layer to n pixels.
//
// setHeight(int n);
//		Sets the height of the layer to n pixels.
//
// setSize(int w,int h);
//		Sets the size of the layer to w pixels wide and h pixels high.
//
// int top();
//		Returns the number of pixels the top of the layer is from the top of the page window.
//
// int left();
//		Returns the number of pixels the left of the layer is from the left of the page window.
//
// int width();
//		Returns the width of the layer in pixels.
//
// int height();
//		Returns the height of the layer in pixels.
//
// show();
//		Shows the layer, making it visible on the page.
//
// hide();
//		Hides the layer, removing it from the page.
//

var ref_Collection = "";
var ref_CollectionEnd = "";
var ref_Style = "";

// Set the collection and style references for IE if needed. This will give the abilty to reference
// the div's in Netscape and IE the same way.
if (document.all) {
	ref_Collection = "all.";
	ref_Style = ".style";
}

// Temporary Netscape 6 detection.  Its a big crap, but it will do for now.
if (parseInt(navigator.appVersion) >= 5 && navigator.appName.indexOf("Netscape") != -1) {
	isNetscape6 = 1;
	ref_Collection = "getElementById('";
	ref_CollectionEnd = "')";
	ref_Style = ".style";
} else {
	isNetscape6 = 0;
}

// layerHandler object constructor.
function layerHandler (objectName) {
	
	var ref_ObjectString = "document." + ref_Collection + objectName + ref_CollectionEnd;
	var ref_Object = eval (ref_ObjectString);
	// Check that the referenced object actually exists.
	//alert ("ref_Object:" + ref_Object + "\nref_ObjectString:" + ref_ObjectString + "\nobjectName:" + objectName);
	if (ref_Object) {
		this.obj = eval ("ref_Object" + ref_Style);
		this.content = ref_Object;
	} else {
		alert ("I don't seem to be able to reference the object.");
	}

	// PROPERTIES
	this.name = objectName;

	// METHODS
	this.setTop = layerHandler_setTop;
	this.setLeft = layerHandler_setLeft;
	this.setPosition = layerHandler_setPosition;
	this.setWidth = layerHandler_setWidth;
	this.setHeight = layerHandler_setHeight;
	this.setSize = layerHandler_setSize;
	
	this.top = layerHandler_getTop;
	this.left = layerHandler_getLeft;
	this.width = layerHandler_getWidth;
	this.height = layerHandler_getHeight;
	
	this.show = layerHandler_show;
	this.hide = layerHandler_hide;
}

// layerHandler::setTop
function layerHandler_setTop(y) {
	if (this.obj) {
		if (document.all) {
			this.obj.pixelTop = y;
		} else {
			this.obj.top = y;
		}
	} else {
		alert("I appear to have lost the object. Doh!");
	}
}

// layerHandler::setLeft
function layerHandler_setLeft(x) {
	if (this.obj) {
		if (document.all) {
			this.obj.pixelLeft = x;
		} else {
			this.obj.left = x;
		}
	}
}

// layerHandler::setPosition
function layerHandler_setPosition(x,y) {
	this.setLeft(x);
	this.setTop(y);
}

// layerHandler::getTop
function layerHandler_getTop() {
	if (this.obj) {
		if (document.all) {
			return this.obj.pixelTop;
		} else {
			return this.obj.top;
		}
	}
}

// layerHandler::getLeft
function layerHandler_getLeft() {
	if (this.obj) {
		if (document.all) {
			return this.obj.pixelLeft;
		} else {
			return this.obj.left;
		}
	}
}

// layerHandler::setWidth
function layerHandler_setWidth(w) {
	if (this.obj) {
		if (isNetscape6) {
			this.obj.width = w;
		} else {
			if (document.all) {
				this.obj.clientWidth = w;
			} else {
				this.obj.clip.width = w;
			}
		}
	}
}

// layerHandler::setHeight
function layerHandler_setHeight(h) {
	if (this.obj) {
		if (isNetscape6) {
			this.obj.height = h;
		} else {
			if (document.all) {
				this.obj.clientWidth = h;
			} else {
				this.obj.clip.height = h;
			}
		}
	}
}

// layerHandler::setSize
function layerHandler_setSize(w,h) {
	this.setWidth(w);
	this.setHeight(h);
}

// layerHandler::getWidth
function layerHandler_getWidth() {
	if (this.obj) {
		if (isNetscape6) {
			return this.obj.width;
		} else {
			if (document.all) {
				return this.content.clientWidth;
			} else {
				return this.obj.clip.width;
			}
		}
	}
}

// layerHandler::getHeight
function layerHandler_getHeight() {
	if (this.obj) {
		if (isNetscape6) {
			return this.obj.height;
		} else {
			if (document.all) {
				return this.content.clientHeight;
			} else {
				return this.obj.clip.height;
			}
		}
	}
}

// layerHandler::show
function layerHandler_show() {
	if (this.obj) {
		this.obj.visibility = "visible";
	}
}

// layerHandler::hide
function layerHandler_hide() {
	if (this.obj) {
		this.obj.visibility = "hidden";
	}
}