var BeanCounter = Class.create();
BeanCounter.prototype = {
    initialize: function(element, options) {
		options = options || {};

        this.element       = $(element);
        this.current_value = options['current_value'] || 0;
		
		this.image_folder  = options['image_folder'] || 'bilder/';
		this.image_folder  = this.image_folder+'/';
		
		this.number_style  = options['number_style'];
		
		this.updateElement(this.current_value);
    },
	updateElement: function(value) {
		this.element.childElements().each(function(e){
			e.remove();
		});
		value = value+'';
		for (i=0; i<value.length; i++) {
			this.insertNumber(value.charAt(i));
		}
	},
	insertNumber: function(number) {
		el = new Element('img',{
			'src':this.image_folder+number+'.png', 'alt':number, 'style':this.number_style});
		this.element.insert(el);
	}
}
