Added template from http://www.freehtml5templates.com/bluenightsky-html5-and-css3...
[treecutter.git] / style / bluenightsky / js / jquery.lightbox-0.5.js
1 /**\r
2  * jQuery lightBox plugin\r
3  * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)\r
4  * and adapted to me for use like a plugin from jQuery.\r
5  * @name jquery-lightbox-0.5.js\r
6  * @author Leandro Vieira Pinho - http://leandrovieira.com\r
7  * @version 0.5\r
8  * @date April 11, 2008\r
9  * @category jQuery plugin\r
10  * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)\r
11  * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US\r
12  * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin\r
13  */\r
14 \r
15 // Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias\r
16 (function($) {\r
17         /**\r
18          * $ is an alias to jQuery object\r
19          *\r
20          */\r
21         $.fn.lightBox = function(settings) {\r
22                 // Settings to configure the jQuery lightBox plugin how you like\r
23                 settings = jQuery.extend({\r
24                         // Configuration related to overlay\r
25                         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.\r
26                         overlayOpacity:                 0.8,            // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9\r
27                         // Configuration related to navigation\r
28                         fixedNavigation:                false,          // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.\r
29                         // Configuration related to images\r
30                         imageLoading:                   'images/lightboximages/lightbox-ico-loading.gif',               // (string) Path and the name of the loading icon\r
31                         imageBtnPrev:                   'images/lightboximages/lightbox-btn-prev.gif',                  // (string) Path and the name of the prev button image\r
32                         imageBtnNext:                   'images/lightboximages/lightbox-btn-next.gif',                  // (string) Path and the name of the next button image\r
33                         imageBtnClose:                  'images/lightboximages/lightbox-btn-close.gif',         // (string) Path and the name of the close btn\r
34                         imageBlank:                             'images/lightboximages/lightbox-blank.gif',                     // (string) Path and the name of a blank image (one pixel)\r
35                         // Configuration related to container image box\r
36                         containerBorderSize:    10,                     // (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value\r
37                         containerResizeSpeed:   400,            // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.\r
38                         // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.\r
39                         txtImage:                               'Image',        // (string) Specify text "Image"\r
40                         txtOf:                                  'of',           // (string) Specify text "of"\r
41                         // Configuration related to keyboard navigation\r
42                         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.\r
43                         keyToPrev:                              'p',            // (string) (p = previous) Letter to show the previous image\r
44                         keyToNext:                              'n',            // (string) (n = next) Letter to show the next image.\r
45                         // Don´t alter these variables in any way\r
46                         imageArray:                             [],\r
47                         activeImage:                    0\r
48                 },settings);\r
49                 // Caching the jQuery object with all elements matched\r
50                 var jQueryMatchedObj = this; // This, in this context, refer to jQuery object\r
51                 /**\r
52                  * Initializing the plugin calling the start function\r
53                  *\r
54                  * @return boolean false\r
55                  */\r
56                 function _initialize() {\r
57                         _start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked\r
58                         return false; // Avoid the browser following the link\r
59                 }\r
60                 /**\r
61                  * Start the jQuery lightBox plugin\r
62                  *\r
63                  * @param object objClicked The object (link) whick the user have clicked\r
64                  * @param object jQueryMatchedObj The jQuery object with all elements matched\r
65                  */\r
66                 function _start(objClicked,jQueryMatchedObj) {\r
67                         // Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.\r
68                         $('embed, object, select').css({ 'visibility' : 'hidden' });\r
69                         // Call the function to create the markup structure; style some elements; assign events in some elements.\r
70                         _set_interface();\r
71                         // Unset total images in imageArray\r
72                         settings.imageArray.length = 0;\r
73                         // Unset image active information\r
74                         settings.activeImage = 0;\r
75                         // We have an image set? Or just an image? Let´s see it.\r
76                         if ( jQueryMatchedObj.length == 1 ) {\r
77                                 settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));\r
78                         } else {\r
79                                 // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references                \r
80                                 for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {\r
81                                         settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));\r
82                                 }\r
83                         }\r
84                         while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {\r
85                                 settings.activeImage++;\r
86                         }\r
87                         // Call the function that prepares image exibition\r
88                         _set_image_to_view();\r
89                 }\r
90                 /**\r
91                  * Create the jQuery lightBox plugin interface\r
92                  *\r
93                  * The HTML markup will be like that:\r
94                         <div id="jquery-overlay"></div>\r
95                         <div id="jquery-lightbox">\r
96                                 <div id="lightbox-container-image-box">\r
97                                         <div id="lightbox-container-image">\r
98                                                 <img src="../fotos/XX.jpg" id="lightbox-image">\r
99                                                 <div id="lightbox-nav">\r
100                                                         <a href="#" id="lightbox-nav-btnPrev"></a>\r
101                                                         <a href="#" id="lightbox-nav-btnNext"></a>\r
102                                                 </div>\r
103                                                 <div id="lightbox-loading">\r
104                                                         <a href="#" id="lightbox-loading-link">\r
105                                                                 <img src="../images/lightbox-ico-loading.gif">\r
106                                                         </a>\r
107                                                 </div>\r
108                                         </div>\r
109                                 </div>\r
110                                 <div id="lightbox-container-image-data-box">\r
111                                         <div id="lightbox-container-image-data">\r
112                                                 <div id="lightbox-image-details">\r
113                                                         <span id="lightbox-image-details-caption"></span>\r
114                                                         <span id="lightbox-image-details-currentNumber"></span>\r
115                                                 </div>\r
116                                                 <div id="lightbox-secNav">\r
117                                                         <a href="#" id="lightbox-secNav-btnClose">\r
118                                                                 <img src="../images/lightbox-btn-close.gif">\r
119                                                         </a>\r
120                                                 </div>\r
121                                         </div>\r
122                                 </div>\r
123                         </div>\r
124                  *\r
125                  */\r
126                 function _set_interface() {\r
127                         // Apply the HTML markup into body tag\r
128                         $('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');       \r
129                         // Get page sizes\r
130                         var arrPageSizes = ___getPageSize();\r
131                         // Style overlay and show it\r
132                         $('#jquery-overlay').css({\r
133                                 backgroundColor:        settings.overlayBgColor,\r
134                                 opacity:                        settings.overlayOpacity,\r
135                                 width:                          arrPageSizes[0],\r
136                                 height:                         arrPageSizes[1]\r
137                         }).fadeIn();\r
138                         // Get page scroll\r
139                         var arrPageScroll = ___getPageScroll();\r
140                         // Calculate top and left offset for the jquery-lightbox div object and show it\r
141                         $('#jquery-lightbox').css({\r
142                                 top:    arrPageScroll[1] + (arrPageSizes[3] / 10),\r
143                                 left:   arrPageScroll[0]\r
144                         }).show();\r
145                         // Assigning click events in elements to close overlay\r
146                         $('#jquery-overlay,#jquery-lightbox').click(function() {\r
147                                 _finish();                                                                      \r
148                         });\r
149                         // Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects\r
150                         $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {\r
151                                 _finish();\r
152                                 return false;\r
153                         });\r
154                         // If window was resized, calculate the new overlay dimensions\r
155                         $(window).resize(function() {\r
156                                 // Get page sizes\r
157                                 var arrPageSizes = ___getPageSize();\r
158                                 // Style overlay and show it\r
159                                 $('#jquery-overlay').css({\r
160                                         width:          arrPageSizes[0],\r
161                                         height:         arrPageSizes[1]\r
162                                 });\r
163                                 // Get page scroll\r
164                                 var arrPageScroll = ___getPageScroll();\r
165                                 // Calculate top and left offset for the jquery-lightbox div object and show it\r
166                                 $('#jquery-lightbox').css({\r
167                                         top:    arrPageScroll[1] + (arrPageSizes[3] / 10),\r
168                                         left:   arrPageScroll[0]\r
169                                 });\r
170                         });\r
171                 }\r
172                 /**\r
173                  * Prepares image exibition; doing a image´s preloader to calculate it´s size\r
174                  *\r
175                  */\r
176                 function _set_image_to_view() { // show the loading\r
177                         // Show the loading\r
178                         $('#lightbox-loading').show();\r
179                         if ( settings.fixedNavigation ) {\r
180                                 $('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();\r
181                         } else {\r
182                                 // Hide some elements\r
183                                 $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();\r
184                         }\r
185                         // Image preload process\r
186                         var objImagePreloader = new Image();\r
187                         objImagePreloader.onload = function() {\r
188                                 $('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);\r
189                                 // Perfomance an effect in the image container resizing it\r
190                                 _resize_container_image_box(objImagePreloader.width,objImagePreloader.height);\r
191                                 //      clear onLoad, IE behaves irratically with animated gifs otherwise\r
192                                 objImagePreloader.onload=function(){};\r
193                         };\r
194                         objImagePreloader.src = settings.imageArray[settings.activeImage][0];\r
195                 };\r
196                 /**\r
197                  * Perfomance an effect in the image container resizing it\r
198                  *\r
199                  * @param integer intImageWidth The image´s width that will be showed\r
200                  * @param integer intImageHeight The image´s height that will be showed\r
201                  */\r
202                 function _resize_container_image_box(intImageWidth,intImageHeight) {\r
203                         // Get current width and height\r
204                         var intCurrentWidth = $('#lightbox-container-image-box').width();\r
205                         var intCurrentHeight = $('#lightbox-container-image-box').height();\r
206                         // Get the width and height of the selected image plus the padding\r
207                         var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value\r
208                         var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value\r
209                         // Diferences\r
210                         var intDiffW = intCurrentWidth - intWidth;\r
211                         var intDiffH = intCurrentHeight - intHeight;\r
212                         // Perfomance the effect\r
213                         $('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });\r
214                         if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {\r
215                                 if ( $.browser.msie ) {\r
216                                         ___pause(250);\r
217                                 } else {\r
218                                         ___pause(100);  \r
219                                 }\r
220                         } \r
221                         $('#lightbox-container-image-data-box').css({ width: intImageWidth });\r
222                         $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });\r
223                 };\r
224                 /**\r
225                  * Show the prepared image\r
226                  *\r
227                  */\r
228                 function _show_image() {\r
229                         $('#lightbox-loading').hide();\r
230                         $('#lightbox-image').fadeIn(function() {\r
231                                 _show_image_data();\r
232                                 _set_navigation();\r
233                         });\r
234                         _preload_neighbor_images();\r
235                 };\r
236                 /**\r
237                  * Show the image information\r
238                  *\r
239                  */\r
240                 function _show_image_data() {\r
241                         $('#lightbox-container-image-data-box').slideDown('fast');\r
242                         $('#lightbox-image-details-caption').hide();\r
243                         if ( settings.imageArray[settings.activeImage][1] ) {\r
244                                 $('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();\r
245                         }\r
246                         // If we have a image set, display 'Image X of X'\r
247                         if ( settings.imageArray.length > 1 ) {\r
248                                 $('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();\r
249                         }               \r
250                 }\r
251                 /**\r
252                  * Display the button navigations\r
253                  *\r
254                  */\r
255                 function _set_navigation() {\r
256                         $('#lightbox-nav').show();\r
257 \r
258                         // Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.\r
259                         $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });\r
260                         \r
261                         // Show the prev button, if not the first image in set\r
262                         if ( settings.activeImage != 0 ) {\r
263                                 if ( settings.fixedNavigation ) {\r
264                                         $('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })\r
265                                                 .unbind()\r
266                                                 .bind('click',function() {\r
267                                                         settings.activeImage = settings.activeImage - 1;\r
268                                                         _set_image_to_view();\r
269                                                         return false;\r
270                                                 });\r
271                                 } else {\r
272                                         // Show the images button for Next buttons\r
273                                         $('#lightbox-nav-btnPrev').unbind().hover(function() {\r
274                                                 $(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });\r
275                                         },function() {\r
276                                                 $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });\r
277                                         }).show().bind('click',function() {\r
278                                                 settings.activeImage = settings.activeImage - 1;\r
279                                                 _set_image_to_view();\r
280                                                 return false;\r
281                                         });\r
282                                 }\r
283                         }\r
284                         \r
285                         // Show the next button, if not the last image in set\r
286                         if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {\r
287                                 if ( settings.fixedNavigation ) {\r
288                                         $('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })\r
289                                                 .unbind()\r
290                                                 .bind('click',function() {\r
291                                                         settings.activeImage = settings.activeImage + 1;\r
292                                                         _set_image_to_view();\r
293                                                         return false;\r
294                                                 });\r
295                                 } else {\r
296                                         // Show the images button for Next buttons\r
297                                         $('#lightbox-nav-btnNext').unbind().hover(function() {\r
298                                                 $(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });\r
299                                         },function() {\r
300                                                 $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });\r
301                                         }).show().bind('click',function() {\r
302                                                 settings.activeImage = settings.activeImage + 1;\r
303                                                 _set_image_to_view();\r
304                                                 return false;\r
305                                         });\r
306                                 }\r
307                         }\r
308                         // Enable keyboard navigation\r
309                         _enable_keyboard_navigation();\r
310                 }\r
311                 /**\r
312                  * Enable a support to keyboard navigation\r
313                  *\r
314                  */\r
315                 function _enable_keyboard_navigation() {\r
316                         $(document).keydown(function(objEvent) {\r
317                                 _keyboard_action(objEvent);\r
318                         });\r
319                 }\r
320                 /**\r
321                  * Disable the support to keyboard navigation\r
322                  *\r
323                  */\r
324                 function _disable_keyboard_navigation() {\r
325                         $(document).unbind();\r
326                 }\r
327                 /**\r
328                  * Perform the keyboard actions\r
329                  *\r
330                  */\r
331                 function _keyboard_action(objEvent) {\r
332                         // To ie\r
333                         if ( objEvent == null ) {\r
334                                 keycode = event.keyCode;\r
335                                 escapeKey = 27;\r
336                         // To Mozilla\r
337                         } else {\r
338                                 keycode = objEvent.keyCode;\r
339                                 escapeKey = objEvent.DOM_VK_ESCAPE;\r
340                         }\r
341                         // Get the key in lower case form\r
342                         key = String.fromCharCode(keycode).toLowerCase();\r
343                         // Verify the keys to close the ligthBox\r
344                         if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {\r
345                                 _finish();\r
346                         }\r
347                         // Verify the key to show the previous image\r
348                         if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {\r
349                                 // If we´re not showing the first image, call the previous\r
350                                 if ( settings.activeImage != 0 ) {\r
351                                         settings.activeImage = settings.activeImage - 1;\r
352                                         _set_image_to_view();\r
353                                         _disable_keyboard_navigation();\r
354                                 }\r
355                         }\r
356                         // Verify the key to show the next image\r
357                         if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {\r
358                                 // If we´re not showing the last image, call the next\r
359                                 if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {\r
360                                         settings.activeImage = settings.activeImage + 1;\r
361                                         _set_image_to_view();\r
362                                         _disable_keyboard_navigation();\r
363                                 }\r
364                         }\r
365                 }\r
366                 /**\r
367                  * Preload prev and next images being showed\r
368                  *\r
369                  */\r
370                 function _preload_neighbor_images() {\r
371                         if ( (settings.imageArray.length -1) > settings.activeImage ) {\r
372                                 objNext = new Image();\r
373                                 objNext.src = settings.imageArray[settings.activeImage + 1][0];\r
374                         }\r
375                         if ( settings.activeImage > 0 ) {\r
376                                 objPrev = new Image();\r
377                                 objPrev.src = settings.imageArray[settings.activeImage -1][0];\r
378                         }\r
379                 }\r
380                 /**\r
381                  * Remove jQuery lightBox plugin HTML markup\r
382                  *\r
383                  */\r
384                 function _finish() {\r
385                         $('#jquery-lightbox').remove();\r
386                         $('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });\r
387                         // Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.\r
388                         $('embed, object, select').css({ 'visibility' : 'visible' });\r
389                 }\r
390                 /**\r
391                  / THIRD FUNCTION\r
392                  * getPageSize() by quirksmode.com\r
393                  *\r
394                  * @return Array Return an array with page width, height and window width, height\r
395                  */\r
396                 function ___getPageSize() {\r
397                         var xScroll, yScroll;\r
398                         if (window.innerHeight && window.scrollMaxY) {  \r
399                                 xScroll = window.innerWidth + window.scrollMaxX;\r
400                                 yScroll = window.innerHeight + window.scrollMaxY;\r
401                         } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac\r
402                                 xScroll = document.body.scrollWidth;\r
403                                 yScroll = document.body.scrollHeight;\r
404                         } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari\r
405                                 xScroll = document.body.offsetWidth;\r
406                                 yScroll = document.body.offsetHeight;\r
407                         }\r
408                         var windowWidth, windowHeight;\r
409                         if (self.innerHeight) { // all except Explorer\r
410                                 if(document.documentElement.clientWidth){\r
411                                         windowWidth = document.documentElement.clientWidth; \r
412                                 } else {\r
413                                         windowWidth = self.innerWidth;\r
414                                 }\r
415                                 windowHeight = self.innerHeight;\r
416                         } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode\r
417                                 windowWidth = document.documentElement.clientWidth;\r
418                                 windowHeight = document.documentElement.clientHeight;\r
419                         } else if (document.body) { // other Explorers\r
420                                 windowWidth = document.body.clientWidth;\r
421                                 windowHeight = document.body.clientHeight;\r
422                         }       \r
423                         // for small pages with total height less then height of the viewport\r
424                         if(yScroll < windowHeight){\r
425                                 pageHeight = windowHeight;\r
426                         } else { \r
427                                 pageHeight = yScroll;\r
428                         }\r
429                         // for small pages with total width less then width of the viewport\r
430                         if(xScroll < windowWidth){      \r
431                                 pageWidth = xScroll;            \r
432                         } else {\r
433                                 pageWidth = windowWidth;\r
434                         }\r
435                         arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);\r
436                         return arrayPageSize;\r
437                 };\r
438                 /**\r
439                  / THIRD FUNCTION\r
440                  * getPageScroll() by quirksmode.com\r
441                  *\r
442                  * @return Array Return an array with x,y page scroll values.\r
443                  */\r
444                 function ___getPageScroll() {\r
445                         var xScroll, yScroll;\r
446                         if (self.pageYOffset) {\r
447                                 yScroll = self.pageYOffset;\r
448                                 xScroll = self.pageXOffset;\r
449                         } else if (document.documentElement && document.documentElement.scrollTop) {     // Explorer 6 Strict\r
450                                 yScroll = document.documentElement.scrollTop;\r
451                                 xScroll = document.documentElement.scrollLeft;\r
452                         } else if (document.body) {// all other Explorers\r
453                                 yScroll = document.body.scrollTop;\r
454                                 xScroll = document.body.scrollLeft;     \r
455                         }\r
456                         arrayPageScroll = new Array(xScroll,yScroll);\r
457                         return arrayPageScroll;\r
458                 };\r
459                  /**\r
460                   * Stop the code execution from a escified time in milisecond\r
461                   *\r
462                   */\r
463                  function ___pause(ms) {\r
464                         var date = new Date(); \r
465                         curDate = null;\r
466                         do { var curDate = new Date(); }\r
467                         while ( curDate - date < ms);\r
468                  };\r
469                 // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once\r
470                 return this.unbind('click').click(_initialize);\r
471         };\r
472 })(jQuery); // Call and execute the function immediately passing the jQuery object