<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -64,6 +64,16 @@ Popup.borderImages = function() {
   ]);
 }
 
+Popup.preloadImages = function() {
+  if (!Popup.imagesPreloaded) {
+    Popup.borderImages().each(function(src) {
+      var image = new Image();
+      image.src = src;
+    });
+    Popup.preloadedImages = true;
+  }
+}
+
 Popup.TriggerBehavior = Behavior.create({
   initialize: function() {
     var matches = this.element.href.match(/\#(.+)$/);
@@ -86,6 +96,7 @@ Popup.TriggerBehavior = Behavior.create({
 
 Popup.AbstractWindow = Class.create({
   initialize: function() {
+    Popup.preloadImages();
     this.buildWindow();
   },
   
@@ -187,13 +198,4 @@ Element.addMethods({
   closePopup: function(element) {
     $(element).up('div.popup_window').hide();
   }
-});
-
-// Preload Images
-document.observe('dom:loaded', function() {
-  var body = $(document.getElementsByTagName('body')[0]);
-  Popup.borderImages().each(function(src) {
-    var image = new Image();
-    image.src = src;
-  });
-});
+});
\ No newline at end of file</diff>
      <filename>javascripts/popup.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>19b48d5d2cb4491625359b77cd40719734d542dd</id>
    </parent>
  </parents>
  <author>
    <name>John W. Long</name>
    <email>me@johnwlong.com</email>
  </author>
  <url>http://github.com/jlong/popupjs/commit/2f88ec024084a831eebac16c34b77d1d6d908d79</url>
  <id>2f88ec024084a831eebac16c34b77d1d6d908d79</id>
  <committed-date>2008-05-29T15:32:43-07:00</committed-date>
  <authored-date>2008-05-29T15:32:43-07:00</authored-date>
  <message>only preload images when a popup link exists</message>
  <tree>7cba39a0f4f5ef6badd0fb8315f061d425a15b50</tree>
  <committer>
    <name>John W. Long</name>
    <email>me@johnwlong.com</email>
  </committer>
</commit>
