Upgrade TinyMCE to v3.4.5
[citadel.git] / webcit / tiny_mce / plugins / inlinepopups / editor_plugin_src.js
index 43d0041b7c8645645b2296d94fd7d571e234b432..67123ca3142ec46384858fda1a641ed6d2401700 100644 (file)
-/**
- * $RCSfile$
- * $Revision$
- * $Date$
- *
- * Moxiecode DHTML Windows script.
- *
- * @author Moxiecode
- * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
- */
-
-// Patch openWindow, closeWindow TinyMCE functions
-
-function TinyMCE_inlinepopups_getInfo() {
-       return {
-               longname : 'Inline Popups',
-               author : 'Moxiecode Systems',
-               authorurl : 'http://tinymce.moxiecode.com',
-               infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
-               version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
-       };
-};
-
-TinyMCE.prototype.orgOpenWindow = TinyMCE.prototype.openWindow;
-
-TinyMCE.prototype.openWindow = function(template, args) {
-       // Does the caller support inline
-       if (args['inline'] != "yes") {
-               mcWindows.selectedWindow = null;
-               args['mce_inside_iframe'] = false;
-               this.orgOpenWindow(template, args);
-               return;
-       }
-
-       var url, resizable, scrollbars;
-
-       args['mce_inside_iframe'] = true;
-       tinyMCE.windowArgs = args;
-
-       if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
-               url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
-       else
-               url = template['file'];
-
-       if (!(width = parseInt(template['width'])))
-               width = 320;
-
-       if (!(height = parseInt(template['height'])))
-               height = 200;
-
-       resizable = (args && args['resizable']) ? args['resizable'] : "no";
-       scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
-
-       height += 18;
-
-       // Replace all args as variables in URL
-       for (var name in args) {
-               if (typeof(args[name]) == 'function')
-                       continue;
-
-               url = tinyMCE.replaceVar(url, name, escape(args[name]));
-       }
-
-       var elm = document.getElementById(this.selectedInstance.editorId + '_parent');
-       var pos = tinyMCE.getAbsPosition(elm);
-
-       // Center div in editor area
-       pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));
-       pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));
-
-       mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);
-};
-
-TinyMCE.prototype.orgCloseWindow = TinyMCE.prototype.closeWindow;
-
-TinyMCE.prototype.closeWindow = function(win) {
-       if (mcWindows.selectedWindow != null)
-               mcWindows.selectedWindow.close();
-       else
-               this.orgCloseWindow(win);
-};
-
-TinyMCE.prototype.setWindowTitle = function(win_ref, title) {
-       for (var n in mcWindows.windows) {
-               var win = mcWindows.windows[n];
-               if (typeof(win) == 'function')
-                       continue;
-
-               if (win_ref.name == win.id + "_iframe")
-                       window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title;
-       }
-};
-
-// * * * * * MCWindows classes below
-
-// Windows handler
-function MCWindows() {
-       this.settings = new Array();
-       this.windows = new Array();
-       this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
-       this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
-       this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
-       this.isMac = navigator.userAgent.indexOf('Mac') != -1;
-       this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
-       this.action = "none";
-       this.selectedWindow = null;
-       this.lastSelectedWindow = null;
-       this.zindex = 100;
-       this.mouseDownScreenX = 0;
-       this.mouseDownScreenY = 0;
-       this.mouseDownLayerX = 0;
-       this.mouseDownLayerY = 0;
-       this.mouseDownWidth = 0;
-       this.mouseDownHeight = 0;
-       this.idCounter = 0;
-};
-
-MCWindows.prototype.init = function(settings) {
-       this.settings = settings;
-
-       if (this.isMSIE)
-               this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
-       else
-               this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
-
-       this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
-
-       this.doc = document;
-};
-
-MCWindows.prototype.getParam = function(name, default_value) {
-       var value = null;
-
-       value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
-
-       // Fix bool values
-       if (value == "true" || value == "false")
-               return (value == "true");
-
-       return value;
-};
-
-MCWindows.prototype.eventDispatcher = function(e) {
-       e = typeof(e) == "undefined" ? window.event : e;
-
-       if (mcWindows.selectedWindow == null)
-               return;
-
-       // Switch focus
-       if (mcWindows.isGecko && e.type == "mousedown") {
-               var elm = e.currentTarget;
-
-               for (var n in mcWindows.windows) {
-                       var win = mcWindows.windows[n];
-
-                       if (win.headElement == elm || win.resizeElement == elm) {
-                               win.focus();
-                               break;
-                       }
-               }
-       }
-
-       switch (e.type) {
-               case "mousemove":
-                       mcWindows.selectedWindow.onMouseMove(e);
-                       break;
-
-               case "mouseup":
-                       mcWindows.selectedWindow.onMouseUp(e);
-                       break;
-
-               case "mousedown":
-                       mcWindows.selectedWindow.onMouseDown(e);
-                       break;
-
-               case "focus":
-                       mcWindows.selectedWindow.onFocus(e);
-                       break;
-       }
-};
-
-MCWindows.prototype.addEvent = function(obj, name, handler) {
-       if (this.isMSIE)
-               obj.attachEvent("on" + name, handler);
-       else
-               obj.addEventListener(name, handler, true);
-};
-
-MCWindows.prototype.cancelEvent = function(e) {
-       if (this.isMSIE) {
-               e.returnValue = false;
-               e.cancelBubble = true;
-       } else
-               e.preventDefault();
-};
-
-MCWindows.prototype.parseFeatures = function(opts) {
-       // Cleanup the options
-       opts = opts.toLowerCase();
-       opts = opts.replace(/;/g, ",");
-       opts = opts.replace(/[^0-9a-z=,]/g, "");
-
-       var optionChunks = opts.split(',');
-       var options = new Array();
-
-       options['left'] = "10";
-       options['top'] = "10";
-       options['width'] = "300";
-       options['height'] = "300";
-       options['resizable'] = "yes";
-       options['minimizable'] = "yes";
-       options['maximizable'] = "yes";
-       options['close'] = "yes";
-       options['movable'] = "yes";
-       options['statusbar'] = "yes";
-       options['scrollbars'] = "auto";
-       options['modal'] = "no";
-
-       if (opts == "")
-               return options;
-
-       for (var i=0; i<optionChunks.length; i++) {
-               var parts = optionChunks[i].split('=');
-
-               if (parts.length == 2)
-                       options[parts[0]] = parts[1];
-       }
-
-       options['left'] = parseInt(options['left']);
-       options['top'] = parseInt(options['top']);
-       options['width'] = parseInt(options['width']);
-       options['height'] = parseInt(options['height']);
-
-       return options;
-};
-
-MCWindows.prototype.open = function(url, name, features) {
-       this.lastSelectedWindow = this.selectedWindow;
-
-       var win = new MCWindow();
-       var winDiv, html = "", id;
-       var imgPath = this.getParam("images_path");
-
-       features = this.parseFeatures(features);
-
-       // Create div
-       id = "mcWindow_" + name;
-       win.deltaHeight = 18;
-
-       if (features['statusbar'] == "yes") {
-               win.deltaHeight += 13;
-
-               if (this.isMSIE)
-                       win.deltaHeight += 1;
-       }
-
-       width = parseInt(features['width']);
-       height = parseInt(features['height'])-win.deltaHeight;
-
-       if (this.isMSIE)
-               width -= 2;
-
-       // Setup first part of window
-       win.id = id;
-       win.url = url;
-       win.name = name;
-       win.features = features;
-       this.windows[name] = win;
-
-       iframeWidth = width;
-       iframeHeight = height;
-
-       // Create inner content
-       html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
-       html += '<html>';
-       html += '<head>';
-       html += '<title>Wrapper iframe</title>';
-       html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
-       html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
-       html += '</head>';
-       html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
-
-       html += '<div id="' + id + '_container" class="mceWindow">';
-       html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
-       html += '  <div id="' + id + '_title" class="mceWindowTitle"';
-       html += '  onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
-       html += '    <div class="mceWindowHeadTools">';
-       html += '      <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';
-//     html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';
-//     html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
-       html += '    </div>';
-       html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
-       html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
-
-       if (features['statusbar'] == "yes") {
-               html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
-
-               if (features['resizable'] == "yes") {
-                       if (this.isGecko)
-                               html += '<div id="' + id + '_resize" class="mceWindowResize"><div style="background-image: url(\'' + imgPath + '/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';
-                       else
-                               html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="' + imgPath + '/window_resize.gif" /></div>';
-               }
-
-               html += '</div>';
-       }
-
-       html += '</div>';
-
-       html += '</body>';
-       html += '</html>';
-
-       // Create iframe
-       this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
-};
-
-// Blocks the document events by placing a image over the whole document
-MCWindows.prototype.setDocumentLock = function(state) {
-       if (state) {
-               var elm = document.getElementById('mcWindowEventBlocker');
-               if (elm == null) {
-                       elm = document.createElement("div");
-
-                       elm.id = "mcWindowEventBlocker";
-                       elm.style.position = "absolute";
-                       elm.style.left = "0px";
-                       elm.style.top = "0px";
-
-                       document.body.appendChild(elm);
-               }
-
-               elm.style.display = "none";
-
-               var imgPath = this.getParam("images_path");
-               var width = document.body.clientWidth;
-               var height = document.body.clientHeight;
-
-               elm.style.width = width;
-               elm.style.height = height;
-               elm.innerHTML = '<img src="' + imgPath + '/spacer.gif" width="' + width + '" height="' + height + '" />';
-
-               elm.style.zIndex = mcWindows.zindex-1;
-               elm.style.display = "block";
-       } else {
-               var elm = document.getElementById('mcWindowEventBlocker');
-
-               if (mcWindows.windows.length == 0)
-                       elm.parentNode.removeChild(elm);
-               else
-                       elm.style.zIndex = mcWindows.zindex-1;
-       }
-};
-
-// Gets called when wrapper iframe is initialized
-MCWindows.prototype.onLoad = function(name) {
-       var win = mcWindows.windows[name];
-       var id = "mcWindow_" + name;
-       var wrapperIframe = window.frames[id + "_iframe"].frames[0];
-       var wrapperDoc = window.frames[id + "_iframe"].document;
-       var doc = window.frames[id + "_iframe"].document;
-       var winDiv = document.getElementById("mcWindow_" + name + "_div");
-       var realIframe = window.frames[id + "_iframe"].frames[0];
-
-       // Set window data
-       win.id = "mcWindow_" + name;
-       win.winElement = winDiv;
-       win.bodyElement = doc.getElementById(id + '_body');
-       win.iframeElement = doc.getElementById(id + '_iframe');
-       win.headElement = doc.getElementById(id + '_head');
-       win.titleElement = doc.getElementById(id + '_title');
-       win.resizeElement = doc.getElementById(id + '_resize');
-       win.containerElement = doc.getElementById(id + '_container');
-       win.left = win.features['left'];
-       win.top = win.features['top'];
-       win.frame = window.frames[id + '_iframe'].frames[0];
-       win.wrapperFrame = window.frames[id + '_iframe'];
-       win.wrapperIFrameElement = document.getElementById(id + "_iframe");
-
-       // Add event handlers
-       mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
-
-       if (win.resizeElement != null)
-               mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
-
-       if (mcWindows.isMSIE) {
-               mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
-               mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
-       } else {
-               mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
-               mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
-               mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
-       }
-
-       for (var i=0; i<window.frames.length; i++) {
-               if (!window.frames[i]._hasMouseHandlers) {
-                       if (mcWindows.isMSIE) {
-                               mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
-                               mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
-                       } else {
-                               mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
-                               mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
-                       }
-
-                       window.frames[i]._hasMouseHandlers = true;
-               }
-       }
-
-       if (mcWindows.isMSIE) {
-               mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
-               mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
-       } else {
-               mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
-               mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
-               mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
-       }
-
-       // Dispatch open window event
-       var func = this.getParam("on_open_window", "");
-       if (func != "")
-               eval(func + "(win);");
-
-       win.focus();
-
-       if (win.features['modal'] == "yes")
-               mcWindows.setDocumentLock(true);
-};
-
-MCWindows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
-       var iframe = document.createElement("iframe");
-       var div = document.createElement("div");
-
-       width = parseInt(width);
-       height = parseInt(height)+1;
-
-       // Create wrapper div
-       div.setAttribute("id", id_prefix + "_div");
-       div.setAttribute("width", width);
-       div.setAttribute("height", (height));
-       div.style.position = "absolute";
-       div.style.left = left + "px";
-       div.style.top = top + "px";
-       div.style.width = width + "px";
-       div.style.height = (height) + "px";
-       div.style.backgroundColor = "white";
-       div.style.display = "none";
-
-       if (this.isGecko) {
-               iframeWidth = width + 2;
-               iframeHeight = height + 2;
-       } else {
-               iframeWidth = width;
-               iframeHeight = height + 1;
-       }
-
-       // Create iframe
-       iframe.setAttribute("id", id_prefix + "_iframe");
-       iframe.setAttribute("name", id_prefix + "_iframe");
-       iframe.setAttribute("border", "0");
-       iframe.setAttribute("frameBorder", "0");
-       iframe.setAttribute("marginWidth", "0");
-       iframe.setAttribute("marginHeight", "0");
-       iframe.setAttribute("leftMargin", "0");
-       iframe.setAttribute("topMargin", "0");
-       iframe.setAttribute("width", iframeWidth);
-       iframe.setAttribute("height", iframeHeight);
-//     iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
-       // iframe.setAttribute("allowtransparency", "false");
-       iframe.setAttribute("scrolling", "no");
-       iframe.style.width = iframeWidth + "px";
-       iframe.style.height = iframeHeight + "px";
-       iframe.style.backgroundColor = "white";
-       div.appendChild(iframe);
-
-       document.body.appendChild(div);
-
-       // Fixed MSIE 5.0 issue
-       div.innerHTML = div.innerHTML;
-
-       if (this.isSafari) {
-               // Give Safari some time to setup
-               window.setTimeout(function() {
-                       doc = window.frames[id_prefix + '_iframe'].document;
-                       doc.open();
-                       doc.write(html);
-                       doc.close();
-               }, 10);
-       } else {
-               doc = window.frames[id_prefix + '_iframe'].window.document;
-               doc.open();
-               doc.write(html);
-               doc.close();
-       }
-
-       div.style.display = "block";
-
-       return div;
-};
-
-// Window instance
-function MCWindow() {
-};
-
-MCWindow.prototype.focus = function() {
-       if (this != mcWindows.selectedWindow) {
-               this.winElement.style.zIndex = ++mcWindows.zindex;
-               mcWindows.lastSelectedWindow = mcWindows.selectedWindow;
-               mcWindows.selectedWindow = this;
-       }
-};
-
-MCWindow.prototype.minimize = function() {
-};
-
-MCWindow.prototype.maximize = function() {
-       
-};
-
-MCWindow.prototype.startResize = function() {
-       mcWindows.action = "resize";
-};
-
-MCWindow.prototype.startMove = function(e) {
-       mcWindows.action = "move";
-};
-
-MCWindow.prototype.close = function() {
-       if (mcWindows.lastSelectedWindow != null)
-               mcWindows.lastSelectedWindow.focus();
-
-       var mcWindowsNew = new Array();
-       for (var n in mcWindows.windows) {
-               var win = mcWindows.windows[n];
-               if (typeof(win) == 'function')
-                       continue;
-
-               if (win.name != this.name)
-                       mcWindowsNew[n] = win;
-       }
-
-       mcWindows.windows = mcWindowsNew;
-
-//     alert(mcWindows.doc.getElementById(this.id + "_iframe"));
-
-       var e = mcWindows.doc.getElementById(this.id + "_iframe");
-       e.parentNode.removeChild(e);
-
-       var e = mcWindows.doc.getElementById(this.id + "_div");
-       e.parentNode.removeChild(e);
-
-       mcWindows.setDocumentLock(false);
-};
-
-MCWindow.prototype.onMouseMove = function(e) {
-       var scrollX = 0;//this.doc.body.scrollLeft;
-       var scrollY = 0;//this.doc.body.scrollTop;
-
-       // Calculate real X, Y
-       var dx = e.screenX - mcWindows.mouseDownScreenX;
-       var dy = e.screenY - mcWindows.mouseDownScreenY;
-
-       switch (mcWindows.action) {
-               case "resize":
-                       width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
-                       height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
-
-                       width = width < 100 ? 100 : width;
-                       height = height < 100 ? 100 : height;
-
-                       this.wrapperIFrameElement.style.width = width+2;
-                       this.wrapperIFrameElement.style.height = height+2;
-                       this.wrapperIFrameElement.width = width+2;
-                       this.wrapperIFrameElement.height = height+2;
-                       this.winElement.style.width = width;
-                       this.winElement.style.height = height;
-
-                       height = height - this.deltaHeight;
-
-                       this.containerElement.style.width = width;
-
-                       this.iframeElement.style.width = width;
-                       this.iframeElement.style.height = height;
-                       this.bodyElement.style.width = width;
-                       this.bodyElement.style.height = height;
-                       this.headElement.style.width = width;
-                       //this.statusElement.style.width = width;
-
-                       mcWindows.cancelEvent(e);
-                       break;
-
-               case "move":
-                       this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
-                       this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
-                       this.winElement.style.left = this.left + "px";
-                       this.winElement.style.top = this.top + "px";
-
-                       mcWindows.cancelEvent(e);
-                       break;
-       }
-};
-
-function debug(msg) {
-       document.getElementById('debug').value += msg + "\n";
-}
-
-MCWindow.prototype.onMouseUp = function(e) {
-       mcWindows.action = "none";
-};
-
-MCWindow.prototype.onFocus = function(e) {
-       // Gecko only handler
-       var winRef = e.currentTarget;
-
-       for (var n in mcWindows.windows) {
-               var win = mcWindows.windows[n];
-               if (typeof(win) == 'function')
-                       continue;
-
-               if (winRef.name == win.id + "_iframe") {
-                       win.focus();
-                       return;
-               }
-       }
-};
-
-MCWindow.prototype.onMouseDown = function(e) {
-       var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
-
-       var scrollX = 0;//this.doc.body.scrollLeft;
-       var scrollY = 0;//this.doc.body.scrollTop;
-
-       mcWindows.mouseDownScreenX = e.screenX;
-       mcWindows.mouseDownScreenY = e.screenY;
-       mcWindows.mouseDownLayerX = this.left;
-       mcWindows.mouseDownLayerY = this.top;
-       mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
-       mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
-
-       if (this.resizeElement != null && elm == this.resizeElement.firstChild)
-               this.startResize(e);
-       else
-               this.startMove(e);
-
-       mcWindows.cancelEvent(e);
-};
-
-// Global instance
-var mcWindows = new MCWindows();
-
-// Initialize windows
-mcWindows.init({
-       images_path : tinyMCE.baseURL + "/plugins/inlinepopups/images",
-       css_file : tinyMCE.baseURL + "/plugins/inlinepopups/css/inlinepopup.css"
-});
+/**\r
+ * editor_plugin_src.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ */\r
+\r
+(function() {\r
+       var DOM = tinymce.DOM, Element = tinymce.dom.Element, Event = tinymce.dom.Event, each = tinymce.each, is = tinymce.is;\r
+\r
+       tinymce.create('tinymce.plugins.InlinePopups', {\r
+               init : function(ed, url) {\r
+                       // Replace window manager\r
+                       ed.onBeforeRenderUI.add(function() {\r
+                               ed.windowManager = new tinymce.InlineWindowManager(ed);\r
+                               DOM.loadCSS(url + '/skins/' + (ed.settings.inlinepopups_skin || 'clearlooks2') + "/window.css");\r
+                       });\r
+               },\r
+\r
+               getInfo : function() {\r
+                       return {\r
+                               longname : 'InlinePopups',\r
+                               author : 'Moxiecode Systems AB',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',\r
+                               version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+                       };\r
+               }\r
+       });\r
+\r
+       tinymce.create('tinymce.InlineWindowManager:tinymce.WindowManager', {\r
+               InlineWindowManager : function(ed) {\r
+                       var t = this;\r
+\r
+                       t.parent(ed);\r
+                       t.zIndex = 300000;\r
+                       t.count = 0;\r
+                       t.windows = {};\r
+               },\r
+\r
+               open : function(f, p) {\r
+                       var t = this, id, opt = '', ed = t.editor, dw = 0, dh = 0, vp, po, mdf, clf, we, w, u, parentWindow;\r
+\r
+                       f = f || {};\r
+                       p = p || {};\r
+\r
+                       // Run native windows\r
+                       if (!f.inline)\r
+                               return t.parent(f, p);\r
+\r
+                       parentWindow = t._frontWindow();\r
+                       if (parentWindow && DOM.get(parentWindow.id + '_ifr')) {\r
+                               parentWindow.focussedElement = DOM.get(parentWindow.id + '_ifr').contentWindow.document.activeElement;\r
+                       }\r
+                       \r
+                       // Only store selection if the type is a normal window\r
+                       if (!f.type)\r
+                               t.bookmark = ed.selection.getBookmark(1);\r
+\r
+                       id = DOM.uniqueId();\r
+                       vp = DOM.getViewPort();\r
+                       f.width = parseInt(f.width || 320);\r
+                       f.height = parseInt(f.height || 240) + (tinymce.isIE ? 8 : 0);\r
+                       f.min_width = parseInt(f.min_width || 150);\r
+                       f.min_height = parseInt(f.min_height || 100);\r
+                       f.max_width = parseInt(f.max_width || 2000);\r
+                       f.max_height = parseInt(f.max_height || 2000);\r
+                       f.left = f.left || Math.round(Math.max(vp.x, vp.x + (vp.w / 2.0) - (f.width / 2.0)));\r
+                       f.top = f.top || Math.round(Math.max(vp.y, vp.y + (vp.h / 2.0) - (f.height / 2.0)));\r
+                       f.movable = f.resizable = true;\r
+                       p.mce_width = f.width;\r
+                       p.mce_height = f.height;\r
+                       p.mce_inline = true;\r
+                       p.mce_window_id = id;\r
+                       p.mce_auto_focus = f.auto_focus;\r
+\r
+                       // Transpose\r
+//                     po = DOM.getPos(ed.getContainer());\r
+//                     f.left -= po.x;\r
+//                     f.top -= po.y;\r
+\r
+                       t.features = f;\r
+                       t.params = p;\r
+                       t.onOpen.dispatch(t, f, p);\r
+\r
+                       if (f.type) {\r
+                               opt += ' mceModal';\r
+\r
+                               if (f.type)\r
+                                       opt += ' mce' + f.type.substring(0, 1).toUpperCase() + f.type.substring(1);\r
+\r
+                               f.resizable = false;\r
+                       }\r
+\r
+                       if (f.statusbar)\r
+                               opt += ' mceStatusbar';\r
+\r
+                       if (f.resizable)\r
+                               opt += ' mceResizable';\r
+\r
+                       if (f.minimizable)\r
+                               opt += ' mceMinimizable';\r
+\r
+                       if (f.maximizable)\r
+                               opt += ' mceMaximizable';\r
+\r
+                       if (f.movable)\r
+                               opt += ' mceMovable';\r
+\r
+                       // Create DOM objects\r
+                       t._addAll(DOM.doc.body, \r
+                               ['div', {id : id, role : 'dialog', 'aria-labelledby': f.type ? id + '_content' : id + '_title', 'class' : (ed.settings.inlinepopups_skin || 'clearlooks2') + (tinymce.isIE && window.getSelection ? ' ie9' : ''), style : 'width:100px;height:100px'}, \r
+                                       ['div', {id : id + '_wrapper', 'class' : 'mceWrapper' + opt},\r
+                                               ['div', {id : id + '_top', 'class' : 'mceTop'}, \r
+                                                       ['div', {'class' : 'mceLeft'}],\r
+                                                       ['div', {'class' : 'mceCenter'}],\r
+                                                       ['div', {'class' : 'mceRight'}],\r
+                                                       ['span', {id : id + '_title'}, f.title || '']\r
+                                               ],\r
+\r
+                                               ['div', {id : id + '_middle', 'class' : 'mceMiddle'}, \r
+                                                       ['div', {id : id + '_left', 'class' : 'mceLeft', tabindex : '0'}],\r
+                                                       ['span', {id : id + '_content'}],\r
+                                                       ['div', {id : id + '_right', 'class' : 'mceRight', tabindex : '0'}]\r
+                                               ],\r
+\r
+                                               ['div', {id : id + '_bottom', 'class' : 'mceBottom'},\r
+                                                       ['div', {'class' : 'mceLeft'}],\r
+                                                       ['div', {'class' : 'mceCenter'}],\r
+                                                       ['div', {'class' : 'mceRight'}],\r
+                                                       ['span', {id : id + '_status'}, 'Content']\r
+                                               ],\r
+\r
+                                               ['a', {'class' : 'mceMove', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {'class' : 'mceMin', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],\r
+                                               ['a', {'class' : 'mceMax', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],\r
+                                               ['a', {'class' : 'mceMed', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],\r
+                                               ['a', {'class' : 'mceClose', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],\r
+                                               ['a', {id : id + '_resize_n', 'class' : 'mceResize mceResizeN', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_s', 'class' : 'mceResize mceResizeS', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_w', 'class' : 'mceResize mceResizeW', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_e', 'class' : 'mceResize mceResizeE', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_nw', 'class' : 'mceResize mceResizeNW', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_ne', 'class' : 'mceResize mceResizeNE', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_sw', 'class' : 'mceResize mceResizeSW', tabindex : '-1', href : 'javascript:;'}],\r
+                                               ['a', {id : id + '_resize_se', 'class' : 'mceResize mceResizeSE', tabindex : '-1', href : 'javascript:;'}]\r
+                                       ]\r
+                               ]\r
+                       );\r
+\r
+                       DOM.setStyles(id, {top : -10000, left : -10000});\r
+\r
+                       // Fix gecko rendering bug, where the editors iframe messed with window contents\r
+                       if (tinymce.isGecko)\r
+                               DOM.setStyle(id, 'overflow', 'auto');\r
+\r
+                       // Measure borders\r
+                       if (!f.type) {\r
+                               dw += DOM.get(id + '_left').clientWidth;\r
+                               dw += DOM.get(id + '_right').clientWidth;\r
+                               dh += DOM.get(id + '_top').clientHeight;\r
+                               dh += DOM.get(id + '_bottom').clientHeight;\r
+                       }\r
+\r
+                       // Resize window\r
+                       DOM.setStyles(id, {top : f.top, left : f.left, width : f.width + dw, height : f.height + dh});\r
+\r
+                       u = f.url || f.file;\r
+                       if (u) {\r
+                               if (tinymce.relaxedDomain)\r
+                                       u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;\r
+\r
+                               u = tinymce._addVer(u);\r
+                       }\r
+\r
+                       if (!f.type) {\r
+                               DOM.add(id + '_content', 'iframe', {id : id + '_ifr', src : 'javascript:""', frameBorder : 0, style : 'border:0;width:10px;height:10px'});\r
+                               DOM.setStyles(id + '_ifr', {width : f.width, height : f.height});\r
+                               DOM.setAttrib(id + '_ifr', 'src', u);\r
+                       } else {\r
+                               DOM.add(id + '_wrapper', 'a', {id : id + '_ok', 'class' : 'mceButton mceOk', href : 'javascript:;', onmousedown : 'return false;'}, 'Ok');\r
+\r
+                               if (f.type == 'confirm')\r
+                                       DOM.add(id + '_wrapper', 'a', {'class' : 'mceButton mceCancel', href : 'javascript:;', onmousedown : 'return false;'}, 'Cancel');\r
+\r
+                               DOM.add(id + '_middle', 'div', {'class' : 'mceIcon'});\r
+                               DOM.setHTML(id + '_content', f.content.replace('\n', '<br />'));\r
+                               \r
+                               Event.add(id, 'keyup', function(evt) {\r
+                                       var VK_ESCAPE = 27;\r
+                                       if (evt.keyCode === VK_ESCAPE) {\r
+                                               f.button_func(false);\r
+                                               return Event.cancel(evt);\r
+                                       }\r
+                               });\r
+\r
+                               Event.add(id, 'keydown', function(evt) {\r
+                                       var cancelButton, VK_TAB = 9;\r
+                                       if (evt.keyCode === VK_TAB) {\r
+                                               cancelButton = DOM.select('a.mceCancel', id + '_wrapper')[0];\r
+                                               if (cancelButton && cancelButton !== evt.target) {\r
+                                                       cancelButton.focus();\r
+                                               } else {\r
+                                                       DOM.get(id + '_ok').focus();\r
+                                               }\r
+                                               return Event.cancel(evt);\r
+                                       }\r
+                               });\r
+                       }\r
+\r
+                       // Register events\r
+                       mdf = Event.add(id, 'mousedown', function(e) {\r
+                               var n = e.target, w, vp;\r
+\r
+                               w = t.windows[id];\r
+                               t.focus(id);\r
+\r
+                               if (n.nodeName == 'A' || n.nodeName == 'a') {\r
+                                       if (n.className == 'mceClose') {\r
+                                               t.close(null, id);\r
+                                               return Event.cancel(e);\r
+                                       } else if (n.className == 'mceMax') {\r
+                                               w.oldPos = w.element.getXY();\r
+                                               w.oldSize = w.element.getSize();\r
+\r
+                                               vp = DOM.getViewPort();\r
+\r
+                                               // Reduce viewport size to avoid scrollbars\r
+                                               vp.w -= 2;\r
+                                               vp.h -= 2;\r
+\r
+                                               w.element.moveTo(vp.x, vp.y);\r
+                                               w.element.resizeTo(vp.w, vp.h);\r
+                                               DOM.setStyles(id + '_ifr', {width : vp.w - w.deltaWidth, height : vp.h - w.deltaHeight});\r
+                                               DOM.addClass(id + '_wrapper', 'mceMaximized');\r
+                                       } else if (n.className == 'mceMed') {\r
+                                               // Reset to old size\r
+                                               w.element.moveTo(w.oldPos.x, w.oldPos.y);\r
+                                               w.element.resizeTo(w.oldSize.w, w.oldSize.h);\r
+                                               w.iframeElement.resizeTo(w.oldSize.w - w.deltaWidth, w.oldSize.h - w.deltaHeight);\r
+\r
+                                               DOM.removeClass(id + '_wrapper', 'mceMaximized');\r
+                                       } else if (n.className == 'mceMove')\r
+                                               return t._startDrag(id, e, n.className);\r
+                                       else if (DOM.hasClass(n, 'mceResize'))\r
+                                               return t._startDrag(id, e, n.className.substring(13));\r
+                               }\r
+                       });\r
+\r
+                       clf = Event.add(id, 'click', function(e) {\r
+                               var n = e.target;\r
+\r
+                               t.focus(id);\r
+\r
+                               if (n.nodeName == 'A' || n.nodeName == 'a') {\r
+                                       switch (n.className) {\r
+                                               case 'mceClose':\r
+                                                       t.close(null, id);\r
+                                                       return Event.cancel(e);\r
+\r
+                                               case 'mceButton mceOk':\r
+                                               case 'mceButton mceCancel':\r
+                                                       f.button_func(n.className == 'mceButton mceOk');\r
+                                                       return Event.cancel(e);\r
+                                       }\r
+                               }\r
+                       });\r
+                       \r
+                       // Make sure the tab order loops within the dialog.\r
+                       Event.add([id + '_left', id + '_right'], 'focus', function(evt) {\r
+                               var iframe = DOM.get(id + '_ifr');\r
+                               if (iframe) {\r
+                                       var body = iframe.contentWindow.document.body;\r
+                                       var focusable = DOM.select(':input:enabled,*[tabindex=0]', body);\r
+                                       if (evt.target.id === (id + '_left')) {\r
+                                               focusable[focusable.length - 1].focus();\r
+                                       } else {\r
+                                               focusable[0].focus();\r
+                                       }\r
+                               } else {\r
+                                       DOM.get(id + '_ok').focus();\r
+                               }\r
+                       });\r
+                       \r
+                       // Add window\r
+                       w = t.windows[id] = {\r
+                               id : id,\r
+                               mousedown_func : mdf,\r
+                               click_func : clf,\r
+                               element : new Element(id, {blocker : 1, container : ed.getContainer()}),\r
+                               iframeElement : new Element(id + '_ifr'),\r
+                               features : f,\r
+                               deltaWidth : dw,\r
+                               deltaHeight : dh\r
+                       };\r
+\r
+                       w.iframeElement.on('focus', function() {\r
+                               t.focus(id);\r
+                       });\r
+\r
+                       // Setup blocker\r
+                       if (t.count == 0 && t.editor.getParam('dialog_type', 'modal') == 'modal') {\r
+                               DOM.add(DOM.doc.body, 'div', {\r
+                                       id : 'mceModalBlocker',\r
+                                       'class' : (t.editor.settings.inlinepopups_skin || 'clearlooks2') + '_modalBlocker',\r
+                                       style : {zIndex : t.zIndex - 1}\r
+                               });\r
+\r
+                               DOM.show('mceModalBlocker'); // Reduces flicker in IE\r
+                               DOM.setAttrib(DOM.doc.body, 'aria-hidden', 'true');\r
+                       } else\r
+                               DOM.setStyle('mceModalBlocker', 'z-index', t.zIndex - 1);\r
+\r
+                       if (tinymce.isIE6 || /Firefox\/2\./.test(navigator.userAgent) || (tinymce.isIE && !DOM.boxModel))\r
+                               DOM.setStyles('mceModalBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2});\r
+\r
+                       DOM.setAttrib(id, 'aria-hidden', 'false');\r
+                       t.focus(id);\r
+                       t._fixIELayout(id, 1);\r
+\r
+                       // Focus ok button\r
+                       if (DOM.get(id + '_ok'))\r
+                               DOM.get(id + '_ok').focus();\r
+                       t.count++;\r
+\r
+                       return w;\r
+               },\r
+\r
+               focus : function(id) {\r
+                       var t = this, w;\r
+\r
+                       if (w = t.windows[id]) {\r
+                               w.zIndex = this.zIndex++;\r
+                               w.element.setStyle('zIndex', w.zIndex);\r
+                               w.element.update();\r
+\r
+                               id = id + '_wrapper';\r
+                               DOM.removeClass(t.lastId, 'mceFocus');\r
+                               DOM.addClass(id, 'mceFocus');\r
+                               t.lastId = id;\r
+                               \r
+                               if (w.focussedElement) {\r
+                                       w.focussedElement.focus();\r
+                               } else if (DOM.get(id + '_ok')) {\r
+                                       DOM.get(w.id + '_ok').focus();\r
+                               } else if (DOM.get(w.id + '_ifr')) {\r
+                                       DOM.get(w.id + '_ifr').focus();\r
+                               }\r
+                       }\r
+               },\r
+\r
+               _addAll : function(te, ne) {\r
+                       var i, n, t = this, dom = tinymce.DOM;\r
+\r
+                       if (is(ne, 'string'))\r
+                               te.appendChild(dom.doc.createTextNode(ne));\r
+                       else if (ne.length) {\r
+                               te = te.appendChild(dom.create(ne[0], ne[1]));\r
+\r
+                               for (i=2; i<ne.length; i++)\r
+                                       t._addAll(te, ne[i]);\r
+                       }\r
+               },\r
+\r
+               _startDrag : function(id, se, ac) {\r
+                       var t = this, mu, mm, d = DOM.doc, eb, w = t.windows[id], we = w.element, sp = we.getXY(), p, sz, ph, cp, vp, sx, sy, sex, sey, dx, dy, dw, dh;\r
+\r
+                       // Get positons and sizes\r
+//                     cp = DOM.getPos(t.editor.getContainer());\r
+                       cp = {x : 0, y : 0};\r
+                       vp = DOM.getViewPort();\r
+\r
+                       // Reduce viewport size to avoid scrollbars while dragging\r
+                       vp.w -= 2;\r
+                       vp.h -= 2;\r
+\r
+                       sex = se.screenX;\r
+                       sey = se.screenY;\r
+                       dx = dy = dw = dh = 0;\r
+\r
+                       // Handle mouse up\r
+                       mu = Event.add(d, 'mouseup', function(e) {\r
+                               Event.remove(d, 'mouseup', mu);\r
+                               Event.remove(d, 'mousemove', mm);\r
+\r
+                               if (eb)\r
+                                       eb.remove();\r
+\r
+                               we.moveBy(dx, dy);\r
+                               we.resizeBy(dw, dh);\r
+                               sz = we.getSize();\r
+                               DOM.setStyles(id + '_ifr', {width : sz.w - w.deltaWidth, height : sz.h - w.deltaHeight});\r
+                               t._fixIELayout(id, 1);\r
+\r
+                               return Event.cancel(e);\r
+                       });\r
+\r
+                       if (ac != 'Move')\r
+                               startMove();\r
+\r
+                       function startMove() {\r
+                               if (eb)\r
+                                       return;\r
+\r
+                               t._fixIELayout(id, 0);\r
+\r
+                               // Setup event blocker\r
+                               DOM.add(d.body, 'div', {\r
+                                       id : 'mceEventBlocker',\r
+                                       'class' : 'mceEventBlocker ' + (t.editor.settings.inlinepopups_skin || 'clearlooks2'),\r
+                                       style : {zIndex : t.zIndex + 1}\r
+                               });\r
+\r
+                               if (tinymce.isIE6 || (tinymce.isIE && !DOM.boxModel))\r
+                                       DOM.setStyles('mceEventBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2});\r
+\r
+                               eb = new Element('mceEventBlocker');\r
+                               eb.update();\r
+\r
+                               // Setup placeholder\r
+                               p = we.getXY();\r
+                               sz = we.getSize();\r
+                               sx = cp.x + p.x - vp.x;\r
+                               sy = cp.y + p.y - vp.y;\r
+                               DOM.add(eb.get(), 'div', {id : 'mcePlaceHolder', 'class' : 'mcePlaceHolder', style : {left : sx, top : sy, width : sz.w, height : sz.h}});\r
+                               ph = new Element('mcePlaceHolder');\r
+                       };\r
+\r
+                       // Handle mouse move/drag\r
+                       mm = Event.add(d, 'mousemove', function(e) {\r
+                               var x, y, v;\r
+\r
+                               startMove();\r
+\r
+                               x = e.screenX - sex;\r
+                               y = e.screenY - sey;\r
+\r
+                               switch (ac) {\r
+                                       case 'ResizeW':\r
+                                               dx = x;\r
+                                               dw = 0 - x;\r
+                                               break;\r
+\r
+                                       case 'ResizeE':\r
+                                               dw = x;\r
+                                               break;\r
+\r
+                                       case 'ResizeN':\r
+                                       case 'ResizeNW':\r
+                                       case 'ResizeNE':\r
+                                               if (ac == "ResizeNW") {\r
+                                                       dx = x;\r
+                                                       dw = 0 - x;\r
+                                               } else if (ac == "ResizeNE")\r
+                                                       dw = x;\r
+\r
+                                               dy = y;\r
+                                               dh = 0 - y;\r
+                                               break;\r
+\r
+                                       case 'ResizeS':\r
+                                       case 'ResizeSW':\r
+                                       case 'ResizeSE':\r
+                                               if (ac == "ResizeSW") {\r
+                                                       dx = x;\r
+                                                       dw = 0 - x;\r
+                                               } else if (ac == "ResizeSE")\r
+                                                       dw = x;\r
+\r
+                                               dh = y;\r
+                                               break;\r
+\r
+                                       case 'mceMove':\r
+                                               dx = x;\r
+                                               dy = y;\r
+                                               break;\r
+                               }\r
+\r
+                               // Boundary check\r
+                               if (dw < (v = w.features.min_width - sz.w)) {\r
+                                       if (dx !== 0)\r
+                                               dx += dw - v;\r
+\r
+                                       dw = v;\r
+                               }\r
+       \r
+                               if (dh < (v = w.features.min_height - sz.h)) {\r
+                                       if (dy !== 0)\r
+                                               dy += dh - v;\r
+\r
+                                       dh = v;\r
+                               }\r
+\r
+                               dw = Math.min(dw, w.features.max_width - sz.w);\r
+                               dh = Math.min(dh, w.features.max_height - sz.h);\r
+                               dx = Math.max(dx, vp.x - (sx + vp.x));\r
+                               dy = Math.max(dy, vp.y - (sy + vp.y));\r
+                               dx = Math.min(dx, (vp.w + vp.x) - (sx + sz.w + vp.x));\r
+                               dy = Math.min(dy, (vp.h + vp.y) - (sy + sz.h + vp.y));\r
+\r
+                               // Move if needed\r
+                               if (dx + dy !== 0) {\r
+                                       if (sx + dx < 0)\r
+                                               dx = 0;\r
+       \r
+                                       if (sy + dy < 0)\r
+                                               dy = 0;\r
+\r
+                                       ph.moveTo(sx + dx, sy + dy);\r
+                               }\r
+\r
+                               // Resize if needed\r
+                               if (dw + dh !== 0)\r
+                                       ph.resizeTo(sz.w + dw, sz.h + dh);\r
+\r
+                               return Event.cancel(e);\r
+                       });\r
+\r
+                       return Event.cancel(se);\r
+               },\r
+\r
+               resizeBy : function(dw, dh, id) {\r
+                       var w = this.windows[id];\r
+\r
+                       if (w) {\r
+                               w.element.resizeBy(dw, dh);\r
+                               w.iframeElement.resizeBy(dw, dh);\r
+                       }\r
+               },\r
+\r
+               close : function(win, id) {\r
+                       var t = this, w, d = DOM.doc, fw, id;\r
+\r
+                       id = t._findId(id || win);\r
+\r
+                       // Probably not inline\r
+                       if (!t.windows[id]) {\r
+                               t.parent(win);\r
+                               return;\r
+                       }\r
+\r
+                       t.count--;\r
+\r
+                       if (t.count == 0) {\r
+                               DOM.remove('mceModalBlocker');\r
+                               DOM.setAttrib(DOM.doc.body, 'aria-hidden', 'false');\r
+                               t.editor.focus();\r
+                       }\r
+\r
+                       if (w = t.windows[id]) {\r
+                               t.onClose.dispatch(t);\r
+                               Event.remove(d, 'mousedown', w.mousedownFunc);\r
+                               Event.remove(d, 'click', w.clickFunc);\r
+                               Event.clear(id);\r
+                               Event.clear(id + '_ifr');\r
+\r
+                               DOM.setAttrib(id + '_ifr', 'src', 'javascript:""'); // Prevent leak\r
+                               w.element.remove();\r
+                               delete t.windows[id];\r
+\r
+                               fw = t._frontWindow();\r
+\r
+                               if (fw)\r
+                                       t.focus(fw.id);\r
+                       }\r
+               },\r
+               \r
+               // Find front most window\r
+               _frontWindow : function() {\r
+                       var fw, ix = 0;\r
+                       // Find front most window and focus that\r
+                       each (this.windows, function(w) {\r
+                               if (w.zIndex > ix) {\r
+                                       fw = w;\r
+                                       ix = w.zIndex;\r
+                               }\r
+                       });\r
+                       return fw;\r
+               },\r
+\r
+               setTitle : function(w, ti) {\r
+                       var e;\r
+\r
+                       w = this._findId(w);\r
+\r
+                       if (e = DOM.get(w + '_title'))\r
+                               e.innerHTML = DOM.encode(ti);\r
+               },\r
+\r
+               alert : function(txt, cb, s) {\r
+                       var t = this, w;\r
+\r
+                       w = t.open({\r
+                               title : t,\r
+                               type : 'alert',\r
+                               button_func : function(s) {\r
+                                       if (cb)\r
+                                               cb.call(s || t, s);\r
+\r
+                                       t.close(null, w.id);\r
+                               },\r
+                               content : DOM.encode(t.editor.getLang(txt, txt)),\r
+                               inline : 1,\r
+                               width : 400,\r
+                               height : 130\r
+                       });\r
+               },\r
+\r
+               confirm : function(txt, cb, s) {\r
+                       var t = this, w;\r
+\r
+                       w = t.open({\r
+                               title : t,\r
+                               type : 'confirm',\r
+                               button_func : function(s) {\r
+                                       if (cb)\r
+                                               cb.call(s || t, s);\r
+\r
+                                       t.close(null, w.id);\r
+                               },\r
+                               content : DOM.encode(t.editor.getLang(txt, txt)),\r
+                               inline : 1,\r
+                               width : 400,\r
+                               height : 130\r
+                       });\r
+               },\r
+\r
+               // Internal functions\r
+\r
+               _findId : function(w) {\r
+                       var t = this;\r
+\r
+                       if (typeof(w) == 'string')\r
+                               return w;\r
+\r
+                       each(t.windows, function(wo) {\r
+                               var ifr = DOM.get(wo.id + '_ifr');\r
+\r
+                               if (ifr && w == ifr.contentWindow) {\r
+                                       w = wo.id;\r
+                                       return false;\r
+                               }\r
+                       });\r
+\r
+                       return w;\r
+               },\r
+\r
+               _fixIELayout : function(id, s) {\r
+                       var w, img;\r
+\r
+                       if (!tinymce.isIE6)\r
+                               return;\r
+\r
+                       // Fixes the bug where hover flickers and does odd things in IE6\r
+                       each(['n','s','w','e','nw','ne','sw','se'], function(v) {\r
+                               var e = DOM.get(id + '_resize_' + v);\r
+\r
+                               DOM.setStyles(e, {\r
+                                       width : s ? e.clientWidth : '',\r
+                                       height : s ? e.clientHeight : '',\r
+                                       cursor : DOM.getStyle(e, 'cursor', 1)\r
+                               });\r
+\r
+                               DOM.setStyle(id + "_bottom", 'bottom', '-1px');\r
+\r
+                               e = 0;\r
+                       });\r
+\r
+                       // Fixes graphics glitch\r
+                       if (w = this.windows[id]) {\r
+                               // Fixes rendering bug after resize\r
+                               w.element.hide();\r
+                               w.element.show();\r
+\r
+                               // Forced a repaint of the window\r
+                               //DOM.get(id).style.filter = '';\r
+\r
+                               // IE has a bug where images used in CSS won't get loaded\r
+                               // sometimes when the cache in the browser is disabled\r
+                               // This fix tries to solve it by loading the images using the image object\r
+                               each(DOM.select('div,a', id), function(e, i) {\r
+                                       if (e.currentStyle.backgroundImage != 'none') {\r
+                                               img = new Image();\r
+                                               img.src = e.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/, '$1');\r
+                                       }\r
+                               });\r
+\r
+                               DOM.get(id).style.filter = '';\r
+                       }\r
+               }\r
+       });\r
+\r
+       // Register plugin\r
+       tinymce.PluginManager.add('inlinepopups', tinymce.plugins.InlinePopups);\r
+})();\r
+\r