function popup(link, windowname, w, h) {
  if (! window.focus) return true;
  var href;
  if (typeof(link) == 'string') {
     href=link;
  } else {
     href=link.href;
  }
  if (typeof(w)=='undefined') w=600;
  if (typeof(h)=='undefined') h=450;
  var theWidth=(screen.width/2) - (w/2);
  var theHeight=(screen.height/2) - (h/2);
  var browser=whichBrowser();
  switch (browser) {
    case 'IE':
      window.open(href, windowname, 'width='+w+',height='+h+',left='+theWidth+',top='+theHeight+',scrollbars=yes,modal=yes');
      break;
    case 'IE_Old':
      window.showModalDialog(href, windowname, 'dialogHeight:'+h+'px;dialogWidth:'+w+'px;dialogLeft:'+theWidth+'px;dialogTop:'+theHeight+'px;center:yes;');
      break;
    default:
      window.open(href, windowname, 'width='+w+',height='+h+',left='+theWidth+',top='+theHeight+',scrollbars=yes,modal=yes');
      break;
  }
  return false;
}

function whichBrowser() {
	  var agt=navigator.userAgent.toLowerCase();
	  if (agt.indexOf("opera") != -1) return 'Opera';
	  if (agt.indexOf("webtv") != -1) return 'WebTV';
	  if (agt.indexOf("chimera") != -1) return 'Chimera';
	  if (agt.indexOf("firefox") != -1) return 'Firefox';
	  if (agt.indexOf("safari") != -1) return 'Safari';
	  if (agt.indexOf("msie") != -1) {
		  if (navigator.appVersion < 7) {
			return 'IE';
		  } else {
			return 'IE_Old';
		  }
	  }
	  if (agt.indexOf("netscape") != -1) return 'Netscape';
	  if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	  if (agt.indexOf('\/') != -1) {
	    if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
	      return navigator.userAgent.substr(0,agt.indexOf('\/'));
	    } else {
	      return 'Netscape';
	    }
	  } else if (agt.indexOf(' ') != -1) {
	    return navigator.userAgent.substr(0,agt.indexOf(' '));
	  } else {
	    return navigator.userAgent;
	  }
	}


