]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/js/overlib.js
d9f5d2220e6c5ad20e448d2085227c4d46b959ea
[bacula/bacula] / gui / bacula-web / js / overlib.js
1 //\/////
2 //\  overLIB 4.00 - You may not remove or change this notice.
3 //\  Copyright Erik Bosrup 1998-2004. All rights reserved.
4 //\
5 //\  Contributors are listed on the homepage.
6 //\  This file might be old, always check for the latest version at:
7 //\  http://www.bosrup.com/web/overlib/
8 //\
9 //\  Please read the license agreement (available through the link above)
10 //\  before using overLIB. Direct any licensing questions to erik@bosrup.com.
11 //\
12 //\  Do not sell this as your own work or remove this copyright notice. 
13 //\  For full details on copying or changing this script please read the
14 //\  license agreement at the link above. Please give credit on sites that
15 //\  use overLIB and submit changes of the script so other people can use
16 //\  them as well.
17 //   $Revision$                $Date$
18 //\/////
19 //\mini
20
21 ////////
22 // PRE-INIT
23 // Ignore these lines, configuration is below.
24 ////////
25 var olLoaded = 0;var pmStart = 10000000; var pmUpper = 10001000; var pmCount = pmStart+1;  var pms = new Array(); var olInfo = new Info('4.00', 1);
26 var FREPLACE = 0; var FBEFORE = 1; var FAFTER = 2; var FALTERNATE = 3;
27 var olHideForm=0;  // parameter for hiding SELECT and ActiveX elements in IE5.5+ 
28 registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass');
29
30 ////////
31 // DEFAULT CONFIGURATION
32 // Settings you want everywhere are set here. All of this can also be
33 // changed on your html page or through an overLIB call.
34 ////////
35 if (typeof ol_fgcolor=='undefined') var ol_fgcolor="#CCCCFF";
36 if (typeof ol_bgcolor=='undefined') var ol_bgcolor="#333399";
37 if (typeof ol_textcolor=='undefined') var ol_textcolor="#000000";
38 if (typeof ol_capcolor=='undefined') var ol_capcolor="#FFFFFF";
39 if (typeof ol_closecolor=='undefined') var ol_closecolor="#9999FF";
40 if (typeof ol_textfont=='undefined') var ol_textfont="Verdana,Arial,Helvetica";
41 if (typeof ol_captionfont=='undefined') var ol_captionfont="Verdana,Arial,Helvetica";
42 if (typeof ol_closefont=='undefined') var ol_closefont="Verdana,Arial,Helvetica";
43 if (typeof ol_textsize=='undefined') var ol_textsize="1";
44 if (typeof ol_captionsize=='undefined') var ol_captionsize="1";
45 if (typeof ol_closesize=='undefined') var ol_closesize="1";
46 if (typeof ol_width=='undefined') var ol_width="200";
47 if (typeof ol_border=='undefined') var ol_border="1";
48 if (typeof ol_cellpad=='undefined') var ol_cellpad=2;
49 if (typeof ol_offsetx=='undefined') var ol_offsetx=10;
50 if (typeof ol_offsety=='undefined') var ol_offsety=10;
51 if (typeof ol_text=='undefined') var ol_text="Default Text";
52 if (typeof ol_cap=='undefined') var ol_cap="";
53 if (typeof ol_sticky=='undefined') var ol_sticky=0;
54 if (typeof ol_background=='undefined') var ol_background="";
55 if (typeof ol_close=='undefined') var ol_close="Close";
56 if (typeof ol_hpos=='undefined') var ol_hpos=RIGHT;
57 if (typeof ol_status=='undefined') var ol_status="";
58 if (typeof ol_autostatus=='undefined') var ol_autostatus=0;
59 if (typeof ol_height=='undefined') var ol_height=-1;
60 if (typeof ol_snapx=='undefined') var ol_snapx=0;
61 if (typeof ol_snapy=='undefined') var ol_snapy=0;
62 if (typeof ol_fixx=='undefined') var ol_fixx=-1;
63 if (typeof ol_fixy=='undefined') var ol_fixy=-1;
64 if (typeof ol_relx=='undefined') var ol_relx=null;
65 if (typeof ol_rely=='undefined') var ol_rely=null;
66 if (typeof ol_fgbackground=='undefined') var ol_fgbackground="";
67 if (typeof ol_bgbackground=='undefined') var ol_bgbackground="";
68 if (typeof ol_padxl=='undefined') var ol_padxl=1;
69 if (typeof ol_padxr=='undefined') var ol_padxr=1;
70 if (typeof ol_padyt=='undefined') var ol_padyt=1;
71 if (typeof ol_padyb=='undefined') var ol_padyb=1;
72 if (typeof ol_fullhtml=='undefined') var ol_fullhtml=0;
73 if (typeof ol_vpos=='undefined') var ol_vpos=BELOW;
74 if (typeof ol_aboveheight=='undefined') var ol_aboveheight=0;
75 if (typeof ol_capicon=='undefined') var ol_capicon="";
76 if (typeof ol_frame=='undefined') var ol_frame=self;
77 if (typeof ol_timeout=='undefined') var ol_timeout=0;
78 if (typeof ol_function=='undefined') var ol_function=null;
79 if (typeof ol_delay=='undefined') var ol_delay=0;
80 if (typeof ol_hauto=='undefined') var ol_hauto=0;
81 if (typeof ol_vauto=='undefined') var ol_vauto=0;
82 if (typeof ol_closeclick=='undefined') var ol_closeclick=0;
83 if (typeof ol_wrap=='undefined') var ol_wrap=0;
84 if (typeof ol_followmouse=='undefined') var ol_followmouse=1;
85 if (typeof ol_mouseoff=='undefined') var ol_mouseoff=0;
86 if (typeof ol_closetitle=='undefined') var ol_closetitle='Close';
87 if (typeof ol_css=='undefined') var ol_css=CSSOFF;
88 if (typeof ol_fgclass=='undefined') var ol_fgclass="";
89 if (typeof ol_bgclass=='undefined') var ol_bgclass="";
90 if (typeof ol_textfontclass=='undefined') var ol_textfontclass="";
91 if (typeof ol_captionfontclass=='undefined') var ol_captionfontclass="";
92 if (typeof ol_closefontclass=='undefined') var ol_closefontclass="";
93
94 ////////
95 // ARRAY CONFIGURATION
96 ////////
97
98 // You can use these arrays to store popup text here instead of in the html.
99 if (typeof ol_texts=='undefined') var ol_texts = new Array("Text 0", "Text 1");
100 if (typeof ol_caps=='undefined') var ol_caps = new Array("Caption 0", "Caption 1");
101
102 ////////
103 // END OF CONFIGURATION
104 // Don't change anything below this line, all configuration is above.
105 ////////
106
107
108
109
110
111 ////////
112 // INIT
113 ////////
114 // Runtime variables init. Don't change for config!
115 var o3_text="";
116 var o3_cap="";
117 var o3_sticky=0;
118 var o3_background="";
119 var o3_close="Close";
120 var o3_hpos=RIGHT;
121 var o3_offsetx=2;
122 var o3_offsety=2;
123 var o3_fgcolor="";
124 var o3_bgcolor="";
125 var o3_textcolor="";
126 var o3_capcolor="";
127 var o3_closecolor="";
128 var o3_width=100;
129 var o3_border=1;
130 var o3_cellpad=2;
131 var o3_status="";
132 var o3_autostatus=0;
133 var o3_height=-1;
134 var o3_snapx=0;
135 var o3_snapy=0;
136 var o3_fixx=-1;
137 var o3_fixy=-1;
138 var o3_relx=null;
139 var o3_rely=null;
140 var o3_fgbackground="";
141 var o3_bgbackground="";
142 var o3_padxl=0;
143 var o3_padxr=0;
144 var o3_padyt=0;
145 var o3_padyb=0;
146 var o3_fullhtml=0;
147 var o3_vpos=BELOW;
148 var o3_aboveheight=0;
149 var o3_capicon="";
150 var o3_textfont="Verdana,Arial,Helvetica";
151 var o3_captionfont="Verdana,Arial,Helvetica";
152 var o3_closefont="Verdana,Arial,Helvetica";
153 var o3_textsize="1";
154 var o3_captionsize="1";
155 var o3_closesize="1";
156 var o3_frame=self;
157 var o3_timeout=0;
158 var o3_timerid=0;
159 var o3_allowmove=0;
160 var o3_function=null; 
161 var o3_delay=0;
162 var o3_delayid=0;
163 var o3_hauto=0;
164 var o3_vauto=0;
165 var o3_closeclick=0;
166 var o3_wrap=0;
167 var o3_followmouse=1;
168 var o3_mouseoff=0;
169 var o3_closetitle='';
170 var o3_css=CSSOFF;
171 var o3_fgclass="";
172 var o3_bgclass="";
173 var o3_textfontclass="";
174 var o3_captionfontclass="";
175 var o3_closefontclass="";
176
177 // Display state variables
178 var o3_x = 0;
179 var o3_y = 0;
180 var o3_showingsticky = 0;
181 var o3_removecounter = 0;
182
183 // Our layer
184 var over = null;
185 var fnRef, hoveringSwitch = false;
186
187 // Decide browser version
188 var isMac = (navigator.userAgent.indexOf("Mac") != -1);
189 var olOp = (navigator.userAgent.toLowerCase().indexOf('opera 7.') > -1);
190 var olNs4 = (navigator.appName=='Netscape' && parseInt(navigator.appVersion) == 4);
191 var olNs6 = (document.getElementById) ? true : false;
192 var olIe4 = (document.all) ? true : false;
193 var olIe5 = false; 
194 var olIe55 = false; // Added additional variable to identify IE5.5+
195 var docRoot = 'document.body';
196
197 // Resize fix for NS4.x to keep track of layer
198 if (olNs4) {
199         var oW = window.innerWidth;
200         var oH = window.innerHeight;
201         window.onresize = function() { if (oW != window.innerWidth || oH != window.innerHeight) location.reload(); }
202 }
203
204 // Microsoft Stupidity Check(tm).
205 if (olIe4) {
206         var versNum=parseFloat(navigator.userAgent.match(/MSIE (\d\.\d+)\.*/i)[1]);
207         if (versNum >= 5){
208                 olIe5=true;
209                 olIe55=(versNum>=5.5&&!olOp) ? true : false;
210                 if (olNs6) olNs6=false;
211         }
212         if (olNs6) olIe4 = false;
213 }
214
215 // Check for compatability mode.
216 if (document.compatMode && document.compatMode == 'CSS1Compat') {
217         docRoot= ((olIe4 && !olOp) ? 'document.documentElement' : docRoot);
218 }
219
220 // Add window onload handlers to indicate when all modules have been loaded
221 // For Netscape 6+ and Mozilla, uses addEventListener method on the window object
222 // For IE it uses the attachEvent method of the window object and for Netscape 4.x
223 // it sets the window.onload handler to the OLonload_handler function
224 if(window.addEventListener) window.addEventListener("load",OLonLoad_handler,true);
225 else if (window.attachEvent) window.attachEvent("onload",OLonLoad_handler);
226 else window.onload=OLonLoad_handler;
227
228 // Capture events, alt. diffuses the overlib function.
229 var olCheckMouseCapture = true;
230 if ((olNs4 || olNs6 || olIe4)) {
231         olMouseCapture();
232 } else {
233         overlib = no_overlib;
234         nd = no_overlib;
235         ver3fix = true;
236 }
237
238
239 ////////
240 // PUBLIC FUNCTIONS
241 ////////
242
243 // overlib(arg0,...,argN)
244 // Loads parameters into global runtime variables.
245 function overlib() {
246         if (!olLoaded || isExclusive(overlib.arguments)) return true;
247         if (olCheckMouseCapture) olMouseCapture();
248         if (over) cClick();
249
250         // Load defaults to runtime.
251         o3_text=ol_text;
252         o3_cap=ol_cap;
253         o3_sticky=ol_sticky;
254         o3_background=ol_background;
255         o3_close=ol_close;
256         o3_hpos=ol_hpos;
257         o3_offsetx=ol_offsetx;
258         o3_offsety=ol_offsety;
259         o3_fgcolor=ol_fgcolor;
260         o3_bgcolor=ol_bgcolor;
261         o3_textcolor=ol_textcolor;
262         o3_capcolor=ol_capcolor;
263         o3_closecolor=ol_closecolor;
264         o3_width=ol_width;
265         o3_border=ol_border;
266         o3_cellpad=ol_cellpad;
267         o3_status=ol_status;
268         o3_autostatus=ol_autostatus;
269         o3_height=ol_height;
270         o3_snapx=ol_snapx;
271         o3_snapy=ol_snapy;
272         o3_fixx=ol_fixx;
273         o3_fixy=ol_fixy;
274         o3_relx=ol_relx;
275         o3_rely=ol_rely;
276         o3_fgbackground=ol_fgbackground;
277         o3_bgbackground=ol_bgbackground;
278         o3_padxl=ol_padxl;
279         o3_padxr=ol_padxr;
280         o3_padyt=ol_padyt;
281         o3_padyb=ol_padyb;
282         o3_fullhtml=ol_fullhtml;
283         o3_vpos=ol_vpos;
284         o3_aboveheight=ol_aboveheight;
285         o3_capicon=ol_capicon;
286         o3_textfont=ol_textfont;
287         o3_captionfont=ol_captionfont;
288         o3_closefont=ol_closefont;
289         o3_textsize=ol_textsize;
290         o3_captionsize=ol_captionsize;
291         o3_closesize=ol_closesize;
292         o3_timeout=ol_timeout;
293         o3_function=ol_function;
294         o3_delay=ol_delay;
295         o3_hauto=ol_hauto;
296         o3_vauto=ol_vauto;
297         o3_closeclick=ol_closeclick;
298         o3_wrap=ol_wrap;        
299         o3_followmouse=ol_followmouse;
300         o3_mouseoff=ol_mouseoff;
301         o3_closetitle=ol_closetitle;
302         o3_css=ol_css;
303         o3_fgclass=ol_fgclass;
304         o3_bgclass=ol_bgclass;
305         o3_textfontclass=ol_textfontclass;
306         o3_captionfontclass=ol_captionfontclass;
307         o3_closefontclass=ol_closefontclass;
308         
309         setRunTimeVariables();
310         
311         fnRef = '';
312         
313         // Special for frame support, over must be reset...
314         o3_frame = ol_frame;
315         
316         if (olNs4) {
317                 over = o3_frame.document.layers['overDiv'];
318         } else if (document.all) {
319                 over = o3_frame.document.all['overDiv'];
320         } else if (document.getElementById) {
321                 over = o3_frame.document.getElementById("overDiv");
322         }
323
324         parseTokens('o3_', overlib.arguments);
325         if (!postParseChecks()) return false;
326
327         if (o3_delay == 0) {
328                 return runHook("olMain", FREPLACE);
329         } else {
330                 o3_delayid = setTimeout("runHook('olMain', FREPLACE)", o3_delay);
331                 return false;
332         }
333 }
334
335 // Clears popups if appropriate
336 function nd(time) {
337         if (olLoaded && !isExclusive()) {
338                 if (time && !o3_delay) {
339                         if (o3_timerid > 0) clearTimeout(o3_timerid);
340                         
341                         o3_timerid = setTimeout("cClick()",(o3_timeout = time));
342                 }
343                 if (o3_removecounter >= 1) { o3_showingsticky = 0 };
344                 
345                 if (o3_showingsticky == 0) {
346                         o3_allowmove = 0;
347                         if (over != null && o3_timerid == 0) runHook("hideObject", FREPLACE, over);
348                 } else {
349                         o3_removecounter++;
350                 }
351         }
352         
353         return true;
354 }
355
356 // The Close onMouseOver function for stickies
357 function cClick() {
358         if (olLoaded) {
359                 runHook("hideObject", FREPLACE, over);
360                 o3_showingsticky = 0;   
361         }       
362         return false;
363 }
364
365 // Method for setting page specific defaults.
366 function overlib_pagedefaults() {
367         parseTokens('ol_', overlib_pagedefaults.arguments);
368 }
369
370
371 ////////
372 // OVERLIB MAIN FUNCTION
373 ////////
374
375 // This function decides what it is we want to display and how we want it done.
376 function olMain() {
377         var layerhtml, styleType;
378         runHook("olMain", FBEFORE);
379         
380         if (o3_background!="" || o3_fullhtml) {
381                 // Use background instead of box.
382                 layerhtml = runHook('ol_content_background', FALTERNATE, o3_css, o3_text, o3_background, o3_fullhtml);
383         } else {
384                 // They want a popup box.
385                 styleType = (pms[o3_css-1-pmStart] == "cssoff" || pms[o3_css-1-pmStart] == "cssclass");
386
387                 // Prepare popup background
388                 if (o3_fgbackground != "") o3_fgbackground = "background=\""+o3_fgbackground+"\"";
389                 if (o3_bgbackground != "") o3_bgbackground = (styleType ? "background=\""+o3_bgbackground+"\"" : o3_bgbackground);
390
391                 // Prepare popup colors
392                 if (o3_fgcolor != "") o3_fgcolor = (styleType ? "bgcolor=\""+o3_fgcolor+"\"" : o3_fgcolor);
393                 if (o3_bgcolor != "") o3_bgcolor = (styleType ? "bgcolor=\""+o3_bgcolor+"\"" : o3_bgcolor);
394
395                 // Prepare popup height
396                 if (o3_height > 0) o3_height = (styleType ? "height=\""+o3_height+"\"" : o3_height);
397                 else o3_height = "";
398
399                 // Decide which kinda box.
400                 if (o3_cap=="") {
401                         // Plain
402                         layerhtml = runHook('ol_content_simple', FALTERNATE, o3_css, o3_text);
403                 } else {
404                         // With caption
405                         if (o3_sticky) {
406                                 // Show close text
407                                 layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, o3_close);
408                         } else {
409                                 // No close text
410                                 layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, "");
411                         }
412                 }
413         }       
414
415         // We want it to stick!
416         if (o3_sticky) {
417                 if (o3_timerid > 0) {
418                         clearTimeout(o3_timerid);
419                         o3_timerid = 0;
420                 }
421                 o3_showingsticky = 1;
422                 o3_removecounter = 0;
423         }
424
425         // Created a separate routine to generate the popup to make it easier
426         // to implement a plugin capability
427         if (!runHook("createPopup", FREPLACE, layerhtml)) return false;
428
429         // Prepare status bar
430         if (o3_autostatus > 0) {
431                 o3_status = o3_text;
432                 if (o3_autostatus > 1) o3_status = o3_cap;
433         }
434
435         // When placing the layer the first time, even stickies may be moved.
436         o3_allowmove = 0;
437
438         // Initiate a timer for timeout
439         if (o3_timeout > 0) {          
440                 if (o3_timerid > 0) clearTimeout(o3_timerid);
441                 o3_timerid = setTimeout("cClick()", o3_timeout);
442         }
443
444         // Show layer
445         runHook("disp", FREPLACE, o3_status);
446         runHook("olMain", FAFTER);
447
448         if (o3_status != '') {
449                 return true;
450         } else {
451                 return;
452         }
453 }
454
455 ////////
456 // LAYER GENERATION FUNCTIONS
457 ////////
458 // These functions just handle popup content with tags that should adhere to the W3C standards specification.
459
460 // Makes simple table without caption
461 function ol_content_simple(text) {
462         txt='<table width="'+o3_width+ '" border="0" cellpadding="'+o3_border+'" cellspacing="0" '+(o3_bgclass ? 'class="'+o3_bgclass+'"' : o3_bgcolor+' '+o3_height)+'><tr><td><table width="100%" border="0" cellpadding="' + o3_cellpad + '" cellspacing="0" '+(o3_fgclass ? 'class="'+o3_fgclass+'"' : o3_fgcolor+' '+o3_fgbackground+' '+o3_height)+'><tr><td valign="TOP"'+(o3_textfontclass ? ' class="'+o3_textfontclass+'">' : '>')+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize))+'</td></tr></table></td></tr></table>';
463
464         set_background("");
465         return txt;
466 }
467
468 // Makes table with caption and optional close link
469 function ol_content_caption(text,title,close) {
470         var nameId;
471         closing="";
472         closeevent="onmouseover";
473         if (o3_closeclick==1) closeevent= (o3_closetitle ? "title='" + o3_closetitle +"'" : "") + " onclick";
474         if (o3_capicon!="") {
475                 nameId=' hspace=\"5\"'+' align=\"middle\" alt=\"\"';
476                 if (typeof o3_dragimg!='undefined'&&o3_dragimg) nameId=' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"';
477                 o3_capicon='<img src=\"'+o3_capicon+'\"'+nameId+' />';
478         }
479
480         if (close != "") closing='<td '+(o3_closefontclass ? 'class="'+o3_closefontclass : 'align="RIGHT')+'"><a href="javascript:return '+fnRef+'cClick();" '+closeevent+'="return '+fnRef+'cClick();">'+(o3_closefontclass ? '' : wrapStr(0,o3_closesize,'close'))+close+(o3_closefontclass ? '' : wrapStr(1,o3_closesize,'close'))+'</a></td>';
481         txt='<table width="'+o3_width+ '" border="0" cellpadding="'+o3_border+'" cellspacing="0" '+(o3_bgclass ? 'class="'+o3_bgclass+'"' : o3_bgcolor+' '+o3_bgbackground+' '+o3_height)+'><tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td'+(o3_captionfontclass ? ' class="'+o3_captionfontclass+'">' : '>')+(o3_captionfontclass ? '' : '<b>'+wrapStr(0,o3_captionsize,'caption'))+o3_capicon+title+(o3_captionfontclass ? '' : wrapStr(1,o3_captionsize)+'</b>')+'</td>'+closing+'</tr></table><table width="100%" border="0" cellpadding="' + o3_cellpad + '" cellspacing="0" '+(o3_fgclass ? 'class="'+o3_fgclass+'"' : o3_fgcolor+' '+o3_fgbackground+' '+o3_height)+'><tr><td valign="TOP"'+(o3_textfontclass ? ' class="'+o3_textfontclass+'">' :'>')+(o3_textfontclass ? '' : wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass ? '' : wrapStr(1,o3_textsize)) + '</td></tr></table></td></tr></table>';
482
483         set_background("");
484         return txt;
485 }
486
487 // Sets the background picture,padding and lots more. :)
488 function ol_content_background(text,picture,hasfullhtml) {
489         if (hasfullhtml) {
490                 txt=text;
491         } else {
492                 txt='<table width="'+o3_width+'" border="0" cellpadding="0" cellspacing="0" height="'+o3_height+'"><tr><td colspan="3" height="'+o3_padyt+'"></td></tr><tr><td width="'+o3_padxl+'"></td><td valign="TOP" width="'+(o3_width-o3_padxl-o3_padxr)+'">'+wrapStr(0,o3_textsize,'text')+text+wrapStr(1,o3_textsize)+'</td><td width="'+o3_padxr+'"></td></tr><tr><td colspan="3" height="'+o3_padyb+'"></td></tr></table>';
493         }
494
495         set_background(picture);
496         return txt;
497 }
498
499 // Loads a picture into the div.
500 function set_background(pic) {
501         if (pic == "") {
502                 if (olNs4) {
503                         over.background.src = null; 
504                 } else if (over.style) {
505                         over.style.backgroundImage = "none";
506                 }
507         } else {
508                 if (olNs4) {
509                         over.background.src = pic;
510                 } else if (over.style) {
511                         over.style.backgroundImage = "url("+pic+")";
512                 }
513         }
514 }
515
516 ////////
517 // HANDLING FUNCTIONS
518 ////////
519
520 // Displays the popup
521 function disp(statustext) {
522         runHook("disp", FBEFORE);
523         
524         if (o3_allowmove == 0) {
525                 runHook("placeLayer", FREPLACE);
526                 runHook("showObject", FREPLACE, over);
527                 o3_allowmove = (o3_sticky || o3_followmouse==0) ? 0 : 1;
528         }
529         
530         runHook("disp", FAFTER);
531
532         if (statustext != "") self.status = statustext;
533 }
534
535 // Creates the actual popup structure
536 function createPopup(lyrContent){
537         runHook("createPopup", FBEFORE);
538         
539         if (o3_wrap && !(olNs4 || olOp)) {
540                 if (olIe4) {
541                         over.style.pixelWidth = 0;
542                 } else if (olNs6) {
543                         repositionTo(over, 0, -over.offsetHeight);
544                 }
545         }
546
547         layerWrite(lyrContent);
548         
549         // Have to set o3_width for placeLayer() routine if o3_wrap is turned on
550         if (o3_wrap) o3_width=(olNs4 ? over.clip.width : over.offsetWidth);
551         
552         runHook("createPopup", FAFTER, lyrContent);
553
554         return true;
555 }
556
557 // Decides where we want the popup.
558 function placeLayer() {
559         var placeX, placeY, widthFix = 0;
560         
561         // HORIZONTAL PLACEMENT
562         if (eval('o3_frame.'+docRoot) && eval("typeof o3_frame."+docRoot+".clientWidth=='number'") && eval('o3_frame.'+docRoot+'.clientWidth')) {
563                 iwidth = eval('o3_frame.'+docRoot+'.clientWidth');
564         } else if (typeof(o3_frame.innerWidth) == 'number') {
565                 widthFix = Math.ceil(1.2*(o3_frame.outerWidth - o3_frame.innerWidth));
566                 iwidth = o3_frame.innerWidth;
567         }
568
569         // Horizontal scroll offset
570         winoffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollLeft') : o3_frame.pageXOffset;
571         var parsedWidth = parseInt(o3_width);
572
573         if (o3_fixx > -1 || o3_relx != null) {
574                 // Fixed position
575                 placeX=(o3_relx != null ? ( o3_relx < 0 ? winoffset +o3_relx+ iwidth - parsedWidth - widthFix : winoffset+o3_relx) : o3_fixx);
576         } else {  
577                 // If HAUTO, decide what to use.
578                 if (o3_hauto == 1) {
579                         if ((o3_x - winoffset) > (iwidth / 2)) {
580                                 o3_hpos = LEFT;
581                         } else {
582                                 o3_hpos = RIGHT;
583                         }
584                 }               
585
586                 // From mouse
587                 if (o3_hpos == CENTER) { // Center
588                         placeX = o3_x+o3_offsetx-(parsedWidth/2);
589
590                         if (placeX < winoffset) placeX = winoffset;
591                 }
592
593                 if (o3_hpos == RIGHT) { // Right
594                         placeX = o3_x+o3_offsetx;
595
596                         if ((placeX+parsedWidth) > (winoffset+iwidth - widthFix)) {
597                                 placeX = iwidth+winoffset - parsedWidth - widthFix;
598                                 if (placeX < 0) placeX = 0;
599                         }
600                 }
601                 if (o3_hpos == LEFT) { // Left
602                         placeX = o3_x-o3_offsetx-parsedWidth;
603                         if (placeX < winoffset) placeX = winoffset;
604                 }       
605
606                 // Snapping!
607                 if (o3_snapx > 1) {
608                         var snapping = placeX % o3_snapx;
609
610                         if (o3_hpos == LEFT) {
611                                 placeX = placeX - (o3_snapx+snapping);
612                         } else {
613                                 // CENTER and RIGHT
614                                 placeX = placeX+(o3_snapx - snapping);
615                         }
616
617                         if (placeX < winoffset) placeX = winoffset;
618                 }
619         }       
620
621         // VERTICAL PLACEMENT
622         if (eval('o3_frame.'+docRoot) && eval("typeof o3_frame."+docRoot+".clientHeight=='number'") && eval('o3_frame.'+docRoot+'.clientHeight')) {
623                 iheight = eval('o3_frame.'+docRoot+'.clientHeight');
624         } else if (typeof(o3_frame.innerHeight)=='number') {
625                 iheight = o3_frame.innerHeight;
626         }
627
628         // Vertical scroll offset
629         scrolloffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollTop') : o3_frame.pageYOffset;
630         var parsedHeight=(o3_aboveheight ? parseInt(o3_aboveheight) : (olNs4 ? over.clip.height : over.offsetHeight));
631
632         if (o3_fixy > -1 || o3_rely != null) {
633                 // Fixed position
634                 placeY=(o3_rely != null ? (o3_rely < 0 ? scrolloffset+o3_rely+iheight - parsedHeight : scrolloffset+o3_rely) : o3_fixy);
635         } else {
636                 // If VAUTO, decide what to use.
637                 if (o3_vauto == 1) {  
638                         if ((o3_y - scrolloffset) > (iheight/2)) {
639                                 o3_vpos = ABOVE;
640                         } else {
641                                 o3_vpos = BELOW;
642                         }
643                 }
644
645                 // From mouse
646                 if (o3_vpos == ABOVE) {
647                         if (o3_aboveheight == 0) o3_aboveheight = parsedHeight; 
648
649                         placeY = o3_y - (o3_aboveheight+o3_offsety);
650                         if (placeY < scrolloffset) placeY = scrolloffset;
651                 } else {
652                         // BELOW
653                         placeY = o3_y+o3_offsety;
654                 } 
655
656                 // Snapping!
657                 if (o3_snapy > 1) {
658                         var snapping = placeY % o3_snapy;                       
659
660                         if (o3_aboveheight > 0 && o3_vpos == ABOVE) {
661                                 placeY = placeY - (o3_snapy+snapping);
662                         } else {
663                                 placeY = placeY+(o3_snapy - snapping);
664                         }                       
665
666                         if (placeY < scrolloffset) placeY = scrolloffset;
667                 }
668         }
669
670         // Actually move the object.
671         repositionTo(over, placeX, placeY);
672 }
673
674 // Moves the layer
675 function olMouseMove(e) {
676         var e = (e) ? e : event;
677
678         if (e.pageX) {
679                 o3_x = e.pageX;
680                 o3_y = e.pageY;
681         } else if (e.clientX) {
682                 o3_x = eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft');
683                 o3_y = eval('e.clientY+o3_frame.'+docRoot+'.scrollTop');
684         }
685         
686         if (o3_allowmove == 1) runHook("placeLayer", FREPLACE);
687
688         // MouseOut handler
689         if (hoveringSwitch && !olNs4 && runHook("cursorOff", FREPLACE)) {
690                 cClick();
691                 hoveringSwitch = !hoveringSwitch;
692         }
693 }
694
695 // Fake function for 3.0 users.
696 function no_overlib() { return ver3fix; }
697
698 // Capture the mouse and chain other scripts.
699 function olMouseCapture() {
700         capExtent = document;
701         var fN, mseHandler = olMouseMove;
702         var re = /function[ ]+(\w+)\(/;
703         
704         if (document.onmousemove || (!olIe4 && window.onmousemove)) {
705                 if (window.onmousemove) capExtent = window;
706                 fN = capExtent.onmousemove.toString().match(re);
707
708                 if (fN[1] == 'anonymous' || fN[1] == 'olMouseMove') {
709                         olCheckMouseCapture = false;
710                         return;
711                 }
712                 var str = fN[1]+'(e); ' + 'olMouseMove(e); ';
713                 mseHandler = new Function('e', str);
714         }
715
716         capExtent.onmousemove = mseHandler;
717         if (olNs4) capExtent.captureEvents(Event.MOUSEMOVE);
718 }
719
720
721 ////////
722 // PARSING FUNCTIONS
723 ////////
724
725 // Does the actual command parsing.
726 function parseTokens(pf, ar) {
727         // What the next argument is expected to be.
728         var v, mode=-1, par = (pf != 'ol_');    
729         var fnMark = (par && !ar.length ? 1 : 0);
730
731         for (i = 0; i < ar.length; i++) {
732                 if (mode < 0) {
733                         // Arg is maintext,unless its a number between pmStart and pmUpper
734                         // then its a command.
735                         if (typeof ar[i] == 'number' && ar[i] > pmStart && ar[i] < pmUpper) {
736                                 fnMark = (par ? 1 : 0);
737                                 i--;   // backup one so that the next block can parse it
738                         } else {
739                                 switch(pf) {
740                                         case 'ol_':
741                                                 ol_text = ar[i].toString();
742                                                 break;
743                                         default:
744                                                 o3_text=ar[i].toString();  
745                                 }
746                         }
747                         mode = 0;
748                 } else {
749                         // Note: NS4 doesn't like switch cases with vars.
750                         if (ar[i] >= pmCount || ar[i]==DONOTHING) { continue; }
751                         if (ar[i]==INARRAY) { fnMark = 0; eval(pf+'text=ol_texts['+ar[++i]+'].toString()'); continue; }
752                         if (ar[i]==CAPARRAY) { eval(pf+'cap=ol_caps['+ar[++i]+'].toString()'); continue; }
753                         if (ar[i]==STICKY) { if (pf!='ol_') eval(pf+'sticky=1'); continue; }
754                         if (ar[i]==BACKGROUND) { eval(pf+'background="'+ar[++i]+'"'); continue; }
755                         if (ar[i]==NOCLOSE) { if (pf!='ol_') opt_NOCLOSE(); continue; }
756                         if (ar[i]==CAPTION) { eval(pf+"cap='"+escSglQuote(ar[++i])+"'"); continue; }
757                         if (ar[i]==CENTER || ar[i]==LEFT || ar[i]==RIGHT) { eval(pf+'hpos='+ar[i]); continue; }
758                         if (ar[i]==OFFSETX) { eval(pf+'offsetx='+ar[++i]); continue; }
759                         if (ar[i]==OFFSETY) { eval(pf+'offsety='+ar[++i]); continue; }
760                         if (ar[i]==FGCOLOR) { eval(pf+'fgcolor="'+ar[++i]+'"'); continue; }
761                         if (ar[i]==BGCOLOR) { eval(pf+'bgcolor="'+ar[++i]+'"'); continue; }
762                         if (ar[i]==TEXTCOLOR) { eval(pf+'textcolor="'+ar[++i]+'"'); continue; }
763                         if (ar[i]==CAPCOLOR) { eval(pf+'capcolor="'+ar[++i]+'"'); continue; }
764                         if (ar[i]==CLOSECOLOR) { eval(pf+'closecolor="'+ar[++i]+'"'); continue; }
765                         if (ar[i]==WIDTH) { eval(pf+'width='+ar[++i]); continue; }
766                         if (ar[i]==BORDER) { eval(pf+'border='+ar[++i]); continue; }
767                         if (ar[i]==CELLPAD) { i=opt_MULTIPLEARGS(++i,ar,(pf+'cellpad')); continue; }
768                         if (ar[i]==STATUS) { eval(pf+"status='"+escSglQuote(ar[++i])+"'"); continue; }
769                         if (ar[i]==AUTOSTATUS) { eval(pf +'autostatus=('+pf+'autostatus == 1) ? 0 : 1'); continue; }
770                         if (ar[i]==AUTOSTATUSCAP) { eval(pf +'autostatus=('+pf+'autostatus == 2) ? 0 : 2'); continue; }
771                         if (ar[i]==HEIGHT) { eval(pf+'height='+pf+'aboveheight='+ar[++i]); continue; } // Same param again.
772                         if (ar[i]==CLOSETEXT) { eval(pf+"close='"+escSglQuote(ar[++i])+"'"); continue; }
773                         if (ar[i]==SNAPX) { eval(pf+'snapx='+ar[++i]); continue; }
774                         if (ar[i]==SNAPY) { eval(pf+'snapy='+ar[++i]); continue; }
775                         if (ar[i]==FIXX) { eval(pf+'fixx='+ar[++i]); continue; }
776                         if (ar[i]==FIXY) { eval(pf+'fixy='+ar[++i]); continue; }
777                         if (ar[i]==RELX) { eval(pf+'relx='+ar[++i]); continue; }
778                         if (ar[i]==RELY) { eval(pf+'rely='+ar[++i]); continue; }
779                         if (ar[i]==FGBACKGROUND) { eval(pf+'fgbackground="'+ar[++i]+'"'); continue; }
780                         if (ar[i]==BGBACKGROUND) { eval(pf+'bgbackground="'+ar[++i]+'"'); continue; }
781                         if (ar[i]==PADX) { eval(pf+'padxl='+ar[++i]); eval(pf+'padxr='+ar[++i]); continue; }
782                         if (ar[i]==PADY) { eval(pf+'padyt='+ar[++i]); eval(pf+'padyb='+ar[++i]); continue; }
783                         if (ar[i]==FULLHTML) { if (pf!='ol_') eval(pf+'fullhtml=1'); continue; }
784                         if (ar[i]==BELOW || ar[i]==ABOVE) { eval(pf+'vpos='+ar[i]); continue; }
785                         if (ar[i]==CAPICON) { eval(pf+'capicon="'+ar[++i]+'"'); continue; }
786                         if (ar[i]==TEXTFONT) { eval(pf+"textfont='"+escSglQuote(ar[++i])+"'"); continue; }
787                         if (ar[i]==CAPTIONFONT) { eval(pf+"captionfont='"+escSglQuote(ar[++i])+"'"); continue; }
788                         if (ar[i]==CLOSEFONT) { eval(pf+"closefont='"+escSglQuote(ar[++i])+"'"); continue; }
789                         if (ar[i]==TEXTSIZE) { eval(pf+'textsize="'+ar[++i]+'"'); continue; }
790                         if (ar[i]==CAPTIONSIZE) { eval(pf+'captionsize="'+ar[++i]+'"'); continue; }
791                         if (ar[i]==CLOSESIZE) { eval(pf+'closesize="'+ar[++i]+'"'); continue; }
792                         if (ar[i]==TIMEOUT) { eval(pf+'timeout='+ar[++i]); continue; }
793                         if (ar[i]==FUNCTION) { if (pf=='ol_') { if (typeof ar[i+1]!='number') { v=ar[++i]; ol_function=(typeof v=='function' ? v : null); }} else {fnMark = 0; v = null; if (typeof ar[i+1]!='number') v = ar[++i];  opt_FUNCTION(v); } continue; }
794                         if (ar[i]==DELAY) { eval(pf+'delay='+ar[++i]); continue; }
795                         if (ar[i]==HAUTO) { eval(pf+'hauto=('+pf+'hauto == 0) ? 1 : 0'); continue; }
796                         if (ar[i]==VAUTO) { eval(pf+'vauto=('+pf+'vauto == 0) ? 1 : 0'); continue; }
797                         if (ar[i]==CLOSECLICK) { eval(pf +'closeclick=('+pf+'closeclick == 0) ? 1 : 0'); continue; }
798                         if (ar[i]==WRAP) { eval(pf +'wrap=('+pf+'wrap == 0) ? 1 : 0'); continue; }
799                         if (ar[i]==FOLLOWMOUSE) { eval(pf +'followmouse=('+pf+'followmouse == 1) ? 0 : 1'); continue; }
800                         if (ar[i]==MOUSEOFF) { eval(pf +'mouseoff=('+pf+'mouseoff == 0) ? 1 : 0'); continue; }
801                         if (ar[i]==CLOSETITLE) { eval(pf+"closetitle='"+escSglQuote(ar[++i])+"'"); continue; }
802                         if (ar[i]==CSSOFF||ar[i]==CSSCLASS) { eval(pf+'css='+ar[i]); continue; }
803                         if (ar[i]==FGCLASS) { eval(pf+'fgclass="'+ar[++i]+'"'); continue; }
804                         if (ar[i]==BGCLASS) { eval(pf+'bgclass="'+ar[++i]+'"'); continue; }
805                         if (ar[i]==TEXTFONTCLASS) { eval(pf+'textfontclass="'+ar[++i]+'"'); continue; }
806                         if (ar[i]==CAPTIONFONTCLASS) { eval(pf+'captionfontclass="'+ar[++i]+'"'); continue; }
807                         if (ar[i]==CLOSEFONTCLASS) { eval(pf+'closefontclass="'+ar[++i]+'"'); continue; }
808                         i = parseCmdLine(pf, i, ar);
809                 }
810         }
811
812         if (fnMark && o3_function) o3_text = o3_function();
813         
814         if ((pf == 'o3_') && o3_wrap) {
815                 o3_width = 0;
816                 
817                 if (olOp || (olIe4 && isMac)) {
818                         var tReg=/<.*\n*>/ig;
819                         if (!tReg.test(o3_text)) o3_text = o3_text.replace(/[ ]+/g, '&nbsp;');
820                         if (!tReg.test(o3_cap))o3_cap = o3_cap.replace(/[ ]+/g, '&nbsp;');
821                 }
822         }
823         if ((pf == 'o3_') && o3_sticky) {
824                 if (!o3_close && (o3_frame != ol_frame)) o3_close = ol_close;
825                 if (o3_mouseoff && (o3_frame == ol_frame)) opt_NOCLOSE(' ');
826         }
827 }
828
829
830 ////////
831 // LAYER FUNCTIONS
832 ////////
833
834 // Writes to a layer
835 function layerWrite(txt) {
836         txt += "\n";
837         if (olNs4) {
838                 var lyr = o3_frame.document.overDiv.document
839                 lyr.write(txt)
840                 lyr.close()
841         } else if (typeof over.innerHTML != 'undefined') {
842                 if (olIe5 && isMac) over.innerHTML = '';
843                 over.innerHTML = txt;
844         } else {
845                 range = o3_frame.document.createRange();
846                 range.setStartAfter(over);
847                 domfrag = range.createContextualFragment(txt);
848                 
849                 while (over.hasChildNodes()) {
850                         over.removeChild(over.lastChild);
851                 }
852                 
853                 over.appendChild(domfrag);
854         }
855 }
856
857 // Make an object visible
858 function showObject(obj) {
859         runHook("showObject", FBEFORE);
860
861         var theObj=(olNs4 ? obj : obj.style);
862         theObj.visibility = 'visible';
863
864         runHook("showObject", FAFTER);
865 }
866
867 // Hides an object
868 function hideObject(obj) {
869         runHook("hideObject", FBEFORE);
870
871         var theObj=(olNs4 ? obj : obj.style);
872         theObj.visibility = 'hidden';
873
874         if (o3_timerid > 0) clearTimeout(o3_timerid);
875         if (o3_delayid > 0) clearTimeout(o3_delayid);
876
877         o3_timerid = 0;
878         o3_delayid = 0;
879         self.status = "";
880
881         if (over.onmouseout || over.onmouseover) {
882                 if (olNs4) over.releaseEvents(Event.MOUSEOUT || Event.MOUSEOVER);
883                 over.onmouseout = over.onmouseover = null;
884         }
885
886         runHook("hideObject", FAFTER);
887 }
888
889 // Move a layer
890 function repositionTo(obj, xL, yL) {
891         var theObj=(olNs4 ? obj : obj.style);
892         theObj.left = xL + (!olNs4 ? 'px' : 0);
893         theObj.top = yL + (!olNs4 ? 'px' : 0);
894 }
895
896 // Check position of cursor relative to overDiv DIVision; mouseOut function
897 function cursorOff() {
898         var left = parseInt(over.style.left);
899         var top = parseInt(over.style.top);
900         var right = left+over.offsetWidth;
901         var bottom = top+ over.offsetHeight;
902
903         if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true;
904
905         return false;
906 }
907
908
909 ////////
910 // COMMAND FUNCTIONS
911 ////////
912
913 // Calls callme or the default function.
914 function opt_FUNCTION(callme) {
915         o3_text = (callme ? (typeof callme=='string' ? (/.+\(.*\)/.test(callme) ? eval(callme) : callme) : callme()) : (o3_function ? o3_function() : 'No Function'));
916
917         return 0;
918 }
919
920 // Handle hovering
921 function opt_NOCLOSE(unused) {
922         if (!unused) o3_close = "";
923
924         if (olNs4) {
925                 over.captureEvents(Event.MOUSEOUT || Event.MOUSEOVER);
926                 over.onmouseover = function () { if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid = 0; } }
927                 over.onmouseout = cClick;
928         } else {
929                 over.onmouseover = function () {hoveringSwitch = true; if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid =0; } }
930         }
931
932         return 0;
933 }
934
935 // Function to scan command line arguments for multiples
936 function opt_MULTIPLEARGS(i, args, parameter) {
937   var k = i, l, re, pV, str = '';
938
939   for(k=i; k<args.length; k++) {
940                 str += args[k] + ',';
941                 if(typeof args[k] == 'number'&&args[k]>pmStart) break;
942         }
943   if(k >= args.length) l = str.length-1;
944   else {
945     re = eval('/,' + args[k] + '/');
946     l = str.search(re);
947   }
948
949         k--;  // reduce by one so the for loop this is in works correctly
950         str = str.substring(0, l);
951         pV = (olNs4&&/cellpad/i.test(parameter)) ? str.split(',')[0] : str;
952         eval(parameter + '="' + pV + '"');
953
954         return k;
955 }
956
957 // Remove &nbsp; in texts when done.
958 function nbspCleanup() {
959         if (o3_wrap && (olOp || (olIe4 && isMac))) {
960                 o3_text = o3_text.replace(/\&nbsp;/g, ' ');
961                 o3_cap = o3_cap.replace(/\&nbsp;/g, ' ');
962         }
963 }
964
965 // Escape embedded single quotes in text strings
966 function escSglQuote(str) {
967   return str.toString().replace(/'/g,"\\'");
968 }
969
970 // Onload handler for window onload event
971 function OLonLoad_handler(e) {
972         if (!olLoaded) olLoaded=1;  // indicates that all modules have loaded now
973
974         // remove the OLonload_handler for Ns6+, Mozilla based browsers, and IE
975         if (window.removeEventListener) window.removeEventListener("load",OLonLoad_handler,true);
976         else if (window.detachEvent) window.detachEvent("onload",OLonLoad_handler);
977         
978         // Route the event to the normal handler in Nx4.x
979         if (olNs4) routeEvent(e);
980 }
981
982 // Wraps strings in Layer Generation Functions with the correct tags
983 //    endWrap true(if end tag) or false if start tag
984 //    fontSizeStr - font size string such as '1' or '10px'
985 //    whichString is being wrapped -- 'text', 'caption', or 'close'
986 function wrapStr(endWrap,fontSizeStr,whichString) {
987         var fontStr, fontColor, isClose=((whichString=='close') ? 1 : 0), hasDims=/[%\-a-z]+$/.test(fontSizeStr);
988         fontSizeStr = (olNs4) ? (!hasDims ? fontSizeStr : '1') : fontSizeStr;
989         if (endWrap) return (hasDims&&!olNs4) ? (isClose ? '</span>' : '</div>') : '</font>';
990         else {
991                 fontStr='o3_'+whichString+'font';
992                 fontColor='o3_'+((whichString=='caption')? 'cap' : whichString)+'color';
993                 return (hasDims&&!olNs4) ? (isClose ? '<span style="font-family: '+quoteMultiNameFonts(eval(fontStr))+'; color: '+eval(fontColor)+'; font-size: '+fontSizeStr+';">' : '<div style="font-family: '+quoteMultiNameFonts(eval(fontStr))+'; color: '+eval(fontColor)+'; font-size: '+fontSizeStr+';">') : '<font face="'+eval(fontStr)+'" color="'+eval(fontColor)+'" size="'+(parseInt(fontSizeStr)>7 ? '7' : fontSizeStr)+'">';
994         }
995 }
996
997 // Quotes Multi word font names; needed for CSS Standards adherence in font-family
998 function quoteMultiNameFonts(theFont) {
999         var v, pM=theFont.split(',');
1000         for (var i=0; i<pM.length; i++) {
1001                 v=pM[i];
1002                 v=v.replace(/^\s+/,'').replace(/\s+$/,'');
1003                 if(/\s/.test(v) && !/['"]/.test(v)) {
1004                         v="\'"+v+"\'";
1005                         pM[i]=v;
1006                 }
1007         }
1008         return pM.join();
1009 }
1010
1011 // dummy function which will be overridden 
1012 function isExclusive(args) {
1013         return false;
1014 }
1015 ////////
1016 //  PLUGIN ACTIVATION FUNCTIONS
1017 ////////
1018
1019 // Runs plugin functions to set runtime variables.
1020 function setRunTimeVariables(){
1021         if (typeof runTime != 'undefined' && runTime.length) {
1022                 for (var k = 0; k < runTime.length; k++) {
1023                         runTime[k]();
1024                 }
1025         }
1026 }
1027
1028 // Runs plugin functions to parse commands.
1029 function parseCmdLine(pf, i, args) {
1030         if (typeof cmdLine != 'undefined' && cmdLine.length) { 
1031                 for (var k = 0; k < cmdLine.length; k++) { 
1032                         var j = cmdLine[k](pf, i, args);
1033                         if (j >- 1) {
1034                                 i = j;
1035                                 break;
1036                         }
1037                 }
1038         }
1039
1040         return i;
1041 }
1042
1043 // Runs plugin functions to do things after parse.
1044 function postParseChecks(){
1045         if (typeof postParse != 'undefined' && postParse.length) {
1046                 for (var k = 0; k < postParse.length; k++) {
1047                         if (postParse[k]()) continue;
1048                         return false;  // end now since have an error
1049                 }
1050         }
1051         return true;
1052 }
1053
1054
1055 ////////
1056 //  PLUGIN REGISTRATION FUNCTIONS
1057 ////////
1058
1059 // Registers commands and creates constants.
1060 function registerCommands(cmdStr) {
1061         if (typeof cmdStr!='string') return;
1062
1063         var pM = cmdStr.split(',');
1064         pms = pms.concat(pM);
1065
1066         for (var i = 0; i< pM.length; i++) {
1067                 eval(pM[i].toUpperCase()+'='+pmCount++);
1068         }
1069 }
1070
1071 // Register a function to hook at a certain point.
1072 function registerHook(fnHookTo, fnRef, hookType, optPm) {
1073         var hookPt, last = typeof optPm;
1074         
1075         if (fnHookTo == 'plgIn'||fnHookTo == 'postParse') return;
1076         if (typeof hookPts == 'undefined') hookPts = new Array();
1077         if (typeof hookPts[fnHookTo] == 'undefined') hookPts[fnHookTo] = new FunctionReference();
1078
1079         hookPt = hookPts[fnHookTo];
1080
1081         if (hookType != null) {
1082                 if (hookType == FREPLACE) {
1083                         hookPt.ovload = fnRef;  // replace normal overlib routine
1084                         if (fnHookTo.indexOf('ol_content_') > -1) hookPt.alt[pms[CSSOFF-1-pmStart]]=fnRef; 
1085
1086                 } else if (hookType == FBEFORE || hookType == FAFTER) {
1087                         var hookPt=(hookType == 1 ? hookPt.before : hookPt.after);
1088
1089                         if (typeof fnRef == 'object') {
1090                                 hookPt = hookPt.concat(fnRef);
1091                         } else {
1092                                 hookPt[hookPt.length++] = fnRef;
1093                         }
1094
1095                         if (optPm) hookPt = reOrder(hookPt, fnRef, optPm);
1096
1097                 } else if (hookType == FALTERNATE) {
1098                         if (last=='number') hookPt.alt[pms[optPm-1-pmStart]] = fnRef;
1099                 }
1100
1101                 return;
1102         }
1103 }
1104
1105 // Register a function that will set runtime variables.
1106 function registerRunTimeFunction(fn) {
1107         if (isFunction(fn)) {
1108                 if (typeof runTime == 'undefined') runTime = new Array();
1109                 if (typeof fn == 'object') {
1110                         runTime = runTime.concat(fn);
1111                 } else {
1112                         runTime[runTime.length++] = fn;
1113                 }
1114         }
1115 }
1116
1117 // Register a function that will handle command parsing.
1118 function registerCmdLineFunction(fn){
1119         if (isFunction(fn)) {
1120                 if (typeof cmdLine == 'undefined') cmdLine = new Array();
1121                 if (typeof fn == 'object') {
1122                         cmdLine = cmdLine.concat(fn);
1123                 } else {
1124                         cmdLine[cmdLine.length++] = fn;
1125                 }
1126         }
1127 }
1128
1129 // Register a function that does things after command parsing. 
1130 function registerPostParseFunction(fn){
1131         if (isFunction(fn)) {
1132                 if (typeof postParse == 'undefined') postParse = new Array();
1133                 if (typeof fn == 'object') {
1134                         postParse = postParse.concat(fn);
1135                 } else {
1136                         postParse[postParse.length++] = fn;
1137                 }
1138         }
1139 }
1140
1141 ////////
1142 //  PLUGIN REGISTRATION FUNCTIONS
1143 ////////
1144
1145 // Runs any hooks registered.
1146 function runHook(fnHookTo, hookType) {
1147         var l = hookPts[fnHookTo], optPm, arS, ar = runHook.arguments;
1148
1149         if (hookType == FREPLACE) {
1150                 arS = argToString(ar, 2);
1151
1152                 if (typeof l == 'undefined' || !(l = l.ovload)) return eval(fnHookTo+'('+arS+')');
1153                 else return eval('l('+arS+')');
1154
1155         } else if (hookType == FBEFORE || hookType == FAFTER) {
1156                 if (typeof l == 'undefined') return;
1157                 l=(hookType == 1 ? l.before : l.after);
1158
1159                 if (!l.length) return;
1160
1161                 arS = argToString(ar, 2);
1162                 for (var k = 0; k < l.length; k++) eval('l[k]('+arS+')'); 
1163
1164         } else if (hookType == FALTERNATE) {
1165                 optPm = ar[2];
1166                 arS = argToString(ar, 3);
1167
1168                 if (typeof l == 'undefined' || (l = l.alt[pms[optPm-1-pmStart]]) == 'undefined') {
1169                         return eval(fnHookTo+'('+arS+')');
1170                 } else {
1171                         return eval('l('+arS+')');
1172                 }
1173         }
1174 }
1175
1176 ////////
1177 //  UTILITY FUNCTIONS
1178 ////////
1179
1180 // Checks if something is a function.
1181 function isFunction(fnRef) {
1182         var rtn = true;
1183
1184         if (typeof fnRef == 'object') {
1185                 for (var i = 0; i < fnRef.length; i++) {
1186                         if (typeof fnRef[i]=='function') continue;
1187                         rtn = false;
1188                         break;
1189                 }
1190         } else if (typeof fnRef != 'function') {
1191                 rtn = false;
1192         }
1193         
1194         return rtn;
1195 }
1196
1197 // Converts an array into an argument string for use in eval.
1198 function argToString(array, strtInd, argName) {
1199         var jS = strtInd, aS = '', ar = array;
1200         argName=(argName ? argName : 'ar');
1201         
1202         if (ar.length > jS) {
1203                 for (var k = jS; k < ar.length; k++) aS += argName+'['+k+'], ';
1204                 aS = aS.substring(0, aS.length-2);
1205         }
1206         
1207         return aS;
1208 }
1209
1210 // Places a hook in the correct position in a hook point.
1211 function reOrder(hookPt, fnRef, order) {
1212         if (!order || typeof order == 'undefined' || typeof order == 'number') return;
1213         
1214         var newPt = new Array(), match;
1215
1216         if (typeof order=='function') {
1217                 if (typeof fnRef=='object') {
1218                         newPt = newPt.concat(fnRef);
1219                 } else {
1220                         newPt[newPt.length++]=fnRef;
1221                 }
1222                 
1223                 for (var i = 0; i < hookPt.length; i++) {
1224                         match = false;
1225                         if (typeof fnRef == 'function' && hookPt[i] == fnRef) {
1226                                 continue;
1227                         } else {
1228                                 for(var j = 0; j < fnRef.length; j++) if (hookPt[i] == fnRef[j]) {
1229                                         match = true;
1230                                         break;
1231                                 }
1232                         }
1233                         if (!match) newPt[newPt.length++] = hookPt[i];
1234                 }
1235
1236                 newPt[newPt.length++] = order;
1237
1238         } else if (typeof order == 'object') {
1239                 if (typeof fnRef == 'object') {
1240                         newPt = newPt.concat(fnRef);
1241                 } else {
1242                         newPt[newPt.length++] = fnRef;
1243                 }
1244                 
1245                 for (var j = 0; j < hookPt.length; j++) {
1246                         match = false;
1247                         if (typeof fnRef == 'function' && hookPt[j] == fnRef) {
1248                                 continue;
1249                         } else {
1250                                 for (var i = 0; i < fnRef.length; i++) if (hookPt[j] == fnRef[i]) {
1251                                         match = true;
1252                                         break;
1253                                 }
1254                         }
1255                         if (!match) newPt[newPt.length++]=hookPt[j];
1256                 }
1257
1258                 for (i = 0; i < newPt.length; i++) hookPt[i] = newPt[i];
1259                 newPt.length = 0;
1260                 
1261                 for (var j = 0; j < hookPt.length; j++) {
1262                         match = false;
1263                         for (var i = 0; i < order.length; i++) {
1264                                 if (hookPt[j] == order[i]) {
1265                                         match = true;
1266                                         break;
1267                                 }
1268                         }
1269                         if (!match) newPt[newPt.length++] = hookPt[j];
1270                 }
1271                 newPt = newPt.concat(order);
1272         }
1273
1274         for(i = 0; i < newPt.length; i++) hookPt[i] = newPt[i];
1275
1276         return hookPt;
1277 }
1278
1279 ////////
1280 // OBJECT CONSTRUCTORS
1281 ////////
1282
1283 // Object for handling hooks.
1284 function FunctionReference() {
1285         this.ovload = null;
1286         this.before = new Array();
1287         this.after = new Array();
1288         this.alt = new Array();
1289 }
1290
1291 // Object for simple access to the overLIB version used.
1292 // Examples: simpleversion:351 major:3 minor:5 revision:1
1293 function Info(version, prerelease) {
1294         this.version = version;
1295         this.prerelease = prerelease;
1296
1297         this.simpleversion = parseInt(this.version*100);
1298         this.major = parseInt(this.simpleversion / 100);
1299         this.minor = parseInt(this.simpleversion / 10) - this.major * 10;
1300         this.revision = parseInt(this.simpleversion) - this.major * 100 - this.minor * 10;
1301 }
1302
1303
1304
1305 ////////
1306 // STANDARD REGISTRATIONS
1307 ////////
1308 registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSOFF);
1309 registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSOFF);
1310 registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSOFF);
1311 registerHook("ol_content_simple", ol_content_simple, FALTERNATE, CSSCLASS);
1312 registerHook("ol_content_caption", ol_content_caption, FALTERNATE, CSSCLASS);
1313 registerHook("ol_content_background", ol_content_background, FALTERNATE, CSSCLASS);
1314 registerHook("hideObject", nbspCleanup, FAFTER);
1315