﻿var editor;


function postForm(controller, overlayId) {
    ShowWaitCover();

    if (editor) {
        $("#editorContent").text(editor.getData());
           
        removeEditor()
    }

    
    $.post('Admin/' + controller + '/', $('#form_' + overlayId).serialize(), function(data) {
        //Inserts the return data in the DOM
    $('#' + overlayId).html(data);
        //Parse the return data and create the tabs
        ParseOverlayContent();
        HideWaitCover();
    }, 'html');
}


function getPageData(controller, id, overlayId) {

    removeEditor()

    $.get('Admin/' + controller + '/' + id, function(data) {

    $('#' + overlayId).html(data);
    ParseOverlayContent();
    HideWaitCover();
    });
}




function createEditor(editorName) {
    removeEditor();

    editor = CKEDITOR.replace(editorName);

}

function removeEditor() {
    if (editor) {
        editor.destroy();
        editor = null;
    }
}
