﻿var param_startGameID = "JanRyuMon";
var param_gameID = "PlayNCLauncher";
var param_userNick = "";
var param_companyID = "0";
var param_user = "";

var param_sessKey = "";
var param_gpvlu = "";
var param_gpllv = "";

function launcherStart() {

   if (slogin == "1") {
    
        /*
        param_sessKey = Cookie.get("GPSESSIONID").toUpperCase();
        param_gpvlu = Cookie.get("GPVLU");
        param_gpllv = Cookie.get("GPLLV");
        */
        
        var gID = 8;
        var url = "/common/launcherparam.aspx" + "?GID=" + gID;
        new Ajax(url, {
            method: 'post',
            onComplete: checkLauncher
        }).request();

    }
    else { alert("ログインしてください。"); }
}


function checkLauncher(data) {

    var launcherStatus = "-1";
    var loginStatus = "0";
    var gamePermisson = "0";
    var alertMessage = "";

var result = getXmlObject(data);


    if (result.getElementsByTagName("launcherStatus")[0].childNodes.length > 0) {
        //launcher Setting

        launcherStatus = result.getElementsByTagName("launcherStatus")[0].firstChild.nodeValue;

        //alert Message Setting
        if (result.getElementsByTagName("alertMessage")[0].childNodes.length > 0) {
            alertMessage = result.getElementsByTagName("alertMessage")[0].firstChild.nodeValue;
        }
        if (launcherStatus == "0") {
            loginStatus = result.getElementsByTagName("loginStatus")[0].firstChild.nodeValue;
            gamePermisson = result.getElementsByTagName("gamePermisson")[0].firstChild.nodeValue;
            param_userNick = result.getElementsByTagName("nickName")[0].firstChild.nodeValue;

            param_sessKey = result.getElementsByTagName("gpsID")[0].firstChild.nodeValue;
            param_gpvlu = result.getElementsByTagName("gpvlu")[0].firstChild.nodeValue;
            param_gpllv = result.getElementsByTagName("gpllv")[0].firstChild.nodeValue;

            if (gamePermisson == "1") {
                StartLauncher();
            }
            else {
                //if (confirm("ゲーム追加が必要です。ゲーム追加をしますか？")) {
                //if (confirm("雀龍門のサービス追加が必要です。サービス追加を行ないますか？")) {
                //    location.href = alertMessage;
                //}
                alert("ゲームの起動を準備中です。少々お待ちください。");
		window.location.reload(true);
            }
        }
        else { alert(alertMessage); }
    }
    //else { alert("しばらく後にまた利用してください。"); }
    else { alert("ご利用のブラウザがIEではない、またはActiveXコントロールが正常にインストールされていません。"); }
}

var getXmlObject = function(text) {
    if (window.ActiveXObject) {
        var doc = new ActiveXObject("Microsoft.XMLDOM");
        doc.async = "false";
        doc.loadXML(text);
    } else {
        var parser = new DOMParser();
        var doc = parser.parseFromString(text, "text/xml");
    }
    return doc;
}
