//--親または子ウインドウの有無確認関数 
function win_closed(winVar) {
  var ua = navigator.userAgent
  if( !!winVar )
    if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 )
      && ua.indexOf('Win')!=-1 ) 
      return winVar.closed
    else return typeof winVar.document != 'object'
  else return true
}



//本閲覧用サブウィンドウオープン
/*ウィンドウを多数起動させない方式*/
var SubWin;
function WinOpenZ( url, winname, size_x, size_y, posi_x, posi_y, options){
  if(!win_closed(SubWin)) SubWin.close();
  if(SubWin && SubWin == winname) SubWin.close();
  var win_x = screen.availWidth;
  var win_y = screen.availHeight;
  if (posi_x == 'center'){
    posi_x = (win_x - size_x)/2;
  }else if(posi_x == 'right'){
    posi_x = win_x - size_x - 15;
  }else if(posi_x == 'left'){
    posi_x = 0;
  }

  if (posi_y == 'middle'){
    posi_y = (win_y - size_y)/2;
  }else if(posi_y == 'bottom'){
    posi_y = win_y - size_y - 30;
  }else if(posi_y == 'top'){
    posi_y = 0;
  }

  if(typeof(options) == 'undefined' || options == ''){
    options = '';	//基本的に全てのツールバーを表示
  }

  SubWin = window.open(url, winname ,"width=" + size_x + ",height=" + size_y + ",top=" + posi_y + ",left=" + posi_x + "," + options);
  //self.status = "";
  SubWin.focus();
  return SubWin;
}

