// script language="JavaScript" src="/js-pool/imagePopup.js"

var _wdss_imagePopup = { window: null };

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

if ( null == window.openImagePopup ) window.openImagePopup = function ( url, title, width, height, href ) {
  //deprecated( 'use wdss_openImagePopup' );
  wdss_openImagePopup( url, title, width, height, href )
}

function _wdss_decode ( str ) { if ( null == str ) return null; return unescape(unescape(str.replace(/\*/g,'%'))); }

function wdss_openImagePopup( url, title, width, height, href ) {
  _wdss_imagePopup.url    = _wdss_decode( url );
  _wdss_imagePopup.title  = _wdss_decode( title );
  _wdss_imagePopup.width  = width;
  _wdss_imagePopup.height = height;
  _wdss_imagePopup.href   = _wdss_decode( 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)

  var img = '<img src="'+escape(p.url)+'" width="'+p.width+'" height="'+p.height+'" border="0" alt="'+_sgmlQuote(p.title)+'" title="'+_sgmlQuote(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>';

  p.window.document.open();
  p.window.document.writeln('<html><head><title>' + p.title + '</title></head>');
  p.window.document.writeln('<body bgcolor="#ffffff" text="#000000" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"><div align="center">'+table+'</div></body></html>');
  p.window.document.close();
}
