function popupWindow(url, w) {
  var i=0;
  if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1 && window.navigator.userAgent.indexOf('SV1') != -1) {
      i=30; //This browser is Internet Explorer 6.x on Windows XP SP2
  } else if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) {
      i=0; //This browser is Internet Explorer 6.x
  } else if (window.navigator.userAgent.indexOf('MSIE 7.0') != -1) {
      i=30; //This browser is Internet Explorer 7.x
  } else if (window.navigator.userAgent.indexOf('Firefox') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
      i=25; //This browser is Firefox on Windows
  } else if (window.navigator.userAgent.indexOf('Mozilla') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
      i=30; //This browser is Mozilla on Windows
  } else {
      i=80; //This is all other browsers including Mozilla on Linux
  }
  
  if (w) {
    var imgHeight = 300+50-i;
    var imgWidth = 400+30;
  } else {
    var imgHeight = 400+30;
    var imgWidth = 300+50-i;
  }

  var screenheight = screen.height;
  var screenwidth = screen.width;
  var leftpos = screenwidth / 2 - imgWidth / 2;
  var toppos = screenheight / 2 - imgHeight / 2;

  var newWin = window.open(url,'PopupImage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+imgWidth+',height='+imgHeight+',screenX='+toppos+',screenY='+leftpos+',top='+toppos+',left='+leftpos+'')

  newWin.focus();
}
