home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / res / html / lightbox / jquery.lightbox-0.5.js < prev   
Encoding:
JavaScript  |  2009-09-11  |  40.2 KB  |  837 lines

  1. /**
  2.  * jQuery lightBox plugin
  3.  * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
  4.  * and adapted to me for use like a plugin from jQuery.
  5.  * @name jquery-lightbox-0.5.js
  6.  * @author Leandro Vieira Pinho - http://leandrovieira.com
  7.  * @version 0.5
  8.  * @date April 11, 2008
  9.  * @category jQuery plugin
  10.  * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
  11.  * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
  12.  * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
  13.  */
  14.  
  15. // Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
  16.  
  17. function center(left, top, width, height) {
  18.   if (width == null && height == null) {
  19.     width = left;
  20.     height = top;
  21.     top = 0;
  22.     left = 0;
  23.   }
  24.  
  25.   return [left + (width / 2), top + (height / 2)];
  26. }
  27. (function($) {
  28.     /**
  29.      * $ is an alias to jQuery object
  30.      *
  31.      */
  32.     $.fn.lightBox = function(settings) {
  33.         // Settings to configure the jQuery lightBox plugin how you like
  34.         settings = jQuery.extend({
  35.             // Configuration related to overlay
  36.             overlayBgColor:         '#000',        // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
  37.             overlayOpacity:            0.0,        // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
  38.             // Configuration related to navigation
  39.             fixedNavigation:        false,        // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
  40.             fixedDataBox:           false,
  41.             imageDir:               'images',
  42.             // Configuration related to images
  43.             imageLoading:           'lightbox-blank.gif',                // (string) Path and the name of the loading icon
  44.             imageBtnPrev:           'lightbox-btn-prev.gif',        // (string) Path and the name of the prev button image
  45.             imageBtnNext:           'lightbox-btn-next.gif',        // (string) Path and the name of the next button image
  46.             imageBtnClose:          'lightbox-blank.gif',                // (string) Path and the name of the close btn
  47.             imageBlank:             'lightbox-blank.gif',            // (string) Path and the name of a blank image (one pixel)
  48.             imageContext:           'lightbox-blank.gif',
  49.             // Configuration related to container image box
  50.             containerBorderSize:    0,            // (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
  51.             containerResizeSpeed:   100,        // (integer) Specify the resize duration of container image. These number are miliseconds. 100 is default.
  52.             // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
  53.             txtImage:               'Image',    // (string) Specify text "Image"
  54.             txtOf:                  'of',        // (string) Specify text "of"
  55.             // Configuration related to keyboard navigation
  56.             keyToClose:             'c',        // (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
  57.             keyToPrev:              'p',        // (string) (p = previous) Letter to show the previous image
  58.             keyToNext:              'n',        // (string) (n = next) Letter to show the next image.
  59.             wrapNav:                false,
  60.             dataBoxFirst:           false,
  61.             clickLoadingClose:      true,
  62.             clickBoxClose:          true,
  63.             linkContextFunction:    function () { return ''; },
  64.             onShowFunction:         function () { return ''; },
  65.             haveShown:              false,
  66.             delayUntilShown:        [],
  67.             onInitFunction:         function () { return ''; },
  68.             lengthTextFunction:     function (arrayLen) { return arrayLen; },
  69.             realIndexFunction:      function (arrayIdx) { return arrayIdx; },
  70.             imgIdFunction:          function (obj) { return obj.getAttribute('href'); },
  71.             showContext:            false,
  72.             windowPadding:          16,
  73.             changeCounterAfterSlide:true,
  74.             iconOffset:             4,
  75.             // Don┤t alter these variables in any way
  76.             imageArray:             [],
  77.             activeImage:            0,
  78.             parentSelector:         null,
  79.         },settings);
  80.         // Caching the jQuery object with all elements matched
  81.         var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
  82.         /**
  83.          * Initializing the plugin calling the start function
  84.          *
  85.          * @return boolean false
  86.          */
  87.         function _initialize() {
  88.             window._activeLightBox = { destroy: _finish, };
  89.             $('.hover-icon').hide();
  90.             _start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
  91.             settings.haveShown = false;
  92.             settings.onInitFunction(this, jQueryMatchedObj);
  93.             return false; // Avoid the browser following the link
  94.         }
  95.         /**
  96.          * Start the jQuery lightBox plugin
  97.          *
  98.          * @param object objClicked The object (link) whick the user have clicked
  99.          * @param object jQueryMatchedObj The jQuery object with all elements matched
  100.          */
  101.         function _start(objClicked,jQueryMatchedObj) {
  102.             // Hide some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
  103.             $('embed, object, select').css({ 'visibility' : 'hidden' });
  104.             // Call the function to create the markup structure; style some elements; assign events in some elements.
  105.             // Unset total images in imageArray
  106.             settings.imageArray.length = 0;
  107.             // Unset image active information
  108.             settings.activeImage = 0;
  109.             if (jQueryMatchedObj.data('imageArray')){
  110.                 storedArray = jQueryMatchedObj.data('imageArray');
  111.                 for ( var i = 0; i < storedArray.length; i++ ) {
  112.                     settings.imageArray.push(storedArray[i]);
  113.                 }
  114.             // We have an image set? Or just an image? Let┤s see it.
  115.             } else if ( jQueryMatchedObj.length == 1 ) {
  116.                 settings.imageArray.push(new Array(objClicked.getAttribute('href'),
  117.                                                    objClicked.getAttribute('title'),
  118.                                                    objClicked.getAttribute('context'),
  119.                                                    $(objClicked).offset(),
  120.                                                    objClicked.getAttribute('alt'),
  121.                                                    settings.imgIdFunction(objClicked)
  122.                                                    ));
  123.             } else {
  124.                 // Add an Array (as many as we have), with href and title attributes, inside the Array that stores the image references
  125.                 for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
  126.                     settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),
  127.                                                        jQueryMatchedObj[i].getAttribute('title'),
  128.                                                        jQueryMatchedObj[i].getAttribute('context'),
  129.                                                        $(jQueryMatchedObj[i]).offset(),
  130.                                                        jQueryMatchedObj[i].getAttribute('alt'),
  131.                                                        settings.imgIdFunction(jQueryMatchedObj[i])
  132.                                                        ));
  133.                 }
  134.             }
  135.             while ( settings.imageArray[settings.activeImage][5] != settings.imgIdFunction(objClicked) ) {
  136.                 settings.activeImage++;
  137.             }
  138.             // Call the function that prepares image exhibition
  139.             //$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
  140.             _set_interface();
  141.             _set_image_to_view();
  142.         }
  143.  
  144.         function _set_interface() {
  145.             // Apply the HTML markup into body tag
  146.             function __get_loading_content() {
  147.             return '<div id="lightbox-loading">' +
  148.                  '<div id="lightbox-loading-inner">' +
  149.                   '<a href="#" id="lightbox-loading-link">' +
  150.                    '<img src="' + settings.imageDir + "/" + settings.imageLoading + '">' +
  151.                   '</a>' +
  152.                  '</div>' +
  153.                 '</div>';
  154.             }
  155.             function __get_image_box() {
  156.              return '<div id="lightbox-container-image-box">' +
  157.               '<div id="lightbox-container-image">' +
  158.                '<img id="lightbox-image">' +
  159.                 '<div style="" id="lightbox-nav">' +
  160.                  '<a href="#" id="lightbox-nav-btnPrev"></a>' +
  161.                  '<a href="#" id="lightbox-nav-btnNext"></a>' +
  162.                 '</div>' +
  163.                 //__get_loading_content() +
  164.                '</div>' +
  165.               '</div>';
  166.             }
  167.             function __get_context_button_content() {
  168.              if (!settings.showContext) {
  169.               return '';
  170.              }
  171.  
  172.              return '<a id="lightbox-secNav-btnContext" href="#">' +
  173.                      '<img src="' + settings.imageDir + '/' + settings.imageContext + '"></a>';
  174.             }
  175.  
  176.             function __get_close_button_content() {
  177.              return '<a href="#" id="lightbox-secNav-btnClose">' +
  178.                      '<img src="' + settings.imageDir + '/' + settings.imageBtnClose + '"></a>';
  179.             }
  180.  
  181.             function __get_image_data_box() {
  182.              return '<div id="lightbox-container-image-data-box" class="header">' +
  183.                '<div id="lightbox-container-image-data">' +
  184.                '<div id="lightbox-secNav">' +
  185.                __get_close_button_content() +
  186.                __get_context_button_content() +
  187.                '</div>' +
  188.                 '<div id="lightbox-image-details">' +
  189.                 '<span id="lightbox-image-details-currentNumber" ' + '>' +
  190.                 /*'style="padding-' + (settings.dataBoxFirst ? 'top' : 'bottom') + ':1em;">' +*/
  191.                 '</span>' +
  192.                 '<span id="lightbox-image-details-caption"></span>' +
  193.                '</div>' +
  194.  
  195.                '</div>' +
  196.               '</div>';
  197.             }
  198.             var top = __get_loading_content() +
  199.                       '<div id="jquery-overlay"></div>' +
  200.                        '<div id="jquery-lightbox">';
  201.  
  202.             var mid = "";
  203.  
  204.             if (settings.dataBoxFirst) {
  205.              mid = __get_image_data_box() + __get_image_box();
  206.             } else {
  207.              mid = __get_image_box() + __get_image_data_box();
  208.             }
  209.             var bottom = '</div>'
  210.  
  211.             _add_to_parent(top + mid + bottom);
  212.  
  213.             if (settings.dataBoxFirst) {
  214.              $("#lightbox-container-image-data-box").css({borderBottomStyle: "none"});
  215.             } else {
  216.              $("#lightbox-container-image-data-box").css({borderTopStyle: "none"});
  217.             }
  218.             // Get page sizes
  219.             var arrPageSizes = ___getPageSize();
  220.             // Style overlay and show it
  221.  
  222.             // # ANIMATE
  223.             $('#jquery-overlay').css({
  224.                 background:            settings.overlayBgColor,
  225.                 opacity:            settings.overlayOpacity,
  226.                 width:                arrPageSizes[0],
  227.                 height:                arrPageSizes[1]
  228.             }).fadeIn();
  229.             // Get page scroll
  230.             var arrPageScroll = ___getPageScroll();
  231.             // Calculate top and left offset for the jquery-lightbox div object and show it
  232.             scrCenter = center(arrPageScroll[0], arrPageScroll[1], arrPageSizes[2], arrPageSizes[3]);
  233.             $('#jquery-lightbox').show().css({
  234.                 width: 0,
  235.                 height: 0,
  236.                 left: scrCenter[0],
  237.                 top: scrCenter[1],
  238.             },
  239.             { queue: false,
  240.               duration: settings.containerResizeSpeed
  241.             });
  242.             // Assigning click events in elements to close overlay
  243.             if (settings.clickBoxClose) {
  244.              $('#jquery-lightbox').click(function () { _finish(); return false; } );
  245.             }
  246.  
  247.             $('#jquery-overlay').click(function() {
  248.                 _finish();
  249.                 return false;
  250.             });
  251.  
  252.             if (settings.showContext) {
  253.              $('#lightbox-secNav-btnContext').attr("href", settings.imageArray[settings.activeImage][2]);
  254.             }
  255.             if (settings.clickLoadingClose) {
  256.              $('#lightbox-loading-link').click(function() { _finish(); return false; });
  257.             }
  258.  
  259.             // make clicking these do nothing
  260.             $('#lightbox-nav-btnPrev').click(function () {return false;});
  261.             $('#lightbox-nav-btnNext').click(function () {return false;});
  262.             // Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
  263.             $('#lightbox-secNav-btnClose').click(function() { _finish(); return false; });
  264.             // If window was resized, calculate the new overlay dimensions
  265.             $(window).resize(function() {
  266.                 // Get page sizes
  267.                 var arrPageSizes = ___getPageSize();
  268.                 // Style overlay and show it
  269.                 $('#jquery-overlay').css({
  270.                     width:        arrPageSizes[0],
  271.                     height:        arrPageSizes[1]
  272.                 });
  273.                 // Get page scroll
  274.                 var arrPageScroll = ___getPageScroll();
  275.                 // Calculate top and left offset for the jquery-lightbox div object and show it
  276.                 scrCenter = center(arrPageScroll[0], arrPageScroll[1], arrPageSizes[2], arrPageSizes[3]);
  277.                 $('#jquery-lightbox').css({
  278.                     left: scrCenter[0],
  279.                     top: scrCenter[1],
  280.                 });
  281.             });
  282.         }
  283.         /**
  284.          * Prepares image exibition; doing a image┤s preloader to calculate it┤s size
  285.          *
  286.          */
  287.         function _set_image_to_view(do_on_show) { // show the loading
  288.             // Bring back border along the edge shared with the data box
  289.             if (!settings.fixedDataBox) {
  290.                 if (settings.dataBoxFirst) {
  291.                  $("#lightbox-container-image-box").css({borderTopStyle: "solid"});
  292.                 } else {
  293.                  $("#lightbox-container-image-box").css({borderBottomStyle: "solid"});
  294.                 }
  295.             }
  296.             if (settings.wrapNav) {
  297.              if (settings.activeImage < 0) {
  298.               // go to last image
  299.               settings.activeImage = settings.imageArray.length - 1;
  300.              } else if (settings.activeImage >= settings.imageArray.length) {
  301.              // go to first image
  302.               settings.activeImage = 0;
  303.              }
  304.             }
  305.             if ( !settings.fixedDataBox) {
  306.                 //$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
  307.             }
  308.             if ( !settings.fixedNavigation ) {
  309.                 // Hide some elements
  310.                 //$('#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext').hide();
  311.             }
  312.             if (settings.showContext) {
  313.              $('#lightbox-secNav-btnContext').attr("href", settings.imageArray[settings.activeImage][2]);
  314.             }
  315.  
  316.             // Image preload process
  317.             var objImagePreloader = new Image();
  318.             objImagePreloader.onload = function() {
  319.                 $('#lightbox-loading').hide();
  320.                 $('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
  321.                 resized = _get_proper_image_size(objImagePreloader.width, objImagePreloader.height);
  322.  
  323.                 //$('#lightbox-image').css({width: resized[0], height: resized[1]});
  324.                 // Perfomance an effect in the image container resizing it
  325.                 _resize_container_image_box(resized[0], resized[1], $("#lightbox-container-image-box").is(":hidden"), do_on_show);
  326.                 //    clear onLoad, IE behaves irratically with animated gifs otherwise
  327.                 objImagePreloader.onload=function(){};
  328.                 objImagePreloader.loaded = true;
  329.             };
  330.             objImagePreloader.src = settings.imageArray[settings.activeImage][0];
  331.             objImagePreloader.loaded = false;
  332.  
  333.             var arrPageScroll = ___getPageScroll();
  334.             var arrPageSizes = ___getPageSize();
  335.             resized = _get_proper_image_size(objImagePreloader.width, objImagePreloader.height);
  336.             scrCenter = center(arrPageScroll[0], arrPageScroll[1], arrPageSizes[2], arrPageSizes[3]);
  337.             $('#lightbox-loading').css({
  338.                 top:  scrCenter[1] - ($('#lightbox-loading').height() / 2),
  339.                 left: scrCenter[0] - ($('#lightbox-loading').width()  / 2),
  340.             });
  341.  
  342.             // Show the loading
  343.             if (!objImagePreloader.loaded) {
  344.                 $('#lightbox-loading').show();
  345.             }
  346.  
  347.             if ( !settings.changeCounterAfterSlide ){
  348.                 // If we have a image set, display 'Image X of X'
  349.                 if ( settings.imageArray.length > 1 ) {
  350.                     $('#lightbox-image-details-currentNumber').html((settings.txtImage || settings.imageArray[settings.activeImage][4] || "")+ ' ' + ( settings.realIndexFunction(settings.activeImage) + 1 ) + ' ' + settings.txtOf + ' ' + settings.lengthTextFunction(settings.imageArray.length)).show();
  351.                 }
  352.             }
  353.         };
  354.  
  355.         /**
  356.         */
  357.         function _get_proper_image_size(iw, ih) {
  358.             var pagesize = ___getPageSize();
  359.             var x = pagesize[2] - (settings.containerBorderSize*2) - (settings.windowPadding*2);
  360.             var y = pagesize[3] - (settings.containerBorderSize*2) - (settings.windowPadding*2) - 60;
  361.             var imageWidth = iw;
  362.             var imageHeight = ih;
  363.             if (imageWidth > x) {
  364.                     imageHeight = imageHeight * (x / imageWidth);
  365.                     imageWidth = x;
  366.                     if (imageHeight > y) {
  367.                             imageWidth = imageWidth * (y / imageHeight);
  368.                             imageHeight = y;
  369.                     }
  370.             } else if (imageHeight > y) {
  371.                     imageWidth = imageWidth * (y / imageHeight);
  372.                     imageHeight = y;
  373.                     if (imageWidth > x) {
  374.                             imageHeight = imageHeight * (x / imageWidth);
  375.                             imageWidth = x;
  376.                     }
  377.             }
  378.             return [imageWidth, imageHeight];
  379.         }
  380.         /**
  381.          * Perfomance an effect in the image container resizing it
  382.          *
  383.          * @param integer intImageWidth The image┤s width that will be showed
  384.          * @param integer intImageHeight The image┤s height that will be showed
  385.          */
  386.         function _resize_container_image_box(intImageWidth,intImageHeight, is_hidden, do_on_show) {
  387.             // Get current width and height
  388.             var intCurrentWidth = $('#lightbox-container-image-box').width();
  389.             var intCurrentHeight = $('#lightbox-container-image-box').height();
  390.             // Get the width and height of the selected image plus the padding
  391.             var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image┤s width and the left and right padding value
  392.             var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image┤s height and the left and right padding value
  393.             // Diferences
  394.             var intDiffW = intCurrentWidth - intWidth;
  395.             var intDiffH = intCurrentHeight - intHeight;
  396.             // Perfomance the effect
  397.  
  398.             $('#lightbox-container-image-data-box').css({ width: intImageWidth });
  399.             $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
  400.             // # ANIMATE
  401.  
  402.             lbcidb_height = $('#lightbox-container-image-data-box').height();
  403.             lbcidb_width = intImageWidth;
  404.             if (is_hidden) {
  405.                 $('#lightbox-container-image-data-box').css({height: 0, width: 0});
  406.                 $('#lightbox-image').css({height: 0, width: 0});
  407.                 $('#lightbox-container-image-box').css({height: 0, width: 0});
  408.                 $('#jquery-lightbox').css({height: 0, width: 0});
  409.                 setsize = "animate";
  410.             } else {
  411.                 setsize = "css";
  412.             }
  413.  
  414.             $('#jquery-lightbox')[setsize]({
  415.                     top: ___getPageScroll()[1] + (___getPageSize()[3] - intImageHeight) / 2,
  416.                     left: ___getPageScroll()[0] + (___getPageSize()[2] - intImageWidth) / 2,
  417.                     width: intImageWidth,
  418.                     height: intImageHeight + lbcidb_height,
  419.             }, { queue: false,
  420.                  duration: settings.containerResizeSpeed,
  421.                  complete: function () {_show_image(do_on_show);}
  422.             });
  423.  
  424.             $('#lightbox-container-image-data-box')[setsize]({
  425.                     height: lbcidb_height,
  426.                     width: lbcidb_width,
  427.                 }, { queue: false, duration: settings.containerResizeSpeed }
  428.             );
  429.  
  430.             $('#lightbox-image')[setsize]({
  431.                     width: intWidth,
  432.                     height: intHeight
  433.             }, { queue: false, duration: settings.containerResizeSpeed });
  434.  
  435.             $('#lightbox-container-image-box')[setsize]({
  436.                     width: intWidth,
  437.                     height: intHeight,
  438.             }, { queue: false, duration: settings.containerResizeSpeed });
  439.  
  440.             if (setsize == 'css') {
  441.                 _show_image(do_on_show);
  442.             }
  443.  
  444.         };
  445.  
  446.         /**
  447.          * Show the prepared image
  448.          *
  449.          */
  450.         function _show_image(do_on_show) {
  451.             $('#lightbox-loading').hide();
  452.             // Remove border along the edge shared with the data box
  453.             if (settings.dataBoxFirst) {
  454.              $("#lightbox-container-image-box").css({borderTopStyle: "none"});
  455.             } else {
  456.              $("#lightbox-container-image-box").css({borderBottomStyle: "none"});
  457.             }
  458.             $('#lightbox-image-details').fadeIn("def", function(){
  459.                 if (settings.haveShown) {
  460.                     return
  461.                 }
  462.                 settings.haveShown = true;
  463.                 for (var i = 0; i < settings.delayUntilShown.length; i++){
  464.                     settings.delayUntilShown[i]();
  465.                 }
  466.                 settings.delayUntilShown.length = 0;
  467.             });
  468.             _show_image_data();
  469.             _set_navigation();
  470.             _preload_neighbor_images();
  471.             if (do_on_show != false) {
  472.                 settings.onShowFunction(this);
  473.             }
  474.         };
  475.         /**
  476.          * Show the image information
  477.          *
  478.          */
  479.         function _show_image_data() {
  480.  
  481.             if (!settings.fixedDataBox) {
  482.                     //$('#lightbox-image-details-caption').hide();
  483.             }
  484.             if ( settings.imageArray[settings.activeImage][1] ) {
  485.                 var dash = settings.imageArray.length > 1 ? '- ' : '';
  486.                 $('#lightbox-image-details-caption').html(dash + settings.imageArray[settings.activeImage][1]).show();
  487.             } else {
  488.                 $('#lightbox-image-details-caption').hide();
  489.             }
  490.             if ( settings.changeCounterAfterSlide ){
  491.                 // If we have a image set, display 'Image X of X'
  492.                 if ( settings.imageArray.length > 1 ) {
  493.                     $('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
  494.                 }
  495.             }
  496.         }
  497.         /**
  498.          * Display the button navigations
  499.          *
  500.          */
  501.         function _set_navigation() {
  502.             $('#lightbox-nav').show();
  503.  
  504.             // Instead to define this configuration in CSS file, we define here. And it┤s need to IE. Just.
  505.             $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url("' + settings.imageDir + "/" + settings.imageBlank + '") no-repeat' });
  506.  
  507.             // Show the prev button
  508.             if ( ((settings.activeImage != 0) || settings.wrapNav) && settings.imageArray.length > 1 ) {
  509.                 if ( settings.fixedNavigation ) {
  510.                     $('#lightbox-nav-btnPrev').css({ 'background' : 'url("' + settings.imageDir + "/" + settings.imageBtnPrev + '") left 15% no-repeat' })
  511.                         .unbind()
  512.                         .bind('click',function() {
  513.                             settings.activeImage = settings.activeImage - 1;
  514.                             _set_image_to_view();
  515.                             return false;
  516.                         });
  517.                 } else {
  518.                     // Show the images button for Next buttons
  519.                     $('#lightbox-nav-btnPrev').unbind().hover(function() {
  520.                         $(this).css({ 'background' : 'url("' + settings.imageDir + "/" + settings.imageBtnPrev + '") left 15% no-repeat' });
  521.                     },function() {
  522.                         $(this).css({ 'background' : 'transparent url("' + settings.imageDir + "/" + settings.imageBlank + '") no-repeat' });
  523.                     }).show().bind('click',function() {
  524.                         settings.activeImage = settings.activeImage - 1;
  525.                         _set_image_to_view();
  526.                         return false;
  527.                     });
  528.                 }
  529.             }
  530.  
  531.             // Show the next button, if not the last image in set
  532.             if ( ((settings.activeImage != ( settings.imageArray.length -1 ) ) || settings.wrapNav) && settings.imageArray.length > 1 ) {
  533.                 if ( settings.fixedNavigation ) {
  534.                     $('#lightbox-nav-btnNext').css({ 'background' : 'url("' + settings.imageDir + "/" + settings.imageBtnNext + '") right 15% no-repeat' })
  535.                         .unbind()
  536.                         .bind('click',function() {
  537.                             settings.activeImage = settings.activeImage + 1;
  538.                             _set_image_to_view();
  539.                             return false;
  540.                         });
  541.                 } else {
  542.                     // Show the images button for Next buttons
  543.                     $('#lightbox-nav-btnNext').unbind().hover(function() {
  544.                         $(this).css({ 'background' : 'url("' + settings.imageDir + "/" + settings.imageBtnNext + '") right 15% no-repeat' });
  545.                     },function() {
  546.                         $(this).css({ 'background' : 'transparent url("' + settings.imageDir + "/" + settings.imageBlank + '") no-repeat' });
  547.                     }).show().bind('click',function() {
  548.                         settings.activeImage = settings.activeImage + 1;
  549.                         _set_image_to_view();
  550.                         return false;
  551.                     });
  552.                 }
  553.             }
  554.             // Enable keyboard navigation
  555.             _enable_keyboard_navigation();
  556.         }
  557.         /**
  558.          * Enable a support to keyboard navigation
  559.          *
  560.          */
  561.         function _enable_keyboard_navigation() {
  562.             $(document).keydown(_keyboard_action);
  563.         }
  564.         /**
  565.          * Disable the support to keyboard navigation
  566.          *
  567.          */
  568.         function _disable_keyboard_navigation() {
  569.             $(document).unbind('keydown', _keyboard_action);
  570.         }
  571.         /**
  572.          * Perform the keyboard actions
  573.          *
  574.          */
  575.         function _keyboard_action(objEvent) {
  576.             // To ie
  577.             if ( objEvent == null ) {
  578.                 keycode = event.keyCode;
  579.                 escapeKey = 27;
  580.             // To Mozilla
  581.             } else {
  582.                 keycode = objEvent.keyCode;
  583.                 escapeKey = objEvent.DOM_VK_ESCAPE;
  584.             }
  585.             // Get the key in lower case form
  586.             key = String.fromCharCode(keycode).toLowerCase();
  587.             // Verify the keys to close the ligthBox
  588.             if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
  589.                 _finish();
  590.             }
  591.             // Verify the key to show the previous image
  592.             if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
  593.                 // If we┤re not showing the first image, call the previous
  594.                 if ( (settings.activeImage != 0) || settings.wrapNav ) {
  595.                     settings.activeImage = settings.activeImage - 1;
  596.                     _set_image_to_view();
  597.                     _disable_keyboard_navigation();
  598.                 }
  599.             }
  600.             // Verify the key to show the next image
  601.             if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
  602.                 // If we┤re not showing the last image, call the next
  603.                 if ( (settings.activeImage != ( settings.imageArray.length - 1 )) || settings.wrapNav ) {
  604.                     settings.activeImage = settings.activeImage + 1;
  605.                     _set_image_to_view();
  606.                     _disable_keyboard_navigation();
  607.                 }
  608.             }
  609.         }
  610.         /**
  611.          * Preload prev and next images being showed
  612.          *
  613.          */
  614.         function _preload_neighbor_images() {
  615.                     function preload(idx) {
  616.                      obj = new Image();
  617.                      obj.src = settings.imageArray[idx][0];
  618.                     }
  619.                     if ( (settings.imageArray.length -1) > settings.activeImage ) {
  620.                             preload(settings.activeImage + 1);
  621.                     } else if (settings.wrapNav) {
  622.                             // we're at the end; preload #0
  623.                             preload(0);
  624.                     }
  625.                     if ( settings.activeImage > 0 ) {
  626.                             preload(settings.activeImage - 1);
  627.                     } else if (settings.wrapNav) {
  628.                             // we're at the start, preload the last one
  629.                             preload(settings.imageArray.length -1);
  630.                     }
  631.         }
  632.         /**
  633.          * Remove jQuery lightBox plugin HTML markup
  634.          *
  635.          */
  636.         function _finish() {
  637.             // stop all fading and animations
  638.             $.each(['#lightbox-image-details', '#jquery-lightbox', '#jquery-overlay'], function (i, id) {
  639.                 $(id).stop(true, true);
  640.             });
  641.  
  642.             window._activeLightBox = null;
  643.             _disable_keyboard_navigation();
  644.             $('.hover-icon').remove();
  645.             $('#lightbox-loading').remove();
  646.             $('#jquery-lightbox').remove();
  647.             $('#jquery-overlay').remove();
  648.             // Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
  649.             $('embed, object, select').css({ 'visibility' : 'visible' });
  650.         }
  651.         /**
  652.          / THIRD FUNCTION
  653.          * getPageSize() by quirksmode.com
  654.          *
  655.          * @return Array Return an array with page width, height and window width, height
  656.          */
  657.         function ___getPageSize() {
  658.             var xScroll, yScroll;
  659.             if (window.innerHeight && window.scrollMaxY) {
  660.                 xScroll = window.innerWidth + window.scrollMaxX;
  661.                 yScroll = window.innerHeight + window.scrollMaxY;
  662.             } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  663.                 xScroll = document.body.scrollWidth;
  664.                 yScroll = document.body.scrollHeight;
  665.             } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  666.                 xScroll = document.body.offsetWidth;
  667.                 yScroll = document.body.offsetHeight;
  668.             }
  669.             var windowWidth, windowHeight;
  670.             if (self.innerHeight) {    // all except Explorer
  671.                 if(document.documentElement.clientWidth){
  672.                     windowWidth = document.documentElement.clientWidth;
  673.                 } else {
  674.                     windowWidth = self.innerWidth;
  675.                 }
  676.                 windowHeight = self.innerHeight;
  677.             } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  678.                 windowWidth = document.documentElement.clientWidth;
  679.                 windowHeight = document.documentElement.clientHeight;
  680.             } else if (document.body) { // other Explorers
  681.                 windowWidth = document.body.clientWidth;
  682.                 windowHeight = document.body.clientHeight;
  683.             }
  684.             // for small pages with total height less then height of the viewport
  685.             if(yScroll < windowHeight){
  686.                 pageHeight = windowHeight;
  687.             } else {
  688.                 pageHeight = yScroll;
  689.             }
  690.             // for small pages with total width less then width of the viewport
  691.             if(xScroll < windowWidth){
  692.                 pageWidth = xScroll;
  693.             } else {
  694.                 pageWidth = windowWidth;
  695.             }
  696.             arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
  697.             return arrayPageSize;
  698.         };
  699.         /**
  700.          / THIRD FUNCTION
  701.          * getPageScroll() by quirksmode.com
  702.          *
  703.          * @return Array Return an array with x,y page scroll values.
  704.          */
  705.         function ___getPageScroll() {
  706.             var xScroll, yScroll;
  707.             if (self.pageYOffset) {
  708.                 yScroll = self.pageYOffset;
  709.                 xScroll = self.pageXOffset;
  710.             } else if (document.documentElement && document.documentElement.scrollTop) {     // Explorer 6 Strict
  711.                 yScroll = document.documentElement.scrollTop;
  712.                 xScroll = document.documentElement.scrollLeft;
  713.             } else if (document.body) {// all other Explorers
  714.                 yScroll = document.body.scrollTop;
  715.                 xScroll = document.body.scrollLeft;
  716.             }
  717.             arrayPageScroll = new Array(xScroll,yScroll);
  718.             return arrayPageScroll;
  719.         };
  720.          /**
  721.           * Stop the code execution from a escified time in milisecond
  722.           *
  723.           */
  724.          function ___pause(ms) {
  725.             var date = new Date();
  726.             curDate = null;
  727.             do { var curDate = new Date(); }
  728.             while ( curDate - date < ms);
  729.          };
  730.         // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
  731.  
  732.         function _add_to_parent(element) {
  733.             sel = settings.parentSelector || "body";
  734.             parent = $($(sel)[0]);
  735.             parent.append(element);
  736.         }
  737.  
  738.         function addHoverToElement(org_image) {
  739.             icon = $("<div></div>").addClass("hover-icon").css({"display":"none"});
  740.             _add_to_parent(icon);
  741.  
  742.             org_image.hover(function() {
  743.                     click_image = function () { $(icon).hide(); $(this).hide(); return org_image.click.call(org_image); };
  744.                     var margin_top = org_image.css("marginTop").slice(0,-2);
  745.                     var margin_bottom = org_image.css("marginBottom").slice(0,-2);
  746.                     var margin_left = org_image.css("marginLeft").slice(0,-2);
  747.                     var margin_right = org_image.css("marginRight").slice(0,-2);
  748.                     if (margin_top < 0 || margin_bottom < 0 || margin_left < 0 || margin_right < 0) {
  749.                         var parent_ele = $(org_image);
  750.                         var parentEls = $(org_image).parents();
  751.                          $(parentEls).each(function(){
  752.                             if(this.tagName == "BODY") {
  753.                                 return false;
  754.                             } else if($(this).css("overflow") == "hidden") {
  755.                                 parent_ele = $(this);
  756.                                 return false;
  757.                             }
  758.                         });
  759.                         var offset = parent_ele.offset();
  760.                         var parent_border_top = parseInt(parent_ele.css("border-top-width"));
  761.                         var parent_border_left = parseInt(parent_ele.css("border-left-width"));
  762.                     } else {
  763.                         var offset = org_image.offset();
  764.                         var parent_border_top = parseInt(org_image.css("border-top-width"));
  765.                         var parent_border_left = parseInt(org_image.css("border-left-width"));
  766.                     }
  767.                     if (!parent_border_top){ parent_border_top = 0; }
  768.                     if (!parent_border_left){ parent_border_left = 0; }
  769.  
  770.                     var displayFlag = false;
  771.                     $("div.hover-icon").each(function(){
  772.                         if(parseInt($(this).css("top")) == (offset.top + settings.iconOffset + parent_border_top) &&
  773.                            parseInt($(this).css("left")) == (offset.left + settings.iconOffset + parent_border_left)){
  774.                             displayFlag = true;
  775.                             curIcon = $(this);
  776.                         }
  777.                     });
  778.                     if(displayFlag == false){
  779.                         $(icon).css({"top": offset.top + settings.iconOffset + parent_border_top,
  780.                                      "left": offset.left + settings.iconOffset + parent_border_left});
  781.                         $("body").prepend(icon);
  782.                     }
  783.                     icon.unbind('click').bind('click', click_image);
  784.                     icon.show();
  785.                 }, function (eventObject) {
  786.                     $(".hover-icon").hide();
  787.                     $(".hover-icon:hover").show();
  788.                 } );
  789.  
  790.                 $(icon).hover(
  791.                     function(){
  792.                         $(this).show();
  793.                     },
  794.                     function(){
  795.                         $(this).hide();
  796.                     });
  797.  
  798.             }
  799.  
  800.         function _updateImageArray(newArray) {
  801.             if (!newArray.length){
  802.                 return;
  803.             }
  804.             if (!settings.haveShown) {
  805.                 settings.delayUntilShown.push(function(){
  806.                     _updateImageArray(newArray);
  807.                 });
  808.                 return;
  809.             }
  810.             var currentId = settings.imageArray[settings.activeImage][5];
  811.             settings.imageArray.length = 0;
  812.             settings.activeImage = 0;
  813.             for ( var i = 0; i < newArray.length; i++ ) {
  814.                 settings.imageArray.push(newArray[i]);
  815.             }
  816.             while ( settings.imageArray[settings.activeImage][5] != currentId ) {
  817.                 settings.activeImage++;
  818.             }
  819.             // Call the function that prepares image exhibition
  820.             //$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
  821.             jQueryMatchedObj.data('imageArray', newArray);
  822.             _set_image_to_view(false);
  823.         }
  824.  
  825.         old_hover_icons = $(".hover-icon");
  826.         old_hover_icons.remove();
  827.         for ( var i = 0; i < this.length; i++ ) {
  828.          addHoverToElement($($(this[i]).find("img")[0]));
  829.         }
  830.         this.unbind('click').click(_initialize);
  831.         var lightBoxHooks = {
  832.             updateImageArray: _updateImageArray
  833.         };
  834.         return lightBoxHooks;
  835.     };
  836. })(jQuery); // Call and execute the function immediately passing the jQuery object
  837.