﻿var currentId=0;

//
// SET THE LIVE AND DEMO WEB TRADER LOGIN URLS HERE
// THIS URL IS ENVIRONMENT SPECIFIC
//
var demoWebTraderLoginUrl;
var liveWebTraderLoginUrl;
var demoPlatformId;
var livePlatformId;

if (window.location.hostname == "www.fxprice.com")	// PRODUCTION
{
	demoWebTraderLoginUrl = "https://demo.webtradingonline.com/web/webtrading.aspx";
	liveWebTraderLoginUrl = "https://live.webtradingonline.com/web/webtrading.aspx";
	demoPlatformId = "3";
	livePlatformId = "4";
} 
else  // EVERYTHING ELSE POINTS TO PREPRODUCTION
{
	demoWebTraderLoginUrl = "https://demo.webtradingonline.com/web/webtrading.aspx";
	liveWebTraderLoginUrl = "https://live.webtradingonline.com/web/webtrading.aspx";
//	demoWebTraderLoginUrl = "http://predemo.webtradingonline.com/webtrading/webtrading.aspx";
//	liveWebTraderLoginUrl = "http://prelive.webtradingonline.com/webtrading/webtrading.aspx";

	demoPlatformId = "3";
	livePlatformId = "4";
}

function loadInstruction(code)
{   
    /*     ***REQUIRED DATA*** */
    
    // SET THE PARTNER HASH CODE HERE
    document.getElementById("partnerId").value = '1';   
    
    // SET START PAGE HERE (LOGON REJECTIONS GO TO HERE)
    document.getElementById("startPage").value = window.location.protocol + '//' + window.location.hostname + window.location.pathname;
    
    // SET END PAGE HERE (SIGNOFF LANDING PAGE)
    document.getElementById("endPage").value = 'http://www.fxprice.com' //document.getElementById("startPage").value;
    
    // REQUIRED, DON'T TOUCH PLEASE
    document.getElementById("timeStamp").value = Date();
    
    // REDIRECTION HANDLER
    switch(code)
    {
        case "1": // DEMONSTRATION "NOT PRESENTLY IN SERVICE"
        { 
           document.getElementById("applicationUse").value = 'demonstration'
            window.document.getElementById("frmSelection").submit();
            break;
        }
        case "2": // PRACTICE ACCOUNT REGISTRATION PAGE
        {
            url = 'http://www.fxsol.com.au/accounts/practice-account.asp';
            break;
        }
        case "3": // *** LOGON TO WEB TRADER DEMO HERE ***
        {
            // SET THE TARGET PATH TO THE DEMO WEB TRADER SOURCE
            document.getElementById("frmSelection").action = demoWebTraderLoginUrl;
            
            // SET THE INTERNAL PLATFORM
            document.getElementById("platform").value = demoPlatformId;
			
			document.getElementById("partnerId").value = '3044775B38383C92';
            
            // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
			
			//document.getElementById("partnerId").value = '3044775B38383C92';   
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
        case "4": // *** LOGON TO WEB TRADER LIVE HERE ***
        {
            // SET THE TARGET PATH TO THE LIVE WEB TRADER SOURCE
            document.getElementById("frmSelection").action = liveWebTraderLoginUrl;
            
           document.getElementById("partnerId").value = '1';
            
             // SET THE INTERNAL PLATFORM
            document.getElementById("platform").value = livePlatformId;
            
            // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
        case "5": // *** LOGON TO WEB TRADER DEMO HERE ***
        {
            // SET THE TARGET PATH TO THE DEMO WEB TRADER SOURCE
            document.getElementById("frmSelection").action = 'https://demo.webtradingonline.com/web/webtrading.aspx';
            
            // SET THE INTERNAL PLATFORM
            document.getElementById("platform").value = demoPlatformId;
            
			// SET THE PARTNERID PLATFORM
			document.getElementById("partnerId").value = '3044775B38383C92';
            
            // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
        case "6": // *** LOGON TO WEB TRADER LIVE HERE ***
        {
            // SET THE TARGET PATH TO THE LIVE WEB TRADER SOURCE
            document.getElementById("frmSelection").action = 'https://live.webtradingonline.com/web/webtrading.aspx';
            
            // SET THE INTERNAL PLATFORM
            document.getElementById("platform").value = livePlatformId;
			            
			// SET THE PARTNERID PLATFORM
			document.getElementById("partnerId").value = '401C874AFFF2D9C2';
            
            // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
        case "7": // *** LOGON TO WEB TRADER DEMO HERE ***
        {
            // SET THE TARGET PATH TO THE DEMO WEB TRADER SOURCE
            document.getElementById("frmSelection").action = 'https://demo.webtradingonline.com/web/webtrading.aspx';
            
            // SET THE INTERNAL PLATFORM
            document.getElementById("platform").value = demoPlatformId;
			            
			// SET THE PARTNERID PLATFORM
			document.getElementById("partnerId").value = '3044775B38383C92';
            
            // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
        case "8": // *** LOGON TO WEB TRADER LIVE HERE ***
        {
            // SET THE TARGET PATH TO THE LIVE WEB TRADER SOURCE
            document.getElementById("frmSelection").action = 'https://live.webtradingonline.com/web/webtrading.aspx';
            
            // SET THE INTERNAL PLATFORM
            document.getElementById("platform").value = livePlatformId;
			            
			// SET THE PARTNERID PLATFORM
			document.getElementById("partnerId").value = '3044775B38383C92';
            
            // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
 default:
        {    
             // REQUIRED FIELD SET THE ACTION HERE
            document.getElementById("applicationUse").value = 'logon'
            
            // SET THE TARGET NAME FOR WINDOW OPENER
            document.getElementById("frmSelection").target = 'main' + currentId++;
            
            // REQUIRED POPUP THE WINDOW (SECURITY REQUIREMENT)
            window.open( '', document.getElementById("frmSelection").target, 'width=900, height=700, resizable=yes, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
            
            // POST THE LOGIN DATA
            window.document.getElementById("frmSelection").submit();
            break;
        }
    }
}

