PageSourceSearch

https://www.macrollc.com/modules/mod_s5_image_and_content_fader/js/jd.gallery.jquery.js

js macrollc.com collected 2026-10-08 01:29:23 UTC 40,055 bytes, 1,091 lines download raw bytes

1/*
2    This file is part of JonDesign's SmoothGallery v2.1beta1.
3
4    JonDesign's SmoothGallery is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    JonDesign's SmoothGallery is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with JonDesign's SmoothGallery; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18    Main Developer: Jonathan Schemoul (JonDesign: http://www.jondesign.net/)
19    Contributed code by:
20    - Christian Ehret (bugfix)
21	- Nitrix (bugfix)
22	- Valerio from Mad4Milk for his great help with the carousel scrolling and many other things.
23	- Archie Cowan for helping me find a bugfix on carousel inner width problem.
24	- Tomocchino from #mootools for the preloader class
25	Many thanks to:
26	- The mootools team for the great mootools lib, and it's help and support throughout the project.
27	- Harald Kirschner (digitarald: http://digitarald.de/) for all his great libs. Some used here as plugins.
28*/
29
30/* some quirks to circumvent broken stuff in mt1.2 */
31
32Array.prototype.from=function (item){
33	if (item == null) return [];
34	return (typeof(item) == 'array') ? item :   [item];
35};
36$A=function (i){return Array.prototype.from(i).slice();};
37Array.prototype.extend=function (a){this.push.apply(this,a);return this}
38if(Function.prototype.passx==undefined){
39	Function.prototype.passx=function (args, bind){
40		var self = this;
41		if (args != null) args = Array.prototype.from(args);
42		return function(){
43			return self.apply(bind, args || arguments);
44		};
45	};
46}
47Function.prototype.chain=function(f){f();return window.chainjdgallery;}
48window.chainjdgallery=function(){};
49
50
51if(undefined == Function.prototype.bind){
52	Function.prototype.bind=function(that){
53		var self = this,
54			args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
55			F = function(){};
56
57		var bound = function(){
58			var context = that, length = arguments.length;
59			if (this instanceof bound){
60				F.prototype = self.prototype;
61				context = new F;
62			}
63			var result = (!args && !length)
64				? self.call(context)
65				: self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
66			return context == that ? result : context;
67		};
68		return bound;
69	}
70};
71//Function.prototype.periodical=function (c,b,a){return setInterval(this.passx((a==null?[]:a),b),c);};
72
73$defined=function (i){return(i!=null);};
74$clear=function (i){clearTimeout(i);clearInterval(i);return null;};
75Function.prototype.delay=function (b,c,a){return setTimeout(this.passx(a,c),b)}
76
77function morphx(elm,opts){
78	this.element=elm;
79	this.complete=function(){};
80	this.options={easing:'linear',duration:1000,complete:this.complete,queue:false};
81	if(opts) this.options=jQuery.extend(this.options,opts);
82}
83morphx.prototype.data=function(){
84	if(arguments.length==1)
85		return this.element.data(arguments[0]);
86	else if(arguments.length==2)
87		return this.element.data(arguments[0], arguments[0]);
88}
89morphx.prototype.start=function(obj,opts){
90	//this.element.stop();
91	//console.log(this.options.duration);
92	if(opts)this.options=jQuery.extend(this.options,opts);
93	this.element.animate(obj, this.options);
94	return this;
95}
96morphx.prototype.stop=function(){
97	this.element.stop();
98	return this;
99}
100morphx.prototype.cancel=function(){
101	this.element.stop();
102	return this;
103}
104morphx.prototype.chain=Function.prototype.chain;
105morphx.prototype.completefunc=function(f){
106
107        this.options.complete=f.bind(this);
108
109        return this;
110
111}
112morphx.prototype.clearChain=function(){
113	window.morphxchain=function(){};
114}
115morphx.prototype.css=function(obj){
116	this.element.css(obj);
117	return this;
118}
119
120var s5_dropdowntext2 = s5_dropdowntext;
121
122(function($){
123	var Scroller = function(element, options){
124
125	this.options= {
126		area: 20,
127		velocity: 1,
128		onChange: function(x, y){
129			//console.log(x,y);
130			//this.element.scrollTo(x, y);
131			//window.scrollTo(x, y);
132		}.bind(this),
133		fps: 50
134		
135	};
136	this.element=null;
137	this.docBody=null;
138	this.listener=null;
139	this.timer=null;
140	this.bound={};
141	this.initialize(element, options);
142}
143
144	Scroller.prototype.initialize= function(element, options){
145		this.options=$.extend(this.options,options);
146		this.element = element[0];
147		this.docBody = $('body')[0];
148		if(this.element.nodeType!=1){
149			this.listener =  this.docBody ;
150			$(this.listener).attr('tag','body');
151		}else{
152			this.listener = this.element;
153			$(this.listener).attr('tag','elm');
154		}
155		
156		this.timer = null;
157		this.bound = {
158			attach: this.attach.bind(this),
159			detach: this.detach.bind(this),
160			getCoords: this.getCoords.bind(this)
161		};
162	};
163
164	Scroller.prototype.start= function(){
165		$(this.listener).bind('mouseover', this.bound.attach);
166			$(this.listener).bind('mouseleave', this.bound.detach);
167		return this;
168	};
169
170	Scroller.prototype.stop= function(){
171		$(this.listener).unbind('mouseover');
172		$(this.listener).unbind('mouseleave');	
173		this.detach();
174		this.timer = clearInterval(this.timer);
175		return this;
176	};
177
178	Scroller.prototype.attach= function(){
179		$(this.listener).bind('mousemove', this.bound.getCoords);
180	};
181
182	Scroller.prototype.detach= function(){
183		$(this.listener).unbind('mousemove');
184		this.timer = clearInterval(this.timer);
185	},
186
187	Scroller.prototype.getCoords= function(event){
188		event.client={x:event.clientX,y:event.clientY};
189		event.page={x:event.pageX,y:event.pageY};
190		this.page = ($(this.listener).attr('tag') == 'body') ? event.client : event.page;
191		//if (!this.timer) this.timer = this.scroll.periodical(Math.round(1000 / this.options.fps), this);
192	},
193
194	Scroller.prototype.scroll= function(){
195		var size = {x:$(this.element).width(),y:$(this.element).height()},
196			scroll = {x:$(this.element).scrollLeft(),y:$(this.element).scrollTop()},
197			pos = this.element != this.docBody ? {x:$(this.element).offset().left,y:$(this.element).offset().top} : {x: 0, y:0},
198			scrollSize = {x:$(this.element).children(0).width(),y: $(this.element).children(0).height()},
199			change = {x: 0, y: 0},
200			top = this.options.area.top || this.options.area,
201			bottom = this.options.area.bottom || this.options.area;
202		for (var z in this.page){
203			if (this.page[z] < (top + pos[z]) && scroll[z] != 0){
204				change[z] = (this.page[z] - top - pos[z]) * this.options.velocity;
205			} else if (this.page[z] + bottom > (size[z] + pos[z]) && scroll[z] + size[z] != scrollSize[z]){
206				change[z] = (this.page[z] - size[z] + bottom - pos[z]) * this.options.velocity;
207			}
208			change[z] = Math.round(change[z]);
209		}
210		if (change.y || change.x) this.options.onChange(scroll.x + change.x, scroll.y + change.y);
211	}
212	
213	
214var s5_dropdowntext2 = s5_dropdowntext;
215var s5_verticalhorizontal2 = s5_verticalhorizontal;
216
217
218// declaring the class
219var gallery =window.gallery= function(element, options) {
220	this.options= {
221		embedLinks: true,
222		fadeDuration: 500,
223		timed: false,
224		preloader: true,
225		preloaderImage: true,
226		preloaderErrorImage: true,
227		/* Data retrieval */
228		manualData: null,
229		populateFrom: false,
230		populateData: true,
231		destroyAfterPopulate: true,
232		elementSelector: "div.imageElement",
233		titleSelector: "h3",
234		subtitleSelector: "p",
235		linkSelector: "a.open",
236		imageSelector: "img.full",
237		thumbnailSelector: "img.thumbnail",
238		defaultTransition: "fade",
239		/* InfoPane options */
240		slideInfoZoneOpacity: s5_slide_opacity,
241		slideInfoZoneSlide: true,
242		/* Carousel options */
243		carouselMinimizedOpacity: 0.4,
244		carouselMinimizedHeight: 20,
245		carouselMaximizedOpacity: 0.9,
246		thumbHeight: 75,
247		thumbWidth: 100,
248		thumbSpacing: 10,
249		thumbIdleOpacity: 0.2,
250		textShowCarousel: s5_dropdowntext2,
251		showCarouselLabel: true,
252		thumbCloseCarousel: true,
253		useThumbGenerator: false,
254		thumbGenerator: 'resizer.php',
255		useExternalCarousel: false,
256		carouselElement: false,
257		carouselHorizontal: s5_verticalhorizontal2,
258		activateCarouselScroller: true,
259		carouselPreloader: true,
260		textPreloadingCarousel: 'Loading...',
261		/* CSS Classes */
262		baseClass: 'jdGallery',
263		withArrowsClass: 'withArrows',
264		/* Plugins: HistoryManager */
265		useHistoryManager: false,
266		customHistoryKey: false,
267		/* Plugins: ReMooz */
268		useReMooz: false,
269		slideShowDuration:3000,
270		slideHideDuration:2000,
271		randomOrder: "no",
272	};
273
274	this.initialize(element, options);
275}
276	gallery.prototype.initialize= function(element, options) {
277		this.options=$.extend(this.options, options);
278		
279		$(this).trigger('onInit');
280		this.currentIter = 0;
281		this.lastIter = 0;
282		this.maxIter = 0;
283		this.galleryElement = element;
284		this.galleryData = this.options.manualData;
285		this.galleryInit = 1;
286		this.galleryElements = Array();
287		this.thumbnailElements = Array();
288		$(this.galleryElement).addClass(this.options.baseClass);
289		
290		if (this.options.useReMooz&&(this.options.defaultTransition=="fade"))
291			this.options.defaultTransition="crossfade";
292		
293		this.populateFrom = element;
294		if (this.options.populateFrom)
295			this.populateFrom = this.options.populateFrom;		
296		if (this.options.populateData)
297			this.populateData();
298		element.css('display',"block");
299		
300		if (this.options.useHistoryManager)
301			this.initHistory();
302		
303		if ((this.options.embedLinks)|(this.options.useReMooz))
304		{
305			this.currentLink = $('<a class="open"></a>').attr({href:'#',title:''}).appendTo(element);
306			if ((!this.options.showArrows) && (!this.options.showCarousel))
307				this.galleryElement = element = this.currentLink;
308			else
309				this.currentLink.css('display', 'none');
310		}
311		
312		this.constructElements();
313		if ((this.galleryData.length>1)&&(this.options.showArrows))
314		{
315			var leftArrow = $('<div class="leftarrowwrap"><a class="left"><span class="iacf_prev">Prev</span></a></div>').bind(
316				'click',
317				this.prevItem.bind(this)
318			).appendTo(element);
319			var rightArrow = $('<div class="rightarrowwrap"><a class="right"><span class="iacf_next">Next</span></a></div>').bind(
320				'click',
321				this.nextItem.bind(this)
322			).appendTo(element);
323			$(this.galleryElement).addClass(this.options.withArrowsClass);
324		}
325		this.loadingElement = $('<div class="loadingElement"></div>').appendTo(element);
326		//if (this.options.showInfopane) this.initInfoSlideshow();
327		this.initInfoSlideshow();
328		if (this.options.showCarousel) this.initCarousel();
329		this.doSlideShow(1);
330	}
331	gallery.prototype.populateData= function() {
332		currentArrayPlace = $(this.galleryData).length;
333		options = this.options;
334		var data = $A(this.galleryData);
335		data.extend(this.populateGallery(this.populateFrom, currentArrayPlace));
336		this.galleryData = data;
337		$(this).trigger('onPopulated');
338	};
339	gallery.prototype.populateGallery= function(element, startNumber) {
340		var data = [];
341		options = this.options;
342		currentArrayPlace = parseInt(startNumber);
343		$(options.elementSelector,element).each(function(i,el) {
344			elementDict = new Object({
345				image: $(options.imageSelector,el).attr('src'),
346				number: currentArrayPlace,
347				transition: this.options.defaultTransition
348			});
349			if ((options.showInfopane) | (options.showCarousel)){
350				  if(s5_hideh2 == "true") {  elementDict.title= $(options.titleSelector,el)[0].innerHTML;  }
351				  elementDict.description= $(options.subtitleSelector,el)[0].innerHTML
352			}	
353			if ((options.embedLinks) | (options.useReMooz)){
354				while($(options.linkSelector,el)[0] == undefined) 
355					; 
356				elementDict.link=$(options.linkSelector,el)[0].href||false;
357					// hides false and open image tooltip popups // linkTitle: el.getElement(options.linkSelector).title||false,
358				elementDict.linkTarget= $(options.linkSelector,el).attr('target')||false;
359			}
360			if ((!options.useThumbGenerator) && (options.showCarousel)){
361				elementDict.thumbnail=$(options.thumbnailSelector,el).attr('src');
362			}else if (options.useThumbGenerator)
363				elementDict.thumbnail= options.thumbGenerator + '?imgfile=' + elementDict.image + '&max_width=' + options.thumbWidth + '&max_height=' + options.thumbHeight;
364			data.extend([elementDict]);
365			currentArrayPlace++;
366			if (this.options.destroyAfterPopulate)
367				$(el).remove();
368		}.bind(this));
369		return data;
370	},
371	gallery.prototype.constructElements= function() {
372		el = this.galleryElement;
373		if (this.options.embedLinks && (!this.options.showArrows))
374			el = this.currentLink;
375		this.maxIter = this.galleryData.length;
376		var currentImg;
377		for(i=0;i<$(this.galleryData).length;i++)
378		{
379			var currentImg = 
380				new morphx($('<div class="slideElement"></div>').css({
381					'position':'absolute',
382					'left':'0px',
383					'right':'0px',
384					'margin':'0px',
385					'padding':'0px',
386					'backgroundPosition':"center center",
387					'opacity':'0'
388				}).appendTo(el),{duration: this.options.fadeDuration});
389				
390			if (this.options.preloader)
391			{
392				
393				currentImg.element.source = this.galleryData[i].image;
394				currentImg.element.loaded=false;
395	
396				currentImg.element.load = function(params) {
397					var imageStyle=params[0];
398					var i=params[1];
399
400					if (!imageStyle.loaded)	{
401						var imgx=new Image();
402						this.galleryData[i].imgloader = imgx.onload=function(params2){
403													img=params2[0];
404													i=params2[1];
405													img.css(
406													'backgroundImage',
407													"url('" + img.source + "')")
408													img.loaded = true;
409													img.width = this.galleryData[i].imgloader.width;
410													img.height = this.galleryData[i].imgloader.height;
411												}.passx([imageStyle, i], this);
412						imgx.src=imageStyle.source;
413						
414					}
415				}.passx([currentImg.element, i],this);
416			} else {
417				currentImg.element.css('backgroundImage',
418									"url('" + this.galleryData[i].image + "')");
419			}
420			this.galleryElements[parseInt(i)] = currentImg;
421		}
422	},
423	gallery.prototype.destroySlideShow= function(element) {
424		var myClassName = element.className;
425		var newElement = $('div class="myClassName"></div>');
426		element.parentNode.replaceChild(newElement, element);
427	},
428	gallery.prototype.startSlideShow= function() {
429		$(this).trigger('onStart');
430		this.loadingElement[0].style.display = "none";
431		this.lastIter = this.maxIter - 1;
432		this.currentIter = 0;
433		this.galleryInit = 0;
434		this.galleryElements[parseInt(this.currentIter)].element.css({opacity: 1});
435		if (this.options.showInfopane)
436			this.showInfoSlideShow.delay(1000, this);
437		if (this.options.useReMooz)
438			this.makeReMooz.delay(1000, this);
439		var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter);
440		if (this.options.showCarousel&&(!this.options.carouselPreloader)&&(!this.options.useExternalCarousel))
441			this.carouselBtn.html(textShowCarousel).attr('title', textShowCarousel);
442		this.prepareTimer();
443		if (this.options.embedLinks)
444			this.makeLink(this.currentIter);
445	},
446	            gallery.prototype.random = function () {
447                function getRandomInt(min, max) {
448                    return Math.floor(Math.random() * (max - min)) + min;
449                }
450                return getRandomInt(0, this.maxIter);
451            },
452            gallery.prototype.nextRandom = function () {
453                var randomInt = this.random();
454                this.goTo(randomInt);
455            },
456	gallery.prototype.nextItem= function() {
457		$(this).trigger('onNextCalled');
458		this.nextIter = this.currentIter+1;
459		if (this.nextIter >= this.maxIter)
460			this.nextIter = 0;
461		this.galleryInit = 0;
462		this.goTo(this.nextIter);
463	},
464	gallery.prototype.prevItem= function() {
465		$(this).trigger('onPreviousCalled');
466		this.nextIter = this.currentIter-1;
467		if (this.nextIter <= -1)
468			this.nextIter = this.maxIter - 1;
469		this.galleryInit = 0;
470		this.goTo(this.nextIter);
471	},
472	gallery.prototype.goTo= function(num) {
473		//console.log(num);
474		this.clearTimer();
475		if(this.options.preloader)
476		{
477			this.galleryElements[num].element.load();
478			if (num==0)
479				this.galleryElements[this.maxIter - 1].element.load();
480			else
481				this.galleryElements[num - 1].element.load();
482			if (num==(this.maxIter - 1))
483				this.galleryElements[0].element.load();
484			else
485				this.galleryElements[num + 1].element.load();
486				
487		}
488		if (this.options.embedLinks)
489			this.clearLink();
490		if (this.options.showInfopane)
491		{
492			this.slideInfoZone.clearChain();
493			//this.hideInfoSlideShow().chain(this.changeItem.passx(num, this));
494			this.hideInfoSlideShow();
495			this.changeItem(num);
496		} else
497			this.currentChangeDelay = this.changeItem.delay(500, this, num);
498		if (this.options.embedLinks)
499			this.makeLink(num);
500		this.prepareTimer();
501		/*if (this.options.showCarousel)
502			this.clearThumbnailsHighlights();*/
503	},
504	gallery.prototype.changeItem= function(num) {
505		//console.log(arguments.callee.caller);
506		$(this).trigger('onStartChanging');
507		this.galleryInit = 0;
508		if (this.currentIter != num)
509		{
510			for(i=0;i<this.maxIter;i++)
511			{
512				if ((i != this.currentIter)) 	this.galleryElements[i].css({opacity: 0});
513			}
514			//console.log(this.galleryData[num].transition);
515			gallery.Transitions[this.galleryData[num].transition].passx([
516				this.galleryElements[this.currentIter],
517				this.galleryElements[num],
518				this.currentIter,
519				num], this)();
520			this.currentIter = num;
521			if (this.options.useReMooz)
522				this.makeReMooz();
523		}
524		var textShowCarousel = formatString(this.options.textShowCarousel, num+1, this.maxIter);
525		if ((this.options.showCarousel)&&(!this.options.useExternalCarousel))
526			this.carouselBtn.html(textShowCarousel).attr('title', textShowCarousel);
527		this.doSlideShow.bind(this)();
528		$(this).trigger('onChanged');
529	},
530	gallery.prototype.clearTimer= function() {
531		if (this.options.timed)
532			$clear(this.timer);
533	},
534	            gallery.prototype.prepareTimer = function () {
535                if (this.options.timed) {
536                    if (this.timer)
537                        this.clearTimer();
538                    if (this.options.randomOrder === "yes") {
539                        this.timer = this.nextRandom.delay(this.options.delay, this);
540                    } else {
541                        this.timer = this.nextItem.delay(this.options.delay, this);
542                    }
543                }
544            },
545	gallery.prototype.doSlideShow= function(position) {
546   // start jv
547        if(this.carousel){
548            var thumbs = $('.thumbnail',this.carousel.element);
549            thumbs.each(function(i,el){
550                if($(el).hasClass('active')) $(el).removeClass('active');
551            });
552
553            $(thumbs[this.currentIter]).addClass('active');
554            
555        }
556        var images = $('.slideElement',this.galleryElement);
557        if(images.length){
558            images.each(function(i,el){
559                if($(el).hasClass('active')) $(el).removeClass('active');
560            });
561            $(images[this.currentIter]).addClass('active');
562        }
563        //end jv
564	
565	
566		if (this.galleryInit == 1)
567		{
568			imgPreloader = new Image();
569			imgPreloader.onload=function(){
570				this.startSlideShow.delay(10, this);
571			}.bind(this);
572			imgPreloader.src = this.galleryData[0].image;
573			if(this.options.preloader)
574				this.galleryElements[0].element.load();
575		} else {
576			
577			if (this.options.showInfopane)
578			{
579				if (this.options.showInfopane)
580				{
581					this.showInfoSlideShow.delay((500 + this.options.fadeDuration), this);
582					//this.showInfoSlideShow();
583				} else
584					if ((this.options.showCarousel)&&(this.options.activateCarouselScroller))
585						this.centerCarouselOn(position);
586			}
587		}
588		
589	},
590	gallery.prototype.createCarousel= function() {
591		var carouselElement;
592		if (!this.options.useExternalCarousel)
593		{
594			var carouselContainerElement = $('<div class="carouselContainer"></div>').appendTo(this.galleryElement);
595			this.carouselContainer = new morphx(carouselContainerElement,{easing: 'easeOutExpo'});
596			this.carouselContainer.element.normalHeight = carouselContainerElement.outerHeight();
597			this.carouselContainer.element.css({'opacity': this.options.carouselMinimizedOpacity, 'top': (this.options.carouselMinimizedHeight - this.carouselContainer.element.normalHeight)});
598			this.carouselBtn = $('<a class="carouselBtn"></a>').attr({
599				title: this.options.textShowCarousel
600			}).appendTo(carouselContainerElement);
601			if(this.options.carouselPreloader)
602				this.carouselBtn.html(this.options.textPreloadingCarousel);
603			else
604				this.carouselBtn.html(this.options.textShowCarousel);
605			this.carouselBtn.bind(
606				'click',
607				(function () {
608					this.carouselContainer.cancel();
609					this.toggleCarousel();
610				}).bind(this)
611			);
612			this.carouselActive = false;
613	
614			carouselElement = $('<div class="carousel"></div>').appendTo(carouselContainerElement);
615			this.carousel = new morphx(carouselElement);
616		} else {
617			carouselElement = $(this.options.carouselElement).addClass('jdExtCarousel');
618		}
619		this.carouselElement = new morphx(carouselElement,{easing:'easeOutExpo'});
620		this.carouselElement.element.normalHeight = carouselElement.offsetHeight;
621		if (this.options.showCarouselLabel)
622			this.carouselLabel = $('<p class="label"></p>').appendTo(carouselElement);
623		carouselWrapper = $('<div class="carouselWrapper"></div>').appendTo(carouselElement);
624		this.carouselWrapper =new morphx(carouselWrapper,{easing:'easeOutExpo'});
625		this.carouselWrapper.element.normalHeight = carouselWrapper.offsetHeight;
626		this.carouselInner = $('<div class="carouselInner"></div>').appendTo(carouselWrapper)[0];
627		if (this.options.activateCarouselScroller)
628		{
629			this.carouselWrapper.element.scroller = new Scroller(carouselWrapper, {
630				area: 100,
631				velocity: 0.2
632			})
633			
634		/*	this.carouselWrapper.elementScroller = new Fx.Scroll(carouselWrapper, {
635				duration: 400,
636				onStart: this.carouselWrapper.scroller.stop.bind(this.carouselWrapper.scroller),
637				onComplete: this.carouselWrapper.scroller.start.bind(this.carouselWrapper.scroller)
638			});*/
639			
640			this.carouselWrapper.element.elementScroller = (function(from,to){
641						this.carouselWrapper.element.scroller.stop.bind(this.carouselWrapper.scroller);
642						this.carouselWrapper.element.animate({left:[from,to]},{duration:400,easing:'linear',queue:false,complete:this.carouselWrapper.element.scroller.start.bind(this.carouselWrapper.element.scroller)}).bind(this);
643					}).bind(this);
644		}
645	},
646	gallery.prototype.fillCarousel= function() {
647		this.constructThumbnails();
648		this.carouselInner.normalWidth = ((this.maxIter * (this.options.thumbWidth + this.options.thumbSpacing + 2))+this.options.thumbSpacing) + "px";
649		if (this.options.carouselHorizontal)
650			this.carouselInner.style.width = this.carouselInner.normalWidth;
651	},
652	gallery.prototype.initCarousel= function () {
653		this.createCarousel();
654		this.fillCarousel();
655		if (this.options.carouselPreloader)
656			this.preloadThumbnails();
657	},
658	gallery.prototype.flushCarousel= function() {
659		$(this.thumbnailElements).each(function(i,myFx) {
660			myFx.element.remove();
661			myFx = myFx.element = null;
662		});
663		this.thumbnailElements = [];
664	},
665	gallery.prototype.toggleCarousel= function() {
666		if (this.carouselActive)
667			this.hideCarousel();
668		else
669			this.showCarousel();
670	},
671	gallery.prototype.showCarousel= function () {
672		$(this).trigger('onShowCarousel');
673		this.carouselContainer.completefunc(function() {
674			this.carouselActive = true;
675			this.carouselWrapper.element.scroller.start();
676			$(this).trigger('onCarouselShown');
677			//this.carouselContainer.options.onComplete = null;
678		}.bind(this)).start({
679			'opacity': this.options.carouselMaximizedOpacity,
680			'top': 0
681		});
682	},
683	gallery.prototype.hideCarousel= function () {
684		$(this).trigger('onHideCarousel');
685		var targetTop = this.options.carouselMinimizedHeight - this.carouselContainer.element.normalHeight;
686		this.carouselContainer.completefunc(function() {
687			this.carouselActive = false;
688			this.carouselWrapper.element.scroller.stop();
689			$(this).trigger('onCarouselHidden');
690			//this.carouselContainer.options.onComplete = null;
691		}.bind(this)).start({
692			'opacity': this.options.carouselMinimizedOpacity,
693			'top': targetTop
694		});
695	},
696	gallery.prototype.constructThumbnails= function () {
697		element = this.carouselInner;
698		for(i=0;i<this.galleryData.length;i++)
699		{
700			var currentImg = new morphx($('<div class="thumbnail"></div>').css({
701					backgroundImage: "url('" + this.galleryData[i].thumbnail + "')",
702					backgroundPosition: "center center",
703					backgroundRepeat: 'no-repeat',
704					marginLeft: this.options.thumbSpacing + "px",
705					width: this.options.thumbWidth + "px",
706					height: this.options.thumbHeight + "px"
707				}).appendTo(element),{duration: 200,easing:'linear'});//.animate({'opacity': this.options.thumbIdleOpacity}, );
708			currentImg.element.bind(
709				'mouseover', function (myself) {
710					myself.cancel();
711					myself.start({'opacity': 0.99});
712					if (this.options.showCarouselLabel)
713						this.carouselLabel.html('<span class="number">' + (myself.element.data('relatedImage').number + 1) + "/" + this.maxIter + ":</span> " + myself.element.data('relatedImage').title);
714				}.passx(currentImg, this));
715				currentImg.element.bind('mouseout', (function (myself) {
716					myself.cancel();
717					myself.start({'opacity': this.options.thumbIdleOpacity});
718				}).passx(currentImg, this));
719				
720				currentImg.element.bind('click', (function (myself) {
721					this.galleryInit = 0;
722					//console.log(myself.data('relatedImage').number);
723					this.goTo(myself.data('relatedImage').number);
724					if (this.options.thumbCloseCarousel&&(!this.options.useExternalCarousel))
725						this.hideCarousel();
726				}).passx(currentImg, this));
727			
728			currentImg.element.data('relatedImage', this.galleryData[i]);
729			this.thumbnailElements[parseInt(i)] = currentImg;
730		}
731	},
732	gallery.prototype.log= function(value) {
733		//if(console.log)
734			//console.log(value);
735	},
736	gallery.prototype.preloadThumbnails= function() {
737		var thumbnails = [];
738		for(i=0;i<this.galleryData.length;i++)
739		{
740			thumbnails[parseInt(i)] = this.galleryData[i].thumbnail;
741		}
742		this.thumbnailPreloader = new Preloader();
743		if (!this.options.useExternalCarousel)
744			$(this.thumbnailPreloader).bind('onComplete', function() {
745				var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter);
746				this.carouselBtn.html(textShowCarousel).attr('title', textShowCarousel);
747			}.bind(this));
748		this.thumbnailPreloader.load(thumbnails);
749	},
750	gallery.prototype.clearThumbnailsHighlights= function()
751	{
752		for(i=0;i<this.galleryData.length;i++)
753		{
754			this.thumbnailElements[i].cancel();
755			this.thumbnailElements[i].start(0.2);
756		}
757	},
758	gallery.prototype.changeThumbnailsSize= function(width, height)
759	{
760		for(i=0;i<this.galleryData.length;i++)
761		{
762			this.thumbnailElements[i].cancel();
763			this.thumbnailElements[i].element.css({
764				'width': width + "px",
765				'height': height + "px"
766			});
767		}
768	},
769	gallery.prototype.centerCarouselOn= function(num) {
770		if (!this.carouselWallMode)
771		{
772			var carouselElement = this.thumbnailElements[num];
773			var position = carouselElement.element.offsetLeft + (carouselElement.element.offsetWidth / 2);
774			var carouselWidth = this.carouselWrapper.element.offsetWidth;
775			var carouselInnerWidth = this.carouselInner.offsetWidth;
776			var diffWidth = carouselWidth / 2;
777			var scrollPos = position-diffWidth;
778			this.carouselWrapper.element.elementScroller(scrollPos,0);
779		}
780	},
781	gallery.prototype.initInfoSli
781deshow= function() {
782		/*if (this.slideInfoZone.element)
783			this.slideInfoZone.element.remove();*/
784		this.slideInfoZone = new morphx($('<div class="slideInfoZone"></div>').appendTo($(this.galleryElement)).css({'opacity':0}));
785		var slideInfoZoneTitle = "";
786		if (s5_hideh2 == "true") {
787		slideInfoZoneTitle = $('<h2></h2>').appendTo(this.slideInfoZone.element);
788		}
789		var slideInfoZoneDescription = $('<p></p>').appendTo(this.slideInfoZone.element);
790		this.slideInfoZone.element.normalHeight = this.slideInfoZone.element[0].offsetHeight;
791		this.slideInfoZone.element.css('opacity',0);
792	},
793	gallery.prototype.changeInfoSlideShow= function()
794	{
795		//this.hideInfoSlideShow.delay(10, this);
796		//this.showInfoSlideShow.delay(500, this);
797		this.hideInfoSlideShow.apply(this);
798		this.showInfoSlideShow.apply(this);
799	},
800	gallery.prototype.showInfoSlideShow= function() {
801		$(this).trigger('onShowInfopane');
802		$('.slideInfoZone').stop();
803		element = this.slideInfoZone.element;
804		$('h2',element).html( this.galleryData[this.currentIter].title);
805		$('p',element).html( this.galleryData[this.currentIter].description);
806		//console.log(this.slideInfoZone.element);
807		if (element.className != 'slideInfoZone slideInfoZone_load') {
808		this.slideInfoZone.element[0].className = 'slideInfoZone';
809		this.adjustclassname.delay(20, this);
810		}
811		this.slideInfoZone.options.duration = this.options.slideShowDuration;
812		if (this.options.showCarousel)
813			this.slideInfoZone.completefunc(this.centerCarouselOn.passx(this.currentIter, this));
814		this.slideInfoZone.completefunc(function(){
815			if(typeof s5_multibox_enabled !== 'undefined'){initMultibox('#myGallery .s5mb');}
816            if(typeof s5_page_scroll_enabled !== 'undefined'){initSmoothscroll();}
817		});
818		if(this.options.slideInfoZoneSlide)
819			this.slideInfoZone.start({'opacity': this.options.slideInfoZoneOpacity, 'height': this.slideInfoZone.element.normalHeight},{easing:'easeOutExpo'});
820		else
821			this.slideInfoZone.start({'opacity':this.options.slideInfoZoneOpacity});
822
823		return this.slideInfoZone;
824	},
825	gallery.prototype.adjustclassname= function() {
826	this.slideInfoZone.element[0].className = 'slideInfoZone slideInfoZone_load';
827	},
828	gallery.prototype.hideInfoSlideShow= function() {
829		$(this).trigger('onHideInfopane');
830		this.slideInfoZone.cancel();
831		this.slideInfoZone.element[0].className = 'slideInfoZone slideInfoZone_unload';
832		this.slideInfoZone.options.duration = this.options.slideHideDuration;
833		//console.log(this.options.slideShowDuration);
834		if(this.options.slideInfoZoneSlide)
835			this.slideInfoZone.start({'opacity': 0, 'height': 0},{easing:'easeOutExpo'});
836		else
837			this.slideInfoZone.start({'opacity': 0});
838		return this.slideInfoZone;
839	},
840	gallery.prototype.makeLink=function(num) {
841		this.currentLink.attr({
842			href: this.galleryData[num].link,
843			title: this.galleryData[num].linkTitle
844		});
845		if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel)))
846			this.currentLink.css('display', 'block');
847	},
848	gallery.prototype.clearLink= function() {
849		this.currentLink.attr({href: '', title: ''});
850		if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel)))
851			this.currentLink.css('display', 'none');
852	},
853	gallery.prototype.makeReMooz= function() {
854		this.currentLink.attr({
855			href: '#'
856		});
857		this.currentLink.css({
858			'display': 'block'
859		});
860		
861		this.galleryElements[this.currentIter].element.attr('title', this.galleryData[this.currentIter].title + ' :: ' + this.galleryData[this.currentIter].description);
862		this.ReMooz = new ReMooz(this.galleryElements[this.currentIter].element, {
863			link: this.galleryData[this.currentIter].link,
864			shadow: false,
865			dragging: false,
866			addClick: false,
867			resizeOpacity: 1
868		});
869		var img = this.galleryElements[this.currentIter];
870		var coords = img.element.offset();
871		coords.width=img.element.width();
872		coords.height=img.element.height();
873		widthDiff = coords.width - img.width;
874		heightDiff = coords.height - img.height;
875		
876		coords.width = img.width;
877		coords.height = img.height;
878		
879		coords.left += Math.ceil(widthDiff/2)+1;
880		coords.top += Math.ceil(heightDiff/2)+1;
881		
882		this.ReMooz.getOriginCoordinates = (function(coords) {
883			return coords;
884		}).bind(this, coords);
885		this.currentLink.onclick = function () {
886			this.ReMooz.open.bind(this.ReMooz)();
887			return false;
888		}.bind(this);
889	},
890	/* To change the gallery data, those two functions : */
891	gallery.prototype.flushGallery= function() {
892		$(this.galleryElements).each(function(i,myFx) {
893			myFx.element.remove();
894			myFx = myFx.element = null;
895		});
896		this.galleryElements = [];
897	},
898	gallery.prototype.changeData= function(data) {
899		this.galleryData = data;
900		this.clearTimer();
901		this.flushGallery();
902		if (this.options.showCarousel) this.flushCarousel();
903		this.constructElements();
904		if (this.options.showCarousel) this.fillCarousel();
905		if (this.options.showInfopane) this.hideInfoSlideShow();
906		this.galleryInit=1;
907		this.lastIter=0;
908		this.currentIter=0;
909		this.doSlideShow(1);
910	},
911	/* Plugins: HistoryManager */
912	gallery.prototype.initHistory= function() {
913		$(this).trigger('onHistoryInit');
914		this.historyKey = this.galleryElement.id + '-picture';
915		if (this.options.customHistoryKey)
916			this.historyKey = this.options.customHistoryKey;
917		
918		this.history = new History.Route({
919			defaults: [1],
920			pattern: this.historyKey + '\\((\\d+)\\)',
921			generate: function(values) {
922				return [this.historyKey, '(', values[0], ')'].join('')
923			}.bind(this),
924			onMatch: function(values, defaults) {
925				if (parseInt(values[0])-1 < this.maxIter)
926					this.goTo(parseInt(values[0])-1);
927			}.bind(this)
928		});
929		this.bind('onChanged', function(){
930			this.history.setValue(0, this.currentIter+1);
931			this.history.defaults=[this.currentIter+1];
932		}.bind(this));
933		$(this).trigger('onHistoryInited');
934	}
935
936
937
938gallery.Transitions = new Object ({
939	fade: function(/*oldFx, newFx, oldPos, newPos*/){
940		//console.log(arguments);
941		oldFx=arguments[0][0];
942		newFx=arguments[0][1];
943		oldPos=arguments[0][2];
944		newPos=arguments[0][3];
945		oldFx.options.easing = newFx.options.easing =  'linear';
946		//oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
947		if (newPos > oldPos) newFx.start({opacity: 1});
948		else
949		{
950			newFx.element.css({opacity: 1});
951			oldFx.start({opacity: 0});
952		}
953	},
954        slideleft: function (/*oldFx, newFx, oldPos, newPos*/) {
955            //console.log(arguments);
956            oldFx = arguments[0][0];
957            newFx = arguments[0][1];
958            oldPos = arguments[0][2];
959            newPos = arguments[0][3];
960            oldFx.options.easing = newFx.options.easing = 'linear';
961            oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
962            //console.log(oldPos);
963            //console.log(newPos);
964
965            /* New element */
966            newFx.element.css('z-index', 0);
967            newFx.element.css('opacity', 0);
968            newFx.element.css('left', 0);
969
970            /* Old Element */
971            oldFx.element.css('z-index', 1);
972            oldFx.element.css('opacity', 1);
973            oldFx.element.css('left', 0);
974
975            oldFx.start({left: '100%', opacity: 0.1}, {duration: this.options.fadeDuration});
976            newFx.element.css('left', 0);
977            newFx.element.css('opacity', 1);
978        },
979        slideright: function (/*oldFx, newFx, oldPos, newPos*/) {
980            //console.log(arguments);
981            oldFx = arguments[0][0];
982            newFx = arguments[0][1];
983            oldPos = arguments[0][2];
984            newPos = arguments[0][3];
985            oldFx.options.easing = newFx.options.easing = 'linear';
986            oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
987            //console.log(oldPos);
988            //console.log(newPos);
989
990            /* New element */
991            newFx.element.css('z-index', 0);
992            newFx.element.css('opacity', 0);
993            newFx.element.css('left', 0);
994
995            /* Old Element */
996            oldFx.element.css('z-index', 1);
997            oldFx.element.css('opacity', 1);
998            oldFx.element.css('left', 0);
999
1000            oldFx.start({left: '-100%', opacity: 0.1}, {duration: this.options.fadeDuration});
1001            newFx.element.css('left', 0);
1002            newFx.element.css('opacity', 1);
1003        },
1004	crossfade: function(/*oldFx, newFx, oldPos, newPos*/){
1005		oldFx=arguments[0][0];
1006		newFx=arguments[0][1];
1007		oldPos=arguments[0][2];
1008		newPos=arguments[0][3];
1009		oldFx.options.easing = newFx.options.easing =  'linear';
1010		//oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
1011		newFx.start({opacity: 1});
1012		oldFx.start({opacity: 0});
1013	},
1014	fadebg: function(/*oldFx, newFx, oldPos, newPos*/){
1015		oldFx=arguments[0][0];
1016		newFx=arguments[0][1];
1017		oldPos=arguments[0][2];
1018		newPos=arguments[0][3];
1019		oldFx.options.easing = newFx.options.easing = 'linear';
1020		//oldFx.options.duration = newFx.options.duration = this.options.fadeDuration / 2;
1021		oldFx.completefunc(newFx.start.passx([{opacity: 1}], newFx)).start({opacity: 0});
1022	}
1023});
1024
1025/* All code copyright 2007 Jonathan Schemoul */
1026
1027/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1028 * Follows: Preloader (class)
1029 * Simple class for preloading images with support for progress reporting
1030 * Copyright 2007 Tomocchino.
1031 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1032
1033var Preloader = function(options){
1034  
1035
1036  this.options= {
1037    root        : '',
1038    period      : 100
1039  }
1040  if(options) this.options=$.extend(this.options,options);
1041}
1042  
1043    Preloader.prototype.load= function(sources) {
1044    this.index = 0;
1045    this.images = [];
1046    this.sources = this.temps = sources;
1047    this.total = this. sources.length;
1048    
1049    $(this).trigger('onStart', [this.index, this.total]);
1050    try{var per=this.options.period;}catch(e){return;}
1051    //this.timer = this.progress.periodical(per, this);
1052    
1053    $(this.sources).each((function( index, source){
1054      this.images[index] = $('<img/>').attr('src',this.options.root + source);
1055        this.images[index].bind('load'  ,function(){ this.index++; if(this.images[index]) $(this).trigger('onLoad', [this.images[index], index, source]); }.bind(this)).bind(this);
1056        this.images[index].bind('error' ,function(){ this.index++; $(this).trigger('onError', [this.images.splice(index, 1), index, source]); }.bind(this)).bind(this);
1057        this.images[index].bind('abort' ,function(){ this.index++; $(this).trigger('onError', [this.images.splice(index, 1), index, source]); }.bind(this)).bind(this);
1058    }).bind( this));
1059  }
1060  
1061  Preloader.prototype.progress= function() {
1062    $(this).trigger('onProgress', [Math.min(this.index, this.total), this.total]);
1063    if(this.index >= this.total) this.complete();
1064  },
1065  
1066  Preloader.prototype.complete= function(){
1067    $clear(this.timer);
1068    $(this).trigger('onComplete', [this.images]);
1069  };
1070  
1071  Preloader.prototype.cancel= function(){
1072    $clear(this.timer);
1073  }
1074  
1075})(jQuery);
1076/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1077 * Follows: formatString (function)
1078 * Original name: Yahoo.Tools.printf
1079 * Copyright Yahoo.
1080 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
1081
1082function formatString() {
1083	var num = arguments.length;
1084	var oStr = arguments[0];
1085	for (var i = 1; i < num; i++) {
1086		var pattern = "\\{" + (i-1) + "\\}"; 
1087		var re = new RegExp(pattern, "g");
1088		oStr = oStr.replace(re, arguments[i]);
1089	}
1090	return oStr; 
1091}

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.