﻿var Push = Push ? Push : new Object();

Push.ControlPanel = Push.ControlPanel ? Push.ControlPanel : function() {
    var public =
    {
        ForceStandardFontFamily: function(editorObj) {
            if (editorObj.search('tinyMCE') == 0) {
                var handlerSet = false;
                try {
                    var editorInstance = eval(editorObj);
                    if (editorInstance) {
                        editorInstance.onChange.add(function(ed, l) {
                            var match = l.content.match(/\s*FONT-FAMILY:[^;"]*;?/gi);
                            if (ed.isDirty && match) {

                                // use regular expression to remove any font-family styles
                                var fixedContent = l.content.replace(/\s*FONT-FAMILY:[^;"]*;?/gi, "");

                                ed.setContent(fixedContent);

                                ed.selection.moveToBookmark(l.bookmark);
                            }
                        });
                        handlerSet = true;
                    }
                } catch (err) {

                }

                if (!handlerSet) {
                    // wait for page to load and try again
                    setTimeout("Push.ControlPanel.ForceStandardFontFamily(\"" + editorObj + "\");", 200);
                }
            }
        }
    };

    return public;
} ();                    
