/* Layers V2.4 ... (C)Gullweig Systems, S.L. */
function miLayer(id,x,y,an,al,v,z){
	if(debug)alert("Creando layer "+id)
	var d=DameLayer(id)
	if(d){ // inline
		if(ns4&&debug)VuelcaObjeto(d)
		if(debug)alert("Encontrada layer "+d.id)
		this.id=id
		this.x=parseInt(ns4?d.left:(ie4?d.style.pixelLeft:(d.style&&d.style.left?parseInt(d.style.left):d.offsetLeft)))
		this.y=parseInt(ns4?d.top:(ie4?d.style.pixelTop:(d.style&&d.style.top?parseInt(d.style.top):d.offsetTop)))
		this.an=parseInt(ns4?d.clip.right:(ie4?d.offsetWidth:(d.style&&d.style.width?parseInt(d.style.width):d.offsetWidth)))
		this.al=parseInt(ns4?d.clip.bottom:(ie4?d.offsetHeight:(d.style&&d.style.height?parseInt(d.style.height):d.offsetHeight)))
		this.v=ns4?(d.visibility!='hide'):(d.style&&d.style.visibility?d.style.visibility!='hidden':null)
		this.z=parseInt(ns4?d.zIndex:(d.style?d.style.zIndex:0))
		this.l=d
		this.d=ns4?d.document:document
		this.esLayer=true
		if(debug)alert("Creada layer "+this.id+" en ("+this.x+","+this.y+") con tamaņo ("+this.an+","+this.al+")")
	}else{ // nueva -- por ahora no funciona
		this.id=id
		this.x=x||0
		this.y=y||0
		this.an=an||10
		this.al=al||10
		this.v=v||false
		this.z=z||0
		this.l=null
		this.d=document
		this.esLayer=false
	}
}
miLayer.prototype.Mueve=function(x,y){
	if(this.esLayer){
		var xx=x,yy=y
		this.x=xx
		this.y=yy
		ns4?this.l.moveTo(xx,yy):(dom?(this.l.style.left=xx,this.l.style.top=yy):(this.l.style.pixelLeft=xx,this.l.style.pixelTop=yy))
		if(debug)alert("Movida layer "+this.id+" a pos. ("+this.x+","+this.y+")")
	}
}
miLayer.prototype.MueveRel=function(dx,dy){
	if(this.esLayer){
		dx=dx||0
		dy=dy||0
		ns4?this.l.moveBy(dx,dy):(dom?(this.l.style.left=this.x+dx,this.l.style.top=this.y+dy):(this.l.style.pixelLeft=this.x+dx,this.l.style.pixelTop=this.y+dy))
		this.x+=dx
		this.y+=dy
	}
}
miLayer.prototype.Muestra=function(){
	if(this.esLayer){
		if(!ns4&&this.l.style)this.l.style.display="inline"
		ns4?this.l.visibility="inherit":this.l.style.visibility="inherit"
		this.v=true
		if(debug)alert("Mostrada layer "+this.id)
	}
}
miLayer.prototype.Oculta=function(){
	if(this.esLayer){
		if(!ns4&&this.l.style)this.l.style.display="none"
		ns4?this.l.visibility="hide":this.l.style.visibility="hidden"
		this.v=false
		if(debug)alert("Ocultada layer "+this.id)
	}
}
miLayer.prototype.AjustaTamanoA=function(lay){
	if(this.esLayer&&lay.esLayer)
		if(lay&&lay.esLayer)this.Ajusta(lay.an,lay.al)
}
miLayer.prototype.Ajusta=function(an,al){
	if(this.esLayer){
		an=an||this.an
		al=al||this.al
		if(ns4){
			this.l.clip.width=an
			this.l.clip.height=al
		}else{
			this.l.style.width=dom?an+'px':an
			this.l.style.height=dom?al+'px':al
			this.l.style.clip='rect(0px '+(an||0)+'px '+(al||0)+'px 0px)';
		}
		this.an=an
		this.al=al
		if(debug)alert("Ajustada layer "+this.id+" a ("+this.an+","+this.al+")")
	}
}
miLayer.prototype.AutoAjusta=function(){
	var an,al
	if(this.esLayer){
		if(ns4){
			an=this.d.width
			al=this.d.height
		}else if(ie4){
			this.l.style.offsetWidth=this.l.style.offsetWidth
			this.l.style.offsetHeight=this.l.style.offsetHeight
        	an=parseInt(this.l.style.scrollWidth)
        	al=parseInt(this.l.style.scrollHeight)
		}else{
			var oan=this.l.style.width
			var oal=this.l.style.height
			this.l.style.width="auto"
			this.l.style.height="auto"
        	an=parseInt(this.l.style.offsetWidth)
        	al=parseInt(this.l.style.offsetHeight)
        	this.l.style.width=oan
        	this.l.style.height=oal
		}
	}
	this.Ajusta(an,al)
}
miLayer.prototype.PosZ=function(z){
	if(this.esLayer){
		this.z=z
		ns4?this.l.zIndex=z:this.l.style.zIndex=z
	}
}
miLayer.prototype.DimePosZ=function(){
	return this.esLayer?this.z:-1
}
miLayer.prototype.Escribe=function(t){
	if(t){
		if(ns4){
			this.d.open('text/html')
			this.d.write(t)
			this.d.close()
		}else{
			this.l.innerHTML=t
		}
	}
}
miLayer.prototype.DimePageX=function(){
	//VuelcaObjeto(this.l)
	return ns4?this.l.pageX:this.l.offsetLeft
}
miLayer.prototype.DimePageY=function(){
	return ns4?this.l.pageY:this.l.offsetTop
}