function MovingLayer(containerId, layerId, restartOffset){				
	this.layerContainerId = containerId;
	this.movingLayerId = layerId;
	this.restartOffset = restartOffset;
	this.maxTopPos = 0;
	this.topPos = 0;
	this.layerHeight = 0;
	
	this.initLayerParameter = initLayerParameter;
	this.initLayerStyle = initLayerStyle;
	
	this.getMovingLayer = getMovingLayer;
	this.getLayerContainer = getLayerContainer;
					
	this.moveLayer = moveLayer;						
	this.resetPos = resetPos;
	this.getPositionValue = getPositionValue;
}

function getMovingLayer(){
	return document.getElementById(this.movingLayerId);
}
function getLayerContainer(){
	return document.getElementById(this.layerContainerId);
}			

function moveLayer(){
	if (this.maxTopPos != 0){
		this.topPos += 1;
		this.getMovingLayer().style.top = this.topPos;
	}
	else{
		this.initLayerParameter();
		this.initLayerStyle();
	}
	this.resetPos();
}

function initLayerParameter(){
	this.maxTopPos = this.getPositionValue(this.getLayerContainer().style.height);	
	this.topPos = this.getPositionValue(this.getMovingLayer().style.top);
	this.layerHeight = this.getPositionValue(this.getMovingLayer().style.height);	
}

function initLayerStyle(){
	this.getLayerContainer().style.overflow = "hidden";
	//this.getLayerContainer().style.position="absolute";
	this.getMovingLayer().style.position="absolute";
}

function resetPos(){
	var posDiff = this.maxTopPos - this.topPos;
	if (posDiff <= 0){
		this.topPos = 0 - this.layerHeight - this.restartOffset;
	}
}

function getPositionValue(pos){
	return pos.substring(0, pos.length-2)*1;
}
