var uagent   = navigator.userAgent.toLowerCase() ;
var uAppType = 0 ;
var uAppVer  = 0 ;

//alert(uagent) ;
nStrOffs = uagent.indexOf('mozilla/') ;
if(nStrOffs >= 0) { // Netscape
  uAppType = 1 ;
  nStrOffs += 8 ;
  uAppVer = parseFloat(uagent.substring(nStrOffs, uagent.length)) ;
}
nStrOffs = uagent.indexOf('msie ') ;
if(nStrOffs >= 0) { // Microsoft IE
  uAppType = 2 ;
  nStrOffs += 5 ;
  uAppVer = parseFloat(uagent.substring(nStrOffs, uagent.length)) ;
}
nStrOffs = uagent.indexOf('opera') ;
if(window.opera || (nStrOffs >= 0)) { // Opera
  uAppType = 3 ;
  nStrOffs += 6 ;
  uAppVer = parseFloat(uagent.substring(nStrOffs, uagent.length)) ;
}
//alert("App["+uAppType+"]:Ver["+uAppVer+"]") ;

var winSubWindow = "" ;
var winURL = "" ;

function openSubWindow(event, url, name, width, height) {
  if((winURL != "") && (winURL != url)){
    if(!winSubWindow.closed) {
      winSubWindow.close() ;
    }
  }
  if(((uAppType == 2) && (uAppVer >= 4)) || (uAppType == 3)) {
    x = window.event.screenX - (width/2) ;
    y = window.event.screenY - (height/3) ;
  }
  else if((uAppType == 1) && (uAppVer >= 4)) {
    x = event.screenX - (width/2) ;
    y = event.screenY - (height/3) ;
  }
  else {
    x = screen.availWidth / 2 - width / 2 ;
    y = screen.availHeight / 2 - height / 2 ;
  }

  if(x < 0) {
    x = 0 ;
  }
  if(y < 0) {
    y = 0 ;
  }
  if(x > screen.availWidth - width) {
    x = screen.availWidth - width ;
  }
  if(y > screen.availHeight - height) {
    y = screen.availHeight - height ;
  }
  winSubWindow = w_open(url, name, x, y, width, height,
    false, false, false, false, false, false, false) ;
  winURL = url ;
  return false ;
}

