/*
  title - title of window
  url   - absolute url which will be opened in iframe
  prms  - startup parametres which will be added to
*/

function get_ctrl( nm ) {
var frm = document.forms[ 0 ];
  if( !nm || nm == null || frm == null )
    return null;
  return frm.elements[ nm ];
} // get_ctrl

function set_ctrl_val( nm, val ) {
var ctrl = get_ctrl( nm );
  // alert( "Control " + nm + ": " + ctrl ); // debug
  if( !ctrl || ctrl == null || !val )
    return;
  ctrl.value = val;
} // set_ctrl_val

//
// Open modal dialog
// sh      - path to modal dialog shell .aspx
// title   - title of shell window, can be empty
// url     - url of existing .aspx which will be opened in shell
// prm     - parametres for 'kid' .aspx
// wprms   - parametres for open modal dialog, such as:
//           dialogWidth, dialogHeight, resizable, status
function mdlg( sh, title, url, prms, wprms, ctrl_id, ctrl_nm ) {
var args = new Object();
var ret = new Object();

  args.prms = prms;
  ret = showModalDialog( sh + '?rand=' + Math.random(99999) +
	                            '&ttl=' + escape( title ) +
	                            '&url=' + escape( url ),
	                       args,
	                       wprms +
                         'center:yes;scroll:no;help:no' );
  if( ret.ret ) {
    set_ctrl_val( ctrl_id, ret.res_id );
    set_ctrl_val( ctrl_nm, ret.res_nm );
    return true;
  }
  return false;
} // modal_dlg

