/* *********************************************************
** JS_OpenWin.js - Open Window JS Library
** ======================================
** This library contains JS code to open a new window with
** specified properties: width, height, features, etc.
** It's yours for free, but please maintain this header!
**
** To load this library in an HTML doc, put the following
** line in the doc's HEAD (before any other SCRIPT tags):
**
** <script src="JS_OpenWin.js" language="JavaScript">
** </script>
********************************************************* */

/* *********************************************************
** USAGE
** =====
** openWin(url, jsName, htmlName, width, height [, ...])
**   url - absolute or relative URL of doc to load in window
**         this can be a blank string "" (will load no doc)
**   jsName - name of window to use in JS coding (can be "")
**     e.g., to refer to a form in the doc loaded into
**     the new window, you'd code: jsName.document.formName
**   htmlName - name of window to use in HTML coding (can be "")
**     e.g., to make a link target the new window, you'd 
**     code: <a href="?????" target="htmlName">link</a>
**   width - width (pixels) of window's doc display area
**   height - height (pixels) of window's doc display area
**   [, ...] - openWin() takes 5 *required* arguments. You
**     can also specify 1+ additional *optional* arguments:
**     DIRECTORIES, LOCATION, MENUBAR, RESIZABLE, SCROLLBARS,
**     STATUS, TOOLBAR, CENTER, UPPERLEFT, UPPERRIGHT (see below).
**
** These are all legal openWin() calls:
**   openWin("mydoc.html", "jswin", "", 500, 500);
**   openWin("", "", "", 500, 500, RESIZABLE);
**   openWin("http://www.yahoo.com", "jswin", "htmlwin",
**           1000, 1000, MENUBAR, STATUS, TOOLBAR, CENTER);
**
** And these are all illegal:
**   openWin("mydoc.html", 500, 500);  // 2 req args missing 
**   openWin("", "", "", 500);  // 1 req arg missing
**   openWin(www.yahoo.com, "jswin", "htmlwin",
**           1000, 1000, MENUBAR, STATUS, TOOLBAR, CENTER);
**           // URL must begin with http:// and be in ""s
********************************************************* */

// Window features constants
var DIRECTORIES = "directories";  // show directory buttons
var LOCATION    = "location";     // show location bar
var MENUBAR     = "menubar";      // show menu bar
var RESIZABLE   = "resizable";    // make window resizable
var SCROLLBARS  = "scrollbars";   // show scrollbars (if needed)
var STATUS      = "status";       // show status bar
var TOOLBAR     = "toolbar";      // show toolbar
var CENTER      = "center";       // center window
var UPPERLEFT   = "upperleft";    // display window in upper-left corner
var UPPERRIGHT  = "upperright";   // display window in upper-right corner

// Open a new window with specified properties
function openWin(url, jsName, htmlName, width, height) {
  var is4up = true;   // for CENTER, UPPERLEFT, UPPERRIGHT features
  var features = "";  // string to hold features argument

  // Set is4up to true/false
  if (parseInt(navigator.appVersion) < 4) {
    is4up = false;
  }

  // Build features string ...
  features += "width=" + width + ",";     // width
  features += "height=" + height + ",";   // height
  // For additional (optional) features ...
  for (var i=5; i<arguments.length; i++) {
    if (arguments[i] == CENTER && is4up) { // center window
      features += "screenx=" + (screen.width-width) / 2 + ",";
      features += "left=" + (screen.width-width) / 2 + ",";
      features += "screeny=" + (screen.height-height) / 2 + ",";
      features += "top=" + (screen.height-height) / 2 + ",";
    }
    else if (arguments[i] == UPPERLEFT && is4up) { // upper-left window
      features += "screenx=0,left=0,screeny=0,top=0";
    }
    else if (arguments[i] == UPPERRIGHT && is4up) { // upper-right window
      features += "screenx=" + (screen.width-width-(screen.width/100)) + ",";
      features += "left=" + (screen.width-width-(screen.width/100)) + ",";
      features += "screeny=0,top=0,";
    }
    else { // all additional features besides CENTER, UPPERLEFT, UPPERRIGHT
      features += arguments[i] + "=1,";
    }
  }
  jsName = window.open(url, htmlName, features);
}

// open a new window without any property
function openWin_Normal(url, jsName, htmlName) {
	jsName = window.open(url, htmlName, "");
}

// open AFE G2 login window...
function openWin_AFEG2Login(lang)
{
	var G2Win = window.open("http://210.176.213.44/i-trade/default.jsp?lang="+lang, "G2FrontOffice", "scrollbars=no, width=790, Height=542, location=no, directories=no, menubar=no, toolbar=no, status=no, top=0, left=0");
	G2Win.opener = top;
	G2Win.focus();
}


