// Funciones auto..máticas.

function div(id, doc) {
	// Si es explorer o	netscape.
	this.id	 = id;
	this.doc = doc ? doc : document;

	if((info.ie	|| info.ns6) &&	(this.doc.getElementById(this.id)))	{
		this.ref = this.doc.getElementById(this.id);
		this.style = this.ref.style;
	} else if (info.ns4	&& this.doc.layers[this.id]) {
		this.ref = this.doc.layers[this.id];
		this.style = this.ref;
	}
	this.top	= _top;
	this.left	= _left;
	this.width	= _width;
	this.height	= _height;
	this.clip	= _clip;
	this.show	= _show;
	this.hide	= _hide;
	this.html	= _html;
	this.moveTo	= _moveTo;
	this.center	= _center;
	this._ref  = __ref;
}

div.prototype.ref =	this.ref;

function __ref() {
	if(this.ref) return;
	if((info.ie	|| info.ns6) &&	(this.doc.getElementById(this.id)))	{
		this.ref = this.doc.getElementById(this.id);
		this.style = this.ref.style;
	} else if (info.ns4	&& this.doc.layers[this.id]) {
		this.ref = this.doc.layers[this.id];
		this.style = this.ref;
	}
}
function _clip(x, y, w,	h) {
	this._ref();
	if (info.ie	|| info.ns6) {
		var	clip = "rect(" + y + " " +	(x + w)	+ "	" +	(y + h)	+  " " + x + ")";
		this.style.clip	= clip;
	} else if (this.ns)	{
		this.style.clip.top	= y;
		this.style.clip.bottom = y + h;
		this.style.clip.left = x;
		this.style.clip.width =	 w;
	}
}

function _top(valor) {
	this._ref();
	if(valor) this.style.top = valor;
	if (info.ie) {
		return this.style.pixelTop;
	} else if (info.ns4	|| info.ns6) {
		return parseInt(this.style.top);
	}
}

function _left(valor) {
	this._ref();
	if(valor) this.style.left =	valor;
	if (info.ie) {
		return this.style.pixelLeft;
	} else if (info.ns4	|| info.ns6) {
		return parseInt(this.style.left);
	}
}

function _width(valor) {
	this._ref();
	if(valor) this.style.width = valor;
	if (info.ie) { return parseInt(this.ref.clientWidth); }
	if (info.ns6) {	return parseInt(this.ref.width); }
	if (info.ns4) {	return this.style.clip.width };
}

function _height(valor)	{
	this._ref();
	if(valor) this.style.height	= valor;
	if (info.ie) { return parseInt(this.ref.clientHeight); }
	if (info.ns6) {	return parseInt(this.style.height);	}
	if (info.ns4) {	return this.style.clip.height };
}

function _hide() {
	this._ref();
	if (info.ie	|| info.ns6) this.style.visibility = "hidden";
	if (info.ns4) this.style.visibility	= "hide";
}

function _show() {
	this._ref();
	if (info.ie	|| info.ns4	|| info.ns6) this.style.visibility = "visible";
}

function _moveTo(x,	y) {
	this._ref();
	this.left(x); this.top(y);
}

function _center() {
	this._ref();
	var	top	= (info.scrollTop()	+ (info.windowHeight() - this.height())	/ 2);
	top	= (top < 0)	? 10 : top;
	this.moveTo(info.scrollLeft() +	(info.windowWidth()	- this.width())	/ 2, top);
}

function _html(texto) {
	this._ref();
	if(texto) {
		if(info.ns4) {
			this.ref.document.open();
			this.ref.document.write(texto);
			this.ref.document.close();
		}
		if(info.ns6	|| info.ie)	{
			this.ref.innerHTML = texto;
		}
	}
	if(info.ie || info.ns6)	return this.ref.innerHTML;
}

function cInfo() { }
function _windowWidth()	{ return parseInt(document.all ? parent.document.body.offsetWidth -	20 : window.innerWidth - 16); }
function _windowHeight() { return parseInt(document.all	? parent.document.body.offsetHeight	- 20 : window.innerHeight -	1);	}
function _scrollLeft() { return	parseInt(document.all ?	parent.document.body.scrollLeft	: window.pageXOffset); }
function _scrollTop() {	return	parseInt(document.all ?	parent.document.body.scrollTop : window.pageYOffset); }
function _pageWidth() {	return	(document.layers ||	(!document.all && document.getElementById))	? window.innerWidth	- 16 : document.body.scrollWidth - 20;	}
function _pageHeight() { return	(document.layers ||	(!document.all && document.getElementById))	? window.innerHeight - 16 :	document.body.scrollHeight - 20;  }
cInfo.prototype.windowWidth	 = _windowWidth;
cInfo.prototype.windowHeight = _windowHeight;
cInfo.prototype.scrollLeft	 = _scrollLeft;
cInfo.prototype.scrollTop	 = _scrollTop;
cInfo.prototype.pageWidth	 = _pageWidth;
cInfo.prototype.pageHeight	 = _pageHeight;

cInfo.prototype.ns4				 = (document.layers) ? true	: false;
cInfo.prototype.ie				 = (document.all)? true	: false;
cInfo.prototype.ns6				 = (document.getElementById	&& !document.all)? true	: false
var	info = new cInfo();
