3 * $Revision: 1.2 $ $Date: 2003/02/07 16:04:18 $
\r
6 /* ***** BEGIN LICENSE BLOCK *****
\r
7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
9 * The contents of this file are subject to the Mozilla Public License Version
\r
10 * 1.1 (the "License"); you may not use this file except in compliance with
\r
11 * the License. You may obtain a copy of the License at
\r
12 * http://www.mozilla.org/MPL/
\r
14 * Software distributed under the License is distributed on an "AS IS" basis,
\r
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
16 * for the specific language governing rights and limitations under the
\r
19 * The Original Code is Netscape code.
\r
21 * The Initial Developer of the Original Code is
\r
22 * Netscape Corporation.
\r
23 * Portions created by the Initial Developer are Copyright (C) 2001
\r
24 * the Initial Developer. All Rights Reserved.
\r
26 * Contributor(s): Bob Clary <bclary@netscape.com>
\r
28 * ***** END LICENSE BLOCK ***** */
\r
32 var i = parseInt(s, 10);
\r
39 function xbGetWindowWidth(windowRef)
\r
48 if (typeof(windowRef.innerWidth) == 'number')
\r
50 width = windowRef.innerWidth;
\r
52 else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number')
\r
54 width = windowRef.document.body.clientWidth;
\r
60 function xbGetWindowHeight(windowRef)
\r
69 if (typeof(windowRef.innerWidth) == 'number')
\r
71 height = windowRef.innerHeight;
\r
73 else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number')
\r
75 height = windowRef.document.body.clientHeight;
\r
80 function xbGetElementsByNameAndType(name, type, windowRef)
\r
85 var elmlist = new Array();
\r
87 xbFindElementsByNameAndType(windowRef.document, name, type, elmlist);
\r
92 function xbFindElementsByNameAndType(doc, name, type, elmlist)
\r
97 for (i = 0; i < doc[type].length; ++i)
\r
99 if (doc[type][i].name && name == doc[type][i].name)
\r
101 elmlist[elmlist.length] = doc[type][i];
\r
107 for (i = 0; i < doc.layers.length; ++i)
\r
109 subdoc = doc.layers[i].document;
\r
110 xbFindElementsByNameAndType(subdoc, name, type, elmlist);
\r
115 if (document.layers)
\r
124 for (i = 0; i < doc.layers.length; ++i)
\r
126 if (doc.layers[i].id && id == doc.layers[i].id)
\r
127 return doc.layers[i];
\r
129 subdoc = doc.layers[i].document;
\r
130 obj = nav4FindLayer(subdoc, id);
\r
137 nav4FindElementsByName =
\r
138 function (doc, name, elmlist)
\r
144 for (i = 0; i < doc.images.length; ++i)
\r
146 if (doc.images[i].name && name == doc.images[i].name)
\r
148 elmlist[elmlist.length] = doc.images[i];
\r
152 for (i = 0; i < doc.forms.length; ++i)
\r
154 for (j = 0; j < doc.forms[i].elements.length; j++)
\r
156 if (doc.forms[i].elements[j].name && name == doc.forms[i].elements[j].name)
\r
158 elmlist[elmlist.length] = doc.forms[i].elements[j];
\r
162 if (doc.forms[i].name && name == doc.forms[i].name)
\r
164 elmlist[elmlist.length] = doc.forms[i];
\r
168 for (i = 0; i < doc.anchors.length; ++i)
\r
170 if (doc.anchors[i].name && name == doc.anchors[i].name)
\r
172 elmlist[elmlist.length] = doc.anchors[i];
\r
176 for (i = 0; i < doc.links.length; ++i)
\r
178 if (doc.links[i].name && name == doc.links[i].name)
\r
180 elmlist[elmlist.length] = doc.links[i];
\r
184 for (i = 0; i < doc.applets.length; ++i)
\r
186 if (doc.applets[i].name && name == doc.applets[i].name)
\r
188 elmlist[elmlist.length] = doc.applets[i];
\r
192 for (i = 0; i < doc.embeds.length; ++i)
\r
194 if (doc.embeds[i].name && name == doc.embeds[i].name)
\r
196 elmlist[elmlist.length] = doc.embeds[i];
\r
200 for (i = 0; i < doc.layers.length; ++i)
\r
202 if (doc.layers[i].name && name == doc.layers[i].name)
\r
204 elmlist[elmlist.length] = doc.layers[i];
\r
207 subdoc = doc.layers[i].document;
\r
208 nav4FindElementsByName(subdoc, name, elmlist);
\r
212 xbGetElementById = function (id, windowRef)
\r
215 windowRef = window;
\r
217 return nav4FindLayer(windowRef.document, id);
\r
220 xbGetElementsByName = function (name, windowRef)
\r
223 windowRef = window;
\r
225 var elmlist = new Array();
\r
227 nav4FindElementsByName(windowRef.document, name, elmlist);
\r
233 else if (document.all)
\r
235 xbGetElementById =
\r
236 function (id, windowRef)
\r
240 windowRef = window;
\r
242 var elm = windowRef.document.all[id];
\r
250 xbGetElementsByName = function (name, windowRef)
\r
253 windowRef = window;
\r
256 var idnamelist = windowRef.document.all[name];
\r
257 var elmlist = new Array();
\r
259 if (!idnamelist.length || idnamelist.name == name)
\r
262 elmlist[elmlist.length] = idnamelist;
\r
266 for (i = 0; i < idnamelist.length; i++)
\r
268 if (idnamelist[i].name == name)
\r
269 elmlist[elmlist.length] = idnamelist[i];
\r
277 else if (document.getElementById)
\r
279 xbGetElementById =
\r
280 function (id, windowRef)
\r
284 windowRef = window;
\r
286 return windowRef.document.getElementById(id);
\r
289 xbGetElementsByName =
\r
290 function (name, windowRef)
\r
294 windowRef = window;
\r
296 return windowRef.document.getElementsByName(name);
\r
301 xbGetElementById =
\r
302 function (id, windowRef)
\r
307 xbGetElementsByName =
\r
308 function (name, windowRef)
\r
310 return new Array();
\r
314 function xbGetPageScrollX(windowRef)
\r
318 windowRef = window;
\r
321 if (typeof(windowRef.pageXOffset) == 'number')
\r
323 return windowRef.pageXOffset;
\r
326 if (typeof(windowRef.document.body && windowRef.document.body.scrollLeft) == 'number')
\r
328 return windowRef.document.body.scrollLeft;
\r
334 function xbGetPageScrollY(windowRef)
\r
338 windowRef = window;
\r
341 if (typeof(windowRef.pageYOffset) == 'number')
\r
343 return windowRef.pageYOffset;
\r
346 if (typeof(windowRef.document.body && windowRef.document.body.scrollTop) == 'number')
\r
348 return windowRef.document.body.scrollTop;
\r
354 if (document.layers)
\r
357 function (element, str)
\r
359 element.document.write(str);
\r
360 element.document.close();
\r
365 xbSetInnerHTML = function (element, str)
\r
367 if (typeof(element.innerHTML) != 'undefined')
\r
369 element.innerHTML = str;
\r