// Objeto que permiten acceder a las caracteristicas css 
// Objeto para navegador cruzado.
//*******************************************************************

// Chequeo del navegador

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false

// Objeto

function capaObj(id) {
        if (ns4) {
                
				this.css = document.layers[id];
				this.event = this.css
                this.x = this.css.left;
                this.y = this.css.top;
				
        }
        else if (ie4) {
                this.css = document.all[id].style;
				this.event = document.all[id]
                this.x = this.css.pixelLeft;
                this.y = this.css.pixelTop;
        }
		this.id = id
		this.obj = id + "capaObj"
		eval(this.obj + "=this")
        this.mueveMas = capaObjMueveMas;
        this.mueveHasta = capaObjMueveHasta;
		this.muestra = capaObjShow;
        this.oculta = capaObjHide;
        this.desplaza = capaObjMueve;
		//  propiedades para el load external file
    	this.load = capaObjLoad
		this.loadFinish = capaObjLoadFinish
		this.url = null

}
function capaObjMueveMas(x,y) {
        this.x += x;
        this.css.left = this.x;
        this.y += y;
        this.css.top = this.y;
}
function capaObjMueveHasta(x,y) {
        this.x = x;
        this.css.left = this.x;
        this.y = y;
        this.css.top = this.y;
}

function capaObjShow() {
        this.css.visibility = (document.layers)? "show" : "visible"
}
function capaObjHide() {
        this.css.visibility = (document.layers)? "hide" : "hidden"
}

// los parametros de esta funcion son 'tid', es un identificador del timer
//se puede pasar cualquier valor, 'hasta', es el valor que ha de tener la x o la y
// dependiendo del eje, 'eje', 1 si el hasta se aplica a la x y 0 si se aplica a la y
// 'ax' y 'ay' son los incrementos es estos ejes, 'veloci', es el intervalo del timer.

function capaObjMueve (tid,hasta,eje,ax,ay,veloci) {
	var mueveal
	if (!eje) mueveal = this.y;
	else mueveal = this.x
	if (mueveal != hasta){
		this.mueveMas(ax,ay);
		tid = setTimeout(this.obj+".desplaza("+tid+","+hasta+","+eje+","+ax+","+ay+","+veloci+")",veloci);
	}
	else  {
		clearTimeout(tid);
		}
}

// Carga como contenido de la capa un archivo html

function capaObjLoad(url) {
        this.loadFinish = capaObjLoadFinish;
        if (ns4) this.css.src = url
        else if (ie4) parent.bufferFrame.document.location = url
		
}

function capaObjLoadFinish() {
        if (ie4) this.event.innerHTML = parent.bufferFrame.document.body.innerHTML
}

//**********************************************************