var def_dhlAlert="1.0";
var defaultWidth = 300;     // Default width of window
var defaultHeight = 200;    // Default height of window
var maxHeight = screen.availHeight / 2; // Maximum height of window
var win;

if (navigator.appName.indexOf("Netscape") >= 0 && parseInt(navigator.appVersion) >= 4)
{
  var aboveNN4 = true
}
if (navigator.appName.indexOf("Explorer") >= 0 && parseInt(navigator.appVersion) >= 4)
{
  var aboveIE4 = true;
}

if( typeof(def_validateForm)!= "undefined" )
{
  alertMethod = "dhlAlert";
  alertMIME   = "html";
}

function keyPress(d)
{
    key = aboveNN4 ? d.which : win.event.keyCode
    if( key == 13 )
    {
        winClose();
    }
}

function winClose(selfRef)
{
  if( typeof( win ) == 'object' && !win.closed )
  {
    win.close();
  }
  else if (typeof(selfRef) == 'object')
  {
    selfRef.close();
  }
  // return commented to prevent "true" from being displayed when close link is clicked on error popup
  // return true;
}

function dhlAlert( name, text, width, height )
{
  winClose();
  if( typeof( width ) == "undefined" )
  {
    width = defaultWidth;
  }
  if( typeof( height ) == "undefined" )
  {
    height = defaultHeight;
  }
  if( height > maxHeight )
  {
    height = maxHeight;
  }
  win = open( "", "dhl_alert", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=" + width + ",height=" + height );
  win.document.write( '<html>\n' +
    '<head>\n' +
    '  <title>' + name + '</title>\n' +
    '  <link rel="stylesheet" type="text/css" href="'+ instance +'/css/general/generalPopup.css" />\n' +
    '</head>\n' +
    '<body onload= focus(); leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">\n' +
    '<table border="0" cellpadding="6" width="100%" height="5%">\n' +
    '<tr>\n' +
    '  <td height="16" class="helpHeading">' + name + '</td>\n' +
    '</tr>\n' +
    '</table>\n' +
    '<table border="0" cellpadding="6" width="100%" height="95%">\n' +
    '<tr>\n' +
    '  <td valign="top" height="75%">' + text + '</td>\n' +
    '</tr>\n' +
    '<tr>\n' +
    '  <td align="center" valign="bottom" width="100%" height="25%"><a href="javascript:opener.winClose(this)">Close</a></td>\n' +
    '</tr>\n' +
    '</table>\n' +
    '</body>\n' +
    '</html>' );

if (aboveNN4 && typeof( win ) == 'object' && !win.closed )
{
    win.captureEvents(Event.KEYDOWN);
    win.onkeydown = keyPress;
}
else if (aboveIE4 && typeof( win ) == 'object' && !win.closed )
{
  win.document.onkeydown = keyPress;
}
  win.document.close();
  win.focus();
  return win;
}
