 function dh_dia(wi,ix,ti,tx,fl,bt,ifrsrc,ifrht) {
  var di = d_ge('dia');
   if (di != undefined)
    dh_can();
  di = dh_dia_top(wi);
  d_ae(document,'keypress',dh_keys);
  var dttl = d_mk('p',di,ti,'diattl');
  var clim = d_mk('img',dttl,'','diabt1',{'src':'services/images/close.gif'});	// note hardcoded address
  clim.style.top = '10px';
  clim.style.left = (wi-30)+'px';
  clim.onclick = dh_can;
  d_mk('p',di,tx,'diatxt');
   if (ifrsrc) {	// see icc3.m_uploads.php for an example
    var ifr = d_mk('iframe',di,'','',{'id':'ifr','width':di.offsetWidth-12,'src':ifrsrc,'frameborder':'no'});
	 if (ifrht)
	  ifr.height = ifrht;
	ifr.frameborder = '0';
	d_ss(ifr,'borderWidth','0px');
    dh_dia_bot(di);
	return true;
   } else {
    d_mk('table',di,'','',{'width':di.offsetWidth*0.8,'align':'center','id':'tbl'+ix});
    var tb = new Jstable(ix,fl);
    tb.setpagebtns(bt);
    tb.setsingle(true);
    tb.writetable();
    dh_dia_bot(di);
     if (fl[0])
      d_ge(tb.fmt.geth(0,1) + ':' + tb.fmt.geth(0,2)).select();
    return tb;
   }
 }
 function dh_dia_top(wi) {
  var sp = dh_gsp();
  var vs = dh_gvs();
  var ps = dh_gps();
   if (vs[1] > ps[1])
    ps[1] = vs[1];
  var bd=d_gb();
  var cn=d_mk('div',bd,'','curtain',{'id':'cur'});
  d_ss(cn,'position','absolute');
  d_ss(cn,'left',0);
  d_ss(cn,'top',0);
  d_ss(cn,'width',ps[0]+'px');
  d_ss(cn,'height',ps[1]+'px');
  var diwi = (wi) ? wi : ps[0]*0.4;
  var di=d_mk('div',bd,'','dialog',{'id':'dia'});
  d_ss(di,'width',diwi+'px');
  d_ss(di,'visibility','hidden');
  d_ss(di,'position','absolute');
  return di;
 }
 function dh_dia_bot(di) {
  var sp = dh_gsp();
  var vs = dh_gvs();
  d_ss(di,'left',sp[0] + parseInt(vs[0]/2) - parseInt(di.offsetWidth/2) + 'px');
  d_ss(di,'top',sp[1] + parseInt(vs[1]/2) - parseInt(di.offsetHeight/2) + 'px');
  d_ss(di,'visibility','visible');
 }
 function dh_gsp() {
  var pos=[0,0];
   if (dh_to(window.pageXOffset))
    pos=[window.pageXOffset,window.pageYOffset];
   else if (dh_to(document.documentElement.scrollLeft) && document.documentElement.scrollTop>0)
    pos=[document.documentElement.scrollLeft,document.documentElement.scrollTop];
   else if (dh_to(document.body.scrollLeft))	
    pos=[document.body.scrollLeft,document.body.scrollTop];
  return pos;	
 }
 function dh_dndstart(e,t) {
   if(!e)e=window.event;
   if (!dh_to(e.pageX)) {
    e.pageX = e.clientX + dh_gsp()[0];
    e.pageY = e.clientY + dh_gsp()[1];
   }
  document.curtgt = t;
  var cl = parseInt(t.style.left);
  var ct = parseInt(t.style.top);
   if (isNaN(cl))cl='0';
   if (isNaN(ct))ct='0';
   if (!dh_to(t.originLeft)) {
    t.originLeft = cl;
	t.originTop = ct;
   } 
  t.cox = e.pageX;
  t.coy = e.pageY;
  t.dx = cl - e.pageX;
  t.dy = ct - e.pageY;
  d_ae(document,'mousemove',dh_dndchkmove); 
  d_ae(document,'mouseup',t.fnclick);
  d_cd(e);
  return false;
 }
 function dh_dndchkmove(e) {
   if(!e)e=window.event;
   if (!dh_to(e.pageX)) {
    e.pageX = e.clientX + dh_gsp()[0];
    e.pageY = e.clientY + dh_gsp()[1];
   }
  var t = document.curtgt;
   if (Math.abs(t.cox-e.pageX)>3 || Math.abs(t.coy-e.pageY)>3) { 
    d_de(document,'mousemove',dh_dndchkmove); 
    d_de(document,'mouseup',t.fnclick); 
    d_ae(document,'mousemove',t.fnmove); 
    d_ae(document,'mouseup',t.fndrop); 
    d_ae(document,'click',dh_dndclick);
   } 
  d_cd(e);
  return false;
 }
 function dh_dndcanmove() {
  var t = document.curtgt;
  d_de(document,'mousemove',dh_dndchkmove); 
  d_de(document,'mouseup',t.fnclick); 
  d_de(document,'click',dh_dndclick);
  return false;
 }
 function dh_dnddomove(e) {
   if(!e)e=window.event;
   if (!dh_to(e.pageX)) {
    e.pageX = e.clientX + dh_gsp()[0];
    e.pageY = e.clientY + dh_gsp()[1];
   }
  var t = document.curtgt;
   if (t.style.zIndex<win_maxz)
    t.style.zIndex = ++win_maxz;
  t.style.left = e.pageX + t.dx + 'px';
  t.style.top = e.pageY + t.dy + 'px';
  d_cd(e);
  return true;
 }
 function dh_dndendmove(e) {
  var t = document.curtgt;
  d_de(document,'mousemove',t.fnmove); 
  d_de(document,'mouseup',t.fndrop); 
  return true;
 } 
 function dh_dndclick(e) {
   if(!e)e=window.event;
  d_de(document,'click',dh_dndclick); 
  d_cd(e);
  return true;
 } 
 function dh_gvs() {
  var sz=[0,0];
   if (dh_to(window.innerWidth))
    sz=[window.innerWidth,window.innerHeight];
   else if (dh_to(document.documentElement.clientWidth) && document.documentElement.clientWidth>0)	
    sz=[document.documentElement.clientWidth,document.documentElement.clientHeight];
   else
    sz=[document.getElementsByTagName('body')[0].clientWidth,document.getElementsByTagName('body')[0].clientHeight];
  return sz;		
 }
 function dh_gps() {
  var bd=d_gb();
  var bow = bd.offsetWidth;
  var boh = bd.offsetHeight;
  var bsw = bd.scrollWidth;
  var bsh = bd.scrollHeight;
  var ps = [0,0];
   if (dh_to(document.documentElement.scrollWidth))
    ps = [document.documentElement.scrollWidth,document.documentElement.scrollHeight];
   if (bow > ps[0])
    ps[0] = bow;
   if (boh > ps[1]);
    ps[1] = boh;
   if (bsw > ps[0]);
    ps[0] = bsw;
   if (bsh > ps[1]);
    ps[1] = bsh;
  return ps;				
 }
 function dh_gpo(el) {
  var px = 0;
  var py = 0;
   while (el != null) {
    px += el.offsetLeft;
	py += el.offsetTop;
	el = el.offsetParent;
   }
  return [px,py]; 
 }
 function dh_gsc() {
  var vs = dh_gvs();
  var ps = dh_gps();
   if (vs[1] > ps[1])
    ps[1] = vs[1];
  return ps;	
 }
 function dh_to(o) {
  return (typeof o != 'undefined');
 }
 function dh_can() {
  d_de(document,'keypress',dh_keys);
  d_rm('dia');
  d_rm('cur');
 }
 function dh_keys(e) {
  if(!e)e=window.event;
  if (e.keyCode==27)
    dh_can();		
 }