// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context

appName = {};
appName.v = {};
appName.form = {
        id: 0,
        record: [],
        guid: '',
        one: function() {
            $.post(
                    'file.php', {
                                    'id': 0
                    },
                    function(data) {
                        appName.form.two(data);
                    }
            );
            // appName.form.one();
        }, //==============================================
        two: function(data) {
            $.ajax({
                    url: 'https://api.duckduckgo.com/?q=DuckDuckGo&format=json',
                    // data: { g: 'test', format: 'json' },
                    dataType: 'jsonp',
                    success: function(data) {
                        appName.form.two(data);
                    }
            });
            // appName.form.two();
        }, //==============================================
        three: function(data) {
            console.log(data);
            // appName.form.three();
        }, //==============================================
        tree: {
            id: 100,
            record: [],
            bracket: false,
            ns: false,
            four: function(data) {
                console.log(data);
                // appName.form.three();
            }, 
        },
};



appName.url = {
        records: [],
        getUrlVars: function() {
            var vars = {};
            var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value ) {
                vars[key] = value;
            });
            return vars;
        }, //==============================================
        getUrlParam: function( parameter, defaultvalue ) {
            var urlparameter = defaultvalue;
            if( window.location.href.indexOf( parameter ) > -1 ) {
                urlparameter = appName.url.getUrlVars()[parameter];
            }
            return urlparameter;
        }, //==============================================
        page: function() {
            var page = location.href.split('?');
            location.href = page[0] + '?card=' + appName.url.getUrlParam( 'card' );
        }, //==============================================
        nullFunction: function(data) {
            console.log(data);
            // appName.form.two();
        } //==============================================
};

test = {
            "a": 1,
            "to": true,
            "the": 1,
            "and": 1,
            "of": false,
            "am": /e/,
            "at": 1,
            "s": [11,22,(33)],
            "in": 1,
            "i": 1,
            "for": 5+5,
            "on": 1,
            "from": {"a": 3, "b": 9999},
            "an": 1
}

appName.form.tree['bracket'] = true;
appName.form.tree.ns = true;
appName.form.three();

if ( appName.form.tree['bracket'] ) {
    console.log( 'SUCCESS_A' )
}
if ( appName.form.tree.ns ) {
    console.log( 'SUCCESS_B' )
}
if ( test.to ) {
    console.log( 'SUCCESS_C' )
}
if ( test['of'] ) {
    console.log( 'SUCCESS_D' )
}




