PageSourceSearch

https://www.centralsan.org/sites/main/files/js/js_a7f02ced48b9f36c7f13e5a5a3523b75.js

js centralsan.org collected 2026-09-28 10:07:56 UTC 50,645 bytes, 1,347 lines download raw bytes

1/* $Id: lightbox.js,v 1.5.2.6.2.136 2010/09/24 08:39:40 snpower Exp $ */
2
3/**
4 * jQuery Lightbox
5 * @author
6 *   Stella Power, <http://drupal.org/user/66894>
7 *
8 * Based on Lightbox v2.03.3 by Lokesh Dhakar
9 * <http://www.huddletogether.com/projects/lightbox2/>
10 * Also partially based on the jQuery Lightbox by Warren Krewenki
11 *   <http://warren.mesozen.com>
12 *
13 * Permission has been granted to Mark Ashmead & other Drupal Lightbox2 module
14 * maintainers to distribute this file via Drupal.org
15 * Under GPL license.
16 *
17 * Slideshow, iframe and video functionality added by Stella Power.
18 */
19
20var Lightbox = {
21  auto_modal : false,
22  overlayOpacity : 0.8, // Controls transparency of shadow overlay.
23  overlayColor : '000', // Controls colour of shadow overlay.
24  disableCloseClick : true,
25  // Controls the order of the lightbox resizing animation sequence.
26  resizeSequence: 0, // 0: simultaneous, 1: width then height, 2: height then width.
27  resizeSpeed: 'normal', // Controls the speed of the lightbox resizing animation.
28  fadeInSpeed: 'normal', // Controls the speed of the image appearance.
29  slideDownSpeed: 'slow', // Controls the speed of the image details appearance.
30  minWidth: 240,
31  borderSize : 10,
32  boxColor : 'fff',
33  fontColor : '000',
34  topPosition : '',
35  infoHeight: 20,
36  alternative_layout : false,
37  imageArray : [],
38  imageNum : null,
39  total : 0,
40  activeImage : null,
41  inprogress : false,
42  disableResize : false,
43  disableZoom : false,
44  isZoomedIn : false,
45  rtl : false,
46  loopItems : false,
47  keysClose : ['c', 'x', 27],
48  keysPrevious : ['p', 37],
49  keysNext : ['n', 39],
50  keysZoom : ['z'],
51  keysPlayPause : [32],
52
53  // Slideshow options.
54  slideInterval : 5000, // In milliseconds.
55  showPlayPause : true,
56  autoStart : true,
57  autoExit : true,
58  pauseOnNextClick : false, // True to pause the slideshow when the "Next" button is clicked.
59  pauseOnPrevClick : true, // True to pause the slideshow when the "Prev" button is clicked.
60  slideIdArray : [],
61  slideIdCount : 0,
62  isSlideshow : false,
63  isPaused : false,
64  loopSlides : false,
65
66  // Iframe options.
67  isLightframe : false,
68  iframe_width : 600,
69  iframe_height : 400,
70  iframe_border : 1,
71
72  // Video and modal options.
73  enableVideo : false,
74  flvPlayer : '/flvplayer.swf',
75  flvFlashvars : '',
76  isModal : false,
77  isVideo : false,
78  videoId : false,
79  modalWidth : 400,
80  modalHeight : 400,
81  modalHTML : null,
82
83
84  // initialize()
85  // Constructor runs on completion of the DOM loading.
86  // The function inserts html at the bottom of the page which is used
87  // to display the shadow overlay and the image container.
88  initialize: function() {
89
90    var s = Drupal.settings.lightbox2;
91    Lightbox.overlayOpacity = s.overlay_opacity;
92    Lightbox.overlayColor = s.overlay_color;
93    Lightbox.disableCloseClick = s.disable_close_click;
94    Lightbox.resizeSequence = s.resize_sequence;
95    Lightbox.resizeSpeed = s.resize_speed;
96    Lightbox.fadeInSpeed = s.fade_in_speed;
97    Lightbox.slideDownSpeed = s.slide_down_speed;
98    Lightbox.borderSize = s.border_size;
99    Lightbox.boxColor = s.box_color;
100    Lightbox.fontColor = s.font_color;
101    Lightbox.topPosition = s.top_position;
102    Lightbox.rtl = s.rtl;
103    Lightbox.loopItems = s.loop_items;
104    Lightbox.keysClose = s.keys_close.split(" ");
105    Lightbox.keysPrevious = s.keys_previous.split(" ");
106    Lightbox.keysNext = s.keys_next.split(" ");
107    Lightbox.keysZoom = s.keys_zoom.split(" ");
108    Lightbox.keysPlayPause = s.keys_play_pause.split(" ");
109    Lightbox.disableResize = s.disable_resize;
110    Lightbox.disableZoom = s.disable_zoom;
111    Lightbox.slideInterval = s.slideshow_interval;
112    Lightbox.showPlayPause = s.show_play_pause;
113    Lightbox.showCaption = s.show_caption;
114    Lightbox.autoStart = s.slideshow_automatic_start;
115    Lightbox.autoExit = s.slideshow_automatic_exit;
116    Lightbox.pauseOnNextClick = s.pause_on_next_click;
117    Lightbox.pauseOnPrevClick = s.pause_on_previous_click;
118    Lightbox.loopSlides = s.loop_slides;
119    Lightbox.alternative_layout = s.use_alt_layout;
120    Lightbox.iframe_width = s.iframe_width;
121    Lightbox.iframe_height = s.iframe_height;
122    Lightbox.iframe_border = s.iframe_border;
123    Lightbox.enableVideo = s.enable_video;
124    if (s.enable_video) {
125      Lightbox.flvPlayer = s.flvPlayer;
126      Lightbox.flvFlashvars = s.flvFlashvars;
127    }
128
129    // Make the lightbox divs.
130    var layout_class = (s.use_alt_layout ? 'lightbox2-alt-layout' : 'lightbox2-orig-layout');
131    var output = '<div id="lightbox2-overlay" style="display: none;"></div>\
132      <div id="lightbox" style="display: none;" class="' + layout_class + '">\
133        <div id="outerImageContainer"></div>\
134        <div id="imageDataContainer" class="clearfix">\
135          <div id="imageData"></div>\
136        </div>\
137      </div>';
138    var loading = '<div id="loading"><a href="#" id="loadingLink"></a></div>';
139    var modal = '<div id="modalContainer" style="display: none;"></div>';
140    var frame = '<div id="frameContainer" style="display: none;"></div>';
141    var imageContainer = '<div id="imageContainer" style="display: none;"></div>';
142    var details = '<div id="imageDetails"></div>';
143    var bottomNav = '<div id="bottomNav"></div>';
144    var image = '<img id="lightboxImage" alt="" />';
145    var hoverNav = '<div id="hoverNav"><a id="prevLink" href="#"></a><a id="nextLink" href="#"></a></div>';
146    var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" href="#"></a><a id="frameNextLink" href="#"></a></div>';
147    var hoverNav = '<div id="hoverNav"><a id="prevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="nextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>';
148    var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="frameNextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>';
149    var caption = '<span id="caption"></span>';
150    var numberDisplay = '<span id="numberDisplay"></span>';
151    var close = '<a id="bottomNavClose" title="' + Drupal.t('Close') + '" href="#"></a>';
152    var zoom = '<a id="bottomNavZoom" href="#"></a>';
153    var zoomOut = '<a id="bottomNavZoomOut" href="#"></a>';
154    var pause = '<a id="lightshowPause" title="' + Drupal.t('Pause Slideshow') + '" href="#" style="display: none;"></a>';
155    var play = '<a id="lightshowPlay" title="' + Drupal.t('Play Slideshow') + '" href="#" style="display: none;"></a>';
156
157    $("body").append(output);
158    $('#outerImageContainer').append(modal + frame + imageContainer + loading);
159    if (!s.use_alt_layout) {
160      $('#imageContainer').append(image + hoverNav);
161      $('#imageData').append(details + bottomNav);
162      $('#imageDetails').append(caption + numberDisplay);
163      $('#bottomNav').append(frameNav + close + zoom + zoomOut + pause + play);
164    }
165    else {
166      $('#outerImageContainer').append(bottomNav);
167      $('#imageContainer').append(image);
168      $('#bottomNav').append(close + zoom + zoomOut);
169      $('#imageData').append(hoverNav + details);
170      $('#imageDetails').append(caption + numberDisplay + pause + play);
171    }
172
173    // Setup onclick handlers.
174    if (Lightbox.disableCloseClick) {
175      $('#lightbox2-overlay').click(function() { Lightbox.end(); return false; } ).hide();
176    }
177    $('#loadingLink, #bottomNavClose').click(function() { Lightbox.end('forceClose'); return false; } );
178    $('#prevLink, #framePrevLink').click(function() { Lightbox.changeData(Lightbox.activeImage - 1); return false; } );
179    $('#nextLink, #frameNextLink').click(function() { Lightbox.changeData(Lightbox.activeImage + 1); return false; } );
180    $('#bottomNavZoom').click(function() { Lightbox.changeData(Lightbox.activeImage, true); return false; } );
181    $('#bottomNavZoomOut').click(function() { Lightbox.changeData(Lightbox.activeImage, false); return false; } );
182    $('#lightshowPause').click(function() { Lightbox.togglePlayPause("lightshowPause", "lightshowPlay"); return false; } );
183    $('#lightshowPlay').click(function() { Lightbox.togglePlayPause("lightshowPlay", "lightshowPause"); return false; } );
184
185    // Fix positioning.
186    $('#prevLink, #nextLink, #framePrevLink, #frameNextLink').css({ 'paddingTop': Lightbox.borderSize + 'px'});
187    $('#imageContainer, #frameContainer, #modalContainer').css({ 'padding': Lightbox.borderSize + 'px'});
188    $('#outerImageContainer, #imageDataContainer, #bottomNavClose').css({'backgroundColor': '#' + Lightbox.boxColor, 'color': '#'+Lightbox.fontColor});
189    if (Lightbox.alternative_layout) {
190      $('#bottomNavZoom, #bottomNavZoomOut').css({'bottom': Lightbox.borderSize + 'px', 'right': Lightbox.borderSize + 'px'});
191    }
192    else if (Lightbox.rtl == 1 && $.browser.msie) {
193      $('#bottomNavZoom, #bottomNavZoomOut').css({'left': '0px'});
194    }
195
196    // Force navigation links to always be displayed
197    if (s.force_show_nav) {
198      $('#prevLink, #nextLink').addClass("force_show_nav");
199    }
200
201  },
202
203  // initList()
204  // Loops through anchor tags looking for 'lightbox', 'lightshow' and
205  // 'lightframe', etc, references and applies onclick events to appropriate
206  // links. You can rerun after dynamically adding images w/ajax.
207  initList : function(context) {
208
209    if (context == undefined || context == null) {
210      context = document;
211    }
212
213    // Attach lightbox to any links with rel 'lightbox', 'lightshow' or
214    // 'lightframe', etc.
215    $("a[rel^='lightbox']:not(.lightbox-processed), area[rel^='lightbox']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
216      if (Lightbox.disableCloseClick) {
217        $('#lightbox').unbind('click');
218        $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
219      }
220      Lightbox.start(this, false, false, false, false);
221      if (e.preventDefault) { e.preventDefault(); }
222      return false;
223    });
224    $("a[rel^='lightshow']:not(.lightbox-processed), area[rel^='lightshow']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
225      if (Lightbox.disableCloseClick) {
226        $('#lightbox').unbind('click');
227        $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
228      }
229      Lightbox.start(this, true, false, false, false);
230      if (e.preventDefault) { e.preventDefault(); }
231      return false;
232    });
233    $("a[rel^='lightframe']:not(.lightbox-processed), area[rel^='lightframe']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
234      if (Lightbox.disableCloseClick) {
235        $('#lightbox').unbind('click');
236        $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
237      }
238      Lightbox.start(this, false, true, false, false);
239      if (e.preventDefault) { e.preventDefault(); }
240      return false;
241    });
242    if (Lightbox.enableVideo) {
243      $("a[rel^='lightvideo']:not(.lightbox-processed), area[rel^='lightvideo']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
244        if (Lightbox.disableCloseClick) {
245          $('#lightbox').unbind('click');
246          $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
247        }
248        Lightbox.start(this, false, false, true, false);
249        if (e.preventDefault) { e.preventDefault(); }
250        return false;
251      });
252    }
253    $("a[rel^='lightmodal']:not(.lightbox-processed), area[rel^='lightmodal']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
254      $('#lightbox').unbind('click');
255      // Add classes from the link to the lightbox div - don't include lightbox-processed
256      $('#lightbox').addClass($(this).attr('class'));
257      $('#lightbox').removeClass('lightbox-processed');
258      Lightbox.start(this, false, false, false, true);
259      if (e.preventDefault) { e.preventDefault(); }
260      return false;
261    });
262    $("#lightboxAutoModal:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
263      Lightbox.auto_modal = true;
264      $('#lightbox').unbind('click');
265      Lightbox.start(this, false, false, false, true);
266      if (e.preventDefault) { e.preventDefault(); }
267      return false;
268    });
269  },
270
271  // start()
272  // Display overlay and lightbox. If image is part of a set, add siblings to
273  // imageArray.
274  start: function(imageLink, slideshow, lightframe, lightvideo, lightmodal) {
275
276    Lightbox.isPaused = !Lightbox.autoStart;
277
278    // Replaces hideSelectBoxes() and hideFlash() calls in original lightbox2.
279    Lightbox.toggleSelectsFlash('hide');
280
281    // Stretch overlay to fill page and fade in.
282    var arrayPageSize = Lightbox.getPageSize();
283    $("#lightbox2-overlay").hide().css({
284      'width': '100%',
285      'zIndex': '10090',
286      'height': arrayPageSize[1] + 'px',
287      'backgroundColor' : '#' + Lightbox.overlayColor
288    });
289    // Detect OS X FF2 opacity + flash issue.
290    if (lightvideo && this.detectMacFF2()) {
291      $("#lightbox2-overlay").removeClass("overlay_default");
292      $("#lightbox2-overlay").addClass("overlay_macff2");
293      $("#lightbox2-overlay").css({'opacity' : null});
294    }
295    else {
296      $("#lightbox2-overlay").removeClass("overlay_macff2");
297      $("#lightbox2-overlay").addClass("overlay_default");
298      $("#lightbox2-overlay").css({'opacity' : Lightbox.overlayOpacity});
299    }
300    $("#lightbox2-overlay").fadeIn(Lightbox.fadeInSpeed);
301
302
303    Lightbox.isSlideshow = slideshow;
304    Lightbox.isLightframe = lightframe;
305    Lightbox.isVideo = lightvideo;
306    Lightbox.isModal = lightmodal;
307    Lightbox.imageArray = [];
308    Lightbox.imageNum = 0;
309
310    var anchors = $(imageLink.tagName);
311    var anchor = null;
312    var rel_parts = Lightbox.parseRel(imageLink);
313    var rel = rel_parts["rel"];
314    var rel_group = rel_parts["group"];
315    var title = (rel_parts["title"] ? rel_parts["title"] : imageLink.title);
316    var rel_style = null;
317    var i = 0;
318
319    if (rel_parts["flashvars"]) {
320      Lightbox.flvFlashvars = Lightbox.flvFlashvars + '&' + rel_parts["flashvars"];
321    }
322
323    // Set the title for image alternative text.
324    var alt = imageLink.title;
325    if (!alt) {
326      var img = $(imageLink).find("img");
327      if (img && $(img).attr("alt")) {
328        alt = $(img).attr("alt");
329      }
330      else {
331        alt = title;
332      }
333    }
334
335    if ($(imageLink).attr('id') == 'lightboxAutoModal') {
336      rel_style = rel_parts["style"];
337      Lightbox.imageArray.push(['#lightboxAutoModal > *', title, alt, rel_style, 1]);
338    }
339    else {
340      // Handle lightbox images with no grouping.
341      if ((rel == 'lightbox' || rel == 'lightshow') && !rel_group) {
342        Lightbox.imageArray.push([imageLink.href, title, alt]);
343      }
344
345      // Handle other items with no grouping.
346      else if (!rel_group) {
347        rel_style = rel_parts["style"];
348        Lightbox.imageArray.push([imageLink.href, title, alt, rel_style]);
349      }
350
351      // Handle grouped items.
352      else {
353
354        // Loop through anchors and add them to imageArray.
355        for (i = 0; i < anchors.length; i++) {
356          anchor = anchors[i];
357          if (anchor.href && typeof(anchor.href) == "string" && $(anchor).attr('rel')) {
358            var rel_data = Lightbox.parseRel(anchor);
359            var anchor_title = (rel_data["title"] ? rel_data["title"] : anchor.title);
360            img_alt = anchor.title;
361            if (!img_alt) {
362              var anchor_img = $(anchor).find("img");
363              if (anchor_img && $(anchor_img).attr("alt")) {
364                img_alt = $(anchor_img).attr("alt");
365              }
366              else {
367                img_alt = title;
368              }
369            }
370            if (rel_data["rel"] == rel) {
371              if (rel_data["group"] == rel_group) {
372                if (Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) {
373                  rel_style = rel_data["style"];
374                }
375                Lightbox.imageArray.push([anchor.href, anchor_title, img_alt, rel_style]);
376              }
377            }
378          }
379        }
380
381        // Remove duplicates.
382        for (i = 0; i < Lightbox.imageArray.length; i++) {
383          for (j = Lightbox.imageArray.length-1; j > i; j--) {
384            if (Lightbox.imageArray[i][0] == Lightbox.imageArray[j][0]) {
385              Lightbox.imageArray.splice(j,1);
386            }
387          }
388        }
389        while (Lightbox.imageArray[Lightbox.imageNum][0] != imageLink.href) {
390          Lightbox.imageNum++;
391        }
392      }
393    }
394
395    if (Lightbox.isSlideshow && Lightbox.showPlayPause && Lightbox.isPaused) {
396      $('#lightshowPlay').show();
397      $('#lightshowPause').hide();
398    }
399
400    // Calculate top and left offset for the lightbox.
401    var arrayPageScroll = Lightbox.getPageScroll();
402    var lightboxTop = arrayPageScroll[1] + (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1;
403    var lightboxLeft = arrayPageScroll[0];
404    $('#frameContainer, #modalContainer, #lightboxImage').hide();
405    $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide();
406    $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide();
407    $('#outerImageContainer').css({'width': '250px', 'height': '250px'});
408    $('#lightbox').css({
409      'zIndex': '10500',
410      'top': lightboxTop + 'px',
411      'left': lightboxLeft + 'px'
412    }).show();
413
414    Lightbox.total = Lightbox.imageArray.length;
415    Lightbox.changeData(Lightbox.imageNum);
416  },
417
418  // changeData()
419  // Hide most elements and preload image in preparation for resizing image
420  // container.
421  changeData: function(imageNum, zoomIn) {
422
423    if (Lightbox.inprogress === false) {
424      if (Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) {
425        if (imageNum >= Lightbox.total) imageNum = 0;
426        if (imageNum < 0) imageNum = Lightbox.total - 1;
427      }
428
429      if (Lightbox.isSlideshow) {
430        for (var i = 0; i < Lightbox.slideIdCount; i++) {
431          window.clearTimeout(Lightbox.slideIdArray[i]);
432        }
433      }
434      Lightbox.inprogress = true;
435      Lightbox.activeImage = imageNum;
436
437      if (Lightbox.disableResize && !Lightbox.isSlideshow) {
438        zoomIn = true;
439      }
440      Lightbox.isZoomedIn = zoomIn;
441
442
443      // Hide elements during transition.
444      $('#loading').css({'zIndex': '10500'}).show();
445      if (!Lightbox.alternative_layout) {
446        $('#imageContainer').hide();
447      }
448      $('#frameContainer, #modalContainer, #lightboxImage').hide();
449      $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide();
450      $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide();
451
452      // Preload image content, but not iframe pages.
453      if (!Lightbox.isLightframe && !Lightbox.isVideo && !Lightbox.isModal) {
454        $("#lightbox #imageDataContainer").removeClass('lightbox2-alt-layout-data');
455        imgPreloader = new Image();
456        imgPreloader.onerror = function() { Lightbox.imgNodeLoadingError(this); };
457
458        imgPreloader.onload = function() {
459          var photo = document.getElementById('lightboxImage');
460          photo.src = Lightbox.imageArray[Lightbox.activeImage][0];
461          photo.alt = Lightbox.imageArray[Lightbox.activeImage][2];
462
463          var imageWidth = imgPreloader.width;
464          var imageHeight = imgPreloader.height;
465
466          // Resize code.
467          var arrayPageSize = Lightbox.getPageSize();
468          var targ = { w:arrayPageSize[2] - (Lightbox.borderSize * 2), h:arrayPageSize[3] - (Lightbox.borderSize * 6) - (Lightbox.infoHeight * 4) - (arrayPageSize[3] / 10) };
469          var orig = { w:imgPreloader.width, h:imgPreloader.height };
470
471          // Image is very large, so show a smaller version of the larger image
472          // with zoom button.
473          if (zoomIn !== true) {
474            var ratio = 1.0; // Shrink image with the same aspect.
475            $('#bottomNavZoomOut, #bottomNavZoom').hide();
476            if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) {
477              ratio = ((targ.w / orig.w) < (targ.h / orig.h)) ? targ.w / orig.w : targ.h / orig.h;
478              if (!Lightbox.disableZoom && !Lightbox.isSlideshow) {
479                $('#bottomNavZoom').css({'zIndex': '10500'}).show();
480              }
481            }
482
483            imageWidth  = Math.floor(orig.w * ratio);
484            imageHeight = Math.floor(orig.h * ratio);
485          }
486
487          else {
488            $('#bottomNavZoom').hide();
489            // Only display zoom out button if the image is zoomed in already.
490            if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) {
491              // Only display zoom out button if not a slideshow and if the
492              // buttons aren't disabled.
493              if (!Lightbox.disableResize && Lightbox.isSlideshow === false && !Lightbox.disableZoom) {
494                $('#bottomNavZoomOut').css({'zIndex': '10500'}).show();
495              }
496            }
497          }
498
499          photo.style.width = (imageWidth) + 'px';
500          photo.style.height = (imageHeight) + 'px';
501          Lightbox.resizeContainer(imageWidth, imageHeight);
502
503          // Clear onLoad, IE behaves irratically with animated gifs otherwise.
504          imgPreloader.onload = function() {};
505        };
506
507        imgPreloader.src = Lightbox.imageArray[Lightbox.activeImage][0];
508        imgPreloader.alt = Lightbox.imageArray[Lightbox.activeImage][2];
509      }
510
511      // Set up frame size, etc.
512      else if (Lightbox.isLightframe) {
513        $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data');
514        var src = Lightbox.imageArray[Lightbox.activeImage][0];
515        // DD Override to allow fullscren videos.
516        $('#frameContainer').html('<iframe id="lightboxFrame" style="display: none;" src="' + src +'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>');
517
518        // Enable swf support in Gecko browsers.
519        if ($.browser.mozilla && src.indexOf('.swf') != -1) {
520          setTimeout(function () {
521            document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0];
522          }, 1000);
523        }
524
525        if (!Lightbox.iframe_border) {
526          $('#lightboxFrame').css({'border': 'none'});
527          $('#lightboxFrame').attr('frameborder', '0');
528        }
529        var iframe = document.getElementById('lightboxFrame');
530        var iframeStyles = Lightbox.imageArray[Lightbox.activeImage][3];
531        iframe = Lightbox.setStyles(iframe, iframeStyles);
532        Lightbox.resizeContainer(parseInt(iframe.width, 10), parseInt(iframe.height, 10));
533      }
534      else if (Lightbox.isVideo || Lightbox.isModal) {
535        $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data');
536        var container = document.getElementById('modalContainer');
537        var modalStyles = Lightbox.imageArray[Lightbox.activeImage][3];
538        container = Lightbox.setStyles(container, modalStyles);
539        if (Lightbox.isVideo) {
540          Lightbox.modalHeight =  parseInt(container.height, 10) - 10;
541          Lightbox.modalWidth =  parseInt(container.width, 10) - 10;
542          Lightvideo.startVideo(Lightbox.imageArray[Lightbox.activeImage][0]);
543        }
544        Lightbox.resizeContainer(parseInt(container.width, 10), parseInt(container.height, 10));
545      }
546    }
547  },
548
549  // imgNodeLoadingError()
550  imgNodeLoadingError: function(image) {
551    var s = Drupal.settings.lightbox2;
552    var original_image = Lightbox.imageArray[Lightbox.activeImage][0];
553    if (s.display_image_size !== "") {
554      original_image = original_image.replace(new RegExp("."+s.display_image_size), "");
555    }
556    Lightbox.imageArray[Lightbox.activeImage][0] = original_image;
557    image.onerror = function() { Lightbox.imgLoadingError(image); };
558    image.src = original_image;
559  },
560
561  // imgLoadingError()
562  imgLoadingError: function(image) {
563    var s = Drupal.settings.lightbox2;
564    Lightbox.imageArray[Lightbox.activeImage][0] = s.default_image;
565    image.src = s.default_image;
566  },
567
568  // resizeContainer()
569  resizeContainer: function(imgWidth, imgHeight) {
570
571    imgWidth = (imgWidth < Lightbox.minWidth ? Lightbox.minWidth : imgWidth);
572
573    this.widthCurrent = $('#outerImageContainer').width();
574    this.heightCurrent = $('#outerImageContainer').height();
575
576    var widthNew = (imgWidth  + (Lightbox.borderSize * 2));
577    var heightNew = (imgHeight  + (Lightbox.borderSize * 2));
578
579    // Scalars based on change from old to new.
580    this.xScale = ( widthNew / this.widthCurrent) * 100;
581    this.yScale = ( heightNew / this.heightCurrent) * 100;
582
583    // Calculate size difference between new and old image, and resize if
584    // necessary.
585    wDiff = this.widthCurrent - widthNew;
586    hDiff = this.heightCurrent - heightNew;
587
588    $('#modalContainer').css({'width': imgWidth, 'height': imgHeight});
589    // Detect animation sequence.
590    if (Lightbox.resizeSequence) {
591      var animate1 = {width: widthNew};
592      var animate2 = {height: heightNew};
593      if (Lightbox.resizeSequence == 2) {
594        animate1 = {height: heightNew};
595        animate2 = {width: widthNew};
596      }
597      $('#outerImageContainer').animate(animate1, Lightbox.resizeSpeed).animate(animate2, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); });
598    }
599    // Simultaneous.
600    else {
601      $('#outerImageContainer').animate({'width': widthNew, 'height': heightNew}, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); });
602    }
603
604    // If new and old image are same size and no scaling transition is necessary
605    // do a quick pause to prevent image flicker.
606    if ((hDiff === 0) && (wDiff === 0)) {
607      if ($.browser.msie) {
608        Lightbox.pause(250);
609      }
610      else {
611        Lightbox.pause(100);
612      }
613    }
614
615    var s = Drupal.settings.lightbox2;
616    if (!s.use_alt_layout) {
617      $('#prevLink, #nextLink').css({'height': imgHeight + 'px'});
618    }
619    $('#imageDataContainer').css({'width': widthNew + 'px'});
620  },
621
622  // showData()
623  // Display image and begin preloading neighbors.
624  showData: function() {
625    $('#loading').hide();
626
627    if (Lightbox.isLightframe || Lightbox.isVideo || Lightbox.isModal) {
628      Lightbox.updateDetails();
629      if (Lightbox.isLightframe) {
630        $('#frameContainer').show();
631        if ($.browser.safari || Lightbox.fadeInSpeed === 0) {
632          $('#lightboxFrame').css({'zIndex': '10500'}).show();
633        }
634        else {
635          $('#lightboxFrame').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed);
636        }
637      }
638      else {
639        if (Lightbox.isVideo) {
640          $("#modalContainer").html(Lightbox.modalHTML).click(function(){return false;}).css('zIndex', '10500').show();
641        }
642        else {
643          var src = unescape(Lightbox.imageArray[Lightbox.activeImage][0]);
644          if (Lightbox.imageArray[Lightbox.activeImage][4]) {
645            $(src).appendTo("#modalContainer");
646            $('#modalContainer').css({'zIndex': '10500'}).show();
647          }
648          else {
649            // Use a callback to show the new image, otherwise you get flicker.
650            $("#modalContainer").hide().load(src, function () {$('#modalContainer').css({'zIndex': '10500'}).show();});
651          }
652          $('#modalContainer').unbind('click');
653        }
654        // This might be needed in the Lightframe section above.
655        //$('#modalContainer').css({'zIndex': '10500'}).show();
656      }
657    }
658
659    // Handle display of image content.
660    else {
661      $('#imageContainer').show();
662      if ($.browser.safari || Lightbox.fadeInSpeed === 0) {
663        $('#lightboxImage').css({'zIndex': '10500'}).show();
664      }
665      else {
666        $('#lightboxImage').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed);
667      }
668      Lightbox.updateDetails();
669      this.preloadNeighborImages();
670    }
671    Lightbox.inprogress = false;
672
673    // Slideshow specific stuff.
674    if (Lightbox.isSlideshow) {
675      if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) {
676        if (Lightbox.autoExit) {
677          Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {Lightbox.end('slideshow');}, Lightbox.slideInterval);
678        }
679      }
680      else {
681        if (!Lightbox.isPaused && Lightbox.total > 1) {
682          Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {Lightbox.changeData(Lightbox.activeImage + 1);}, Lightbox.slideInterval);
683        }
684      }
685      if (Lightbox.showPlayPause && Lightbox.total > 1 && !Lightbox.isPaused) {
686        $('#lightshowPause').show();
687        $('#lightshowPlay').hide();
688      }
689      else if (Lightbox.showPlayPause && Lightbox.total > 1) {
690        $('#lightshowPause').hide();
691        $('#lightshowPlay').show();
692      }
693    }
694
695    // Adjust the page overlay size.
696    var arrayPageSize = Lightbox.getPageSize();
697    var arrayPageScroll = Lightbox.getPageScroll();
698    var pageHeight = arrayPageSize[1];
699    if (Lightbox.isZoomedIn && arrayPageSize[1] > arrayPageSize[3]) {
700      var lightboxTop = (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1;
701      pageHeight = pageHeight + arrayPageScroll[1] + lightboxTop;
702    }
703    $('#lightbox2-overlay').css({'height': pageHeight + 'px', 'width': arrayPageSize[0] + 'px'});
704
705    // Gecko browsers (e.g. Firefox, SeaMonkey, etc) don't handle pdfs as
706    // expected.
707    if ($.browser.mozilla) {
708      if (Lightbox.imageArray[Lightbox.activeImage][0].indexOf(".pdf") != -1) {
709        setTimeout(function () {
710          document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0];
711        }, 1000);
712      }
713    }
714  },
715
716  // updateDetails()
717  // Display caption, image number, and bottom nav.
718  updateDetails: function() {
719
720    $("#imageDataContainer").hide();
721
722    var s = Drupal.settings.lightbox2;
723
724    if (s.show_caption) {
725      var caption = Lightbox.filterXSS(Lightbox.imageArray[Lightbox.activeImage][1]);
726      if (!caption) caption = '';
727      $('#caption').html(caption).css({'zIndex': '10500'}).show();
728    }
729
730    // If image is part of set display 'Image x of x'.
731    var numberDisplay = null;
732    if (s.image_count && Lightbox.total > 1) {
733      var currentImage = Lightbox.activeImage + 1;
734      if (!Lightbox.isLightframe && !Lightbox.isModal && !Lightbox.isVideo) {
735        numberDisplay = s.image_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
736      }
737      else if (Lightbox.isVideo) {
738        numberDisplay = s.video_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
739      }
740      else {
741        numberDisplay = s.page_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
742      }
743      $('#numberDisplay').html(numberDisplay).css({'zIndex': '10500'}).show();
744    }
745    else {
746      $('#numberDisplay').hide();
747    }
748
749    $("#imageDataContainer").hide().slideDown(Lightbox.slideDownSpeed, function() {
750      $("#bottomNav").show();
751    });
752    if (Lightbox.rtl == 1) {
753      $("#bottomNav").css({'float': 'left'});
754    }
755    Lightbox.updateNav();
756  },
757
758  // updateNav()
759  // Display appropriate previous and next hover navigation.
760  updateNav: function() {
761
762    $('#hoverNav').css({'zIndex': '10500'}).show();
763    var prevLink = '#prevLink';
764    var nextLink = '#nextLink';
765
766    // Slideshow is separated as we need to show play / pause button.
767    if (Lightbox.isSlideshow) {
768      if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage !== 0) {
769        $(prevLink).css({'zIndex': '10500'}).show().click(function() {
770          if (Lightbox.pauseOnPrevClick) {
771            Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
772          }
773          Lightbox.changeData(Lightbox.activeImage - 1); return false;
774        });
775      }
776      else {
777        $(prevLink).hide();
778      }
779
780      // If not last image in set, display next image button.
781      if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage != (Lightbox.total - 1)) {
782        $(nextLink).css({'zIndex': '10500'}).show().click(function() {
783          if (Lightbox.pauseOnNextClick) {
784            Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
785          }
786          Lightbox.changeData(Lightbox.activeImage + 1); return false;
787        });
788      }
789      // Safari browsers need to have hide() called again.
790      else {
791        $(nextLink).hide();
792      }
793    }
794
795    // All other types of content.
796    else {
797
798      if ((Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) && !Lightbox.alternative_layout) {
799        $('#frameHoverNav').css({'zIndex': '10500'}).show();
800        $('#hoverNav').css({'zIndex': '10500'}).hide();
801        prevLink = '#framePrevLink';
802        nextLink = '#frameNextLink';
803      }
804
805      // If not first image in set, display prev image button.
806      if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage !== 0) {
807        // Unbind any other click handlers, otherwise this adds a new click handler
808        // each time the arrow is clicked.
809        $(prevLink).css({'zIndex': '10500'}).show().unbind().click(function() {
810          Lightbox.changeData(Lightbox.activeImage - 1); return false;
811        });
812      }
813      // Safari browsers need to have hide() called again.
814      else {
815        $(prevLink).hide();
816      }
817
818      // If not last image in set, display next image button.
819      if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage != (Lightbox.total - 1)) {
820        // Unbind any other click handlers, otherwise this adds a new click handler
821        // each time the arrow is clicked.
822        $(nextLink).css({'zIndex': '10500'}).show().unbind().click(function() {
823          Lightbox.changeData(Lightbox.activeImage + 1); return false;
824        });
825      }
826      // Safari browsers need to have hide() called again.
827      else {
828        $(nextLink).hide();
829      }
830    }
831
832    // Don't enable keyboard shortcuts so forms will work.
833    if (!Lightbox.isModal) {
834      this.enableKeyboardNav();
835    }
836  },
837
838
839  // enableKeyboardNav()
840  enableKeyboardNav: function() {
841    $(document).bind("keydown", this.keyboardAction);
842  },
843
844  // disableKeyboardNav()
845  disableKeyboardNav: function() {
846    $(document).unbind("keydown", this.keyboardAction);
847  },
848
849  // keyboardAction()
850  keyboardAction: function(e) {
851    if (e === null) { // IE.
852      keycode = event.keyCode;
853      escapeKey = 27;
854    }
855    else { // Mozilla.
856      keycode = e.keyCode;
857      escapeKey = e.DOM_VK_ESCAPE;
858    }
859
860    key = String.fromCharCode(keycode).toLowerCase();
861
862    // Close lightbox.
863    if (Lightbox.checkKey(Lightbox.keysClose, key, keycode)) {
864      Lightbox.end('forceClose');
865    }
866    // Display previous image (p, <-).
867    else if (Lightbox.checkKey(Lightbox.keysPrevious, key, keycode)) {
868      if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage !== 0) {
869        Lightbox.changeData(Lightbox.activeImage - 1);
870      }
871
872    }
873    // Display next image (n, ->).
874    else if (Lightbox.checkKey(Lightbox.keysNext, key, keycode)) {
875      if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage != (Lightbox.total - 1)) {
876        Lightbox.changeData(Lightbox.activeImage + 1);
877      }
878    }
879    // Zoom in.
880    else if (Lightbox.checkKey(Lightbox.keysZoom, key, keycode) && !Lightbox.disableResize && !Lightbox.disableZoom && !Lightbox.isSlideshow && !Lightbox.isLightframe) {
881      if (Lightbox.isZoomedIn) {
882        Lightbox.changeData(Lightbox.activeImage, false);
883      }
884      else if (!Lightbox.isZoomedIn) {
885        Lightbox.changeData(Lightbox.activeImage, true);
886      }
887      return false;
888    }
889    // Toggle play / pause (space).
890    else if (Lightbox.checkKey(Lightbox.keysPlayPause, key, keycode) && Lightbox.isSlideshow) {
891
892      if (Lightbox.isPaused) {
893        Lightbox.togglePlayPause("lightshowPlay", "lightshowPause");
894      }
895      else {
896        Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
897      }
898      return false;
899    }
900  },
901
902  preloadNeighborImages: function() {
903
904    if ((Lightbox.total - 1) > Lightbox.activeImage) {
905      preloadNextImage = new Image();
906      preloadNextImage.src = Lightbox.imageArray[Lightbox.activeImage + 1][0];
907    }
908    if (Lightbox.activeImage > 0) {
909      preloadPrevImage = new Image();
910      preloadPrevImage.src = Lightbox.imageArray[Lightbox.activeImage - 1][0];
911    }
912
913  },
914
915  end: function(caller) {
916    var closeClick = (caller == 'slideshow' ? false : true);
917    if (Lightbox.isSlideshow && Lightbox.isPaused && !closeClick) {
918      return;
919    }
920    // To prevent double clicks on navigation links.
921    if (Lightbox.inprogress === true && caller != 'forceClose') {
922      return;
923    }
924    Lightbox.disableKeyboardNav();
925    $('#lightbox').hide();
926    $("#lightbox2-overlay").fadeOut();
927    Lightbox.isPaused = true;
928    Lightbox.inprogress = false;
929    // Replaces calls to showSelectBoxes() and showFlash() in original
930    // lightbox2.
931    Lightbox.toggleSelectsFlash('visible');
932    if (Lightbox.isSlideshow) {
933      for (var i = 0; i < Lightbox.slideIdCount; i++) {
934        window.clearTimeout(Lightbox.slideIdArray[i]);
935      }
936      $('#lightshowPause, #lightshowPlay').hide();
937    }
938    else if (Lightbox.isLightframe) {
939      $('#frameContainer').empty().hide();
940    }
941    else if (Lightbox.isVideo || Lightbox.isModal) {
942      if (!Lightbox.auto_modal) {
943        $('#modalContainer').hide().html("");
944      }
945      Lightbox.auto_modal = false;
946    }
947  },
948
949
950  // getPageScroll()
951  // Returns array with x,y page scroll values.
952  // Core code from - quirksmode.com.
953  getPageScroll : function() {
954
955    var xScroll, yScroll;
956
957    if (self.pageYOffset || self.pageXOffset) {
958      yScroll = self.pageYOffset;
959      xScroll = self.pageXOffset;
960    }
961    else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {  // Explorer 6 Strict.
962      yScroll = document.documentElement.scrollTop;
963      xScroll = document.documentElement.scrollLeft;
964    }
965    else if (document.body) {// All other Explorers.
966      yScroll = document.body.scrollTop;
967      xScroll = document.body.scrollLeft;
968    }
969
970    arrayPageScroll = [xScroll,yScroll];
971    return arrayPageScroll;
972  },
973
974  // getPageSize()
975  // Returns array with page width, height and window width, height.
976  // Core code from - quirksmode.com.
977  // Edit for Firefox by pHaez.
978
979  getPageSize : function() {
980
981    var xScroll, yScroll;
982
983    if (window.innerHeight && window.scrollMaxY) {
984      xScroll = window.innerWidth + window.scrollMaxX;
985      yScroll = window.innerHeight + window.scrollMaxY;
986    }
987    else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac.
988      xScroll = document.body.scrollWidth;
989      yScroll = document.body.scrollHeight;
990    }
991    else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari.
992      xScroll = document.body.offsetWidth;
993      yScroll = document.body.offsetHeight;
994    }
995
996    var windowWidth, windowHeight;
997
998    if (self.innerHeight) { // All except Explorer.
999      if (document.documentElement.clientWidth) {
1000        windowWidth = document.documentElement.clientWidth;
1001      }
1002      else {
1003        windowWidth = self.innerWidth;
1004      }
1005      windowHeight = self.innerHeight;
1006    }
1007    else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode.
1008      windowWidth = document.documentElement.clientWidth;
1009      windowHeight = document.documentElement.clientHeight;
1010    }
1011    else if (document.body) { // Other Explorers.
1012      windowWidth = document.body.clientWidth;
1013      windowHeight = document.body.clientHeight;
1014    }
1015    // For small pages with total height less than height of the viewport.
1016    if (yScroll < windowHeight) {
1017      pageHeight = windowHeight;
1018    }
1019    else {
1020      pageHeight = yScroll;
1021    }
1022    // For small pages with total width less than width of the viewport.
1023    if (xScroll < windowWidth) {
1024      pageWidth = xScroll;
1025    }
1026    else {
1027      pageWidth = windowWidth;
1028    }
1029    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
1030    return arrayPageSize;
1031  },
1032
1033
1034  // pause(numberMillis)
1035  pause : function(ms) {
1036    var date = new Date();
1037    var curDate = null;
1038    do { curDate = new Date(); }
1039    while (curDate - date < ms);
1040  },
1041
1042
1043  // toggleSelectsFlash()
1044  // Hide / unhide select lists and flash objects as they appear above the
1045  // lightbox in some browsers.
1046  toggleSelectsFlash: function (state) {
1047    if (state == 'visible') {
1048      $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").show();
1049    }
1050    else if (state == 'hide') {
1051      $("select:visible, embed:visible, object:visible").not('#lightboxAutoModal select, #lightboxAutoModal embed, #lightboxAutoModal object').addClass("lightbox_hidden");
1052      $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").hide();
1053    }
1054  },
1055
1056
1057  // parseRel()
1058  parseRel: function (link) {
1059    var parts = [];
1060    parts["rel"] = parts["title"] = parts["group"] = parts["style"] = parts["flashvars"] = null;
1061    if (!$(link).attr('rel')) return parts;
1062    parts["rel"] = $(link).attr('rel').match(/\w+/)[0];
1063
1064    if ($(link).attr('rel').match(/\[(.*)\]/)) {
1065      var info = $(link).attr('rel').match(/\[(.*?)\]/)[1].split('|');
1066      parts["group"] = info[0];
1067      parts["style"] = info[1];
1068      if (parts["style"] != undefined && parts["style"].match(/flashvars:\s?(.*?);/)) {
1069        parts["flashvars"] = parts["style"].match(/flashvars:\s?(.*?);/)[1];
1070      }
1071    }
1072    if ($(link).attr('rel').match(/\[.*\]\[(.*)\]/)) {
1073      parts["title"] = $(link).attr('rel').match(/\[.*\]\[(.*)\]/)[1];
1074    }
1075    return parts;
1076  },
1077
1078  // setStyles()
1079  setStyles: function(item, styles) {
1080    item.width = Lightbox.iframe_width;
1081    item.height = Lightbox.iframe_height;
1082    item.scrolling = "auto";
1083
1084    if (!styles) return item;
1085    var stylesArray = styles.split(';');
1086    for (var i = 0; i< stylesArray.length; i++) {
1087      if (stylesArray[i].indexOf('width:') >= 0) {
1088        var w = stylesArray[i].replace('width:', '');
1089        item.width = jQuery.trim(w);
1090      }
1091      else if (stylesArray[i].indexOf('height:') >= 0) {
1092        var h = stylesArray[i].replace('height:', '');
1093        item.height = jQuery.trim(h);
1094      }
1095      else if (stylesArray[i].indexOf('scrolling:') >= 0) {
1096        var scrolling = stylesArray[i].replace('scrolling:', '');
1097        item.scrolling = jQuery.trim(scrolling);
1098      }
1099      else if (stylesArray[i].indexOf('overflow:') >= 0) {
1100        var overflow = stylesArray[i].replace('overflow:', '');
1101        item.overflow = jQuery.trim(overflow);
1102      }
1103    }
1104    return item;
1105  },
1106
1107
1108  // togglePlayPause()
1109  // Hide the pause / play button as appropriate.  If pausing the slideshow also
1110  // clear the timers, otherwise move onto the next image.
1111  togglePlayPause: function(hideId, showId) {
1112    if (Lightbox.isSlideshow && hideId == "lightshowPause") {
1113      for (var i = 0; i < Lightbox.slideIdCount; i++) {
1114        window.clearTimeout(Lightbox.slideIdArray[i]);
1115      }
1116    }
1117    $('#' + hideId).hide();
1118    $('#' + showId).show();
1119
1120    if (hideId == "lightshowPlay") {
1121      Lightbox.isPaused = false;
1122      if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) {
1123        Lightbox.end();
1124      }
1125      else if (Lightbox.total > 1) {
1126        Lightbox.changeData(Lightbox.activeImage + 1);
1127      }
1128    }
1129    else {
1130      Lightbox.isPaused = true;
1131    }
1132  },
1133
1134  triggerLightbox: function (rel_type, rel_group) {
1135    if (rel_type.length) {
1136      if (rel_group && rel_group.length) {
1137        $("a[rel^='" + rel_type +"\[" + rel_group + "\]'], area[rel^='" + rel_type +"\[" + rel_group + "\]']").eq(0).trigger("click");
1138      }
1139      else {
1140        $("a[rel^='" + rel_type +"'], area[rel^='" + rel_type +"']").eq(0).trigger("click");
1141      }
1142    }
1143  },
1144
1145  detectMacFF2: function() {
1146    var ua = navigator.userAgent.toLowerCase();
1147    if (/firefox[\/\s](\d+\.\d+)/.test(ua)) {
1148      var ffversion = new Number(RegExp.$1);
1149      if (ffversion < 3 && ua.indexOf('mac') != -1) {
1150        return true;
1151      }
1152    }
1153    return false;
1154  },
1155
1156  checkKey: function(keys, key, code) {
1157    return (jQuery.inArray(key, keys) != -1 || jQuery.inArray(String(code), keys) != -1);
1158  },
1159
1160  filterXSS: function(str, allowed_tags) {
1161    var output = "";
1162    $.ajax({
1163      url: Drupal.settings.basePath + 'system/lightbox2/filter-xss',
1164      data: {
1165        'string' : str,
1166        'allowed_tags' : allowed_tags
1167      },
1168      type: "POST",
1169      async: false,
1170      dataType:  "json",
1171      success: function(data) {
1172        output = data;
1173      }
1174    });
1175    return output;
1176  }
1177
1178};
1179
1180// Initialize the lightbox.
1181Drupal.behaviors.initLightbox = function (context) {
1182  $('body:not(.lightbox-processed)', context).addClass('lightbox-processed').each(function() {
1183    Lightbox.initialize();
1184    return false; // Break the each loop.
1185  });
1186
1187  // Attach lightbox to any links with lightbox rels.
1188  Lightbox.initList(context);
1189  $('#lightboxAutoModal', context).triggerHandler('click');
1190};
1191
1192;
1193Drupal.behaviors.ddContactLoadReferrers = function(context) {
1194  var teasers = $('#node-sidebar .field-email a, #block-digitaldcore-node_contacts .node-teaser .field-email a', context);
1195
1196  teasers.each(function() {
1197    var teaser = $(this);
1198
1199    if (teaser.attr('href').indexOf('?profile=') > 0) {
1200      // Add destination parameter to the end to be able to track where the link came from
1201      var destination = window.location.pathname.substring(Drupal.settings.basePath.length);
1202      teaser.attr('href', teaser.attr('href') + '&destination=' + encodeURIComponent(destination));
1203    }
1204  });
1205};
1206;
1207
1208Drupal.behaviors.ddAnalytics = function(context) {
1209  // Ensure global _gaq Google Analytics queue has been initialized.
1210  var _gaq = _gaq || [];
1211
1212  // Track when video lightboxes are opened
1213  $('a.video-lightframe').click(function() {
1214    var title = $(this).parents('.node').find('.title').html();
1215    _gaq.push(['_trackEvent', 'Videos', 'Open', title]);
1216  });
1217};
1218
1219/**
1220 * @fileoverview A simple script to automatically track Facebook and Twitter
1221 * buttons using Google Analytics social tracking feature.
1222 * @author [email protected] (Nick Mihailovski)
1223 */
1224
1225/**
1226 * Namespace.
1227 * @type {Object}.
1228 */
1229var _ga = _ga || {};
1230
1231/**
1232 * Ensure global _gaq Google Analytics queue has been initialized.
1233 * @type {Array}
1234 */
1235var _gaq = _gaq || [];
1236
1237/**
1238 * Helper method to track social features. This assumes all the social
1239 * scripts / apis are loaded synchronously. If they are loaded async,
1240 * you might need to add the nextwork specific tracking call to the
1241 * a callback once the network's script has loaded.
1242 * @param {string} opt_pageUrl An optional URL to associate the social
1243 *     tracking with a particular page.
1244 * @param {string} opt_trackerName An optional name for the tracker object.
1245 */
1246_ga.trackSocial = function(opt_pageUrl, opt_trackerName) {
1247  _ga.trackFacebook(opt_pageUrl, opt_trackerName);
1248  _ga.trackTwitter(opt_pageUrl, opt_trackerName);
1249};
1250
1251/**
1252 * Tracks Facebook likes, unlikes and sends by suscribing to the Facebook
1253 * JSAPI event model. Note: This will not track facebook buttons using the
1254 * iFrame method.
1255 * @param {string} opt_pageUrl An optional URL to associate the social
1256 *     tracking with a particular page.
1257 * @param {string} opt_trackerName An optional name for the tracker object.
1258 */
1259_ga.trackFacebook = function(opt_pageUrl, opt_trackerName) {
1260  var trackerName = _ga.buildTrackerName_(opt_trackerName);
1261  try {
1262    if (FB && FB.Event && FB.Event.subscribe) {
1263      FB.Event.subscribe('edge.create', function(targetUrl) {
1264        _gaq.push([trackerName + '_trackSocial', 'facebook', 'like',
1265          targetUrl, opt_pageUrl]);
1266      });
1267      FB.Event.subscribe('edge.remove', function(targetUrl) {
1268        _gaq.push([trackerName + '_trackSocial', 'facebook', 'unlike',
1269          targetUrl, opt_pageUrl]);
1270      });
1271      FB.Event.subscribe('message.send', function(targetUrl) {
1272        _gaq.push([trackerName + '_trackSocial', 'facebook', 'send',
1273          targetUrl, opt_pageUrl]);
1274      });
1275    }
1276  } catch (e) {}
1277};
1278
1279/**
1280 * Returns the normalized tracker name configuration parameter.
1281 * @param {string} opt_trackerName An optional name for the tracker object.
1282 * @return {string} If opt_trackerName is set, then the value appended with
1283 *     a . Otherwise an empty string.
1284 * @private
1285 */
1286_ga.buildTrackerName_ = function(opt_trackerName) {
1287  return opt_trackerName ? opt_trackerName + '.' : '';
1288};
1289
1290/**
1291 * Tracks everytime a user clicks on a tweet button from Twitter.
1292 * This subscribes to the Twitter JS API event mechanism to listen for
1293 * clicks coming from this page. Details here:
1294 * http://dev.twitter.com/pages/intents-events#click
1295 * This method should be called once the twitter API has loaded.
1296 * @param {string} opt_pageUrl An optional URL to associate the social
1297 *     tracking with a particular page.
1298 * @param {string} opt_trackerName An optional name for the tracker object.
1299 */
1300_ga.trackTwitter = function(opt_pageUrl, opt_trackerName) {
1301  var trackerName = _ga.buildTrackerName_(opt_trackerName);
1302  try {
1303    if (twttr && twttr.events && twttr.events.bind) {
1304      twttr.events.bind('tweet', function(event) {
1305        if (event) {
1306          var targetUrl; // Default value is undefined.
1307          if (event.target && event.target.nodeName == 'IFRAME') {
1308            targetUrl = _ga.extractParamFromUri_(event.target.src, 'url');
1309          }
1310          _gaq.push([trackerName + '_trackSocial', 'twitter', 'tweet',
1311            targetUrl, opt_pageUrl]);
1312        }
1313      });
1314    }
1315  } catch (e) {}
1316};
1317
1318/**
1319 * Extracts a query parameter value from a URI.
1320 * @param {string} uri The URI from which to extract the parameter.
1321 * @param {string} paramName The name of the query paramater to extract.
1322 * @return {string} The un-encoded value of the query paramater. underfined
1323 *     if there is no URI parameter.
1324 * @private
1325 */
1326_ga.extractParamFromUri_ = function(uri, paramName) {
1327  if (!uri) {
1328    return;
1329  }
1330  var uri = uri.split('#')[0];  // Remove anchor.
1331  var parts = uri.split('?');  // Check for query params.
1332  if (parts.length == 1) {
1333    return;
1334  }
1335  var query = decodeURI(parts[1]);
1336
1337  // Find url param.
1338  paramName += '=';
1339  var params = query.split('&');
1340  for (var i = 0, param; param = params[i]; ++i) {
1341    if (param.indexOf(paramName) === 0) {
1342      return unescape(param.split('=')[1]);
1343    }
1344  }
1345  return;
1346};
1347;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.