SimpleBarGraph = Class.create();
SimpleBarGraph.prototype = {
	initialize: function(id){
		this.element_id = id;
		$(this.element_id).slider = this;
		
		graph_elem = $(id);
		values 	   = $$('#'+id+' .bgInner .value');
		
		this.options = Object.extend({
			height:		300,
			width:		500,
			spacing: 	5,
			max_value:	$$('#'+id+' .maxValue')[0].innerHTML
	    }, arguments[1] || {});

		max_value  = this.options.max_value;

		graph_height  = this.options.height;
		
		if(this.options.width == 'auto'){
			graph_elem.style.width  = '100%';
			graph_width				= graph_elem.offsetWidth;
		}
		else {
			graph_width				= this.options.width;
			graph_elem.style.width  = graph_width  + 'px';
		}
		
		value_spacing = this.options.spacing;
		value_width   = Math.round((graph_width / values.length) - (value_spacing * 1.25));

		graph_elem.style.height = graph_height + 'px';

		x = 0;
		values.each(function(elem){
			current_value = Number(elem.innerHTML);

			elem.parentNode.style.width  = value_width + 'px';
			elem.parentNode.style.left   = (x * value_width) + ((x + 1) * value_spacing) + 'px';

			// Enforce ceiling if one is present 
			if(current_value > max_value){
				current_value = max_value;
			}

			does = (graph_height - 10) * (current_value / max_value);
			does = Math.round(does);

			if(does <= 20) {
				does = 20;
				elem.hide();
			}

			elem.parentNode.style.height = (does - 10) + 'px';

			x += 1;
		});
	}
}