﻿/*
 * Implementation of Game Facade
 */

function ReadyForInitData() {
//    alert('ReadyForInitData');
    InstantGames.Manager.executeCommand('ReadyForInitData', null);
}

function GameReady() {
//    alert('GameReady');
    InstantGames.Manager.executeCommand('GameReady', null);
}

function ExitToLobby() {
    InstantGames.Manager.executeCommand('ExitToLobby', null);
}


function NavigationButtonsState(state) {
    //InstantGames.Manager.executeCommand('NavigationButtonsState', state);
}


function CreditManagerUpdate(xml) {
    //alert('CreditManagerUpdate: ' + xml);
    var creditDoc = null;

    if (window.ActiveXObject) {
        creditDoc = new ActiveXObject("Microsoft.XMLDOM");
        creditDoc.async = "false";
        creditDoc.loadXML(xml);
    }
    else {
        parser = new DOMParser();
        creditDoc = parser.parseFromString(xml, "text/xml");
    }

    var info = {
        operation: parseInt(creditDoc.getElementsByTagName('Operation')[0].firstChild.nodeValue),
        credit: parseInt(creditDoc.getElementsByTagName('Credit')[0].firstChild.nodeValue),
        bet: parseInt(creditDoc.getElementsByTagName('Bet')[0].firstChild.nodeValue)
    };
    InstantGames.Manager.executeCommand('CreditManagerUpdate', info);
//    alert('CreditManagerUpdate: operation=' + info.operation+', credit='+info.credit+', bet='+info.bet);
}
