// <script type="text/javascript" src="/js-pool/wdss/imagePopup.js"></script>

var _wdss_imagePopup = { window: null };

//window.onerror = function () { return true; };

function wdss_openImagePopup( url, title, width, height, href ) {
  _wdss_imagePopup.url    = url;
  _wdss_imagePopup.title  = title;
  _wdss_imagePopup.width  = width;
  _wdss_imagePopup.height = height;
  _wdss_imagePopup.href   = href;

  // close old window if open
  if ( _wdss_imagePopup.window != null && !_wdss_imagePopup.window.closed ) {
    if ( _wdss_imagePopup.window.close ) _wdss_imagePopup.window.close();
  }
  if ( 0 ) {
    setTimeout("_showImagePopup()",0); // mozilla does not like this if popups are blocked
  } else {
    _showImagePopup();
  }
}


function wdss_openFilePopup( url, title, args ) {
  window.open( url, title, args );
}


function _sgmlQuote(str) {
  str = str.replace(/&/,'&amp;' );
  str = str.replace(/"/,'&quot;' );

  return str;
}


function _showImagePopup() {
  var p = _wdss_imagePopup;
  var options = 'toolbar=no,dependent=yes,left=20,top=20,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height='+(p.height+3)+',width='+(p.width+0);
  p.window = window.open('','',options)
  with ( p.window ) {
    var img = '<img src="'+_sgmlQuote(p.url)+'" width="'+p.width+'" height="'+p.height+'" border="0" alt="'+p.title+'" title="'+p.title+'" />';
    if ( null != p.href && p.href.length ) {
      img = '<a href="'+p.href+'" target="_blank">'+img+'</a>';
    }
    var table = '<table border="0" cellspacing="0" cellpadding="0" height="100%"><tr><td valign="center">'+img+'</td></tr></table>';
    document.open();
    document.writeln('<html><head><title>' + p.title + '</title></head>');
    document.writeln('<body bgcolor="#ffffff" text="#000000" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"><div align="center">'+table+'</div></body></html>');
    document.close();
  }
}
