    // selects 'value' in selectbox 'box' if that value exists
      function select(box, value) {
	//alert ("selecting page "+ value);
	for (var i=0; i<box.options.length; i++) {
	  var option= box.options[i];
	  //alert(option.value);
	  if (option.value == value) {
	    option.selected=true;
	  } else {
	    option.selected=false;
	  }
	}
      }

  //run gets the mode from the object part of the editor (upper frame)
    function run() { 
      var id        = arguments[0];
      var parent_id = arguments[1];
      var mode      = arguments[2];

      var frm = document.radform;
      frm.mode.value=mode;
      if (frm.mode.value=='edit_item' && id==0) {
	alert("You need to select an object to edit");
	return;
      }
      if (frm.mode.value=='cut' && id==0) {
	alert("You need to select an object to cut");
	return;
      }
      if (frm.mode.value=='copy' && id==0) {
	alert("You need to select an object to copy");
	return;
      }
      if (frm.mode.value=='remove_child' && id==0) {
	alert("You need to select an object to remove");
	return ;
      }	

      if (frm.mode.value!='remove_child'
	  && frm.mode.value!='cut'
	  && frm.mode.value!='insert_cell'
	  && frm.mode.value!='paste') {
	frm.target='Editor';
	window.open('','Editor','width=500,height='+(window.screen.availHeight-50)+',status=no,resizable=yes,toolbar=no,menubar=no,scrollbars=yes');
	//Editor.window.moveTo(0,0);
      } else {
	frm.target='';
      }
      if (frm.mode.value=='remove_child' 
	  || frm.mode.value=='pick_object' 
	  || frm.mode.value=='insert_cell'
	  || frm.mode.value=='cut'
	  || frm.mode.value=='paste') {
	frm.object_id.value= parent_id;
	frm.child_id.value = id;
      } else {
	frm.object_id.value = id;	  
      }
      if (frm.mode.value=='paste') {
	//alert (frm.paste_id.value);
	if (!(frm.paste_id.value>0)) {
	  alert('You must first select an Item to Paste');
	  return;
	}
      }
      debug(frm);
      frm.submit();
    }
  
  // the most general purpose. runs mode on id and displays to target
    function display()  {
      var target   = arguments[0];
      var id       = arguments[1];	 
      var mode     = arguments[2];
      var child_id = arguments[3];
      if ((target != '') && (target != 'EditRoot') ) {
	window.open('',target,'width=500,height='+(window.screen.availHeight-50)+',status=no,resizable=yes,toolbar=no,menubar=no,scrollbars=yes');
      }
      document.radform.target=target;
      document.radform.mode.value=mode;
      document.radform.object_id.value=id;
      document.radform.child_id.value=child_id;
      document.radform.submit();
      //alert("display");
    }
  
  function debug(frm) {
    var msg = "RADFORM SUBMITTED:\n";
    msg += "target="        + frm.target + "\n";
    msg += "old_object_id=" + frm.old_object_id.value + "\n";
    msg += "object_id="     + frm.object_id.value + "\n";
    msg += "old_mode="      + frm.old_mode.value + "\n";
    msg += "mode="          + frm.mode.value + "\n";
    //alert(msg);
  }

  function popup(mode,id,attribname) {
    window.open('','Popup','width=500,height='+(window.screen.availHeight-50)+',status=no,resizable=yes,toolbar=no,menubar=no,scrollbars=yes');
    document.radform.target='Popup';
    document.radform.mode.value=mode;
    document.radform.object_id.value=id;
    document.radform.attribname.value = attribname;
    document.radform.submit();
  }
  function edit_item(id) {	
    display('Editor',id,'edit_item');
  }

  function radonload() {
    setTimeout('delayload()',1500);    
  }

  function isblank(s) {
	if (!s.match(/\S/)) {
      return true;
   }
  } 

    // do link is specific to Link objects: jumps to an object_id and
      //    sets mode to edit or view depending on current value
	function dolink(page) {
	  var mode = document.radform.old_mode.value;
       document.radform.target="";
	  if (!( (mode == 'quickedit') || (mode == 'view') || (mode==''))) {
	    alert ("mode " + mode);
	    // document.radform.mode.value='edit';
	  }
	  document.radform.object_id.value=page;
	  document.radform.submit();
	}


