function NeatDialog(sHTML, sTitle, bCancel, bTop, bLeft)
{
  window.neatDialog = null;
  this.elt = null;
  if (document.createElement && document.getElementById)
  {
    var dg = document.createElement("div");
    dg.className = "neat-dialog";
	dg.id = "neat-dialog";
    if (sTitle)
      sHTML = '<div class="neat-dialog-title">'+sTitle+
              ((bCancel)?
                '<img src="x.gif" alt="Cancel" class="nd-cancel" />':'')+
                '</div>\n' + sHTML;
    dg.innerHTML = sHTML;

    var dbg = document.createElement("div");
    dbg.id = "nd-bdg";
    dbg.className = "neat-dialog-bg";
	if(window.screen.height < document.body.offsetHeight){
		dbg.style.height = document.body.offsetHeight;
	}else{
		dbg.style.height = window.screen.height;
	}

    var dgc = document.createElement("div");
    dgc.className = "neat-dialog-cont";
	
    if (bTop && bLeft)
	{
		dg.style.left = bLeft;
		dg.style.top = bTop;
	}
	else
	{
		var width = 250;
		var height = 150;
		var screenW = window.screen.width;
		var screenH = window.screen.height;
		var w = document.body.clientWidth;
		var h = document.body.clientHeight;
		var w0 = Math.abs(Math.floor(((w - width) / 2) - 350));
		var h0 = Math.abs(Math.floor((h - height) - 250 ));

		if (isIE) {
			dg.style.left=w0 + 'px';
			dg.style.top=h0 + 'px';
		} else {
			var wfox = ((screenW - width) / 2) - 350;
			if (screenH > 700) var hfox = h-324;
			else if (screenH < 700) var hfox = h-124;
			dg.style.left = Math.abs(wfox) + 'px';
			dg.style.top = Math.abs(hfox) + 'px';
		}
	}
	dgc.appendChild(dbg);
    dgc.appendChild(dg);

    //adjust positioning if body has a margin
    if (document.body.offsetLeft > 0)
      dgc.style.marginLeft = document.body.offsetLeft + "px";

    document.body.appendChild(dgc);
    if (bCancel) document.getElementById("nd-cancel").onclick = function()
    {
      window.neatDialog.close();
    };
    this.elt = dgc;
    window.neatDialog = this;
  }
}
NeatDialog.prototype.close = function()
{
  if (this.elt)
  {
    this.elt.style.display = "none";
    this.elt.parentNode.removeChild(this.elt);
  }
  window.neatDialog = null;
}


