--- modules/overlay/overlay-child.js	2010-11-06 00:18:24.000000000 +0000
+++ modules/overlay/overlay-child.js	2011-03-23 22:38:50.000000000 +0000
@@ -113,13 +113,30 @@
     // Obtain the action attribute of the form.
     var action = $(this).attr('action');
     // Keep internal forms in the overlay.
-    if (action == undefined || (action.indexOf('http') != 0 && action.indexOf('https') != 0)) {
-      action += (action.indexOf('?') > -1 ? '&' : '?') + 'render=overlay';
-      $(this).attr('action', action);
+    var re=/^([^\/\:]+\:)?\/\/([^\/]+)/;
+    var matched=re.exec(action);
+    var actionhost=false;
+    if (matched){
+      actionhost=matched[2];
+      var atsign=actionhost.indexOf('@');
+      if(atsign != -1){
+        actionhost=actionhost.substring(atsign+1);
+      }
+      var colon=actionhost.indexOf(':');
+      if(colon != -1){
+        actionhost=actionhost.substring(0,colon);
+      }
+    }
+    if (action == undefined || !actionhost || actionhost == window.location.host) {
+      // Make sure render=overlay is not added more than once.
+      if (action.indexOf('render=overlay') == -1) {
+        action += (action.indexOf('?') > -1 ? '&' : '?') + 'render=overlay';
+        $(this).attr('action', action);
+      }
     }
     // Submit external forms into a new window.
     else {
-      $(this).attr('target', '_new');
+      $(this).attr('target', '_blank');
     }
   });
 };
