function StarSelect(selector)
{
  $$(selector).each(function (obj, index) {
    var classes = ['no', 'one', 'two', 'three', 'four', 'five']
    var options = obj.options;
    var id = obj.id;
    var obj_value = options[obj.selectedIndex].value;
    
    var html = '<input type="hidden" name="' + obj.name + '" id="' + id + '" value="' + obj_value + '" />'; 
    html += '<ul id="starSelect' + index + '" class="' + classes[parseInt(obj_value)] + 'star">';

    for (var i = 0; i < options.length; i++) {
      var option = options[i];
      var value = parseInt(option.value);
      if (value) {
        html += '<li class="' + classes[value] + '"><a href="#" onclick="$(\'' + id + '\').value = ' + value + '; $(\'starSelect' + index + '\').className = \'' + classes[value] + 'star\';$(this).blur(); return false;">' + value + '</a></li>';
      }
    }

    html += '</ul>';

    obj.replace(html);
  });
}

document.observe('dom:loaded', function () { new StarSelect('select.starSelect') });
