From 9d93a6860b5c7f43c5909072ef84847e580f003e Mon Sep 17 00:00:00 2001
From: Thomas BrĂ¼derli
Date: Mon, 4 Aug 2008 09:13:00 +0000
Subject: Move it_element() from map.search.ch to itools

---
 itjs/it.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/itjs/it.js b/itjs/it.js
index aa8072f..9cc03ec 100644
--- a/itjs/it.js
+++ b/itjs/it.js
@@ -132,6 +132,25 @@ function it_get_obj_y(obj)
 	return curtop;
 }
 
+/* Common accessor for dom elements */
+function it_find_obj(obj)
+{
+	if (document.getElementById)
+		return document.getElementById(obj);
+	else if (document.all)
+		return document.all[obj];
+	else if (document.layers)
+   		return document.layers[obj];
+	return null;
+}
+
+/* Get dom element by ID but always return a valid object */
+function it_element(label)
+{
+	var tmp = it_find_obj(label);
+	return tmp ? tmp : {style:{}, src:""};
+}
+
 /* Get an iframe's content document in a compatible way */
 function it_get_iframe_document(iframe)
 {
-- 
cgit v1.2.3