function CSS (habitat) {
	this.habitat = habitat;
	this.css_config();
}

CSS.prototype.css_config = function () {
	if (document.images) {
		this.isCSS = (document.body && document.body.style) ? true : false;
		this.isW3C = (this.isCSS && document.getElementById) ? true : false;
		this.isIE4 = (this.isCSS && document.all) ? true : false;
		this.isNN4 = (document.layers) ? true : false;
		this.isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	}
};

CSS.prototype.get_nn4_layer = function (doc, name) {
	var layer;
	for (var inc = 0; inc < doc.layers.length; inc++) {
		var div = doc.layers[inc];
		if (div.name == name) {
			layer = div;
			break;
		}
		if (div.document.layers.length > 0) {
			layer = this.get_nn4_layer(div.document, name);
		}
	}
	return layer;
};

CSS.prototype.get_element = function (obj) {
	if (typeof obj == "string") {
		if (this.isW3C) {
			return document.getElementById(obj);
		}
		else if (this.isIE4) {
			return document.all(obj);
		}
		else if (this.isNN4) {
			return this.get_nn4_layer(document, obj);
		}
	}
	return obj;
};

CSS.prototype.get_height = function (obj) {
	var element = this.get_element(obj);
	var height = 0;
	if (element.offsetHeight) {
		height = element.offsetHeight;
	} else if (element.clip && element.clip.height) {
		height = element.clip.height;
	} else if (element.style && element.style.pixelHeight) {
		height = element.style.pixelHeight;
	}
	return parseInt(height);
}

CSS.prototype.get_inner_height = function (obj) {
	if (window.innerHeight) {
		return window.innerHeight;
	} else if (this.isIE6CSS) {
		return document.body.parentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		return document.body.clientHeight;
	}
	return 0;
}

CSS.prototype.get_inner_width = function (obj) {
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (this.isIE6CSS) {
		return document.body.parentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}
	return 0;
}

CSS.prototype.get_left = function (obj) {
	var element = this.get_element(obj);
	var left = 0;
	if (document.defaultView) {
		var style = document.defaultView;
		var computed = style.getComputedStyle(element, "");
		left = computed.getPropertyValue("left");
	} else if (element.currentStyle) {
		left = element.currentStyle.left;
	} else if (element.style) {
		left = element.style.left;
	} else if (this.isNN4) {
		left = element.left;
	}
	return parseInt(left);
}

CSS.prototype.get_style = function (obj) {
	var element = this.get_element(obj);
	if (element && this.isCSS) {
		element = element.style;
	}
	return element;
};

CSS.prototype.get_top = function (obj) {
	var element = this.get_element(obj);
	var top = 0;
	if (document.defaultView) {
		var style = document.defaultView;
		var computed = style.getComputedStyle(element, "");
		top = computed.getPropertyValue("top");
	} else if (element.currentStyle) {
		top = element.currentStyle.top;
	} else if (element.style) {
		top = element.style.top;
	} else if (this.isNN4) {
		top = element.top;
	}
	return parseInt(top);
}

CSS.prototype.get_width = function (obj) {
	var element = this.get_element(obj);
	var width = 0;
	if (element.offsetWidth) {
		width = element.offsetWidth;
	} else if (element.clip && element.clip.width) {
		width = element.clip.width;
	} else if (element.style && element.style.pixelWidth) {
		width = element.style.pixelWidth;
	}
	return parseInt(width);
}

CSS.prototype.hide = function (obj) {
	var style = this.get_style(obj);
	if (style) {
		style.visibility = "hidden";
	}
};

CSS.prototype.set_bg_color = function (obj, color) {
	var style = this.get_style(obj);
	if (style) {
		if (this.isCSS) {
			style.backgroundColor = color;
		} else if (this.isNN4) {
			style.bgColor = color;
		}
	}
};

CSS.prototype.set_z = function (obj, order) {
	var style = this.get_style(obj);
	if (style) {
		style.zIndex = order;
	}
};

CSS.prototype.shift_by = function (obj, delta_x, delta_y) {
	var style = this.get_style(obj);
	if (style) {
		if (this.isCSS) {
			var units = (typeof style.left == "string") ? "px" : 0;
			style.left = (this.get_left(obj) + delta_x) + units;
			style.top = (this.get_top(obj) + delta_y) + units;
		} else if (this.isNN4) {
			style.moveBy(delta_x,delta_y);
		}
	}
};

CSS.prototype.shift_to = function (obj, x, y) {
	var style = this.get_style(obj);
	if (style) {
		if (this.isCSS) {
			var units = (typeof style.left == "string") ? "px" : 0;
			style.left = x + units;
			style.top = y + units;
		} else if (this.isNN4) {
			style.moveTo(x,y);
		}
	}
};

CSS.prototype.show = function (obj) {
	var style = this.get_style(obj);
	if (style) {
		style.visibility = "visible";
	}
};


