// Cantidad de pixels que se mueva en cada iteración
var offset=4;
// Define si es un movimiento contínuo o simple
var continuous=true;
// Velocidad del movimiento (en milisegundos)
var speed=200;

// Top Location
var tp=0; 
// Variables que definen si esta en movimento arriba o abajo
var movingUp=0;
var movingDown=0;

function MoveUp(Move)
{
	if( Move ) {
		movingUp=1;
		StartMoveUp();
	}
	else movingUp=0;
}

function MoveDown(Move)
{
	if( Move ) {
		movingDown=1;
		StartMoveDown();
	}
	else movingDown=0;
}


function StartMoveUp(){ 
	
   if( movingUp ) {
	   contHeight = Contenedor.style.height.substring(0,Contenedor.style.height.indexOf("px",0));
	   movHeight = Movil.style.height.substring(0,Movil.style.height.indexOf("px",0));
	   if( tp > contHeight-movHeight ) {
		   tp=tp-offset; 
		   Movil.style.top=tp; 
		   if( continuous )
		   		setTimeout('StartMoveUp()',speed);
		}
		else  movingUp=0;
	}
} 

function StartMoveDown(){ 
	
	if( movingDown ) {
		if( tp < 0 ) {
		   tp=tp+offset; 
		   Movil.style.top=tp; 
		   if( continuous )
		   		setTimeout('StartMoveDown()',speed);
		}
		else movingDown=0;
	}
} 
