2 //\ overLIB 4.00 - You may not remove or change this notice.
3 //\ Copyright Erik Bosrup 1998-2004. All rights reserved.
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/
9 //\ Please read the license agreement (available through the link above)
10 //\ before using overLIB. Direct any licensing questions to erik@bosrup.com.
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
23 // Ignore these lines, configuration is below.
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');
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.
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="";
95 // ARRAY CONFIGURATION
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");
103 // END OF CONFIGURATION
104 // Don't change anything below this line, all configuration is above.
114 // Runtime variables init. Don't change for config!
118 var o3_background="";
119 var o3_close="Close";
127 var o3_closecolor="";
140 var o3_fgbackground="";
141 var o3_bgbackground="";
148 var o3_aboveheight=0;
150 var o3_textfont="Verdana,Arial,Helvetica";
151 var o3_captionfont="Verdana,Arial,Helvetica";
152 var o3_closefont="Verdana,Arial,Helvetica";
154 var o3_captionsize="1";
155 var o3_closesize="1";
160 var o3_function=null;
167 var o3_followmouse=1;
169 var o3_closetitle='';
173 var o3_textfontclass="";
174 var o3_captionfontclass="";
175 var o3_closefontclass="";
177 // Display state variables
180 var o3_showingsticky = 0;
181 var o3_removecounter = 0;
185 var fnRef, hoveringSwitch = false;
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;
194 var olIe55 = false; // Added additional variable to identify IE5.5+
195 var docRoot = 'document.body';
197 // Resize fix for NS4.x to keep track of layer
199 var oW = window.innerWidth;
200 var oH = window.innerHeight;
201 window.onresize = function() { if (oW != window.innerWidth || oH != window.innerHeight) location.reload(); }
204 // Microsoft Stupidity Check(tm).
206 var versNum=parseFloat(navigator.userAgent.match(/MSIE (\d\.\d+)\.*/i)[1]);
209 olIe55=(versNum>=5.5&&!olOp) ? true : false;
210 if (olNs6) olNs6=false;
212 if (olNs6) olIe4 = false;
215 // Check for compatability mode.
216 if (document.compatMode && document.compatMode == 'CSS1Compat') {
217 docRoot= ((olIe4 && !olOp) ? 'document.documentElement' : docRoot);
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;
228 // Capture events, alt. diffuses the overlib function.
229 var olCheckMouseCapture = true;
230 if ((olNs4 || olNs6 || olIe4)) {
233 overlib = no_overlib;
243 // overlib(arg0,...,argN)
244 // Loads parameters into global runtime variables.
246 if (!olLoaded || isExclusive(overlib.arguments)) return true;
247 if (olCheckMouseCapture) olMouseCapture();
250 // Load defaults to runtime.
254 o3_background=ol_background;
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;
266 o3_cellpad=ol_cellpad;
268 o3_autostatus=ol_autostatus;
276 o3_fgbackground=ol_fgbackground;
277 o3_bgbackground=ol_bgbackground;
282 o3_fullhtml=ol_fullhtml;
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;
297 o3_closeclick=ol_closeclick;
299 o3_followmouse=ol_followmouse;
300 o3_mouseoff=ol_mouseoff;
301 o3_closetitle=ol_closetitle;
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;
309 setRunTimeVariables();
313 // Special for frame support, over must be reset...
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");
324 parseTokens('o3_', overlib.arguments);
325 if (!postParseChecks()) return false;
328 return runHook("olMain", FREPLACE);
330 o3_delayid = setTimeout("runHook('olMain', FREPLACE)", o3_delay);
335 // Clears popups if appropriate
337 if (olLoaded && !isExclusive()) {
338 if (time && !o3_delay) {
339 if (o3_timerid > 0) clearTimeout(o3_timerid);
341 o3_timerid = setTimeout("cClick()",(o3_timeout = time));
343 if (o3_removecounter >= 1) { o3_showingsticky = 0 };
345 if (o3_showingsticky == 0) {
347 if (over != null && o3_timerid == 0) runHook("hideObject", FREPLACE, over);
356 // The Close onMouseOver function for stickies
359 runHook("hideObject", FREPLACE, over);
360 o3_showingsticky = 0;
365 // Method for setting page specific defaults.
366 function overlib_pagedefaults() {
367 parseTokens('ol_', overlib_pagedefaults.arguments);
372 // OVERLIB MAIN FUNCTION
375 // This function decides what it is we want to display and how we want it done.
377 var layerhtml, styleType;
378 runHook("olMain", FBEFORE);
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);
384 // They want a popup box.
385 styleType = (pms[o3_css-1-pmStart] == "cssoff" || pms[o3_css-1-pmStart] == "cssclass");
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);
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);
395 // Prepare popup height
396 if (o3_height > 0) o3_height = (styleType ? "height=\""+o3_height+"\"" : o3_height);
399 // Decide which kinda box.
402 layerhtml = runHook('ol_content_simple', FALTERNATE, o3_css, o3_text);
407 layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, o3_close);
410 layerhtml = runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, "");
415 // We want it to stick!
417 if (o3_timerid > 0) {
418 clearTimeout(o3_timerid);
421 o3_showingsticky = 1;
422 o3_removecounter = 0;
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;
429 // Prepare status bar
430 if (o3_autostatus > 0) {
432 if (o3_autostatus > 1) o3_status = o3_cap;
435 // When placing the layer the first time, even stickies may be moved.
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);
445 runHook("disp", FREPLACE, o3_status);
446 runHook("olMain", FAFTER);
448 if (o3_status != '') {
456 // LAYER GENERATION FUNCTIONS
458 // These functions just handle popup content with tags that should adhere to the W3C standards specification.
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>';
468 // Makes table with caption and optional close link
469 function ol_content_caption(text,title,close) {
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+' />';
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>';
487 // Sets the background picture,padding and lots more. :)
488 function ol_content_background(text,picture,hasfullhtml) {
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>';
495 set_background(picture);
499 // Loads a picture into the div.
500 function set_background(pic) {
503 over.background.src = null;
504 } else if (over.style) {
505 over.style.backgroundImage = "none";
509 over.background.src = pic;
510 } else if (over.style) {
511 over.style.backgroundImage = "url("+pic+")";
517 // HANDLING FUNCTIONS
520 // Displays the popup
521 function disp(statustext) {
522 runHook("disp", FBEFORE);
524 if (o3_allowmove == 0) {
525 runHook("placeLayer", FREPLACE);
526 runHook("showObject", FREPLACE, over);
527 o3_allowmove = (o3_sticky || o3_followmouse==0) ? 0 : 1;
530 runHook("disp", FAFTER);
532 if (statustext != "") self.status = statustext;
535 // Creates the actual popup structure
536 function createPopup(lyrContent){
537 runHook("createPopup", FBEFORE);
539 if (o3_wrap && !(olNs4 || olOp)) {
541 over.style.pixelWidth = 0;
543 repositionTo(over, 0, -over.offsetHeight);
547 layerWrite(lyrContent);
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);
552 runHook("createPopup", FAFTER, lyrContent);
557 // Decides where we want the popup.
558 function placeLayer() {
559 var placeX, placeY, widthFix = 0;
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;
569 // Horizontal scroll offset
570 winoffset=(olIe4) ? eval('o3_frame.'+docRoot+'.scrollLeft') : o3_frame.pageXOffset;
571 var parsedWidth = parseInt(o3_width);
573 if (o3_fixx > -1 || o3_relx != null) {
575 placeX=(o3_relx != null ? ( o3_relx < 0 ? winoffset +o3_relx+ iwidth - parsedWidth - widthFix : winoffset+o3_relx) : o3_fixx);
577 // If HAUTO, decide what to use.
579 if ((o3_x - winoffset) > (iwidth / 2)) {
587 if (o3_hpos == CENTER) { // Center
588 placeX = o3_x+o3_offsetx-(parsedWidth/2);
590 if (placeX < winoffset) placeX = winoffset;
593 if (o3_hpos == RIGHT) { // Right
594 placeX = o3_x+o3_offsetx;
596 if ((placeX+parsedWidth) > (winoffset+iwidth - widthFix)) {
597 placeX = iwidth+winoffset - parsedWidth - widthFix;
598 if (placeX < 0) placeX = 0;
601 if (o3_hpos == LEFT) { // Left
602 placeX = o3_x-o3_offsetx-parsedWidth;
603 if (placeX < winoffset) placeX = winoffset;
608 var snapping = placeX % o3_snapx;
610 if (o3_hpos == LEFT) {
611 placeX = placeX - (o3_snapx+snapping);
614 placeX = placeX+(o3_snapx - snapping);
617 if (placeX < winoffset) placeX = winoffset;
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;
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));
632 if (o3_fixy > -1 || o3_rely != null) {
634 placeY=(o3_rely != null ? (o3_rely < 0 ? scrolloffset+o3_rely+iheight - parsedHeight : scrolloffset+o3_rely) : o3_fixy);
636 // If VAUTO, decide what to use.
638 if ((o3_y - scrolloffset) > (iheight/2)) {
646 if (o3_vpos == ABOVE) {
647 if (o3_aboveheight == 0) o3_aboveheight = parsedHeight;
649 placeY = o3_y - (o3_aboveheight+o3_offsety);
650 if (placeY < scrolloffset) placeY = scrolloffset;
653 placeY = o3_y+o3_offsety;
658 var snapping = placeY % o3_snapy;
660 if (o3_aboveheight > 0 && o3_vpos == ABOVE) {
661 placeY = placeY - (o3_snapy+snapping);
663 placeY = placeY+(o3_snapy - snapping);
666 if (placeY < scrolloffset) placeY = scrolloffset;
670 // Actually move the object.
671 repositionTo(over, placeX, placeY);
675 function olMouseMove(e) {
676 var e = (e) ? e : event;
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');
686 if (o3_allowmove == 1) runHook("placeLayer", FREPLACE);
689 if (hoveringSwitch && !olNs4 && runHook("cursorOff", FREPLACE)) {
691 hoveringSwitch = !hoveringSwitch;
695 // Fake function for 3.0 users.
696 function no_overlib() { return ver3fix; }
698 // Capture the mouse and chain other scripts.
699 function olMouseCapture() {
700 capExtent = document;
701 var fN, mseHandler = olMouseMove;
702 var re = /function[ ]+(\w+)\(/;
704 if (document.onmousemove || (!olIe4 && window.onmousemove)) {
705 if (window.onmousemove) capExtent = window;
706 fN = capExtent.onmousemove.toString().match(re);
708 if (fN[1] == 'anonymous' || fN[1] == 'olMouseMove') {
709 olCheckMouseCapture = false;
712 var str = fN[1]+'(e); ' + 'olMouseMove(e); ';
713 mseHandler = new Function('e', str);
716 capExtent.onmousemove = mseHandler;
717 if (olNs4) capExtent.captureEvents(Event.MOUSEMOVE);
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);
731 for (i = 0; i < ar.length; i++) {
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
741 ol_text = ar[i].toString();
744 o3_text=ar[i].toString();
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);
812 if (fnMark && o3_function) o3_text = o3_function();
814 if ((pf == 'o3_') && o3_wrap) {
817 if (olOp || (olIe4 && isMac)) {
818 var tReg=/<.*\n*>/ig;
819 if (!tReg.test(o3_text)) o3_text = o3_text.replace(/[ ]+/g, ' ');
820 if (!tReg.test(o3_cap))o3_cap = o3_cap.replace(/[ ]+/g, ' ');
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(' ');
835 function layerWrite(txt) {
838 var lyr = o3_frame.document.overDiv.document
841 } else if (typeof over.innerHTML != 'undefined') {
842 if (olIe5 && isMac) over.innerHTML = '';
843 over.innerHTML = txt;
845 range = o3_frame.document.createRange();
846 range.setStartAfter(over);
847 domfrag = range.createContextualFragment(txt);
849 while (over.hasChildNodes()) {
850 over.removeChild(over.lastChild);
853 over.appendChild(domfrag);
857 // Make an object visible
858 function showObject(obj) {
859 runHook("showObject", FBEFORE);
861 var theObj=(olNs4 ? obj : obj.style);
862 theObj.visibility = 'visible';
864 runHook("showObject", FAFTER);
868 function hideObject(obj) {
869 runHook("hideObject", FBEFORE);
871 var theObj=(olNs4 ? obj : obj.style);
872 theObj.visibility = 'hidden';
874 if (o3_timerid > 0) clearTimeout(o3_timerid);
875 if (o3_delayid > 0) clearTimeout(o3_delayid);
881 if (over.onmouseout || over.onmouseover) {
882 if (olNs4) over.releaseEvents(Event.MOUSEOUT || Event.MOUSEOVER);
883 over.onmouseout = over.onmouseover = null;
886 runHook("hideObject", FAFTER);
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);
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;
903 if (o3_x < left || o3_x > right || o3_y < top || o3_y > bottom) return true;
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'));
921 function opt_NOCLOSE(unused) {
922 if (!unused) o3_close = "";
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;
929 over.onmouseover = function () {hoveringSwitch = true; if (o3_timerid > 0) { clearTimeout(o3_timerid); o3_timerid =0; } }
935 // Function to scan command line arguments for multiples
936 function opt_MULTIPLEARGS(i, args, parameter) {
937 var k = i, l, re, pV, str = '';
939 for(k=i; k<args.length; k++) {
940 str += args[k] + ',';
941 if(typeof args[k] == 'number'&&args[k]>pmStart) break;
943 if(k >= args.length) l = str.length-1;
945 re = eval('/,' + args[k] + '/');
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 + '"');
957 // Remove in texts when done.
958 function nbspCleanup() {
959 if (o3_wrap && (olOp || (olIe4 && isMac))) {
960 o3_text = o3_text.replace(/\ /g, ' ');
961 o3_cap = o3_cap.replace(/\ /g, ' ');
965 // Escape embedded single quotes in text strings
966 function escSglQuote(str) {
967 return str.toString().replace(/'/g,"\\'");
970 // Onload handler for window onload event
971 function OLonLoad_handler(e) {
972 if (!olLoaded) olLoaded=1; // indicates that all modules have loaded now
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);
978 // Route the event to the normal handler in Nx4.x
979 if (olNs4) routeEvent(e);
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>';
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)+'">';
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++) {
1002 v=v.replace(/^\s+/,'').replace(/\s+$/,'');
1003 if(/\s/.test(v) && !/['"]/.test(v)) {
1011 // dummy function which will be overridden
1012 function isExclusive(args) {
1016 // PLUGIN ACTIVATION FUNCTIONS
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++) {
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);
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
1056 // PLUGIN REGISTRATION FUNCTIONS
1059 // Registers commands and creates constants.
1060 function registerCommands(cmdStr) {
1061 if (typeof cmdStr!='string') return;
1063 var pM = cmdStr.split(',');
1064 pms = pms.concat(pM);
1066 for (var i = 0; i< pM.length; i++) {
1067 eval(pM[i].toUpperCase()+'='+pmCount++);
1071 // Register a function to hook at a certain point.
1072 function registerHook(fnHookTo, fnRef, hookType, optPm) {
1073 var hookPt, last = typeof optPm;
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();
1079 hookPt = hookPts[fnHookTo];
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;
1086 } else if (hookType == FBEFORE || hookType == FAFTER) {
1087 var hookPt=(hookType == 1 ? hookPt.before : hookPt.after);
1089 if (typeof fnRef == 'object') {
1090 hookPt = hookPt.concat(fnRef);
1092 hookPt[hookPt.length++] = fnRef;
1095 if (optPm) hookPt = reOrder(hookPt, fnRef, optPm);
1097 } else if (hookType == FALTERNATE) {
1098 if (last=='number') hookPt.alt[pms[optPm-1-pmStart]] = fnRef;
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);
1112 runTime[runTime.length++] = fn;
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);
1124 cmdLine[cmdLine.length++] = fn;
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);
1136 postParse[postParse.length++] = fn;
1142 // PLUGIN REGISTRATION FUNCTIONS
1145 // Runs any hooks registered.
1146 function runHook(fnHookTo, hookType) {
1147 var l = hookPts[fnHookTo], optPm, arS, ar = runHook.arguments;
1149 if (hookType == FREPLACE) {
1150 arS = argToString(ar, 2);
1152 if (typeof l == 'undefined' || !(l = l.ovload)) return eval(fnHookTo+'('+arS+')');
1153 else return eval('l('+arS+')');
1155 } else if (hookType == FBEFORE || hookType == FAFTER) {
1156 if (typeof l == 'undefined') return;
1157 l=(hookType == 1 ? l.before : l.after);
1159 if (!l.length) return;
1161 arS = argToString(ar, 2);
1162 for (var k = 0; k < l.length; k++) eval('l[k]('+arS+')');
1164 } else if (hookType == FALTERNATE) {
1166 arS = argToString(ar, 3);
1168 if (typeof l == 'undefined' || (l = l.alt[pms[optPm-1-pmStart]]) == 'undefined') {
1169 return eval(fnHookTo+'('+arS+')');
1171 return eval('l('+arS+')');
1177 // UTILITY FUNCTIONS
1180 // Checks if something is a function.
1181 function isFunction(fnRef) {
1184 if (typeof fnRef == 'object') {
1185 for (var i = 0; i < fnRef.length; i++) {
1186 if (typeof fnRef[i]=='function') continue;
1190 } else if (typeof fnRef != 'function') {
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');
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);
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;
1214 var newPt = new Array(), match;
1216 if (typeof order=='function') {
1217 if (typeof fnRef=='object') {
1218 newPt = newPt.concat(fnRef);
1220 newPt[newPt.length++]=fnRef;
1223 for (var i = 0; i < hookPt.length; i++) {
1225 if (typeof fnRef == 'function' && hookPt[i] == fnRef) {
1228 for(var j = 0; j < fnRef.length; j++) if (hookPt[i] == fnRef[j]) {
1233 if (!match) newPt[newPt.length++] = hookPt[i];
1236 newPt[newPt.length++] = order;
1238 } else if (typeof order == 'object') {
1239 if (typeof fnRef == 'object') {
1240 newPt = newPt.concat(fnRef);
1242 newPt[newPt.length++] = fnRef;
1245 for (var j = 0; j < hookPt.length; j++) {
1247 if (typeof fnRef == 'function' && hookPt[j] == fnRef) {
1250 for (var i = 0; i < fnRef.length; i++) if (hookPt[j] == fnRef[i]) {
1255 if (!match) newPt[newPt.length++]=hookPt[j];
1258 for (i = 0; i < newPt.length; i++) hookPt[i] = newPt[i];
1261 for (var j = 0; j < hookPt.length; j++) {
1263 for (var i = 0; i < order.length; i++) {
1264 if (hookPt[j] == order[i]) {
1269 if (!match) newPt[newPt.length++] = hookPt[j];
1271 newPt = newPt.concat(order);
1274 for(i = 0; i < newPt.length; i++) hookPt[i] = newPt[i];
1280 // OBJECT CONSTRUCTORS
1283 // Object for handling hooks.
1284 function FunctionReference() {
1286 this.before = new Array();
1287 this.after = new Array();
1288 this.alt = new Array();
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;
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;
1306 // STANDARD REGISTRATIONS
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);