/** 
 * Updates an arbitrary number of targets with new HTML
 * 
 * @fragments  object  an object containing properties that map
 *                     fragment identifiers to HTML element IDs
 * @xml        string  the XML text that contains the fragment
 *                     identifiers and replacement HTML
 *
 * See http://www.cube6media.com/weblog/entry/2005/11/24/rails-ajax-form-error-handling
 */
function updatesFromXML(fragments, xml) {
  for(fragment in fragments) {
    var matches = new RegExp("<" + fragment + 
    "><!\\[CDATA\\[([\\s\\S]*)\\]\\]></" + fragment + 
    ">").exec(xml);
    if(matches) {
      $(fragments[fragment]).innerHTML = matches[1];
    }
  }
}
