var objsCreated=false;

//W3C objects for NN6 and IE
function W3CDOM_object(target) {
	this.css2 = target;
	this.name = target.id;
	this.Hide = mthdHide;
	this.Show = mthdShow;
	this.Left = mthdLeft;
	this.Top = mthdTop;
	this.setLeft = mthdSetLeft;
	this.setTop = mthdSetTop;
	this.setAbs = mthdSetAbs;
	this.width = mthdGetWidth;
	this.height = mthdGetHeight
	this.setWidth = mthdSetWidth;
	this.setHeight = mthdSetHeight;
	this.zIndex = mthdGetZ;
	this.setZIndex = mthdSetZ;
}

//Objects for NN4
function NN4_object(target) {
	this.css2 = target;
	this.name = target.name;
	this.Hide = nnmthdHide;
	this.Show = nnmthdShow;
	this.Left = nnmthdLeft;
	this.Top = nnmthdTop;
	this.setLeft = nnmthdSetLeft;
	this.setTop = nnmthdSetTop;
	this.setAbs = nnmthdSetAbs;	
	this.width = nnmthdGetWidth;
	this.height = nnmthdGetHeight
	this.setWidth = nnmthdSetWidth;
	this.setHeight = nnmthdSetHeight;
	this.zIndex = nnmthdGetZ;
	this.setZIndex = nnmthdSetZ;
}


//DOM_objects API

//gets left pos
function mthdLeft() {
	var lft = parseInt(this.css2.style.left);
	return lft;
}

//gets top pos
function mthdTop() {
	var tp = parseInt(this.css2.style.top);
	return tp;
}

//sets left pos
function mthdSetLeft(newLeft) {
	this.css2.style.left = newLeft + "px";
}

//sets top pos
function mthdSetTop(newTop) {
	this.css2.style.top = newTop + "px";
}

//make set an absolute pos
function mthdSetAbs(newTop) {
	this.setTop(newTop);
}

//gets width
function mthdGetWidth() {
	var wdth = parseInt(this.css2.style.width);
	return wdth;
}

//gets height
function mthdGetHeight() {
	var hght = parseInt(this.css2.style.height);
	return hgtht;
}

//sets Width
function mthdSetWidth(newWidth) {
	this.css2.style.width = newWidth + "px";
}

//sets Height
function mthdSetHeight(newHeight) {
	this.css2.style.Height = newHeight + "px";
}

//hide me
function mthdHide() {
	this.css2.style.visibility = "hidden";
}

//show me
function mthdShow() {
	this.css2.style.visibility = "visible";
}

//my Z index
function mthdGetZ() {
	return this.css2.style.zIndex;
}

//set my Z index
function mthdSetZ(newZ) {
	this.css2.style.zIndex = newZ;
}


//That other browser API

//gets left pos
function nnmthdLeft() {
	return this.css2.left;
}

//gets top pos
function nnmthdTop() {
	return this.css2.top;
}

//sets left pos
function nnmthdSetLeft(newLeft) {
	this.css2.left = newLeft;
}

//sets top pos
function nnmthdSetTop(newTop) {
	this.css2.top = newTop;
}

//make set an absolute pos
function nnmthdSetAbs(newTop) {
	this.setTop(newTop);
}

//gets width
function nnmthdGetWidth() {
	return this.css2.clip.width;
}

//gets height
function nnmthdGetHeight() {
	return this.css2.clip.height;
}

//sets Width
function nnmthdSetWidth(newWidth) {
	this.css2.clip.width = newWidth;
}

//sets Height
function nnmthdSetHeight(newHeight) {
	this.css2.clip.Height = newHeight;
}

//hide me
function nnmthdHide() {
	this.css2.visibility = "hidden";
}

//show me
function nnmthdShow() {
	this.css2.visibility = "inherit";
}

//my Z index
function nnmthdGetZ() {
	return this.css2.zIndex;
}

//set my Z index
function nnmthdSetZ(newZ) {
	this.css2.zIndex = newZ;
}

//initializer
function objects_initializer() {
	//discovers ie or nn
	if (navigator.appName == "Microsoft Internet Explorer")
		init_ie_objs();
	else
		if (navigator.appVersion.indexOf("4.") ==-1)
			init_dom_objs();
		else
			init_nn_objs();
	objsCreated = true;
}

//ie initializer
function init_ie_objs() {
	objElements = document.all.tags("DIV");
	theObjs = new Array();
	for (i=0;i<objElements.length;i++) {
		if (objElements[i].id != "") {
			theObjs[objElements[i].id] = new W3CDOM_object(objElements[i]);
		}
	}
}

//NN4 initializer
function init_nn_objs() {
	theObjs = new Array();
	for (i=0;i<document.layers.length;i++) {
		if (document.layers[i].name != "") {
			theObjs[document.layers[i].name] = new NN4_object(document.layers[i]);
		}
	}
}

//NN6 initializer
function init_dom_objs() {
	objElements = document.getElementsByTagName("div");
	theObjs = new Array();
	for (i=0;i<objElements.length;i++) {
		var obj = objElements[i];
		if (obj.id != "") {
			theObjs[obj.id] = new W3CDOM_object(obj);
		}
	}
}
