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