var capa =
{ 
	topMargin : 35, //posicion inicial 
	ceiling : 0 , //pixels del efecto de amortiguacion 
	desplazaTime : 2400 , //tiempo en recorrer la distancia anterior 
	capaDiv : document.all ? document.all.capa : 
	(document.layers ? document.capa : document.getElementById('capa')) 
} 

window.setInterval("capa.coordenadas( )", 20) 

capa.coordenadas = function( ) 
{ 
if(document.all) 
{ 
this.actualY = this.capaDiv.style.pixelTop; 
this.scrollTop = document.body.scrollTop; 
} 
else if(document.layers) 
{ 
this.actualY = this.capaDiv.top; 
this.scrollTop = window.pageYOffset; 
} 
else if(document.getElementById) 
{ 
this.actualY = parseInt(this.capaDiv.style.top); 
this.scrollTop = window.pageYOffset; 
} 

var nuevoScrollTop = Math.max( this.scrollTop + this.topMargin, this.ceiling ); 

if ( this.actualY != nuevoScrollTop ) 
{ 
if ( nuevoScrollTop != this.targetY ) 
{ 
this.targetY = nuevoScrollTop; 
this.desplazaInit( ); 
} 
this.desplaza( ); 
} 
} 
capa.desplazaInit = function( ) 
{ 
var ahora = new Date( ) 
this.A = this.targetY - this.actualY ; 
this.B = Math.PI / ( 2 * this.desplazaTime ); 
this.C = ahora.getTime( ); 
this.D = this.actualY; 
} 

capa.desplaza = function( ) 
{ 
var ahora = new Date( ); 
var nuevaY = this.A * Math.sin( this.B * ( ahora.getTime( ) - this.C ) ) + this.D; 
nuevaY = Math.round( nuevaY ); 

if ( ( this.A > 0 && nuevaY > this.actualY ) || ( this.A < 0 && nuevaY < this.actualY ) ) 
{ 
if (document.all) 
this.capaDiv.style.pixelTop = nuevaY; 
else if(document.layers) 
this.capaDiv.top = nuevaY; 
else if(document.getElementById) 
this.capaDiv.style.top = nuevaY; 
} 
} 

