﻿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;


	demoWebTraderLoginUrl = "https://demo.webtradingonline.com/web/webtrading.aspx";
	liveWebTraderLoginUrl = "https://live.webtradingonline.com/web/webtrading.aspx";
	demoPlatformId = "3";
	livePlatformId = "4";


function loadInstruction(code)
{   
    /*     ***REQUIRED DATA*** */
    
    // SET THE PARTNER HASH CODE HERE
    document.getElementById("partnerId").value = '3044775B38383C92';   
    
    // 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://es.fxsol.co.uk' //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://es.fxsol.co.uk/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;
            
            // 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 "4": // *** LOGON TO WEB TRADER LIVE HERE ***
        {
            // SET THE TARGET PATH TO THE LIVE WEB TRADER SOURCE
            document.getElementById("frmSelection").action = liveWebTraderLoginUrl;
            
            // 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;
        }
 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;
        }
    }
}
