var radioButtons = document.getElementById("radioButtons");

function removeRadioButtons(){
  if (radioButtons.hasChildNodes()){
	while (radioButtons.childNodes.length >= 1){
		radioButtons.removeChild(radioButtons.firstChild);       
	} 
  }
}

function addHiddenInput(){
var theInput = document.createElement('input');
theInput.type = "hidden";
theInput.name = "answerScore";
theInput.id = "answerScore";
theInput.value = "";
radioButtons.appendChild(theInput);
}

function createStars(){
var poorSpan = document.createElement('span');
poorSpan.className = "ratingText";
var poorSpanText = document.createTextNode('Poor');
poorSpan.appendChild(poorSpanText);
radioButtons.appendChild(poorSpan);

var theList = document.createElement('ul');
theList.className = "rating";
  for (i=1;i<=5;i++){
	var theListItem = document.createElement('li');
	theListItem.className = 'star' + i;
	var theLink = document.createElement('a');
	theLink.href = "#";
	var pluralStars = ((i==1) ? " star" : " stars");
	theLink.title = i + pluralStars;
	theLink.rel = i;
	theLink.onclick = function(){document.getElementById('answerScore').value = this.rel; document.rate_form.submit(); return false;}
	var theText = document.createTextNode(i);
	theLink.appendChild(theText);
	theListItem.appendChild(theLink);
	theList.appendChild(theListItem);
  }
radioButtons.appendChild(theList);
var excellentSpan = document.createElement('span');
excellentSpan.id = "ratingTextRight";
var excellentSpanText = document.createTextNode('Excellent');
excellentSpan.appendChild(excellentSpanText);
radioButtons.appendChild(excellentSpan);
}

function showRater(){
removeRadioButtons();
addHiddenInput();
createStars();
}