﻿function webDesign_contentControl_setContentSize(minWidth, minHeight, contentAreaDivID, contentDivID, editorDivID, editDivID, cuteEditorID) {
    // Resize the content area controls to make them consistant in size with the content (or the minimum size)
    var contentAreaDiv = document.getElementById(contentAreaDivID);
    var contentDiv = document.getElementById(contentDivID);
    var editorDiv = document.getElementById(editorDivID);
    var editDiv = document.getElementById(editDivID);
    var cuteEditor = document.getElementById(cuteEditorID);

    var contentWidth = minWidth;
    var contentHeight = minHeight;

    if (contentDiv) {
        contentWidth = Math.max(contentDiv.offsetWidth, minWidth);
        contentHeight = Math.max(contentDiv.offsetHeight, minHeight);
    }

    if ($('#' + contentAreaDivID).parent().width() > 0)
        contentWidth = $('#' + contentAreaDivID).parent().width();

    if (contentAreaDiv) {
        contentAreaDiv.style.width = contentWidth.toString() + 'px';
        contentAreaDiv.style.height = contentHeight.toString() + 'px';
    }
    if (contentDiv) {
        contentDiv.style.width = contentWidth.toString() + 'px';
        contentDiv.style.height = contentHeight.toString() + 'px';
    }
    if (editDiv) {
        editDiv.style.width = (contentWidth - 10).toString() + 'px';
        editDiv.style.height = (contentHeight - 10).toString() + 'px';
        editDiv.style.lineHeight = (contentHeight - 10).toString() + 'px';
    }
    /*if (editorDiv) {
        editorDiv.style.width = (contentWidth + 40).toString() + 'px';
        editorDiv.style.height = (contentHeight + 75).toString() + 'px';
    }*/
    if (cuteEditor) {
        cuteEditor.style.width = (contentWidth + 30).toString() + 'px';
        cuteEditor.style.height = (contentHeight + 100).toString() + 'px';
    }
}

function webDesign_contentControl_onEditStart(editor, contentAreaDivID) {
    // Starting editing...
    // Show modal background while editing to prevent the user clicking on anything else
    showDiv('modalBackground');
    var contentArea = $('#' + contentAreaDivID);
    contentArea.css('z-index', '101');
}

function webDesign_contentControl_onEditEnd() {
    // Ending editing (applied or cancelled)...
    hideDiv('modalBackground');
}
