﻿
/* Global Variables */
var txtInput = null;
var txtGUID = null;
var store = null;

/* Initialize the store and fire an event when loaded */
function init(input, guidInput) {

    txtInput = input;
    txtGUID = guidInput;

    // Create the engine object with the location of the swf file and the replacement div
    engineObj = new Object();
    engineObj.swfURL = 'swfstore.swf';
    engineObj.containerID = 'replace_div';

    store = YAHOO.util.StorageManager.get(
                YAHOO.util.StorageEngineSWF.ENGINE_NAME,
                YAHOO.util.StorageManager.LOCATION_LOCAL,
                {
                    order: [
                        YAHOO.util.StorageEngineSWF,
                        YAHOO.util.StorageEngineGears,
                        YAHOO.util.StorageEngineHTML5
                        ],
                    force: false,
                    engine: engineObj
                }
            );

    store.subscribe(store.CE_READY, function (e) {
        load();
    });
}


/* Once the store is ready, load the saved data */
function onContentReady(event) {
    load();
}

/* Save a value to the store */
function save() {
    var txt = document.getElementById(txtInput);
    if (txt != null)
        store.setItem('umid', txt.value);
}

/* Load the value from the store */
function load() {

    // Get references to the textboxes
    var txt = document.getElementById(txtInput);
    var txt2 = document.getElementById(txtGUID);

    var found = false;

    if (store.hasKey("umid")) {
        found = true;
        txt.value = store.getItem("umid");
    }

    // Did not locate it, so set the textbox to the value of the GUID textbox (will be a new member entry) and save to the store
    if (!found) {
        txt.value = txt2.value;
        save();
    }


}

function redirect() {
    window.location.href = 'SurveyInvitation.aspx?redirect=true';
}
