﻿






// Gets the session state value.
function GetAjaxString(action, key) {
    PageMethods.GetAjaxString(action, key,
        OnSucceeded, OnFailed);
}

//Sets the session state value.
function SetAjaxString(action, key, value) {
    PageMethods.SetAjaxString(action, key, value,
        OnSucceeded, OnFailed);
}
function GetStates() {
    return jsonStates;
}


function PpAc(idx) {
    if (ppAc && ppAc.length > idx) {
        return ppAc[idx];
    } 
}
// Callback function invoked on successful 
// completion of the page method.
function OnSucceeded(result, userContext, methodName) {

    var stateElem = $get("statesDiv");
    var testJson = eval("(" + result + ")");
    var jsonKey;
    var testTxt = '';
    var action = testJson["action"];
    // remove action node once we have it
    delete testJson["action"];
    switch (action) {
        case "st8":
            jsonStates = eval("(" + result + ")");
            for (key in testJson) {
                if (!(jsonKey in Object.prototype) || testJson[key] != Object.prototype[jsonKey]) {
                    /* do something with JSONObject[key] */
                    testTxt = testTxt + key;
                }
            }
            displayElement.innerHTML = "<textarea cols=50 rows=20>Current session state value: " +
            testTxt + "</textarea>";
            break;
        case "st81":
            jsonStates = eval("(" + result + ")");
            FinishPrepop();
            break;
        case "ac":
            CreateStateAc(eval("(" + result + ")"));
        default:
            
    }


}

// Callback function invoked on failure 
// of the page method.
function OnFailed(error, userContext, methodName) {
    if (error !== null) {
        displayElement.innerHTML = "An error occurred: " +
            error.get_message();
    }
}

if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

