var newEOPEN
var newACE
var newNYMEX
var newSUN
var newSUNNYMEX
var newCTS
var win = null;

function openSUN(url, wname, para)
{


    if(!win||!win.open||win.closed) {
        win=window.open('','ptsClient',
            'menubar=0,toolbar=0,location=0,directories=0,status=0,resizable=1,'+
            'scrollbars=0,width=620,height=105,screenX=0,screenY=0,left=0,top=0');

        win.document.writeln('<HTML><HEAD></HEAD>');
        win.document.writeln('<BODY marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" onLoad="startTimer()">');
        win.document.writeln('<DIV ID="app"');
        win.document.writeln('STYLE="position:absolute; top:0; left:0; width:620; height:105; z-index:1;">');
        win.document.writeln('<OBJECT ID="jtrader"');
        win.document.writeln('classid = "clsid:CAFEEFAC-0014-0002-0003-ABCDEFFEDCBA"');
        win.document.writeln('WIDTH = 0 HEIGHT = 0 NAME = "JavaClient" ALIGN = top VSPACE = 0 HSPACE = 0 >');
        win.document.writeln('<PARAM NAME = "archive"                    VALUE = "/jtrader_sun/Pats.jar">');
        win.document.writeln('<PARAM NAME = "cache_archive"              VALUE = "/jtrader_sun/Pats.jar">');
        win.document.writeln('<PARAM NAME = CODE                         VALUE = "patsystems.ui.PATSClient" >');
        win.document.writeln('<PARAM NAME = CODEBASE                     VALUE = "/jtrader_sun/" >');
        win.document.writeln('<PARAM NAME = NAME                         VALUE = "JavaClient" >');
        win.document.writeln('<PARAM NAME = "type"                       VALUE = "application/x-java-applet;jpi-version=1.4.2_03">');
        win.document.writeln('<PARAM NAME = "scriptable"                 VALUE = "true">');
        win.document.writeln('<PARAM NAME = "DEMO"                       VALUE = "false">');
        win.document.writeln('<PARAM NAME = "TEST"                       VALUE = "false">');
        win.document.writeln('<PARAM NAME = "HOST_ADDRESS"               VALUE = "65.174.225.110">');
        win.document.writeln('<PARAM NAME = "HOST_PORT"                  VALUE = "9990">');
        win.document.writeln('<PARAM NAME = "HOST_LOCK"                  VALUE = "true">');
        win.document.writeln('<PARAM NAME = "PRICE_FEED_ADDRESS"         VALUE = "65.174.225.124">');
        win.document.writeln('<PARAM NAME = "PRICE_FEED_PORT"            VALUE = "2000">');
        win.document.writeln('<PARAM NAME = "PRICE_FEED_LOCK"            VALUE = "true">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE1"         VALUE = "MGEX=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE2"         VALUE = "WCE=America/Winnipeg">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE3"         VALUE = "CME FX=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE4"         VALUE = "EUREX US=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE5"         VALUE = "ONE CHICAGO=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE6"         VALUE = "ECBOT=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE7"         VALUE = "CME GLOBEX2=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE8"         VALUE = "KCBT=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE9"         VALUE = "CBOT ORDER DIRECT=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE10"         VALUE = "CME FLOOR=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE11"         VALUE = "CBOT FLOOR=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE12"         VALUE = "COMEX=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE13"         VALUE = "ITOPS=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE14"         VALUE = "MONTRAL=America/Montreal">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE15"         VALUE = "NYMEX=America/New_York">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE16"         VALUE = "NYBOT=America/New_York">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE17"         VALUE = "LIFFE=Europe/London">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE18"         VALUE = "IPE=Europe/London">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE19"         VALUE = "IFX=Europe/London">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE20"         VALUE = "EURONEXT LISBON=Europe/Lisbon">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE21"         VALUE = "EUREX=Europe/Berlin">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE22"         VALUE = "EURONEXT PARIS=Europe/Paris">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE23"         VALUE = "EURONEXT BRUSSELS=Europe/Brussels">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE24"         VALUE = "MEFF=Europe/Madrid">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE25"         VALUE = "IDEM=Europe/Rome">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE26"         VALUE = "NCEL=Asia/Karachi">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE27"         VALUE = "AFET=Asia/Bangkok">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE28"         VALUE = "HKFE=Asia/Hong_Kong">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE29"         VALUE = "SGX-DT=Asia/Singapore">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE30"         VALUE = "TGE=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE31"         VALUE = "KANMON=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE32"         VALUE = "KANSAI=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE33"         VALUE = "CHUBU=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE34"         VALUE = "TIFFE=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE35"         VALUE = "TOCOM=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE36"         VALUE = "TSE=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE37"         VALUE = "OSE=Asia/Tokyo">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE38"         VALUE = "KOFEX=Asia/Seoul">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE39"         VALUE = "SFE=Australia/Sydney">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE40"         VALUE = "NZFOE=Pacific/Auckland">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE41"         VALUE = "STAS=Europe/London">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE42"         VALUE = "CME=America/Chicago">');
	    win.document.writeln('<PARAM NAME = "TIME_ZONE43"         VALUE = "CME_E$=America/Chicago">');
        win.document.writeln('<PARAM NAME = "ENCRYPTION_CODE"            VALUE = "A">');
        win.document.writeln('<PARAM NAME = "BACKGROUND_IMAGE"           VALUE = "bluebk.jpg">');
        win.document.writeln('<PARAM NAME = "LOGO_IMAGE"                 VALUE = "logo.gif">');
        win.document.writeln('<PARAM NAME = "ICON_IMAGE"                 VALUE = "pts16-16c.gif">');
        win.document.writeln('<PARAM NAME = "TEXT_COLOUR"                VALUE = "#000000">');
        win.document.writeln('<PARAM NAME = "COMPANY_NAME"               VALUE = "TENCO">');
        win.document.writeln('<PARAM NAME = "PRODUCT_NAME"               VALUE = "TENCO Direct">');
        win.document.writeln('<PARAM NAME = "INSTALL_PATH"               VALUE = "TENCO Direct Client">');
        win.document.writeln('<PARAM NAME = "ENABLE_RESET"               VALUE = "false">');
        win.document.writeln('<PARAM NAME = "USER"                       VALUE = "">');
        win.document.writeln('<PARAM NAME = "PWD"                        VALUE = "">');
        win.document.writeln('<PARAM NAME = "NULL_USER"                  VALUE = "false">');
        win.document.writeln('<PARAM NAME = "LOGIN"                      VALUE = "false">');
        win.document.writeln('<PARAM NAME = "SUPERTAS"                   VALUE = "true">');
        win.document.writeln('<PARAM NAME = "SSL"                        VALUE = "false">');
        win.document.writeln('<PARAM NAME = "HOST_HANDSHAKE_INTERVAL"    VALUE = "5">');
        win.document.writeln('<PARAM NAME = "HOST_HANDSHAKE_TIMEOUT"     VALUE = "15">');
        win.document.writeln('<PARAM NAME = "PRICE_HANDSHAKE_INTERVAL"   VALUE = "5">');
        win.document.writeln('<PARAM NAME = "PRICE_HANDSHAKE_TIMEOUT"    VALUE = "15">');
        win.document.writeln('<PARAM NAME = "DISABLE_PATS_LINK"          VALUE = "false">');
        win.document.writeln('<PARAM NAME = "BID_OFFER_REVERSED"         VALUE = "false">');
        win.document.writeln('</OBJECT>');
        win.document.writeln('</<DIV>');
        win.document.writeln(' ');
        win.document.writeln('<DIV ID="wait"');
        win.document.writeln('STYLE="position:absolute; background-color:003599 ; top:0; left:0; width:620; height:100; z-index:1">');
        win.document.writeln('<p align="center"><font color="#FFFFFF" face="Arial"><b>Please wait.</p>');
        win.document.writeln('<p align="center">Sun JVM being initialised / downloaded...</b></font></p>');
        win.document.writeln('</DIV>');
        win.document.writeln(' ');
        win.document.writeln('<'+'script  language=JavaScript>');
        win.document.writeln('  var intervalID = "";');
        win.document.writeln(' ');
        win.document.writeln('  function startTimer() {');
        win.document.writeln('    window.moveTo(0,0);');
        win.document.writeln('    intervalID = window.setInterval("waitForTitle()",1000);');
        win.document.writeln('  }');
        win.document.writeln(' ');
        win.document.writeln('  function waitForTitle() {');
        win.document.writeln('    try {');
        win.document.writeln('      title = document.JavaClient.getWindowTitle();');
        win.document.writeln('      if (title && title != "") {');
        win.document.writeln('        jtrader.style.width=1000;');
        win.document.writeln('        jtrader.style.height=105;');
        win.document.writeln('        w = document.JavaClient.getPadding();');
        win.document.writeln('        h = document.JavaClient.getHeightAdd();');
        win.document.writeln('        resizeTo(630+w,133+h);');
        win.document.writeln('        document.JavaClient.setWidth(620+w);');
        win.document.writeln('        document.JavaClient.setHeight(105);');
        win.document.writeln('        document.title = title;');
        win.document.writeln('        wait.style.visibility="hidden";');
        win.document.writeln('        window.clearInterval(intervalID);');
        win.document.writeln('      }');
        win.document.writeln('    } catch (e) { }');
        win.document.writeln('  }');
        win.document.writeln('<'+'/script>');
        win.document.writeln(' ');
        win.document.writeln('</BODY></HTML>');
        win.startTimer();
    }
    else
        win.focus();

}
function openSUNNYMEX(url, wname, para)
{
	if (!newSUNNYMEX || newSUNNYMEX.closed) {
		newSUNNYMEX = openwindow(url, wname, para)
	} else {
		newSUNNYMEX.focus();
	}
}
function openEOPEN(url, wname, para)
{
	if (!newEOPEN || newEOPEN.closed) {
		newEOPEN = openwindow(url, wname, para)
	} else {
		newEOPEN.focus();
	}
}
function openACE(url, wname, para)
{
	if (!newACE || newACE.closed) {
		newACE = openwindow(url, wname, para)
	} else {
		newACE.focus();
	}
}
function openNYMEX(url, wname, para)
{
	if (!newNYMEX || newNYMEX.closed) {
		newNYMEX = openwindow(url, wname, para)
	} else {
		newNYMEX.focus();
	}
}
function openCTS(url, wname, para)
{
	if (!newCTS || newCTS.closed) {
		newCTS = openwindow(url, wname, para)
	} else {
		newCTS.focus();
	}
}
function openwindow(url, wname, para)
{
	var newWindow = window.open(url, wname, para);
	return newWindow
}

