/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//
//  Configurationl
//
var RatingStatic = Class.create({
    initialize: function(classRating) {
		RatingStatic.instances.push(this);
		this.classR = classRating;
		this.refresh();
    },
	
	refresh: function () {
		$$('div.' + this.classR).each(function(node) {
			var node = $(node);
			var _className = node.className;
			var _l = _className.split(' ');
			if (_l.length > 1) _l = _l[1].split('=')[1];
			node.addClassName('clearfix');
			var _r = _l;
			if (isNaN(_r)) _r = 0;
			//if (_r == 0) return;
			for (i = 1; i <= 5; i++) {
				if (i <= Math.ceil(_r)) {
					if (i <= _r) {
						node.insert('<span class="star-static star-static-on"></span>');
					} else {
						node.insert('<span class="star-static star-static-half-on"></span>');
						node.insert('<span class="star-static star-static-half-off"></span>');
					}
				} else {
					node.insert('<span class="star-static star-static-off"></span>');
				}
			}
        }.bind(this));
	}
});

Object.extend(RatingStatic,{
    instances: [],
    findByElementId: function(id){
        return RatingStatic.instances.find(function(instance){
            return (instance.container.id && instance.container.id == id);
        });
    }
});

