// Videocounter 
var VideoCounter = new Class({
	Implements: [Options, Events],
	options: {
		backgroundNumberHeight:48,
		backgroundOffset:15
	},
	initialize: function(element,options){
		if (!element){return false;}
		this.setOptions(options);
		// Counter injecten:
		this.myVideoCounterWrapper = new Element('div',{
			id:'myVideoCounterWrapper'
		}).inject(element,'top');
		this.MyDigitWrapper = new Element('div',{
			id:'digitwrapper'
		}).inject(this.myVideoCounterWrapper);
		this.digit1 = new Element ('div',{'class':'digit'}).inject(this.MyDigitWrapper);
		this.digit2 = new Element ('div',{'class':'digit'}).inject(this.MyDigitWrapper);
		this.digitdoppel = new Element ('div',{'class':'digitdoppelpunkt'}).inject(this.MyDigitWrapper);
		this.digit3 = new Element ('div',{'class':'digit'}).inject(this.MyDigitWrapper);
		this.digit4 = new Element ('div',{'class':'digit'}).inject(this.MyDigitWrapper);		
		this.myCurrValue = 0;
	},
	setTime: function(currtime,duration){
		
		var newValue = Math.round(duration-currtime).toInt();
		if (newValue > 99){newValue=99;}
		if (newValue != this.myCurrValue){
			var zehnerstelle = (newValue-newValue%10)/10*this.options.backgroundNumberHeight+this.options.backgroundOffset;
			var einserstelle = newValue%10*this.options.backgroundNumberHeight+this.options.backgroundOffset;
			this.digit1.setStyle('background-position','0px -'+zehnerstelle+'px');
			this.digit2.setStyle('background-position','0px -'+einserstelle+'px');
			this.myCurrValue = newValue;
		}
	}
});
