// JScript source code

function launchDemoStage3Player(session_id, promotion_id, startTime, reseller_id) {
    var initialW = 250;
    var initialH = 200;
    var x = (screen.width / 2) - initialW / 2;
    var y = (screen.height / 2) - initialH / 2;

    var params = "toolbar=no,resizable=no,width=" + initialW +
",height=" + initialH + ",top=" + y + ",left=" + x + " ";


    var timer = new Date();
    var CurHour = timer.getHours();
    var CurMinute = timer.getMinutes();
    var CurSecond = timer.getSeconds();
    var title = 'DS3' + '_' + CurHour + CurMinute + CurSecond;

    var openerURL = "";
    var encrOpenerURL = "";

    if (document.getElementById("frame_type_alk") != null) {
        openerURL = document.getElementById("frame_type_alk").value;
        encrOpenerURL = openerURL + Encrypt('||' + timer);
    }

    if (openerURL == "") {
        openerURL = window.location.href;
        encrOpenerURL = Encrypt(openerURL + '||' + timer);
    }


    url = "http://www.demosondemand.com/DemoStage3/index.asp?sessID=" + session_id + '&promotion_id=' + promotion_id + '&startTime=' + startTime + '&eo=' + encrOpenerURL + '&reseller_id=' + reseller_id;


    var win = window.open(url, title, params);
    win.focus();

}

function Encrypt(text) {
    output = "";

    for (i = 0; i < text.length; i++) {
        ch = text.charCodeAt(i).toString();


        if (ch.length == 1) { ch = "00" + ch; }
        else if (ch.length == 2) { ch = "0" + ch; }
        else if (ch.length == 3) { ch = "" + ch; }
        else { ch = "" + ch.toString().substring(0, 2); }

        output += "" + ch;
    }

    return output;
}

