/**
 * prepareHotelLists
 * Get a list of span tags in a hotel list and:
 * - remove those that don't have images (i.e. ratings)
 * - Change "Self-catering grade" to Grade
 */
function prepareHotelLists() {

  if (!document.getElementById("hotel_list")) return;

  var hotel_list = document.getElementById("hotel_list");
  var spans = hotel_list.getElementsByTagName("span");
  var newtext;

  for (i=0; i<spans.length; i++) {

    if (spans[i].getAttribute("class") == "hotel_type" || spans[i].getAttribute("className") == "hotel_type") {

      // if this span tag doesn't contain an image (i.e. a rating), remove the children
      // if it does, replace Self-catering grade with grade
      if (spans[i].getElementsByTagName("img").length < 1) {
        removeChildren(spans[i]);
      } else {
        if (spans[i].firstChild.nodeType == 3 && spans[i].firstChild.nodeValue.match(/Self-catering grade/)) {
          spans[i].firstChild.nodeValue = spans[i].firstChild.nodeValue.replace(/Self-catering grade/, "Grade");
        }
      }

    }
  }

} // end prepareHotelLists()
