/*
var constrict_ini_bg = '#FFFFFF';
var constrict_err_bg = '#FF0000';
var constrict_err_check = 'rgb(255, 0, 0)';
function constrict (element, length, name) {
  if (element.value.length > length) {
    if (element.style.backgroundColor.toString () != constrict_err_check) {
      alert (name + ' is longer than the allowed maximum of ' + length + ' characters, and will be truncated');
    }
    element.style.backgroundColor = constrict_err_bg;
    return false;
  } else {
    element.style.backgroundColor = constrict_ini_bg;
    return true;
  }
}
*/

function update_select (id, url) {
  
  id = String (id);
  
  var node = document.getElementById (id);
  if (!node) {
    window.alert ("Called update_select with invalid node id: " + id);
    return;
  } else if (!node.nodeName) {
    window.alert ("Called update_select on invalid node type");
    return;
  } else if (node.nodeName != 'SELECT') {
    window.alert ("Called update_select with invalid node type: " + node.nodeName);
    return;
  }
  
  // remove all children and add "Please wait..."
  var child;
  if (node.childNodes) {
    for (var i = node.childNodes.length - 1; i >= 0; i --) {
      child = node.childNodes.item (i);
      node.removeChild (child);
    }
  }
  child = document.createElement ('option');
  child.appendChild (document.createTextNode ('Please wait...'));
  node.appendChild (child);
  // update children via ajax
  var request_options = new Array ();
  request_options['node'] = id;
  queue.request ('get', url, TYPE_OVERWRITE_NODE, null, request_options);
  
}
