
dojo.require("dojo.parser");	// scan page for widgets and instantiate them

var dojo_widgets = new Array();		
function registerWidget(id) {
        var widget = dojo.byId(id);
        dojo_widgets[dojo_widgets.length] = widget;
}

var dojo_code = new Array();		
function registerCode(code) {
        dojo_code[dojo_code.length] = code;
}

var dojo_buttons = new Array();
function registerButton(form_id,button) {
        alert(form_id + ' ' + button);
        if (dojo_buttons[form_id] == null) {
                dojo_buttons[form_id] = new Array();
        }
        dojo_buttons[form_id][dojo_buttons.length] = button;
}

window.fck_editors = new Array();
function FCKeditor_OnComplete( editorInstance ){
        var name = editorInstance.Name;
        window.fck_editors[name] = editorInstance;
}

function parseWidgets() {
        dojo.parser.instantiate(dojo_widgets);
}

/*			function postForm(button,target_form,target_pane) {
        target_pane = dijit.byId(target_pane);  //this isn't accessible in the scope of the form, but is here
//				alert(button + ' ' + target_form + ' ' + target_pane);
//				dojo.connect(button, "onClick", function(event){
                //Stop the submit event since we want to control form submission.
//					event.preventDefault();
//					event.stopPropagation();
//					alert('here');

                var args = {
                        form: target_form,
                        handleAs: "text",
                        load: function(data){
                          dojo.byId(target_pane).setContent = data;
                        },
                        error: function(error){
                          dojo.byId(target_pane).setContent = error;
                        }
                }
                var response = dojo.xhrPost(args);
//				});
}

function setupButton(button,target_form,target_pane) {
        target_pane = dijit.byId(target_pane);  //this isn't accessible in the scope of the form, but is here
//				alert(button + ' ' + target_form + ' ' + target_pane);
        dojo.connect(button, "onClick", function(event){
                //Stop the submit event since we want to control form submission.
                event.preventDefault();
                event.stopPropagation();
                alert('here');

                var args = {
                        form: target_form,
                        handleAs: "text",
                        load: function(data){
                          dojo.byId(target_pane).setContent = data;
                        },
                        error: function(error){
                          dojo.byId(target_pane).setContent = error;
                        }
                }
                var response = dojo.xhrPost(args);
        });
}

*/			
dojo.addOnLoad(parseWidgets);
//			alert(dojo_code.length);
for (var i = 0; i < dojo_code.length; i++) {
        //dojo.addOnLoad(dojo_code[i]);				
}

