/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



var CrappleAdmin = {
    defaultpage : 'startpage',
    
    loadDefault : function(resultDomElement) {
        //        postAjaxEvent = PostAjaxEvent();
        PostAjaxEvent.application = 'CrappleAdmin';
        PostAjaxEvent.resultDomElement = resultDomElement;
        PostAjaxEvent.execute = 'mainView';
        PostAjaxEvent.async = false;

        CrappleCommon.postAjax();
        CrappleAdmin.loadCrappleAddNew();
        CrappleAdmin.loadCrappleList();
    },

    loadCrappleAddNew : function() {
        PostAjaxEvent.application = 'CrappleHandler';
        PostAjaxEvent.resultDomElement = 'AddNewCrapple';
        PostAjaxEvent.execute = 'showAddNew';
        PostAjaxEvent.async = false;

        CrappleCommon.postAjax();
    }, 
    
    loadCrappleList : function() {
        PostAjaxEvent.application = 'CrappleHandler';
        PostAjaxEvent.resultDomElement = 'CrappleList';
        PostAjaxEvent.execute = 'showCrappleList';
        PostAjaxEvent.async = false;

        CrappleCommon.postAjax();
    },
    
    changeTest : function(testid) {
        var testid = jQuery("#testselector :selected").attr('testid');
        var events = 
            [
                {
                    "domElement":"mainApplicationArea",
                    "executionClass":"QuestAdminPage",
                    "executionCommand":"run",
                    "extraVariables": {
                        "testid" : testid
                    },
                    "fetchValuesFrom":[],
                    "type":"PostAjaxEvent",
                    "fetchRadioSet":[],
                    "crudElements":[],
                    "showProcessingIcon":true
                },
                {
                    '5s55a55a5as4d5fas1df5asd1fa65sd1f3654512346551savehistory' : true 
                }
            ];
            
        CrappleCommon.executeEvents(JSON.stringify(events), true, null);
        
    }
} 
