/*
 * =================================================================
 * HTML Editor - A WYSIWYG web based editor for IE5.5+ and Mozilla v1.4+
 *
 *   Website  : http://gossamer-threads.com/
 *   Support  : http://gossamer-threads.com/scripts/support/
 *   Revision : $Id: editor_dialog.js,v 1.2 2009/04/08 20:13:20 brewt Exp $
 *
 * Copyright (c) 2005 Gossamer Threads Inc.  All Rights Reserved.
 * Redistribution in part or in whole strictly prohibited. Please
 * see LICENSE file for full details.
 * =================================================================
 */

function initForm() {
    for (var item in opener.dialogWindow.values) {
        if (opener.dialogWindow.values[item] == null)
            continue;
        var obj;
        if (obj = document.getElementById(item)) {
            if (obj.type == 'radio' || obj.type == 'checkbox')
                obj.checked = opener.dialogWindow.values[item];
            else {
                obj.value = opener.dialogWindow.values[item];
                if (isWebkit && item == 'font') {
                    obj.value = opener.dialogWindow.values[item].replace(/'/g, '');
                }
                if (isWebkit && item == 'size') {
                    var fontsize = {
                        '8px'  : 0, // not used
                        '10px' : 1,
                        '13px' : 2,
                        '16px' : 3,
                        '18px' : 4,
                        '24px' : 5,
                        '32px' : 6,
                        '48px' : 7
                    };
                    obj.value = fontsize[opener.dialogWindow.values[item]];
                }
            }
        }
    }
}

function submitForm() {
    for (var item in opener.dialogWindow.values) {
        var obj;
        if (obj = document.getElementById(item))
            opener.dialogWindow.values[item] = (obj.type == 'radio' || obj.type == 'checkbox') ? obj.checked : obj.value;
    }
    if (typeof(opener.dialogWindow.returnCall) == 'function')
        opener.dialogWindow.returnCall();
    else if (opener.dialogWindow.returnCall)
        eval(opener.dialogWindow.returnCall);
    window.close();
}
