OpenLayers.Layer.TimedLayer = OpenLayers.Class(OpenLayers.Layer, {
	
	layerList: [],	
	isTimeDependant: true, //TODO: replace in LayerSwitcherTimed by .class
	currentTime: null,
	
	initialize: function(timeLayers,options) {
		this.layerList = timeLayers;
		
		OpenLayers.Layer.prototype.initialize.apply(this, options);
		
		this.events.register( "visibilitychanged", undefined, this.refreshTimedLayers );
	},
	
	timeChanged: function(newTimeStr) {
		this.currentTime = newTimeStr;
		this.refreshTimedLayers();
	},
	
	refreshTimedLayers: function(e) {
		for( var i in this.layerList ){
			this.layerList[i].setVisibility( i==this.currentTime && this.visibility );
		}
	},
	
	setOpacity: function(opacity){
		this.opacity = opacity;
		for( var i in this.layerList ){
			this.layerList[i].setOpacity(opacity);
		}
	},
	
	CLASS_NAME: "OpenLayers.Layer.TimedLayer"
});

