d=document

var is=new Browser()
function Browser()
{
 this.opera=navigator.userAgent.indexOf("Opera")!=-1
 this.ie=(d.all&&!this.opera)?true:false
 this.ns=d.layers?true:false
 this.dom=(d.getElementById)?true:false
 this.any=this.ie||this.dom||this.ns||this.opera
}

function CLayer(id)
{
 ar=arguments

 this.parent=null;
 this.ref=null
 this.obj=null
 this.linkTo(id)
 this.clipX=0
 this.clipY=0
 this.clipW=null
 this.clipH=null
 
 if(ar[1])this.x(ar[1])
 if(ar[2])this.y(ar[2])
 if(ar[3])this.w(ar[3])
 if(ar[4])this.h(ar[4])
 if(ar.length>5)this.show(ar[5])
 
 this.htmlBuffer=null
 this.onHtmlBuffer=false
}

var CL_p=CLayer.prototype

CL_p.z=function()
{
 a=arguments
 if(a.length!=0)
 {
  this.ref.zIndex=a[0]
  return
 }
 return this.ref.zIndex
}

CL_p.x=function()
{
 a=arguments
 if(a.length!=0)
 {
	if(is.ie)this.ref.posLeft=a[0]
	else if(is.dom||is.ns)this.ref.left=a[0]
	return
 }
 if(is.ie)return parseInt(this.ref.posLeft)
 else if(is.dom||is.ns)return parseInt(this.ref.left)
}

CL_p.y=function()
{
 a=arguments
 if(a.length!=0)
 {
  if(is.ie)this.ref.posTop=a[0]
  if(is.dom||is.ns)this.ref.top=a[0]
  return
 }
 if(is.ie)return parseInt(this.ref.posTop)
 else if(is.dom||is.ns)return parseInt(this.ref.top)
}

CL_p.minW=function()
{
 if(is.opera)r=this.ref.pixelWidth
 else if(is.dom||is.ie)r=this.obj.offsetWidth
 else if(is.ns)r=this.ref.document.width
 return r
}

CL_p.w=function()
{
 a=arguments
 if(a.length!=0)
 {
  v=a[0]
  if(is.ns)if(v<this.minW())v=this.minW()
  this.ref.width=v
  if(is.ns)this.ref.resizeTo(v,this.h());
 }
 else
 {
  if(this.ref.width&&is.ns)return parseInt(this.ref.width)
  else return this.minW()
 }
}

CL_p.minH=function()
{
 if(is.opera)r=this.ref.pixelHeight
 else if(is.dom||is.ie)r=this.obj.offsetHeight
 else if(is.ns)r=this.ref.document.height
 return r
}

CL_p.h=function()
{
 a=arguments
 if(a.length!=0)
 {
  v=a[0]
  if(is.ns)if(v<this.minH())v=this.minH()
  this.ref.height=v
  if(is.ns)this.ref.resizeTo(this.w(),v);
 }
 else
 {
  if(this.ref.height&&is.ns)return parseInt(this.ref.height)
  else return this.minH()
 }
}

CL_p.bg=function()
{
 a=arguments
 if(a.length!=0)
 {
  if(is.ie||is.dom||is.opera)this.ref.background=a[0]
  if(is.ns)this.ref.bgColor=a[0]
  return
 }
 if(is.ie||is.dom||is.opera)return this.ref.background
 if(is.ns)return this.ref.bgColor
}

CL_p.clip=function()
{
 a=arguments
 r=this.ref.clip
 if(a.length!=0)
 {
  if(a[0]==null)this.clip(0,0,this.w(),this.h())
  else
  {
	if(is.ie||is.dom)this.ref.clip="rect("+a[1]+","+(a[2]+a[0])+","+(a[3]+a[1])+","+a[0]+")"
	if(is.ns)
	{
		r.top=a[0]
		r.left=a[1]
		r.right=a[2]+a[0]
		r.bottom=a[3]+a[1]
	}
	this.clipX=a[0]
	this.clipY=a[1]
	this.clipW=a[2]
	this.clipH=a[3]
  }
  return
 }
 if(this.clipW==null)
 {
	if(is.ie||is.dom)return this.ref.clip
	if(is.ns)return [r.left,r.top,r.right-r.left,r.bottom-r.top]
 }
 return [this.clipX,this.clipY,this.clipW,this.clipH]
}

CL_p.show=function()
{
 a=arguments
 if(is.ie||is.dom){_vis='visible'; _hid='hidden'}
 if(is.ns){_vis='show'; _hid='hide'}
 if(a.length==0)
 {
	if(this.ref.visibility.toLowerCase()==_vis)return true
	return false
 }
 else
 {
	if(a[0])this.ref.visibility=_vis
	else this.ref.visibility=_hid
 }
}

CL_p.linkTo=function(id)
{
 this.id=id
 if(is.ie){this.obj=d.all[id]; this.ref=this.obj.style }
 else if(is.dom){ this.obj=d.getElementById(id); this.ref=this.obj.style }
 else if(is.ns) this.ref=d[id];
}

CL_p.html=function(html)
{
 a=arguments
 if(a.length==0)
 {
	if(is.dom||is.ie)return this.obj.innerHTML
	else if(is.ns)return ((this.htmlBuffer)?this.htmlBuffer:null)
 }
 if(is.dom||is.ie)this.obj.innerHTML=html
 else if(is.ns)
 {
	this.ref.document.open()
	this.ref.document.write(html)
	if(this.onHtmlBuffer)this.htmlBuffer=html
	this.ref.document.close()
 }
}

CL_p.display=function()
{
 a=arguments
 if(a.length==0)
 {
	if(!is.ns)return this.ref.display;
	return "";
 }
 else if(is.any)this.ref.display = a[0]
}

CL_p.pos=function()
{
 if( !(is.ns||is.opera) )return this.ref.position;
 else return "absolute"
}