function showMailForm() {
  showMyModalDialog('mailform.html', null, 450, 333, '');
}

function doCallback(s) {
//debugger;
  if (s) {
    if (popUp.callbackFunction) {
      popUp.callbackFunction(s);
    }
  }
  document.body.removeChild(popUp);
  document.body.removeChild(blocker);
  document.body.style.overflow="auto";
  window.top.document.body.style.marginRight="";
}

function showMyModalDialog(frmName, cBack, dlgW, dlgH, dlgArgs) {

  if (document.all && window.showModalDialog) {
    var x = window.showModalDialog(frmName, dlgArgs, 'resizable: off; center: on; dialogWidth: ' + dlgW + 'px; dialogHeight: ' + (dlgH + 25) + 'px; status: no; scroll: no; resizable: no; center: yes;'); 
    if (x) { 
      if (cBack)  cBack(x) 
    } 
  } else { 
    showSafeDialog(frmName, cBack, dlgW, dlgH, dlgArgs); 
  }
}

function showSafeDialog(frmName, cBack, dlgW, dlgH, dlgArgs) {

  dTop = document.body.scrollTop
  
  var frm2 = document.createElement('IFRAME'); 
  frm2.id = "blocker";
  frm2.src = "";
  frm2.style.position = "absolute";
  frm2.style.backgroundColor = '#000000';
  frm2.style.opacity = ".25";                  
  frm2.style.MozOpacity = ".25";               
  frm2.style.KhtmlOpacity = ".25";
  frm2.style.filter = "alpha(opacity=25)";
  frm2.style.height = "100%";
  frm2.style.width = "100%";
  
  frm2.style.top = dTop;
  frm2.style.left = 0;
  frm2.frameBorder = '0';
  frm2.style.display='block';
  
  blocker = document.body.appendChild(frm2);
  
  var frm = document.createElement('IFRAME');
  frm.id = "popUp";
  frm.style.position = "absolute";
  frm.src = frmName;
  frm.style.height = dlgH + "px";
  frm.style.width = dlgW + "px";
  frm.style.left = ((getSize(1) - dlgW) / 2) + "px";
  frm.style.top = (dTop + ((getSize(0) - dlgH) / 2)) + "px";
  frm.style.overflow = 'hidden';

  frm.style.display='block';
  //frm.frameBorder = '2';
  frm.style.border = 'outset 2px gray';

  popUp = document.body.appendChild(frm);

  popUp.callback = doCallback;
  popUp.callbackFunction = cBack;
  popUp.dlgArgs = dlgArgs; // access with window.frameElement.dlgArgs

  window.top.document.body.style.overflow="hidden";
  if (window.scrollMaxY > 0) { window.top.document.body.style.marginRight="25px"; }
  
  //window.scrollTo(0, dTop);
}

function getSize(horw) {
  var myWidth = 0, myHeight = 0;
  if( typeof( this.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = this.innerWidth;
    myHeight = this.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if (horw) {
  return myWidth;
  } else {
  return myHeight;
  }
}

//get content of text node in both browser types
function getTextContent(el){
  return (el.innerText == undefined ? el.textContent : el.innerText);
} 

//find out if a given HTML element is empty - useful for editors
function isElementEmpty(obj) {
  var empty = (obj.childNodes.length == 0) || obj.innerHTML == "" || 
                (obj.childNodes[0].childNodes.length == 0 && getTextContent(obj) == "") ||
                (obj.childNodes[0].childNodes.length == 1 && obj.childNodes[0].childNodes[0].tagName == 'BR' && getTextContent(obj) == "");
  return empty;
}