From 58196e7e69318fdcf447946d8a26d98b0f3bde0f Mon Sep 17 00:00:00 2001
From: garvinhicking <garvinhicking>
Date: Mon, 29 Aug 2005 14:16:00 +0000
Subject: [PATCH] Check for existance of the function first

---
 deployment/serendipity_editor.js | 3 +++
 serendipity_editor.js            | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/deployment/serendipity_editor.js b/deployment/serendipity_editor.js
index d7dc031..782d9b2 100644
--- a/deployment/serendipity_editor.js
+++ b/deployment/serendipity_editor.js
@@ -139,6 +139,9 @@ function serendipity_imageSelector_addToElement (str, el)
 {
     document.getElementById(el).value = str;
     document.getElementById(el).focus();
+    if (document.getElementById(el).onchange) {
+        document.getElementById(el).onchange();
+    }
 }
 
 function serendipity_imageSelector_addToBody (str, textarea)
diff --git a/serendipity_editor.js b/serendipity_editor.js
index c4ca8e6..6e0484e 100644
--- a/serendipity_editor.js
+++ b/serendipity_editor.js
@@ -139,7 +139,9 @@ function serendipity_imageSelector_addToElement (str, el)
 {
     document.getElementById(el).value = str;
     document.getElementById(el).focus();
-    document.getElementById(el).onchange();
+    if (document.getElementById(el).onchange) {
+        document.getElementById(el).onchange();
+    }
 }
 
 function serendipity_imageSelector_addToBody (str, textarea)
-- 
2.39.5