//
// Author: Shelley Powers
// copyright: 1997
//

// create NS cross-browser object
function ns_object(obj) {
	this.css1 = obj;
	this.name = obj.name;
	this.objResizeBy = objResizeBy;
	this.objHide = objHide;
	this.objShow = objShow;
	this.objGetLeft = objGetLeft;
	this.objGetTop = objGetTop;
	this.objSetTop = objSetTop;
	this.objSetLeft = objSetLeft;
	this.objMoveAbsolute = objMoveAbsolute;
	this.objMoveRelative = objMoveRelative;
	this.objGetWidth = objGetWidth;
	this.objGetHeight = objGetHeight;
	this.objSetHeight = objSetHeight;
	this.objSetWidth = objSetWidth;
	this.objSetZIndex = objSetZIndex;
	this.objGetZIndex = objGetZIndex;
	this.objSetClipRect = objSetClipRect;
	this.objGetClipLeft = objGetClipLeft;
	this.objGetClipRight = objGetClipRight;
	this.objGetClipTop = objGetClipTop;
	this.objGetClipBottom = objGetClipBottom;
	this.objGetClipWidth = objGetClipWidth;
	this.objGetClipHeight = objGetClipHeight;
	this.replace_html = replace_html;
	this.objChangeSource = objChangeSource;
}

// resize element
function objResizeBy(w_incr, h_incr) {
	this.css1.left-=w_incr / 2;
	this.css1.width-=w_incr / 2;
	this.css1.top+=h_incr / 2;
	this.css1.height+=h_incr / 2;
}

// hide element
function objHide() {
	this.css1.visibility = "hidden";
}

// show element
function objShow() {
	this.css1.visibility = "inherit";
}

// element's left position
function objGetLeft() {
	return this.css1.left;
}

// element's top position
function objGetTop () {
	return this.css1.top;
}

// set element's top position
function objSetTop(top) {
	this.css1.top = top;
}

// set element's left position
function objSetLeft(left) {
	this.css1.left = left;
}

// make absolute move
function objMoveAbsolute(newleft, newtop) {
	this.objSetLeft(newleft);
	this.objSetTop(newtop);
}

// move relative to current location
function objMoveRelative(left, top) {
	this.objSetLeft(left + this.objGetLeft());
	this.objSetTop(top + this.objGetTop());
}

// get element's width
function objGetWidth() {
	return this.css1.clip.width;
}

// get element's height
function objGetHeight() {
	return this.css1.clip.height;
}

// set element's width
function objSetWidth(width) {
	this.css1.clip.width = width;
}

// set element's height
function objSetHeight(height) {
	this.css1.clip.height = height;
}

// set element's zindex order
function objSetZIndex(zindex) {
	this.css1.zIndex = zindex;
}

// get element's current zindex order
function objGetZIndex() {
	return style.zIndex;
}

// clip object
function objSetClipRect (top,left,bottom,right) {
	if (top == null) top = this.objGetClipTop();
	if (left == null) left = this.objGetClipLeft();
	if (bottom == null) bottom = this.objGetClipBottom();
	if (right == null) right = this.objGetClipRight();
	this.css1.clip.left = left;
	this.css1.clip.right = right;
	this.css1.clip.top = top;
	this.css1.clip.bottom = bottom;
}

// get current clip right 
function objGetClipRight() {
	return this.css1.clip.right;
}

// get current clip left
function objGetClipLeft() {
	return this.css1.clip.left;
}

// get current clip top
function objGetClipTop() {
	return this.css1.clip.top;
}

// get current clip bottom
function objGetClipBottom() {
	return this.css1.clip.bottom;
}

// get current clip bottom
function objGetClipWidth() {
	return this.css1.clip.width;
}

// get current clip bottom
function objGetClipHeight() {
	return this.css1.clip.height;
}


function replace_html(html_string) {
	this.css1.document.write(html_string);
	this.css1.document.close();
}

function objChangeSource(sourcefile, width) {
   var clipbottom;
   this.objHide();
   clipbottom = this.objGetClipBottom();
   this.obj.load(sourcefile, width);
   this.obj.clip.bottom = clipbottom;
   this.objShow();
}

// function to instantiate equalizer objects
function create_objects() {
   theobjs = new Array(document.layers.length);
   thenobjs = new Array(document.layers.length);
   for (i = 0; i < document.layers.length; i++){
   	theobjs[document.layers[i].name] = new ns_object(document.layers[i]);
        thenobjs[i] = theobjs[document.layers[i].name];
	}
}

// function to instantiate equalizer objects
function sample_create_objects() {
   thesobjs = new Array(document.layers.length);
   thenobjs = new Array(document.layers.length);
   for (i = 0; i < document.layers.length; i++){
   	thesobjs[document.layers[i].name] = new ns_object(document.layers[i]);
      thenobjs[i] = theobjs[document.layers[i].name];
	}
}
